[jboss-user] [Microcontainer] - Re: Beans loading with Microcontainer in JBoss AS
DGuralnik
do-not-reply at jboss.com
Mon Jan 8 17:06:39 EST 2007
I wouldn't like switching to 2.0 because JBoss AS 4.0.5 has Microcontainer 1.0.
I think the stateless bean is not important in the discussion. I don't understant how to use this Microcontainer. Spring was pretty easy.
So I has beans I declared in jboss-beans.xml. To load them I need a kernel controller as Wiki says. Well, I create ActionFactory with the kernel controller in it and expected using it as a factory for other beans (defined in jboss-beans.xml). The question is how to create ActionFactory. If it was Spring I would use some factory class provided by Spring. But here I didn't find a common approach to get the class instance. What should I do to get ActionFactory instance and then call getBean("addProvider").
| package com.mcp.server.action;
|
| import org.jboss.dependency.spi.ControllerContext;
| import org.jboss.kernel.spi.dependency.KernelController;
| import org.jboss.kernel.spi.dependency.KernelControllerContext;
| import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
|
| public class ActionFactory implements KernelControllerContextAware {
| private KernelController controller;
|
|
| public Object getBean(String name) {
| ControllerContext context = controller.getInstalledContext(name);
| return context.getTarget();
| }
|
| public void setKernelControllerContext(KernelControllerContext arg0) throws Exception {
| controller = arg0.getKernel().getController();
|
| }
|
| public void unsetKernelControllerContext(KernelControllerContext arg0) throws Exception {
| // TODO Auto-generated method stub
|
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3999222#3999222
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3999222
More information about the jboss-user
mailing list