1 19 20 package org.netbeans.modules.j2ee.jboss4.config; 21 22 import org.netbeans.modules.j2ee.deployment.common.api.Datasource; 23 import org.openide.util.NbBundle; 24 25 26 30 public final class JBossDatasource implements Datasource { 31 32 private String jndiName; 33 private String url; 34 private String username; 35 private String password; 36 private String driverClassName; 37 private String minPoolSize = "5"; private String maxPoolSize = "20"; private String idleTimeoutMinutes = "5"; private String description; 41 42 private volatile int hash = -1; 43 44 public JBossDatasource(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() + "]"; 88 } 89 return description; 90 } 91 92 public boolean equals(Object obj) { 93 if (this == obj) 94 return true; 95 if (!(obj instanceof JBossDatasource)) 96 return false; 97 98 JBossDatasource ds = (JBossDatasource)obj; 99 if (jndiName == null && ds.getJndiName() != null || jndiName != null && !jndiName.equals(ds.getJndiName())) 100 return false; 101 if (url == null && ds.getUrl() != null || url != null && !url.equals(ds.getUrl())) 102 return false; 103 if (username == null && ds.getUsername() != null || username != null && !username.equals(ds.getUsername())) 104 return false; 105 if (password == null && ds.getPassword() != null || password != null && !password.equals(ds.getPassword())) 106 return false; 107 if (driverClassName == null && ds.getDriverClassName() != null || driverClassName != null && !driverClassName.equals(ds.getDriverClassName())) 108 return false; 109 if (minPoolSize == null && ds.getMinPoolSize() != null || minPoolSize != null && !minPoolSize.equals(ds.getMinPoolSize())) 110 return false; 111 if (maxPoolSize == null && ds.getMaxPoolSize() != null || maxPoolSize != null && !maxPoolSize.equals(ds.getMaxPoolSize())) 112 return false; 113 if (idleTimeoutMinutes == null && ds.getIdleTimeoutMinutes() != null || idleTimeoutMinutes != null && !idleTimeoutMinutes.equals(ds.getIdleTimeoutMinutes())) 114 return false; 115 116 return true; 117 } 118 119 public int hashCode() { 120 if (hash == -1) { 121 int result = 17; 122 result += 37 * result + (jndiName == null ? 0 : jndiName.hashCode()); 123 result += 37 * result + (url == null ? 0 : url.hashCode()); 124 result += 37 * result + (username == null ? 0 : username.hashCode()); 125 result += 37 * result + (password == null ? 0 : password.hashCode()); 126 result += 37 * result + (driverClassName == null ? 0 : driverClassName.hashCode()); 127 result += 37 * result + (minPoolSize == null ? 0 : minPoolSize.hashCode()); 128 result += 37 * result + (maxPoolSize == null ? 0 : maxPoolSize.hashCode()); 129 result += 37 * result + (idleTimeoutMinutes == null ? 0 : idleTimeoutMinutes.hashCode()); 130 131 hash = result; 132 } 133 134 return hash; 135 } 136 137 public String toString() { 138 return "[ " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_JNDI") + ": '" + jndiName + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_URL") + ": '" + url + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_USER") + ": '" + username + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_PASS") + ": '" + password + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_DRV") + ": '" + driverClassName + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_MINPS") + ": '" + minPoolSize + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_MAXPS") + ": '" + maxPoolSize + "', " + NbBundle.getMessage(JBossDatasource.class, "LBL_DS_IDLE") + ": '" + idleTimeoutMinutes + "' ]"; } 148 } 149 | Popular Tags |