Hello,
I have a MBean that must behave differently in clustered and standalone environments.
In the former case, it must be started/stopped by HASingletonController through the methods startSingleton() and stopSingleton(), in the latter case it must be started/stopped by the standard ServiceController through the methods start() and stop().
What that I want is that in clustered environments start() and stop() methods do nothing, (because the MBean is actually started by startSingleton() and stopSingleton()), while in standalone environments they actually start/stop the MBean.
Is this the correct way to implement this behavior ? Here below I attached the startService() and stopService() methods. They do not seem to work, because I cannot find a valid way to see if DefaultPartition is available.
Can you help me ?
Thanks.
L.
private boolean existsDefaultPartition() throws Exception {
try {
MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
server.getMBeanInfo(new ObjectName("jboss:service=DefaultPartition"));
return true;
}catch(InstanceNotFoundException e){
return false;
}
}
public void startService() throws Exception {
if (existsDefaultPartition()){
// do nothing, because it will be done by startSingleton method on the master node
}else{
startSingleton();
}
}
public void stopService() throws Exception {
if (existsDefaultPartition()){
// do nothing, because it will be done by startSingleton method on the master node
}else{
stopSingleton();
}
}
Here is the dot-service file:
DefaultDomain:name=LogManager
jboss:service=DefaultPartition
DefaultDomain:name=LogManager
startSingleton
stopSingleton
jboss.jca:name=NoTransLDAP,service=ManagedConnectionFactory
jboss.jca:name=NoTransLDAP,service=ManagedConnectionPool
jboss.jca:name=NoTransLDAP,service=NoTxCM
1
3
-1
-1
0
60000
0.8f