1 23 24 package com.sun.enterprise.management.model; 25 26 28 import java.util.Set ; 29 import javax.management.ObjectName ; 30 31 public class JDBCDataSourceMdl extends J2EEManagedObjectMdl { 32 33 private static String MANAGED_OBJECT_TYPE = "JDBCDataSource"; 34 private String jdbcDataSourceName = null; 35 private String driverName = null; 36 private boolean debug = false; 37 private String username = null; 38 private String password = null; 39 private String url = null; 40 private String [] propNames = null; 41 private String [] propValues = null; 42 43 public JDBCDataSourceMdl(String dataSourceJndiName, String dataSourceName, 44 String url, 45 String username, 46 String password, 47 String [] propNames, 48 String [] propValues) { 49 super(dataSourceJndiName,false,false,false); 50 this.jdbcDataSourceName = dataSourceName; 51 this.url = url; 52 this.username = username; 53 this.password = password; 54 this.propNames = propNames; 55 this.propValues = propValues; 56 } 57 public JDBCDataSourceMdl(String dataSourceJndiName, String serverName, String dataSourceName, 58 String url, 59 String username, 60 String password, 61 String [] propNames, 62 String [] propValues) { 63 super(dataSourceJndiName,serverName,false,false,false); 64 this.jdbcDataSourceName = dataSourceName; 65 this.url = url; 66 this.username = username; 67 this.password = password; 68 this.propNames = propNames; 69 this.propValues = propValues; 70 } 71 72 public String getjdbcDriver() { 73 if (driverName == null) { 74 Set s; 75 try { 76 java.sql.Driver drv = java.sql.DriverManager.getDriver(jdbcDataSourceName); 78 s = findNames("j2eeType=JDBCDriver,name="+drv.getClass().getName()); 80 } catch(java.sql.SQLException e) { 81 s = findNames("j2eeType=JDBCDriver,name="+jdbcDataSourceName); 83 } 84 85 Object [] objs = s.toArray(); 86 if (objs.length > 0) { 87 String name = ((ObjectName )objs[0]).toString(); 88 driverName = name; 89 } 90 } 91 return driverName; 92 } 93 94 97 public String getj2eeType() { 98 return MANAGED_OBJECT_TYPE; 99 } 100 101 105 public String getobjectName() { 106 Set s = findNames("j2eeType="+getj2eeType()+",name="+this.getname()+",JDBCResource="+getJDBC()+",J2EEServer="+this.getJ2EEServer()); 107 Object [] objs = s.toArray(); 108 if (objs.length > 0) { 109 String name = ((ObjectName )objs[0]).toString(); 110 return name; 111 } else { 112 return null; 113 } 114 } 115 116 119 public String getJDBC(){ 120 return getname(); } 122 123 public String geturl() { 124 return url; 125 } 126 127 public String getusername() { 128 return username; 129 } 130 131 public String getpassword() { 132 return password; 133 } 134 135 public String [] getpropNames() { 136 return propNames; 137 } 138 139 public String [] getpropValues() { 140 return propValues; 141 } 142 143 public String getjdbcDataSourceName() { 144 return jdbcDataSourceName; 145 } 146 } 147 | Popular Tags |