Mark Grand | 4 Dec 2002 12:18
Picon

Design Patterns


Mark Grand proudly presents

Two Design Pattern Courses

I am proud to announce that two design pattern course previously taught at 
U.C. Berkeley are now available to the public.

<http://www.clickblocks.com/cgi-sz/webcwrap/szw/st_prod.html?p_prodid=1>Design 
Patterns in Java is an intensive introduction to Design Patterns taught by 
the author of the book Patterns in Java. The course is intended for 
experienced programmers and software engineers who want to better 
understand object-oriented design or make the transition from software 
engineer to software 
architect. 
[<http://www.clickblocks.com/cgi-sz/webcwrap/szw/st_prod.html?p_prodid=1>Detailed 
course description]

<http://www.clickblocks.com/cgi-sz/webcwrap/szw/st_prod.html?p_prodid=2>Distributed 
Patterns for Java Enterprise Applications is an introduction to 
architectural and design patterns for building transaction-oriented and 
distributed systems. These patterns are reusable solutions to common 
problems that occur when building distributed or transaction-oriented 
systems. These patterns focus on issues that are independent of any 
implementation 
technology. 
[<http://www.clickblocks.com/cgi-sz/webcwrap/szw/st_prod.html?p_prodid=2>Detailed 
course description]

Location:
(Continue reading)

Nic Ferrier | 4 Dec 2002 12:59
Picon

ANN: free software web in danger

Here's a GNU statement on a proposed w3c policy.

http://www.gnu.org/philosophy/w3c-patent.html

The policy has the unfortunate effect of allowing patents for w3c
standards which cannot be implemented by free software.

If you feel as I do then please take a few moments to mail

   www-patentpolicy-comment <at> w3.org

before the end of December and tell them that this is a bad idea.

Nic 

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/saFolB/TM
---------------------------------------------------------------------~->

Before posting a question, try to find your answer here: 
<http://www.egroups.com/links/advanced-servlets>
Announcements should go to: advanced-servlets-announce <at> egroups.com
To Post a message, send it to: advanced-servlets <at> eGroups.com
To Unsubscribe, send a blank message to: advanced-servlets-unsubscribe <at> eGroups.com 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

Tom & Sharon Kochanowicz | 4 Dec 2002 16:42
Picon

RE: ANN: free software web in danger

Thanks for the tip Nic, I have read the policy and sent my protest.
Maybe the W3 should start using a .com instead of .org for its web site?

TK

-----Original Message-----
From: nferrier <at> pooh-sticks-bridge.tapsellferrier.co.uk
[mailto:nferrier <at> pooh-sticks-bridge.tapsellferrier.co.uk] On Behalf Of
Nic Ferrier
Sent: Wednesday, December 04, 2002 6:00 AM
To: advanced-servlets <at> yahoogroups.com
Subject: [advanced-servlets] ANN: free software web in danger

Here's a GNU statement on a proposed w3c policy.

http://www.gnu.org/philosophy/w3c-patent.html

The policy has the unfortunate effect of allowing patents for w3c
standards which cannot be implemented by free software.

If you feel as I do then please take a few moments to mail

   www-patentpolicy-comment <at> w3.org

before the end of December and tell them that this is a bad idea.

Nic 

Before posting a question, try to find your answer here: 
<http://www.egroups.com/links/advanced-servlets>
(Continue reading)

Steven J. Owens | 9 Dec 2002 04:56

Dynamically Generating Javabeans

Hi,

     This is a bit offbeat but, I think, on-topic.  At least it's
likely to be advanced :-).  I'm doing this fairly vanilla project,
servlets, JSP and JDBC, and I'm getting annoyed at the amount of rote
code I need to write. 

     A common tactic is having the JSP instantiate a javabean which
will hold all the parameters, then dispatch the request, with
javabean, off to a servlet for processing.  Besides instance variables
for the parameters, the bean typically has validation code which
checks the parameters and stores error messages about the failed
validation in another instance variable on the javabean.  The JSP
instantiates the bean, uses the "usebean" JSP tag to copy all matching
parameters into the bean (via reflection), calls the validate() method
on the bean, and if it passes stores the bean in the user session (or
in a request attribute) and dispatches the request off to the servlet
for further handling. 

     Unfortunately, using this approach means I need to code a bean
for each form, and each bean has to have gobs of rote code for the
getters and setters, mostly rote code for the validators and error
messages (though I can easily factor a lot of the primitives for
validation out into reusable methods on a parent javabean class).  I
hate doing rote work :-).

     What I'm considering is generating the javabeans dynamically from
a configuration file, using Kawa (http://www.gnu.org/software/kawa/)
or BCEL (http://jakarta.apache.org/bcel/index.html).  I haven't looked
too deeply into either package, though I know Nic thinks highly of
(Continue reading)

Martin Cooper | 9 Dec 2002 05:41

RE: Dynamically Generating Javabeans

Something else you might want to consider is using Commons BeanUtils and
Commons Validator, from Jakarta. BeanUtils has something called a DynaBean,
which is a dynamically generated bean, usually configured using an XML
config file. Validator allows you to validate beans by specifying the
validation rules in an XML config file.

Struts combines these into DynaValidatorForms to do exactly the kind of
thing you describe - configure the bean properties and their validation
rules in XML so that you can avoid the drudgery of coding the beans and the
validation rules every time.

There are also some other solutions, linked to from the Resources page on
the Struts web site, that will generate Java code for your beans, which you
can then modify if necessary. Personally, I prefer the "no code" approach,
though.

--
Martin Cooper

> -----Original Message-----
> From: Steven J. Owens [mailto:puffmail <at> darksleep.com]
> Sent: Sunday, December 08, 2002 7:56 PM
> To: advanced-servlets <at> yahoogroups.com
> Subject: [advanced-servlets] Dynamically Generating Javabeans
> 
> 
> Hi,
> 
>      This is a bit offbeat but, I think, on-topic.  At least it's
> likely to be advanced :-).  I'm doing this fairly vanilla project,
(Continue reading)

Nic Ferrier | 9 Dec 2002 16:26
Picon

Re: Dynamically Generating Javabeans

"Steven J. Owens" <puffmail <at> darksleep.com> writes:

>      What I'm considering is generating the javabeans dynamically from
> a configuration file, using Kawa (http://www.gnu.org/software/kawa/)
> or BCEL (http://jakarta.apache.org/bcel/index.html).  I haven't looked
> too deeply into either package, though I know Nic thinks highly of
> Kawa and BCEL is used a fair bit in the jakarta projcets.  I'll still
> have to write the configuration file, but hopefully it'll be easier
> and more cleanly separated from the presentation/form-handling code.

I do think highly of kawa - it's a very good tool.

But personally, I'd just write a bit of emacs lisp to write jsps from
beans (or vice versa).

I'm doing something similar right now with callable statements. I'm
using a lot of stored procs for a website I'm building (no state in
the webserver that way) and I built a bit of elisp so that I can turn
simple s-exps into full java code to call particular procs, eg if I
write this:

   public static int getNewThingFromDb (String x)
   {
      (my_proc x)
   }

and I run the magic "proc expand" emacs function with the cursor
positioned after the close paren then this is what I get:

   public static int getNewThingFromDb (String x)
(Continue reading)

Nic Ferrier | 16 Dec 2002 02:00
Picon

map with java.

I've been trying to find the best way to abstract querys to SQL for
ages.

What I've normally done is to build an object to represent a row in a
query (or several different query's row's) and used an Iterator to
wrap a ResultSet, the Iterator's next() method produces a new row
object.

This seems pretty natural but there are one or two problems:

- there's no easy way to close the ResultSet and free any pooled SQL
  connection, it's fairly easy to add close_on_exhausted but this
  adds a little bit of hidden complexity that's easy to forget.

- the row object creation can be expensive: again it's easy to
  alleviate by using object reuse, but that adds hidden complexity
  that's difficult to make more obvious. Sometimes I want to have
  object reuse and sometimes I find it necessary to have real new
  objects for each row; doing things with wrapped ResultSet's means
  it's necessary to add more methods to get switchable reuse.

I've just been experimenting with an alternative approach, namely
mapping.

Mapping is used in LISP all the time, but I've never thought of using
it in Java before and wondered whether anybody else had.

Briefly I'm doing this:

public class SearchRoutines
(Continue reading)

David M. Lehrian | 16 Dec 2002 03:15

Re: map with java.

Hi Nic,
I too have grappled with the best way to abstract an SQL data model.  The mapping concept that you outline
certainly looks workable, but it seems like a lot of code needs to be written for each table you want to map. 
i.e.  create the interface, get the connection, formulate the query and code the mapper to handle the
result set (doesn't solve the first problem you mention).  I am guessing that the idea is to get data from the
database into HTML as quickly as possible in a manner that doesn't cause a new object to be allocated for
each row in the result set (solves the second problem you mention).  It just doesn't seem to do that much for
you.  

I prefer the Object-Relational mapping method whereby each row is turned into a real java object and handed
back to the programmer as an ArrayList of objects.  They can then be programmed to have many different
output "views".  And rather than hand code each individual persistent object, I prefer to store the
mapping information in an XML file and use an abstract superclass to create the actual java objects and
populate their data.  I wrote such an O-R mapping layer and a graphical modeling tool that generates the
necessary XML mapping files, the SQL to create the database and the persistent Java objects.  It is
available at http://www.redshift.com/~lehrian/DMLDataAccess.  It implements to-one and to-many
relationships and will sort them if set up to do so in the model.  As it is written in a thread safe manner I have
been able to use it for all my work including servlet/JSP development.  If there were ever interest, I would
opensource the code.  I have an example of how it i
 s used in a servlet on the web site.  
Warm Regards,
Dave

_______________________________________________
David M. Lehrian
Software Engineer
http://www.easypetidtags.com/
http://www.redshift.com/~lehrian/DMLDataAccess
http://www.redshift.com/~lehrian/JDBCQueryTool
http://www.redshift.com/~lehrian
(Continue reading)

Charles Forsythe | 16 Dec 2002 08:49
Picon
Favicon

Re: map with java.

Nic Ferrier wrote:

>I've been trying to find the best way to abstract querys to SQL for
>ages.
>  
>
Check out Castor JDO at http://castor.exolab.org.  I've started using it 
for a new project and I like it.  It can handily map an object to a row; 
I have some issues with it, but they involve functionality that goes far 
beyond the mere mapping of tables.

Benefits of JDO:

    * Open Source (BSD-style)
    * Doesn't follow the controversial Sun JDO spec
    * Total isolation from the DB (changing DB's involves changing a
      attribute in an XML file)
    * Performance features (caching)
    * Object-to-DB mapping done with XML files
    * These XML files can be generated from tags in the java files using
      XDoclet

I've done a lot of groundwork figuring out how to map some complex 
object relationships in Castor, so I'd be happy to share tips.

-- Charles

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/saFolB/TM
(Continue reading)

Nic Ferrier | 16 Dec 2002 14:06
Picon

Re: map with java.

"David M. Lehrian" <david <at> lehrian.com> writes:

> Hi Nic,
> I too have grappled with the best way to abstract an SQL data model.
> The mapping concept that you outline certainly looks workable, but it
> seems like a lot of code needs to be written for each table you want
> to map.  

I don't tend to use tables directly, I tend to abstract all my querys
with procs that return ResultSets. Of course, there is still a tabular
structure at the end of the day but I think of it more as calling a
proc which generates a stream of rows of a certain type.

> i.e.  create the interface, get the connection, formulate the
> query and code the mapper to handle the result set (doesn't solve the
> first problem you mention).  

It does solve that problem, the iteration is done within the confines
of a method dedicated to the database glue. The connection gets
closed when the mapping completes.

> I am guessing that the idea is to get data from the database into
> HTML as quickly as possible in a manner that doesn't cause a new
> object to be allocated for each row in the result set (solves the
> second problem you mention).  It just doesn't seem to do that much
> for you.

What mapping does is seperate the output of the row data from the
means of obtaining the row data. Obtaining the row data (after the
stored proc has been written) is the sort of thing that can be written
(Continue reading)


Gmane