You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Quintin Beukes <qu...@last.za.net> on 2009/09/08 11:44:42 UTC

3.0 Singleton in Container Question

Hey,

How does the classloaders for OpenEJB 3.0 work. I'm looking into
getting an application wide, or at least client login session-wide
Spring ApplicationContext. Just to clarify, I want to get a Spring
context so to be able to have certain spring benefits like AOP and
configurable wiring+beans+services, etc. The standard spring features.
To get this, either Geronimo 2.1.4 needs some Spring support to give
me an ApplicationContext, or OpenEJB needs some way with which I can
manage a singleton (ApplicationContext).

I was thinking of making a PropertyEditor, that translates back to a
wrapper for the ApplicationContext, and then I inject it with an
@Resource. Something like:

@Resource
private MyApplicationContext applicationContext;

void someMethod()
{
  applicationContext.getBean("...");
}

But for this context to work I need to make it a Singleton? The main
reason for this is so 2 consecutive requests to an EJB that might
reach a different instance, need to get the same appcontext instance
for a given login session, so if not possible I would rather have all
my EJBs reach a single wrapper instance, and then based on the current
security context (ie. session) distinguish between application
instances, that is if that security context is accessible via static
methods (similar to JAAS's method for accessing it).

Any ideas/advise? Is this even necessary? If it needs some work, I'll
be willing to invest the time to perhaps build a plugin for
OpenEJB/Geronimo, which someone can use to add basic Spring
integration to Geronimo 2.1 or OpenEJB 3.0.

-- 
Quintin Beukes

Re: 3.0 Singleton in Container Question

Posted by David Blevins <da...@visi.com>.
On Sep 11, 2009, at 5:52 AM, Quintin Beukes wrote:

> That's great. I didn't even think of the EJB interceptors. Can they be
> cross JAR as well? I basically have all my EJB projects.
>
> Then I have a 2 different auditing modules. Depending on the auditing
> module you deploy (which would be a separate jar) you should get
> different interceptors (not just different implementations but
> completely different 'approaches').

Not sure of the intended distinction between implementations and  
approaches, but yes you can have different interceptors for each  
module, each bean or even each method of a bean.

In terms of instantiation and lifecycle, the interceptor instances  
share the exact same lifecycle of the bean they are intercepting  
(wrapping).  So interceptor instances are created when individual  
beans are created and destroyed when the individual beans are destroyed.

In terms of configuration you can say "this interceptor class applies  
to all ejbs in this module" (a global interceptor) or to "this  
bean" (class interceptor) or "this method".  You can even exclude the  
global interceptors or exclude the class interceptors, etc. etc.  It's  
pretty flexible.

-David


Re: 3.0 Singleton in Container Question

Posted by Quintin Beukes <qu...@skywalk.co.za>.
That's great. I didn't even think of the EJB interceptors. Can they be
cross JAR as well? I basically have all my EJB projects.

Then I have a 2 different auditing modules. Depending on the auditing
module you deploy (which would be a separate jar) you should get
different interceptors (not just different implementations but
completely different 'approaches').

Is this possible?

Q

On Thu, Sep 10, 2009 at 8:47 PM, David Blevins <da...@visi.com> wrote:
>
> On Sep 8, 2009, at 6:41 AM, Quintin Beukes wrote:
>
>> Take for instance a real world example. I want to strap all my classes
>> with AOP interceptors, for auditing purposes. This way I can record
>> what each user did, without having to add a bunch of code into each
>> method. I can also disable it for certain users, and easily modify
>> it's behaviour. Perfect example of where AOP is a life saver.
>
> Sounds like a regular EJB Interceptor would work.  Something configured
> globally.
>
>> How difficult would it be to integrate OpenEJB 3.1 into Geronimo?
>
> The pending Geronimo 2.2 uses our current trunk which is 3.1.2.  We're in
> the process of finishing up issues/bugs for 3.1.2 also waiting on another
> xbean release.  Geronimo 2.2 is good to go TCK wise and is branched and
> frozen simply waiting for the 3rd party releases from OpenEJB, ActiveMQ,
> XBean and a few others.  We're looking at another week or two before
> Geronimo 2.2 can go up for a vote.
>
> -David
>
>



-- 
Quintin Beukes

Re: 3.0 Singleton in Container Question

Posted by David Blevins <da...@visi.com>.
On Sep 8, 2009, at 6:41 AM, Quintin Beukes wrote:

> Take for instance a real world example. I want to strap all my classes
> with AOP interceptors, for auditing purposes. This way I can record
> what each user did, without having to add a bunch of code into each
> method. I can also disable it for certain users, and easily modify
> it's behaviour. Perfect example of where AOP is a life saver.

Sounds like a regular EJB Interceptor would work.  Something  
configured globally.

> How difficult would it be to integrate OpenEJB 3.1 into Geronimo?

The pending Geronimo 2.2 uses our current trunk which is 3.1.2.  We're  
in the process of finishing up issues/bugs for 3.1.2 also waiting on  
another xbean release.  Geronimo 2.2 is good to go TCK wise and is  
branched and frozen simply waiting for the 3rd party releases from  
OpenEJB, ActiveMQ, XBean and a few others.  We're looking at another  
week or two before Geronimo 2.2 can go up for a vote.

-David


Re: 3.0 Singleton in Container Question

Posted by Quintin Beukes <qu...@skywalk.co.za>.
Hey,

Those links you gave me is exactly what I'm looking for, and I've
looked at them. Though they're only for OpenEJB 3.1, which is not
available in Geronimo. Further I had a look at the OpenEJB 3.0 Spring
integration, but that won't help me.

Take for instance a real world example. I want to strap all my classes
with AOP interceptors, for auditing purposes. This way I can record
what each user did, without having to add a bunch of code into each
method. I can also disable it for certain users, and easily modify
it's behaviour. Perfect example of where AOP is a life saver.

Though OpenEJB 3.0 doesn't have Spring integration.

How difficult would it be to integrate OpenEJB 3.1 into Geronimo?

Q

On Tue, Sep 8, 2009 at 1:59 PM, Jean-Louis MONTEIRO
<je...@atosorigin.com> wrote:
>
>
>
> Q Beukes wrote:
>>
>> Hey,
>>
>> How does the classloaders for OpenEJB 3.0 work. I'm looking into
>> getting an application wide, or at least client login session-wide
>> Spring ApplicationContext. Just to clarify, I want to get a Spring
>> context so to be able to have certain spring benefits like AOP and
>> configurable wiring+beans+services, etc. The standard spring features.
>> To get this, either Geronimo 2.1.4 needs some Spring support to give
>> me an ApplicationContext, or OpenEJB needs some way with which I can
>> manage a singleton (ApplicationContext).
>>
>> I was thinking of making a PropertyEditor, that translates back to a
>> wrapper for the ApplicationContext, and then I inject it with an
>> @Resource. Something like:
>>
>> @Resource
>> private MyApplicationContext applicationContext;
>>
>> void someMethod()
>> {
>>   applicationContext.getBean("...");
>> }
>>
>> But for this context to work I need to make it a Singleton? The main
>> reason for this is so 2 consecutive requests to an EJB that might
>> reach a different instance, need to get the same appcontext instance
>> for a given login session, so if not possible I would rather have all
>> my EJBs reach a single wrapper instance, and then based on the current
>> security context (ie. session) distinguish between application
>> instances, that is if that security context is accessible via static
>> methods (similar to JAAS's method for accessing it).
>>
>> Any ideas/advise? Is this even necessary? If it needs some work, I'll
>> be willing to invest the time to perhaps build a plugin for
>> OpenEJB/Geronimo, which someone can use to add basic Spring
>> integration to Geronimo 2.1 or OpenEJB 3.0.
>>
>> --
>> Quintin Beukes
>>
>>
>
>
> Hello Quintin,
>
> did you have a look to spring sample ?
> OpenEJB have a nice (starting) Spring integration. It allows injecting
> spring beans in Java EE components and Java EE components in Spring beans.
>
> http://openejb.apache.org/3.0/spring.html
> http://openejb.apache.org/3.0/spring-ejb-and-jpa.html
>
>
> Hope it helps.
> Jean-Louis
> --
> View this message in context: http://www.nabble.com/3.0-Singleton-in-Container-Question-tp25342947p25344767.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>



-- 
Quintin Beukes

Re: 3.0 Singleton in Container Question

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.


Q Beukes wrote:
> 
> Hey,
> 
> How does the classloaders for OpenEJB 3.0 work. I'm looking into
> getting an application wide, or at least client login session-wide
> Spring ApplicationContext. Just to clarify, I want to get a Spring
> context so to be able to have certain spring benefits like AOP and
> configurable wiring+beans+services, etc. The standard spring features.
> To get this, either Geronimo 2.1.4 needs some Spring support to give
> me an ApplicationContext, or OpenEJB needs some way with which I can
> manage a singleton (ApplicationContext).
> 
> I was thinking of making a PropertyEditor, that translates back to a
> wrapper for the ApplicationContext, and then I inject it with an
> @Resource. Something like:
> 
> @Resource
> private MyApplicationContext applicationContext;
> 
> void someMethod()
> {
>   applicationContext.getBean("...");
> }
> 
> But for this context to work I need to make it a Singleton? The main
> reason for this is so 2 consecutive requests to an EJB that might
> reach a different instance, need to get the same appcontext instance
> for a given login session, so if not possible I would rather have all
> my EJBs reach a single wrapper instance, and then based on the current
> security context (ie. session) distinguish between application
> instances, that is if that security context is accessible via static
> methods (similar to JAAS's method for accessing it).
> 
> Any ideas/advise? Is this even necessary? If it needs some work, I'll
> be willing to invest the time to perhaps build a plugin for
> OpenEJB/Geronimo, which someone can use to add basic Spring
> integration to Geronimo 2.1 or OpenEJB 3.0.
> 
> -- 
> Quintin Beukes
> 
> 


Hello Quintin,

did you have a look to spring sample ?
OpenEJB have a nice (starting) Spring integration. It allows injecting
spring beans in Java EE components and Java EE components in Spring beans.

http://openejb.apache.org/3.0/spring.html
http://openejb.apache.org/3.0/spring-ejb-and-jpa.html


Hope it helps.
Jean-Louis
-- 
View this message in context: http://www.nabble.com/3.0-Singleton-in-Container-Question-tp25342947p25344767.html
Sent from the OpenEJB User mailing list archive at Nabble.com.