1 22 package org.jboss.management.j2ee; 23 24 import java.security.InvalidParameterException ; 25 26 import javax.management.MBeanServer ; 27 import javax.management.MalformedObjectNameException ; 28 import javax.management.ObjectName ; 29 30 import org.jboss.logging.Logger; 31 32 42 public class RMI_IIOPResource extends J2EEResource 43 implements RMI_IIOPResourceMBean 44 { 45 47 private static Logger log = Logger.getLogger(RMI_IIOPResource.class); 49 50 private ObjectName mService; 51 52 54 public static ObjectName create(MBeanServer mbeanServer, String resName, ObjectName corbaServiceName) 55 { 56 ObjectName lServer = null; 57 try 58 { 59 lServer = (ObjectName ) mbeanServer.queryNames(new ObjectName (J2EEDomain.getDomainName() + ":" + 60 J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," + 61 "*"), 62 null).iterator().next(); 63 } 64 catch (Exception e) 65 { 66 log.error("Could not find parent J2EEServer", e); 67 return null; 68 } 69 try 70 { 71 RMI_IIOPResource rmiiiopRes = new RMI_IIOPResource(resName, lServer, corbaServiceName); 72 ObjectName jsr77Name = rmiiiopRes.getObjectName(); 73 mbeanServer.registerMBean(rmiiiopRes, jsr77Name); 74 log.debug("Created JSR-77 RMI_IIOPResource: " + resName); 75 76 return jsr77Name; 77 } 78 catch (Exception e) 79 { 80 log.error("Could not create JSR-77 RMI_IIOPResource: " + resName, e); 81 return null; 82 } 83 } 84 85 public static void destroy(MBeanServer mbeanServer, String resName) 86 { 87 try 88 { 89 J2EEManagedObject.removeObject(mbeanServer, 90 J2EEDomain.getDomainName() + ":" + 91 J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," + 92 "name=" + resName + "," + 93 "*"); 94 } 95 catch (Exception e) 96 { 97 log.error("Could not destroy JSR-77 RMI_IIOPResource: " + resName, e); 98 } 99 } 100 101 103 107 public RMI_IIOPResource(String resName, ObjectName pServer, ObjectName corbaServiceName) 108 throws MalformedObjectNameException , 109 InvalidParentException 110 { 111 super(J2EETypeConstants.RMI_IIOPResource, resName, pServer); 112 log.debug("Service name: " + corbaServiceName); 113 mService = corbaServiceName; 114 } 116 117 119 120 public String [] getEventTypes() 121 { 122 return StateManagement.stateTypes; 123 } 124 125 public String getEventType(int pIndex) 126 { 127 if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length) 128 { 129 return StateManagement.stateTypes[pIndex]; 130 } 131 else 132 { 133 return null; 134 } 135 } 136 137 public void postCreation() 138 { 139 sendNotification(NotificationConstants.OBJECT_CREATED, "RMI_IIOP Resource created"); 140 } 141 142 public void preDestruction() 143 { 144 sendNotification(NotificationConstants.OBJECT_DELETED, "RMI_IIOP Resource deleted"); 145 } 146 147 149 public String toString() 150 { 151 return "RMI_IIOPResource { " + super.toString() + " } [ " + 152 "Service name: " + mService + 153 " ]"; 154 } 155 156 158 160 162 } 164 | Popular Tags |