[jboss-user] [EJB 3.0] - Re: Requesting the EJB container to remove an instance
pete.muir@jboss.org
do-not-reply at jboss.com
Fri Mar 13 07:06:59 EDT 2009
I talked to ALR about this a bit, here is a precis:
"Andrew Rubinger" wrote : So maybe you can explain a couple things then I'll weigh in? "This needs to be in a portable way"
The standard WB requirement - that WB must operate on other AS than JBoss - we can't have JBoss code in WB itself - if we do need to make a AS specific call we have to do it through the SPI
"Andrew Rubinger" wrote : And you want to invoke upon what object? The proxy from JNDI?
The problem is not that i need to invoke on an EJB but request the EJB container remove it.
Then, we talked about the background:
We need to remove ejbs (e.g. when the coversation context is destroyed), if there is a Session bean proxied instance stored in a context, it get's cleaned up automatically.
"Andrew Rubinger" wrote : And you can't call @Remove ?
We can't call @Remove as there might be multiple @Remove methods (which one to we call?) or there might be parameters to the remove method (how do we know what they are)
"Andrew Rubinger" wrote : So you want to remove the backing session, and have no callback upon the SFSB. Which is possible but feels like a real back-door approach...
The @PreDestroy callback should still be executed. In other words, if we did this through bytecode instr, it would be like adding in a @Remove public void wbRemove() {} method
Then, I described a possible SPI Web Beans could use:
interface EJBInstance<T> implements Serializable {
|
| public void remove();
| T getInstance();
|
| }
and an addition to the EJBResolver Web Beans SPI:
interface EJBResolver {
|
| // ...
|
| EJBInstance resolve(String jndiName);
| }
Where Web Beans would use it like:
// initial lookup
| EJBInstance ejb = ejbResolver.lookup(jndiName);
| // Some requests go by, JSR299 context needs destroying
| // destroy
| ejb.remove();
for example, in JBoss we could implement this like:
class JBossEjbInstance<T> implements EjbInstance<T> {
|
| Object proxy;
| String jndiName;
|
| JBossEjbInstance(String jndiName) {
| this.jndiName = jndiName;
| }
|
| private init() {
| if (proxy == null) {
| proxy = getInitialContext().lookup(jndiName);
| if (!(proxy instanceof Serializable))
| throw new IllegalStateException();
| }
| }
|
| public T getInstance() {
| init();
| return (T) instance;
| }
|
| public void remove() {
| ((StatefulSessionProxy) instance).remove();
| }
| }
"Andrew Rubinger" wrote : Why Serializable?
Because the proxy needs e.g. to be serialzied to http session
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4217807#4217807
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4217807
More information about the jboss-user
mailing list