1 8 9 package mx4j.tools.remote.resolver.soap; 10 11 import java.io.IOException ; 12 import java.io.InputStream ; 13 import java.util.Map ; 14 15 import javax.management.remote.JMXServiceURL ; 16 17 import mx4j.log.Logger; 18 import mx4j.tools.remote.http.HTTPResolver; 19 import mx4j.tools.remote.soap.SOAPClientInvoker; 20 import org.apache.axis.client.AdminClient; 21 import org.apache.axis.client.Service; 22 import org.apache.axis.configuration.FileProvider; 23 import org.apache.axis.transport.http.AxisServlet; 24 import org.apache.axis.utils.Options; 25 26 29 public class Resolver extends HTTPResolver 30 { 31 private static final String SERVER_DEPLOY_WSDD = "server-deploy.wsdd"; 32 private static final String SERVER_UNDEPLOY_WSDD = "server-undeploy.wsdd"; 33 private static final String CLIENT_WSDD = "client.wsdd"; 34 private static final String AXIS_DEPLOY_SERVICE = "AdminService"; 35 36 public Object lookupClient(JMXServiceURL address, Map environment) throws IOException 37 { 38 String endpoint = getEndpoint(address, environment); 39 40 InputStream wsdd = getClass().getResourceAsStream(CLIENT_WSDD); 41 if (wsdd == null) throw new IOException ("Could not find AXIS deployment descriptor"); 42 Service service = new Service(new FileProvider(wsdd)); 43 service.setMaintainSession(true); 44 45 return new SOAPClientInvoker(endpoint, service); 46 } 47 48 protected String getServletClassName() 49 { 50 return AxisServlet.class.getName(); 51 } 52 53 protected void deploy(JMXServiceURL address, Map environment) throws IOException 54 { 55 String path = address.getURLPath(); 56 if (!path.endsWith("/")) path += "/"; 57 String deployPath = path + AXIS_DEPLOY_SERVICE; 58 59 JMXServiceURL temp = new JMXServiceURL (address.getProtocol(), address.getHost(), address.getPort(), deployPath); 60 String deployEndpoint = getEndpoint(temp, environment); 61 62 try 63 { 64 AdminClient deployer = new AdminClient(); 65 Options options = new Options(null); 66 options.setDefaultURL(deployEndpoint); 67 InputStream wsdd = getClass().getResourceAsStream(SERVER_DEPLOY_WSDD); 68 if (wsdd == null) throw new IOException ("Could not find AXIS deployment descriptor"); 69 deployer.process(options, wsdd); 70 } 71 catch (RuntimeException x) 72 { 73 throw x; 74 } 75 catch (Exception x) 76 { 77 Logger logger = getLogger(); 78 if (logger.isEnabledFor(Logger.INFO)) logger.info("Exception while deploying AXIS service", x); 79 throw new IOException ("Could not deploy connector server to AXIS " + x.toString()); 80 } 81 } 82 83 protected void undeploy(JMXServiceURL address, Map environment) throws IOException 84 { 85 String path = address.getURLPath(); 86 if (!path.endsWith("/")) path += "/"; 87 String undeployPath = path + AXIS_DEPLOY_SERVICE; 88 89 JMXServiceURL temp = new JMXServiceURL (address.getProtocol(), address.getHost(), address.getPort(), undeployPath); 90 String undeployEndpoint = getEndpoint(temp, environment); 91 92 try 93 { 94 AdminClient deployer = new AdminClient(); 95 Options options = new Options(null); 96 options.setDefaultURL(undeployEndpoint); 97 InputStream wsdd = getClass().getResourceAsStream(SERVER_UNDEPLOY_WSDD); 98 if (wsdd == null) throw new IOException ("Could not find AXIS deployment descriptor " + SERVER_UNDEPLOY_WSDD); 99 deployer.process(options, wsdd); 100 } 101 catch (Exception x) 102 { 103 Logger logger = getLogger(); 104 if (logger.isEnabledFor(Logger.INFO)) logger.info("Exception while undeploying AXIS service", x); 105 throw new IOException ("Could not undeploy connector server " + x.toString()); 106 } 107 } 108 } 109 | Popular Tags |