7 Replies Latest reply on Aug 13, 2009 9:44 AM by mukulb

    Use of JBoss MC Pojo from in distributed env

      Sorry, if this question have been answered earlier and i knw it is very basic question but i need answer.

      I am using JBoss MC as a standlone container for POJO deployment but how do i access these POJO services from a client running on a different JVM on different machine? basically distributed environment like JavaEE but since i am not using any JavaEE server and i want to acess my POJOs deployed in Jboss MC from a different machine, how do i do this? as there is nO JNDI here and no java EE APp server just Microcontainer.

        • 1. Re: Use of JBoss MC Pojo from in distributed env
          alesj

          MC only provides the means to "connect" to existing distributable envs.
          e.g. @JMX, @JndiBinding

          You will have to provide your own distributed env:
          * RMI
          * Hessian or Burlap
          * Infinispan
          * ...

          And then simply register your beans against it.

          • 2. Re: Use of JBoss MC Pojo from in distributed env
            manik

            One way to do this - and this would involve extending or modifying the MC - is to replace whatever backing container the MC uses to store beans it creates (probably a Map) with an Infinispan Cache.

            This should be trivial since org.infinispan.Cache extends java.util.concurrent.ConcurrentMap.

            Maybe alesj can comment more on whether this is something viable from a MC standpoint.

            • 3. Re: Use of JBoss MC Pojo from in distributed env
              alesj

               

              "manik.surtani@jboss.com" wrote:
              One way to do this - and this would involve extending or modifying the MC - is to replace whatever backing container the MC uses to store beans it creates (probably a Map) with an Infinispan Cache.

              You can easily achieve this with the bean implementing KernelRegistryPlugin.

              public interface KernelRegistryPlugin
              {
               /**
               * Get a registration
               *
               * @param name the name of the object
               * @return the registration
               * @throws IllegalArgumentException for a null name
               */
               KernelRegistryEntry getEntry(Object name);
              }
              


              Every such bean becomes part of MC registry,
              and as such it's always "asked" if it knows how to provide a bean per name parameter.

              e.g. JNDI KRP

              public class JNDIKernelRegistryPlugin implements KernelRegistryPlugin
              {
               private Hashtable<?,?> properties;
               private Context context;
              
               public void setProperties(Hashtable<?,?> properties)
               {
               this.properties = properties;
               }
              
               public void create() throws NamingException
               {
               if (properties != null)
               context = new InitialContext(properties);
               else
               context = new InitialContext();
               }
              
               public void destroy() throws NamingException
               {
               if (context != null)
               context.close();
               context = null;
               }
              
               public KernelRegistryEntry getEntry(Object name)
               {
               try
               {
               Object target = context.lookup(name.toString());
               if (target != null)
               return new AbstractKernelRegistryEntry(name, target);
               }
               catch (NamingException e)
               {
               }
               return null;
               }
              }
              


              In Infinispan's case you would simply replace context with cache.

              • 4. Re: Use of JBoss MC Pojo from in distributed env
                manik

                Nice and easy! :-) We should document this on a wiki somewhere.

                • 5. Re: Use of JBoss MC Pojo from in distributed env
                  alesj

                   

                  "manik.surtani@jboss.com" wrote:
                  We should document this on a wiki somewhere.

                  I guess we can ask mukulb if he's willing to do this once he's done? :-)

                  • 6. Re: Use of JBoss MC Pojo from in distributed env
                    manik

                    @mukulb wdyt? :)

                    • 7. Re: Use of JBoss MC Pojo from in distributed env

                      Thanks Ales and Manik. I can definitely add information to Wiki but i haven't used infinispan. But if whatever we discussed only needs to be documented then i will do it.

                      Thanks,