as a design consideration we are planning to cache all the EJB Homes as soon as the Application server starts .
Also we want to make the code as generic as possible and not dependent on the specific classes .
So while narrowing the Object references can we do a generic narrow as shown below ?
ejbHome = (EJBHome)
PortableRemoteObject.narrow(objref, EJBHome.class);
Note that the object is being narrowed to EJBHome .
Later in the application when ever a jndi lookup is done the object is taken from the cache and narrowed to the specific class ...
is this ok ? does this cause any problems ? if so what ?
Thanks in advance for the help ...
Mohan
-
passing an interface/parent class to narrow an object ? (3 messages)
- Posted by: Mohan Navaratna
- Posted on: April 22 2002 18:44 EDT
Threaded Messages (3)
- passing an interface/parent class to narrow an object ? by Gal Binyamini on April 22 2002 19:21 EDT
- passing an interface/parent class to narrow an object ? by Neeraj Nargund on April 23 2002 11:17 EDT
- passing an interface/parent class to narrow an object ? by Marcus Eriksson on May 08 2002 10:37 EDT
- passing an interface/parent class to narrow an object ? by Neeraj Nargund on April 23 2002 11:17 EDT
-
passing an interface/parent class to narrow an object ?[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: April 22 2002 19:21 EDT
- in response to Mohan Navaratna
You have to call PortableRemoteObject.narrow for the actual interface you intend to cast the EJBHome to later. Is you only narrow to EJBHome.class, you can't be sure that the result be be cast to your specific home interface.
You can do:
ejbHome = (EJBHome)PortableRemoteObject.narrow(objref, EJBHome.class);
Class ejbHomeInterface = ejbHome.getEJBMetaData().getHomeInterfaceClass();
EJBHome narrowEJBHome = (EJBHome)PortableRemoteObject.narrow(objref, ejbHomeInterface);
Gal -
passing an interface/parent class to narrow an object ?[ Go to top ]
- Posted by: Neeraj Nargund
- Posted on: April 23 2002 11:17 EDT
- in response to Gal Binyamini
what about the different create and finder methods..they will be different for different beans...right...????
-
passing an interface/parent class to narrow an object ?[ Go to top ]
- Posted by: Marcus Eriksson
- Posted on: May 08 2002 10:37 EDT
- in response to Neeraj Nargund
Probably.
Could we use reflection?
Something like:
Class c = narrowEJBHome.getClass();
Method create = c.getMethod("create");
create.invoke();
In my case, I need some method that returns a created bean instance based only on the jndi name of the bean (or perhaps the class name of the home interface and bean class).
Any ideas?