1 22 package org.jboss.management.j2ee; 23 24 import org.jboss.logging.Logger; 25 26 import javax.management.MBeanServer ; 27 import javax.management.MalformedObjectNameException ; 28 import javax.management.ObjectName ; 29 30 37 public class JDBCDriver extends J2EEManagedObject 38 implements JDBCDriverMBean 39 { 40 private static Logger log = Logger.getLogger(JDBCDriver.class); 42 43 45 47 public static ObjectName create(MBeanServer pServer, String pName, ObjectName pService) 48 { 49 ObjectName lServer = null; 50 try 51 { 52 lServer = (ObjectName ) pServer.queryNames(new ObjectName (J2EEDomain.getDomainName() + ":" + 53 J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," + 54 "*"), 55 null).iterator().next(); 56 } 57 catch (Exception e) 58 { 59 log.error("Could not create JSR-77 JNDI: " + pName, e); 60 return null; 61 } 62 try 63 { 64 return pServer.createMBean("org.jboss.management.j2ee.JDBCDriver", 66 null, 67 new Object []{ 68 pName, 69 lServer 70 }, 71 new String []{ 72 String .class.getName(), 73 ObjectName .class.getName() 74 }).getObjectName(); 75 } 76 catch (Exception e) 77 { 78 log.error("Could not create JSR-77 JNDI: " + pName, e); 79 return null; 80 } 81 } 82 83 public static void destroy(MBeanServer pServer, String pName) 84 { 85 try 86 { 87 ObjectName lSearch = new ObjectName (J2EEDomain.getDomainName() + ":" + 89 J2EEManagedObject.TYPE + "=" + J2EETypeConstants.JDBCDriver + "," + 90 "name=" + pName + "," + 91 "*"); 92 ObjectName lJNDI = (ObjectName ) pServer.queryNames(lSearch, 93 null).iterator().next(); 94 pServer.unregisterMBean(lJNDI); 96 } 97 catch (Exception e) 98 { 99 log.error("Could not destroy JSR-77 JNDI: " + pName, e); 100 } 101 } 102 103 105 109 public JDBCDriver(String pName, ObjectName pServer) 110 throws 111 MalformedObjectNameException , 112 InvalidParentException 113 { 114 super(J2EETypeConstants.JDBCDriver, pName, pServer); 115 } 116 117 119 121 123 public String toString() 124 { 125 return "JDBCDriver { " + super.toString() + " } [ " + 126 " ]"; 127 } 128 129 131 133 135 137 } 138 | Popular Tags |