Hello,
Sorry, if this question is quite out of topic.
If it is absolutely obvious, just point me
to a book/faq or, well, any other direction.
Let me explain, what I'm trying to achieve:
I want some of my stateless session (computation) beans
implement a predefined interface, for instance
public interface ComputationBean
{
public String compute(String xml)
throws ComputationException;
}
I need that, because these beans could be deployed
at run time, and the client (web-application) needs to
perform the same common task on all of them. I don't
own those beans, they are supposed to be written by
user/customers.
It's not a problem, right? Remote interfaces just need
to be extended from ComputationBean and been classes should
implement ComputationBean as well.
Ok, but how the client can call the bean compute method,
or actually, how can I obtain its Home Interface and
create the bean?
Suppose I know a JNDI name for any bean, and I can look
up the bean up by name:
Object homeRef = jndiContext.lookup(beanNameString);
but, how can I cast (narrow) homeRef to the specific
bean home interface? I don't know the name and it's
not in the client CLASSPATH as well. Can I define some
generic Home and Remote Interfaces and force users
inherit their home/remote interfaces from them?
I think it won't work, though.
public interface ComputationBeanHome extends EJBHome
{
public ComputationBean create();
}
public UserBeanHome extends ComputationBeanHome
{
}
and on the client
ComputationBeanHome homeBean =
(ComputationBeanHome)PortableRemoteObject
.narrow(homeRef, ComputationBeanHome.class);
ComputationBean userBean =
(ComputationBean)homeBean.create();
Is this possible somehow? I'm thinking about some other
possible solutions, but really don't know which is
right or even will work.
Perhaps, I should process userbeen.jar at the deployment
time and by parsing ejb-jar.xml get real Remote and Home
interfaces, then load them dynamically on the client, use
reflection to find a "create()" method and so on.
Is anybody doing something similar? Could you share
your design or give me a hint?
Thanks a lot in advance.
Best regards,
Alex.
--
_________________________________________________________
Alexander Kogan Parametric Technology Corporation
[EMAIL PROTECTED] 128 Technology Drive, Waltham MA 02453
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]