7 Replies Latest reply on Apr 20, 2006 8:51 AM by Ales Justin

    Binding JBoss MC with JBoss-Spring

    Ales Justin Master

      What about binding JBoss MicroContainer and JBoss Spring?

      For example:
      - we could set jbossmc as a parent bean factory to jboss spring beans
      - or register jboss spring beans as jbossmc beans ... with all the injection functionality

      How do you currently use / glue jbossmc beans with ejb (or any other non mc beans)?
      Is there something similar to what we have done with SpringInjectionInterceptor (if not, should we do it?)?

      How do you access those beans which are defined in a certain jboss-beans.xml file?

      Just going through this ( http://docs.jboss.org/nightly/microkernel/docs/reference/en/html/), hopefully I can 'discover' some things on my own. :-)

        • 1. Re: Binding JBoss MC with JBoss-Spring
          Adrian Brock Master

          Try the examples from the release.
          There are some on implementing locator patterns.

          • 2. Re: Binding JBoss MC with JBoss-Spring
            Ales Justin Master

            I've looked at the locator example.
            I see how you access 'jboss.kernel:service=KernelController'.

            Just a few simple questions to clear if my understanding of MC is the right one.

            Is KernelController 'equivalent' to Spring's bean factory (you don't get bean directly, but through ControllerContext)?
            Can you make a kernelController hierarchy (similar to bean factory's parent bean factory)? If so, how do you 'tell' which is parent kc?
            To which already registered beans can you access through -beans.xml? Like in locator example - can you access some beans from other deployed .beans archives?

            But how do you access (globaly or just in your application) a certain kernelController created from .beans archive (or -beans.xml)?

            I followed JBossBeanDeployer class on how it creates kernelController.
            I see that you register JBossBeanDeployment class

            SimpleSubDeployerSupport.registerDeployment ["jboss.beans:service=JBossBeanDeployment,name='" + name + "'"]
            


            which is actually a service mbean that calls AbstractKernelDeployer to deploy KernelDeployment -> deployBeans.

            Is there a way to access AbstractKernelDeployer's controller or kernel?

            Rgds, Ales


            • 3. Re: Binding JBoss MC with JBoss-Spring
              Ales Justin Master

              I've added a new kernel package in spring-int module.

              MicrocontainerConfigurer class looks up microcontainer beans if there is bean injection in Spring's xml descriptor file marked with mc${beanName}.

              Lookup is done via Locator interface (similar to kernel example).

              What I'm missing is a way to get to some already deployed Kernel or KernelController.

              • 4. Re: Binding JBoss MC with JBoss-Spring
                Adrian Brock Master

                 

                "alesj" wrote:

                What I'm missing is a way to get to some already deployed Kernel or KernelController.


                Explain what you mean with a usecase/requirement statement.

                • 5. Re: Binding JBoss MC with JBoss-Spring
                  Ales Justin Master

                   

                  "adrian@jboss.org" wrote:
                  Explain what you mean with a usecase/requirement statement.


                  Let's say I have a .beans module in my enterprise app. I would like to get a reference to Kernel instance that is created by that .beans archive, in order to use it in my .spring module (which is deployed after .beans module).

                  Or if I could get a reference to the 'main' Kernel instance (main JBossAS Kernel).

                  ex. My microcontainer beans description file

                  <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
                   xmlns="urn:jboss:bean-deployer">
                  
                   <bean name="simpleBean1" class="org.jboss.example.microcontainer.locator.SimpleBean">
                   <property name="text">Simple1</property>
                   </bean>
                  
                  </deployment>
                  


                  Then I can do something like this:

                  <beans>
                   <bean id="propertyConfigurer" class="org.foo.BarConfig">
                   <property name="order"><value>1</value></property>
                   <property name="simpleBean"><value>mc${simpleBean1}</value></property>
                   </bean>
                  </beans>
                  


                  So my BarConfig instance would get SimpleBean injected from mc beans.

                  <beans>
                   <bean id="transactionService" class="org.foo.TransactionService">
                   <property name="transactionManager"><value>mc${TransactionManager}</value></property>
                   </bean>
                  </beans>
                  


                  Or a global Kernel lookup for a TransactionManager instance.

                  Maybe something like this - through MBeanServer:

                  public class KernelBinderLocator extends KernelLocator
                  {
                  
                   private String objectNameString;
                  
                   public KernelBinderLocator(String objectNameString)
                   {
                   this.objectNameString = objectNameString;
                   }
                  
                   public synchronized Kernel getKernel()
                   {
                   Kernel kernel = super.getKernel();
                   if (kernel == null)
                   {
                   kernel = lookupKernel();
                   setKernel(kernel);
                   }
                   return kernel;
                   }
                  
                   private Kernel lookupKernel()
                   {
                   ObjectName objectName = new ObjectName(objectNameString);
                   MBeanServer server = MBeanServerLocator.locateJBoss();
                   return (Kernel)MBeanProxy.get(Kernel.class, objectName, server);
                   }
                  
                  }
                  


                  Or KernelControllerBinderLocator - since it is an interface - for MBean proxying.


                  • 6. Re: Binding JBoss MC with JBoss-Spring
                    Adrian Brock Master

                    There are a number of other discussions/tasks on this type of feature
                    from a single dependency space for both JMX and MC dependencies inside
                    JBossAS to having your own notion of an "application scoped" configuration
                    space.

                    But nothing exists yet. Maybe it would if I spent less time answering
                    these FAQs and more time coding.

                    Read the other threads. You'll also have to read through the duplicates
                    where people keep asking the same questions that are already discussed
                    and I just shout at them rather than answering it.
                    http://wiki.jboss.org/wiki/Wiki.jsp?page=BadPostSearch

                    • 7. Re: Binding JBoss MC with JBoss-Spring
                      Ales Justin Master

                       

                      "adrian@jboss.org" wrote:

                      But nothing exists yet. Maybe it would if I spent less time answering
                      these FAQs and more time coding.


                      OK, np.
                      Could you just let me know (post to this thread) when something exists?