dcsimg
Abstract handling of EJB classes/interface inheritance during port to J2EE from COM
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bob_Riddle
Posted On:   Wednesday, April 3, 2002 05:19 PM

I am a new Java developer who is porting a Delphi / MTS COM message-oriented-middleware system to J2EE. I have hit an issue of abstract handling of EJB class/interface inheritance during this port for which I would love to hear the "best" Java solution. In this system, a central dispatcher object receives an XML request, parses out some relevant parameter data, and calls a factory method passing in the parameters. The factory method looks at a table, instantiates an instance of the proper adaptor to field the request, and returns the specific adaptor class cast back to a standardized base adaptor class. This base adaptor class cast instance is used by the dispatcher to process the class. So in the COM system d   More>>

I am a new Java developer who is porting a Delphi / MTS COM message-oriented-middleware system to J2EE. I have hit an issue of abstract handling of EJB class/interface inheritance during this port for which I would love to hear the "best" Java solution.


In this system, a central dispatcher object receives an XML request, parses out some relevant parameter data, and calls a factory method passing in the parameters. The factory method looks at a table, instantiates an instance of the proper adaptor to field the request, and returns the specific adaptor class cast back to a standardized base adaptor class. This base adaptor class cast instance is used by the dispatcher to process the class.


So in the COM system dispatcher object, we basically had:

			
In Dispatcher Object:
BaseAdaptor ba = AdaptorFactory.Create(InputParameters);
ba.ProcessRequest(InputXmlStream);

			
Method declaration in BaseAdaptorClass:
String ProcessRequest(InputXmlStream);

			
In each specific adaptor:
SpecificAdaptorClass extends BaseAdaptor;

			
In AdaptorFactory:
(Determines proper class for input data parameters)
SpecificAdaptorClass sac = SpecificAdaptorClass.create()
return (BaseAdaptor) sac


Before I got this project, several Java novices converted the various adaptors to J2EE EJB session beans. Each came back with both a local and remote EJB 2.0 interface. They changed the implementation to:

			
Method declaration in the Java BaseInterfaceClass:
Interface BaseInterfaceClass
String processRequest(String Input XmlStream) throws RemoteException

			
In BaseAdaptorClass:
class BaseAdaptorClass implements BaseInterfaceClass


In each each specific adaptor EJB remote interface declaration:

			
interface SpecificAdaptorClass extends javax.ejb.EJBObject
String processRequest(String XmlStream);


In each each specific adaptor EJB local interface declaration:

			
interface SpecificAdaptorClassLocal extends javax.ejb.EJBLocalObject;
String processRequest(String XmlStream);


In each specific adaptor Bean class:

			
SpecificAdaptorClassBean extends BaseAdaptorClass implements SessionBean


Some adaptors may be instantiated as local interfaces; others as remote. This decision must not be hard-coded; it is to be determined at run-time by configuration property file based on the size and capacity requirements of each client.


I had little problem writing most of the Dispatcher session EJB. But I hit problems deciding what common class to pass back from the factory to the Dispatcher. My problem is to understand what I have in common that can be used generically from the dispatcher. The local and remote interfaces from each SpecificAdaptorClassBean do not descend from a common ancestor.


The SpecificAdaptorClassBeans themselves descend from a common base class, but I do not seem to have access to the class instance remotely. I cannot follow our old paradigm of calling the factory and getting back a cast to BaseAdaptorClass because the EJB instantiation process returns an interface instance; not a class instance.


I can't simply pass the interface class back to the dispatcher because the local and remote interfaces do not have a usable common ancestor interface with the custom method (processRequest) I need. Neither descends from our BaseInterfaceClass.


How is this kind of thing best done in the J2EE paradigm? Do we manually edit the interface inheritance tree in each SpecificAdaptorBean to insert our BaseInterfaceClass in the middle? We could try to cast each EJB reference interface back to that BaseIntefaceClass for use by the generic Dispatcher. Will that then properly marshall and function remotely as an EJB 2.0 bean? Is there a way, or is it proper, to derive a base class instance variable to return to the Dispatcher from the factory? Can we simply do a getInterfaces() to get an interface array and find / directly use the BaseInterfaceClass that should be obtained? Will that remotely marshall correctly?

   <<Less
About | Sitemap | Contact