1 19 20 24 25 package org.netbeans.modules.j2ee.deployment.plugins.api; 26 27 import javax.enterprise.deploy.spi.DeploymentManager ; 28 import javax.enterprise.deploy.spi.Target ; 29 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; 30 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; 31 import org.netbeans.modules.j2ee.deployment.impl.InstancePropertiesImpl; 32 import java.beans.PropertyChangeListener ; 33 import java.beans.PropertyChangeEvent ; 34 import java.util.*; 35 36 37 53 public abstract class InstanceProperties { 54 55 60 public static final String URL_ATTR = "url"; 62 65 public static final String USERNAME_ATTR = "username"; 67 70 public static final String PASSWORD_ATTR = "password"; 72 75 public static final String DISPLAY_NAME_ATTR = "displayName"; 77 81 public static final String REMOVE_FORBIDDEN = "removeForbidden"; 83 86 public static final String HTTP_PORT_NUMBER = "httpportnumber"; 87 88 91 private List changeListeners = Collections.synchronizedList(new LinkedList()); 92 93 99 public static InstanceProperties getInstanceProperties(String url) { 100 ServerInstance inst = ServerRegistry.getInstance().getServerInstance(url); 101 if (inst == null) 102 return null; 103 return inst.getInstanceProperties(); 104 } 105 106 119 public static InstanceProperties createInstanceProperties( 120 String url, String username, String password) throws InstanceCreationException { 121 return createInstanceProperties(url, username, password, null); 122 } 123 124 137 public static InstanceProperties createInstanceProperties(String url, String username, 138 String password, String displayName) throws InstanceCreationException { 139 ServerRegistry registry = ServerRegistry.getInstance(); 140 registry.addInstance(url, username, password, displayName); 141 ServerInstance inst = registry.getServerInstance(url); 142 InstanceProperties ip = inst.getInstanceProperties(); 143 return ip; 144 } 145 146 150 public static String [] getInstanceList() { 151 return ServerRegistry.getInstance().getInstanceURLs(); 152 } 153 154 157 public static InstanceProperties getDefaultInstance() { 158 return new InstancePropertiesImpl(ServerRegistry.getInstance().getDefaultInstance().getServerInstance()); 159 } 160 161 166 public abstract void setProperties(java.util.Properties props) throws IllegalStateException ; 167 168 174 public abstract void setProperty(String propname, String value) throws IllegalStateException ; 175 176 182 public abstract String getProperty(String propname) throws IllegalStateException ; 183 184 189 public abstract java.util.Enumeration propertyNames() throws IllegalStateException ; 190 191 195 public abstract boolean isDefaultInstance(); 196 197 200 public abstract DeploymentManager getDeploymentManager(); 201 202 205 public abstract Target getDefaultTarget(); 206 207 211 public abstract void setAsDefaultServer(String targetName); 212 213 217 public abstract void refreshServerInstance(); 218 219 227 public void addPropertyChangeListener(PropertyChangeListener listener) { 228 changeListeners.add(listener); 229 } 230 231 238 protected void firePropertyChange(PropertyChangeEvent evt) { 239 ArrayList cloned = null; 240 synchronized (this) { 241 if (changeListeners != null) { 242 cloned = new ArrayList(); 243 cloned.addAll(changeListeners); 244 } 245 } 246 if (cloned != null) { 247 Iterator i = cloned.iterator(); 248 while (i.hasNext()) { 249 ((PropertyChangeListener )i.next()).propertyChange(evt); 250 } 251 } 252 } 253 } 254 | Popular Tags |