1 19 20 package org.netbeans.modules.j2ee.oc4j.config; 21 22 import org.netbeans.modules.j2ee.deployment.common.api.Datasource; 23 import org.openide.util.NbBundle; 24 25 29 public class OC4JDatasource implements Datasource { 30 31 private String jndiName; 32 private String url; 33 private String username; 34 private String password; 35 private String driverClassName; 36 private String minPoolSize = "5"; private String maxPoolSize = "20"; private String idleTimeoutMinutes = "5"; private String description; 40 41 private volatile int hash = -1; 42 43 44 public OC4JDatasource(String jndiName, String url, String username, String password, String driverClassName) { 45 this.jndiName = jndiName; 46 this.url = url; 47 this.username = username; 48 this.password = password; 49 this.driverClassName = driverClassName; 50 } 51 52 public String getJndiName() { 53 return jndiName; 54 } 55 56 public String getUrl() { 57 return url; 58 } 59 60 public String getUsername() { 61 return username; 62 } 63 64 public String getPassword() { 65 return password; 66 } 67 68 public String getDriverClassName() { 69 return driverClassName; 70 } 71 72 public String getMinPoolSize() { 73 return minPoolSize; 74 } 75 76 public String getMaxPoolSize() { 77 return maxPoolSize; 78 } 79 80 public String getIdleTimeoutMinutes() { 81 return idleTimeoutMinutes; 82 } 83 84 public String getDisplayName() { 85 if (description == null) { 86 description = getJndiName() + " [" + getUrl() + "]"; 87 } 88 return description; 89 } 90 91 public boolean equals(Object obj) { 92 if (this == obj) 93 return true; 94 if (!(obj instanceof OC4JDatasource)) 95 return false; 96 97 OC4JDatasource ds = (OC4JDatasource) obj; 98 if (jndiName == null && ds.getJndiName() != null || jndiName != null && !jndiName.equals(ds.getJndiName())) 99 return false; 100 if (url == null && ds.getUrl() != null || url != null && !url.equals(ds.getUrl())) 101 return false; 102 if (username == null && ds.getUsername() != null || username != null && !username.equals(ds.getUsername())) 103 return false; 104 if (password == null && ds.getPassword() != null || password != null && !password.equals(ds.getPassword())) 105 return false; 106 if (driverClassName == null && ds.getDriverClassName() != null || driverClassName != null && !driverClassName.equals(ds.getDriverClassName())) 107 return false; 108 if (minPoolSize == null && ds.getMinPoolSize() != null || minPoolSize != null && !minPoolSize.equals(ds.getMinPoolSize())) 109 return false; 110 if (maxPoolSize == null && ds.getMaxPoolSize() != null || maxPoolSize != null && !maxPoolSize.equals(ds.getMaxPoolSize())) 111 return false; 112 if (idleTimeoutMinutes == null && ds.getIdleTimeoutMinutes() != null || idleTimeoutMinutes != null && !idleTimeoutMinutes.equals(ds.getIdleTimeoutMinutes())) 113 return false; 114 115 return true; 116 } 117 118 public int hashCode() { 119 if (hash == -1) { 120 int result = 17; 121 result += 37 * result + (jndiName == null ? 0 : jndiName.hashCode()); 122 result += 37 * result + (url == null ? 0 : url.hashCode()); 123 result += 37 * result + (username == null ? 0 : username.hashCode()); 124 result += 37 * result + (password == null ? 0 : password.hashCode()); 125 result += 37 * result + (driverClassName == null ? 0 : driverClassName.hashCode()); 126 result += 37 * result + (minPoolSize == null ? 0 : minPoolSize.hashCode()); 127 result += 37 * result + (maxPoolSize == null ? 0 : maxPoolSize.hashCode()); 128 result += 37 * result + (idleTimeoutMinutes == null ? 0 : idleTimeoutMinutes.hashCode()); 129 130 hash = result; 131 } 132 133 return hash; 134 } 135 136 public String toString() { 137 return "[ " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_JNDI") + ": '" + jndiName + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_URL") + ": '" + url + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_USER") + ": '" + username + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_PASS") + ": '" + password + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_DRV") + ": '" + driverClassName + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_MINPS") + ": '" + minPoolSize + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_MAXPS") + ": '" + maxPoolSize + "', " + NbBundle.getMessage(OC4JDatasource.class, "LBL_DS_IDLE") + ": '" + idleTimeoutMinutes + "' ]"; } 147 } | Popular Tags |