[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Pushing beans into the kernel

adrian@jboss.org do-not-reply at jboss.com
Wed Aug 9 14:09:51 EDT 2006


"scott.stark at jboss.org" wrote : So the problem is that the KernelController knows nothing about the server. I did get past this doing:
  | 
  | 
  |   |       // Register the Server instance in the kernel
  |   |       Kernel kernel = getKernel();
  |   |       KernelController controller = kernel.getController();
  |   |       KernelRegistry registry = kernel.getRegistry();
  |   |       KernelConfigurator config = kernel.getConfigurator();
  |   |       BeanInfo info = config.getBeanInfo(server.getClass());;
  |   |       AbstractBeanMetaData metaData = new AbstractBeanMetaData("org.jboss.system.server.Server", null);
  |   |       AbstractKernelControllerContext serverEntry = new AbstractKernelControllerContext(info, metaData, server);
  |   |       controller.install(serverEntry);
  |   | 
  | 
  | At first this failed because the server instance was being restarted by the kernel while it was already in start due to the ServerLoader calling start. I just worked around this for now by checking for a duplicate call. I need to figure out how to install a bean that is already started.
  | 

There currently is no way to do this.

Don't get hung up on the kernel controller.install(BeanMetaData)
this is just a convenience over the
controller.install(ControllerContext)

What you need to do is create an AbstractKernelControllerContext
that has a minimal set of actions

e.g. add

   
  |    /** The no actions */
  |    private static final KernelControllerContextActions noActions = KernelControllerContextActions.getNoActions();
  | 
  |    /**
  |     * Create an abstract controller context
  |     * with no actions and no meta data
  |     * 
  |     * @name the name of the bean
  |     * @param target the target object
  |     */
  |    public AbstractKernelControllerContext(Object name, Object target)
  |    {
  |       super(name, noActions, new AbstractDependencyInfo(), target);
  |       if (System.getSecurityManager() != null)
  |          accessContext = AccessController.getContext();
  |    }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964123#3964123

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964123



More information about the jboss-dev-forums mailing list