preventing use of EJB outside container

Can explicit instantiation of an EJB be prevented in some way?

What I mean is I have a stateless session bean MyBean.

Can I prevent:

MyBean bean = new MyBean();

from being called, thus enforcing a lookup or injection to get an instance?

Am I right in assuming that this call will result in an instance of the bean outside of the container.

Thanks

[390 byte] By [bart_bva] at [2007-10-3 3:20:41]
# 1

Hi Bart,

Lookup/injection is the only way to get a reference to an EJB component(Session bean, 2.x Entity bean) In the EJB programming model, the EJB client never has a direct reference to the bean class instance.If a piece of code explicitly instantiates an ejb bean class by calling new(), it isn't an EJB.

Note that this is not to be confused with the programming model for the new Java Persistence API, which *is* based on application code calling new(). Java Persistence API entity classes are not EJB components so they have a different access semantics.

--ken

ksaksa at 2007-7-14 21:12:54 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...