1 23 24 package com.sun.enterprise.deployapi; 25 26 import com.sun.appserv.management.client.ConnectionSource; 27 import com.sun.enterprise.admin.common.exception.AFException; 28 import com.sun.enterprise.deployment.client.DeploymentClientUtils; 29 import com.sun.enterprise.deployment.client.ServerConnectionIdentifier; 30 import com.sun.enterprise.util.i18n.StringManager; 31 32 import java.io.File ; 33 import java.io.FileOutputStream ; 34 import java.io.IOException ; 35 import java.io.Serializable ; 36 37 import javax.enterprise.deploy.spi.Target ; 38 import javax.management.MBeanServerConnection ; 39 40 47 public class SunTarget implements Target , Serializable { 48 49 private ServerConnectionIdentifier connectionInfo; 50 private String appServer; 51 private boolean connected=false; 52 private ConnectionSource dasConnection = null; 53 private MBeanServerConnection mbsc = null; 54 private String targetType; 55 56 private static StringManager localStrings = StringManager.getManager(SunTarget.class); 57 58 private static final String DAS_TARGET_NAME = "server"; 59 60 public SunTarget(ServerConnectionIdentifier svi) { 61 this.connectionInfo = svi; 62 } 63 64 public SunTarget(SunTarget other) { 65 this.connectionInfo = other.connectionInfo; 66 this.appServer = other.appServer; 67 this.dasConnection = other.dasConnection; 68 this.mbsc = other.mbsc; 69 this.targetType = other.targetType; 70 } 71 72 75 public String getDescription() { 76 String version = localStrings.getString( 78 "enterprise.deployapi.spi.ProductVersion", "9.0"); 79 80 return localStrings.getString( 81 "enterprise.deployapi.spi.suntargetdescription", 82 version, getHostName()); 83 } 84 85 87 public String getName() { 88 return appServer; 89 } 90 91 94 public void release() { 95 connected=false; 96 } 97 98 101 public String getHostName(){ 102 return connectionInfo.getHostName(); 103 } 104 105 108 public String getPort() { 109 return (new Integer (connectionInfo.getHostPort())).toString(); 110 } 111 112 115 public ServerConnectionIdentifier getConnectionInfo() { 116 return connectionInfo; 117 } 118 119 122 public boolean isConnected() { 123 return connected; 124 } 125 126 129 public String toString() { 130 return getHostName() + ":" + (getPort()!=null?getPort():"DefaultPort") + "_" + appServer; 131 } 132 133 136 public String debugString() { 137 String s = ""; 138 if (connected) { 139 s = "Connected "; 140 } 141 return s + "Server " + getHostName() + ":" + (getPort()!=null?getPort():"DefaultPort") + "; Name: " + appServer; 142 } 143 144 145 148 public boolean equals(Object other) { 149 150 if (other instanceof SunTarget) { 151 SunTarget theOther = (SunTarget) other; 152 return (connectionInfo.equals(theOther.connectionInfo) 153 && getName() != null && getName().equals(theOther.getName()) 154 && getTargetType() != null && getTargetType().equals(theOther.getTargetType())); 155 } 156 return false; 157 } 158 159 162 public boolean isManagedBySameDAS(Object other) { 163 if (other instanceof SunTarget) { 164 SunTarget theOther = (SunTarget) other; 165 return connectionInfo.equals(theOther.connectionInfo); 166 } 167 return false; 168 } 169 170 174 public boolean isDAS() { 175 return (appServer.equals(DAS_TARGET_NAME)); 176 } 177 178 181 public String getAppServerInstance() { 182 return appServer; 183 } 184 185 188 public void setAppServerInstance(String appServer) { 189 this.appServer = appServer; 190 } 191 192 195 public void setTargetType(String type) { 196 this.targetType = type; 197 } 198 199 202 public String getTargetType() { 203 return this.targetType; 204 } 205 206 public void setConnectionSource(ConnectionSource conn){ 207 this.dasConnection = conn; 208 } 209 210 public ConnectionSource getConnectionSource() { 211 return this.dasConnection; 212 } 213 214 public MBeanServerConnection getMBeanServerConnection() { 215 return this.dasConnection.getExistingMBeanServerConnection(); 216 } 217 218 226 public String exportClientStubs(String appName, 227 int appType, 228 String destDir) 229 throws AFException 230 { 231 try{ 232 return DeploymentClientUtils.downloadClientStubs( 233 appName, destDir, dasConnection); 234 }catch(Exception e){ 235 e.printStackTrace(); 236 throw new AFException(e.getMessage()); 237 } 238 } 239 } 240 | Popular Tags |