-
1. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
alesj Mar 9, 2010 6:30 AM (in response to userless)It depends from where you wanna access it.
If this is a service inside JBossAS, simply inject the PSDeployer.
MC's "BeanFactory" == org.jboss.dependency.spi.Controller
-
2. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
userless Mar 9, 2010 6:38 AM (in response to alesj)I'm inside a servlet which was deployed in the server.
I need to load the "MainDeployer" programmatically.
How I can get a handle of the Controller which Jboss started with?
-
3. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
alesj Mar 9, 2010 7:05 AM (in response to userless)I'm inside a servlet which was deployed in the server.
I need to load the "MainDeployer" programmatically.
How I can get a handle of the Controller which Jboss started with?
Check this MC's sub-project for the glue code:
* http://anonsvn.jboss.org/repos/jbossas/projects/mc-int/trunk/servlet/
The usage is here:
Afaik, mc-servlet-int.jar should already be part of AS6,
otherwise simply drop it, either in your app or jboss-as/common/lib.
-
4. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
userless Mar 9, 2010 9:30 AM (in response to alesj)I managed to get the Controller class. How I can get a bean ? (in Spring BeanFactory.getBean)
-
5. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
alesj Mar 9, 2010 9:37 AM (in response to userless)I managed to get the Controller class. How I can get a bean ? (in Spring BeanFactory.getBean)
Controller c = ...;
ControllerContext cc = c.getInstalledContext(name);
return cc != null ? cc.getTarget() : null;
-
6. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
userless Mar 10, 2010 3:55 AM (in response to alesj)Is it possible to get controller class from any class? (don't have servlet context) -
7. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
alesj Mar 10, 2010 5:13 AM (in response to userless)Is it possible to get controller class from any class? (don't have servlet context)
I don't understand what you mean?
I'll try to guess though.
Unless your service/bean instance is tied into MC's Kernel, then no.
Well, one can always use static hacks, but that's what they are -- hacks. So, I wouldn't go that way.
If you can somehow get a hold of an instance that is tied to Kernel/Controller,
you can simply inject the Controller into that instance -- @Inject(bean=KernelContsants.KERNEL_CONTROLLER_NAME).
-
8. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
userless Mar 10, 2010 5:26 AM (in response to alesj)I don't understand what you mean?
I'll try to guess though.
Unless your service/bean instance is tied into MC's Kernel, then no.
Well, one can always use static hacks, but that's what they are -- hacks. So, I wouldn't go that way.
That's interesting, how can do "static hacks" to do that? and why not to go that way?
If you can somehow get a hold of an instance that is tied to Kernel/Controller,
you can simply inject the Controller into that instance -- @Inject(bean=KernelContsants.KERNEL_CONTROLLER_NAME).
This means that I need to create a bean / service, right? I have a limitation which is to do that inside a war and I can't deploy extra things with xml. and btw - can I create a bean only by annotations (without xml - which I coudn't find a way)
Thank you!
-
9. Re: What is the equivalent of Spring BeanFactory in JBoss 5?
alesj Mar 10, 2010 6:26 AM (in response to userless)That's interesting, how can do "static hacks" to do that? and why not to go that way?
See KernelLocator class in MC/Kernel.
Why not? The idea is to be able to run hierarchy of Kernels, so how are you gonna know then which one is the right one,
from the set of statically set kernels. ;-)
This means that I need to create a bean / service, right? I have a limitation which is to do that inside a war and I can't deploy extra things with xml. and btw - can I create a bean only by annotations (without xml - which I coudn't find a way)
war doesn't make any difference for MC -- you can simply drop -jboss-beans.xml file in WEB-INF and it's gonna work.
Things also work w/o xml, but it requires a bit more work.
See my demos on how to do this:
(see *ScanDeployer)
btw, it's super easy to setup this MC demos in your IDE ;-)