package org.jboss.management.j2ee;
import org.jboss.logging.Logger;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
public class RMI_IIOPResource
extends J2EEResource
implements RMI_IIOPResourceMBean
{
private static Logger log = Logger.getLogger(RMI_IIOPResource.class);
private ObjectName mService;
public static ObjectName create(MBeanServer pServer, String pName, ObjectName pService)
{
ObjectName lServer = null;
try
{
lServer = (ObjectName) pServer.queryNames(new ObjectName(J2EEDomain.getDomainName() + ":" +
J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," +
"*"),
null).iterator().next();
}
catch (Exception e)
{
log.error("Could not create JSR-77 RMI_IIOPResource: " + pName, e);
return null;
}
try
{
return pServer.createMBean("org.jboss.management.j2ee.RMI_IIOPResource",
null,
new Object[]{
pName,
lServer,
pService
},
new String[]{
String.class.getName(),
ObjectName.class.getName(),
ObjectName.class.getName()
}).getObjectName();
}
catch (Exception e)
{
log.error("Could not create JSR-77 RMI_IIOPResource: " + pName, e);
return null;
}
}
public static void destroy(MBeanServer pServer, String pName)
{
try
{
J2EEManagedObject.removeObject(pServer,
J2EEDomain.getDomainName() + ":" +
J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," +
"name=" + pName + "," +
"*");
}
catch (Exception e)
{
log.error("Could not destroy JSR-77 RMI_IIOPResource: " + pName, e);
}
}
public RMI_IIOPResource(String pName, ObjectName pServer, ObjectName pService)
throws MalformedObjectNameException,
InvalidParentException
{
super(J2EETypeConstants.RMI_IIOPResource, pName, pServer);
if (log.isDebugEnabled())
log.debug("Service name: " + pService);
mService = pService;
}
public String[] getEventTypes()
{
return StateManagement.stateTypes;
}
public String getEventType(int pIndex)
{
if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length)
{
return StateManagement.stateTypes[pIndex];
}
else
{
return null;
}
}
public void postCreation()
{
sendNotification(NotificationConstants.OBJECT_CREATED, "RMI_IIOP Resource created");
}
public void preDestruction()
{
sendNotification(NotificationConstants.OBJECT_DELETED, "RMI_IIOP Resource deleted");
}
public String toString()
{
return "RMI_IIOPResource { " + super.toString() + " } [ " +
" ]";
}
}