3 Replies Latest reply on Dec 20, 2012 8:48 AM by keerti

    Deploying POJO Service in both Clustered and Non-Clustered Environment

    keerti

      Dear All,

       

      I have a requirement to create EJB POJO  Service that can be deployed both in Clustered and Non-Clustered environment. 

       

      I mean, In Clustered environment, is there any way to identify if the application is deployed in the Cluster environment or whether the node is a master node in the create() method of POJO Service.

       

      Thanks for the suggestion. Please let me know if more information is needed.

       

      Thanks,

       

      Keertiraj

        • 1. Re: Deploying POJO Service in both Clustered and Non-Clustered Environment
          keerti

          And I am trying to solve the issue in JBoss 5.

           

          Thanks,

           

          Keertiraj

          • 3. Re: Deploying POJO Service in both Clustered and Non-Clustered Environment
            keerti

            I found a work around for the problem. Usage of type=barrier makes sure that onlysingle instance of the POJO service is instantiated any time. Just having start() and stop() method is enough. It will work for both Clustered and non-clustered environment. This default behaviour is helpful for both clustered and non-clustered environment.

             

            Sample Code:

             

            package com.foo;

             

            import org.jboss.ejb3.annotation.Management;

            import org.jboss.ejb3.annotation.Service;

            import org.jboss.ejb3.annotation.LocalBinding;

            import org.jboss.ejb3.annotation.Depends;

             

            @Service(objectName = "myBean:service=ExampleHAControllerservice", name = "ExampleHAControllerserviceMBean")

            @Management(ExampleHAController.class)

            @LocalBinding(jndiBinding = "/com/foo/ExampleHAController/local")

            @Depends({"jboss.ha:service=HASingletonDeployer,type=Barrier"})

            public class ExampleHAControllerservice implements ExampleHAController {

             

             

               public void create() throws Exception{

             

                   System.out.println("%%%%% CREATE METHOD%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");

             

               }     

             

                public void start() throws Exception{

             

                    System.out.println("%%%%% START METHOD%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");

             

                }

             

                public void stop(){

             

                    System.out.println("-------------------THE APP IN HA CONFIG IS STOPPED----------------");

                }

             

             

            }

             

            Interface:

             

             

            package com.foo;

             

             

            import javax.ejb.Local;

            import org.jboss.ejb3.annotation.Management;

             

             

            @Local

            @Management(ExampleHAController.class)

            public interface ExampleHAController {

             

                    public void create() throws Exception;

                    public void start() throws Exception;

                   public void stop();

               }