Re: How to remove stateful sessions programmatically ?

2008-10-17 Thread David Blevins


On Oct 17, 2008, at 5:57 AM, Jean-Sébastien Scrève wrote:



Hi all,

I'd like to remove stateful sessions beans by calling a method from  
OpenEJB

itself and I don't see how I can do that.
I don't want to call a method with @Remove annotation because I did  
not

create the stateful myself.
Is there a way I can do that ?
More generally, how I can interact with the container at runtime ?


If the bean had a 2.x home/remote interface that'd be easy as you  
could call remove on the home interface and pass in the stateful bean  
reference.  Aside from that, not sure it can be done.  The code we  
have for removing stateful beans is very much tied to the invoking of  
the remove method, calling the predestroy methods of the interceptors  
and bean, taking care of the transaction settings for the method,  
handling the exceptions thrown from the method, etc.  We don't have a  
second way to remove stateful beans.


The only other way I can think of is via an interceptor.  If an  
interceptor method throws a runtime exception then the bean is  
destroyed.


-David




Re: How to remove stateful sessions programmatically ?

2008-10-17 Thread David Blevins


On Oct 17, 2008, at 1:49 PM, David Blevins wrote:



On Oct 17, 2008, at 5:57 AM, Jean-Sébastien Scrève wrote:



Hi all,

I'd like to remove stateful sessions beans by calling a method from  
OpenEJB

itself and I don't see how I can do that.
I don't want to call a method with @Remove annotation because I did  
not

create the stateful myself.
Is there a way I can do that ?
More generally, how I can interact with the container at runtime ?


If the bean had a 2.x home/remote interface that'd be easy as you  
could call remove on the home interface and pass in the stateful  
bean reference.  Aside from that, not sure it can be done.  The code  
we have for removing stateful beans is very much tied to the  
invoking of the remove method, calling the predestroy methods of the  
interceptors and bean, taking care of the transaction settings for  
the method, handling the exceptions thrown from the method, etc.  We  
don't have a second way to remove stateful beans.


The only other way I can think of is via an interceptor.  If an  
interceptor method throws a runtime exception then the bean is  
destroyed.


Feel free to elaborate on the use case.  Might be an alternate way of  
looking at the problem that could also solve the issue.


-David