-
1. Re: Deploying POJO Service in both Clustered and Non-Clustered Environment
keerti Dec 18, 2012 3:35 AM (in response to keerti)And I am trying to solve the issue in JBoss 5.
Thanks,
Keertiraj
-
2. Re: Deploying POJO Service in both Clustered and Non-Clustered Environment
rhusar Dec 20, 2012 4:33 AM (in response to keerti)This should help if you want to elect and use a master node:
-
3. Re: Deploying POJO Service in both Clustered and Non-Clustered Environment
keerti Dec 20, 2012 8:48 AM (in response to 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();
}