-
1. Re: How do I access the JBoss Kernel from an EJB3?
alesj Jan 5, 2010 12:06 PM (in response to ewittmann)Perhaps this ALR's blog post can help you:
* http://exitcondition.alrubinger.com/2008/12/20/doing-two-models-at-the-same-time/
-
2. Re: How do I access the JBoss Kernel from an EJB3?
ewittmann Jan 6, 2010 1:55 PM (in response to alesj)Thanks for the link. The blog post discusses the opposite of what I need to do (i.e. injecting an EJB into an MC Bean). That said, perhaps the same sort of approach will work going the other way. -
3. Re: How do I access the JBoss Kernel from an EJB3?
alesj Jan 6, 2010 3:23 PM (in response to ewittmann)Ah, you're right.
Unfortunately I don't know enough about our EJB architecture to help you,
hence I think you should move the question to their forum.
Just link the issues, so someone looking for similar stuff can link them.
-
4. Re: How do I access the JBoss Kernel from an EJB3?
alesj Jan 6, 2010 3:47 PM (in response to alesj)Unfortunately I don't know enough about our EJB architecture to help you,
hence I think you should move the question to their forum.
I just had a quick chat with ALR (EJB core dev), and he said we currently don't have anything similar for the other way around.
So, I was thinking we could/should add something to our MC-int project, some simple, but nice/clean MC&EJB integration.
e.g. I did something similar for MC & Servlet integration
ALR and me are willing to "chaperone" you if you would be interested in implementing this.
I would go in the following direction
* have EJB3 interceptor that would understand MC
* see what it takes to integrate this interceptor with our EJB container and MC
* then simple declare this interceptor on your EJB bean to get whatever "MC style" behavior
This code would then live in MC-int/ejb project and would be added to AS common lib (if EJB is used).
Wdyt?
-
5. Re: How do I access the JBoss Kernel from an EJB3?
alrubinger Jan 6, 2010 3:50 PM (in response to alesj)This gets back to debates we have within the EJB3 team about Interceptors being able to see their owning EJB Container. The Container in turn has a reference to the Kernel.
S,
ALR
-
6. Re: How do I access the JBoss Kernel from an EJB3?
alesj Jan 6, 2010 3:55 PM (in response to alrubinger)This gets back to debates we have within the EJB3 team about Interceptors being able to see their owning EJB Container. The Container in turn has a reference to the Kernel.
Why is this an issue?
In the worst case we could only allow for certain lookups.
e.g. by wrapping the beans capable of doing "invalid" lookup
-
7. Re: How do I access the JBoss Kernel from an EJB3?
alrubinger Jan 6, 2010 4:01 PM (in response to alesj)It's only an issue now as in the current implementation we don't have a mechanism to get from A to B. It's not a conceptual problem, but one stemming out of how we (currently) use AOP and don't have a reference to the Container as an instance member of an interceptor.
We can, however, look up the Container ID as a property of the current invocation, and then check that against the Ejb3Registry.
Hmm, or we can take Interceptors out of the picture entirely, grab the current invocation from the ThreadLocal with which it's registered, and look up that way.
In short I'm still mulling over a clean way.
S,
ALR
-
8. Re: How do I access the JBoss Kernel from an EJB3?
alrubinger Jan 6, 2010 5:09 PM (in response to alrubinger)Or we can say that EJB will have a few feature: support injection of MC beans via @Inject.
Then you can make an MC bean:
public class MyBean{ @Inject private Kernel kernel; public Kernel getKernel(){ return kernel; } }
...and put into your EJB:
@Stateless public class MyEjbBean implements MyEjbLocalBusiness{ @Inject private MyBean bean; public void businessMethod(){ bean.getKernel(); // There you go } }
I've held off on this feature in hopes we rework the injection framework first.
S,
ALR
-
9. Re: How do I access the JBoss Kernel from an EJB3?
alrubinger Jan 7, 2010 1:43 PM (in response to alrubinger)Of course if the EJB impl supports @Inject then you could just inject the Kernel directly.
S,
ALR
-
10. Re: How do I access the JBoss Kernel from an EJB3?
ewittmann Jan 7, 2010 3:00 PM (in response to alrubinger)This is a very interesting discussion, and of course I think that @Inject would be ideal. Mixing the models seems like it might sometimes be necessary, and the ability to inject an MC bean into an EJB (and vice versa) would be a great addition to both frameworks.
And yeah, I imagine that if the EJB supported @Inject I would simply inject the Kernel.
All of this is very cool but sadly incidental to my actual goal, which is to dynamically generate EJBs (using javassist probably) and deploy them programmatically.
-
11. Re: How do I access the JBoss Kernel from an EJB3?
alrubinger Jan 7, 2010 4:58 PM (in response to ewittmann)Declarative deployment you can get from EmbeddedAS.
And if you've got bytecode enough to back a dynamically-generated class, you can use ShrinkWrap to assemble the archive into a deployment. Each of these types may be added to an archive:
S,
ALR