Here is a link that talks about Dynamic Proxy classes. That is essentially what we are 
using, but the underlying storage is a map.  
 
http://java.sun.com/j2se/1.3/docs/guide/reflection/proxy.html
 
thanks,
dave

-----Original Message-----
From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 5:25 AM
To: [EMAIL PROTECTED]
Subject: RE: Use of stuts in J2EE



Dave,

Thanks again for the detailed reply.

Where can I find information about the Map proxy pattern? I found Dynamic pattern but 
not Map Proxy?

Rgs

Vikram

 

1) We use many patterns to implement this, but I think that you are referring to the 
Value Object pattern
2) The copy part of the strategy is somewhat inefficient (processor wise), but it 
saves network traffic since the data is sent to the EJBs and the setters are called 
within a bean method rather than from a remote client. Also, we are mostly concerned 
with horizontal scalability so the extra processing time isn't as bad as the network 
traffic. Doing a copy from one object to another reduces coupling since you never 
explicitly call a setter method. As far as implementation inefficiency, we use another 
pattern called the Map Proxy (Dynamic Proxy Class) Pattern to dynamically create the 
input objects based on interfaces, so the bean implements the interface, and you 
dynamically construct the value objects from the interface. You only need to create 
one interface and your ejb. 

3) Here is a simple example of the value object pattern in struts:

public class MyForm {

        private AddressVO address;

        // getters and setters for the AddressVO are here
}

All of the ejbs take in Value Objects (VOs) so for example:

addressHomeInterface.create(addressVO);
or
addressRemoteInterface.setAddress(addressVO);

In the jsp you simply access fields by referencing the value object stored inside:

<html:text property="addressVO.city"/>

In the Action you just extract the value object and pass it to the EJB layer. 

addressHomeInterface.create(myForm.getAddressVO());

The way that we do it is much more complicated than this simple example, but this 
should give you an idea of how to use value objects. We are also using a MapProxy 
pattern that allows you to dynamically create classes based off of interfaces. So 
instead of having an implemented addressVO we have an interface. We can dynamically 
build a class based off of several interfaces which allows us to combine value objects 
into one object. We are also using a Command pattern on top of that that lets you run 
a large chunk of business logic on the EJB container with only two peices of network 
traffic. It is kind of a batch processor for database logic. It would be a rather long 
email if I explained all of them. Let me know if you want me to explain it any 
further. IBM describes the command pattern in one of it's redbooks 
http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg245754.html?Open

Javaworld has an article on Dynamic Proxy Classes (the base pattern for Map Proxy): 
http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-proxy.html

Thanks,
dave


Reply via email to