mx4j/src/tools/mx4j/tools/remote/resolver/soap SOAPResolver.java,1.7,1.8 server-deploy.wsdd,1.6,1.7
Simone Bordet <[email protected]>
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/resolver/soap
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28350/src/tools/mx4j/tools/remote/resolver/soap
Modified Files:
SOAPResolver.java server-deploy.wsdd
Log Message:
Refactoring of the SOAP implementation, to support other protocols that runs over HTTP
Index: SOAPResolver.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/resolver/soap/SOAPResolver.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** SOAPResolver.java 19 Jul 2004 22:21:27 -0000 1.7
--- SOAPResolver.java 10 Aug 2004 09:02:28 -0000 1.8
***************
*** 11,27 ****
import java.io.IOException;
import java.io.InputStream;
- import java.util.HashMap;
- import java.util.HashSet;
import java.util.Map;
- import java.util.Set;
- import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
import mx4j.log.Logger;
! import mx4j.remote.ConnectionResolver;
! import mx4j.tools.remote.soap.ClientSOAPConnection;
! import mx4j.tools.remote.soap.SOAPConnector;
! import mx4j.tools.remote.soap.SOAPConnectorServer;
! import mx4j.tools.remote.soap.web.WebContainer;
import org.apache.axis.client.AdminClient;
import org.apache.axis.client.Service;
--- 11,20 ----
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import javax.management.remote.JMXServiceURL;
import mx4j.log.Logger;
! import mx4j.tools.remote.http.HTTPResolver;
! import mx4j.tools.remote.soap.SOAPClientInvoker;
import org.apache.axis.client.AdminClient;
import org.apache.axis.client.Service;
***************
*** 34,49 ****
* @version $Revision$
*/
! public class SOAPResolver extends ConnectionResolver
{
- private static final String SERVICE_JMX_SOAP = "service:jmx:soap";
private static final String SERVER_DEPLOY_WSDD = "server-deploy.wsdd";
private static final String SERVER_UNDEPLOY_WSDD = "server-undeploy.wsdd";
private static final String CLIENT_WSDD = "client.wsdd";
private static final String AXIS_DEPLOY_SERVICE = "AdminService";
- private static final WebContainer EXTERNAL_WEB_CONTAINER = new ExternalWebContainer();
-
- // TODO: maybe worth to use weak references to hold web containers
- private static Map webContainers = new HashMap();
- private static Map deployedURLs = new HashMap();
public Object lookupClient(JMXServiceURL address, Map environment) throws IOException
--- 27,36 ----
* @version $Revision$
*/
! public class SOAPResolver extends HTTPResolver
{
private static final String SERVER_DEPLOY_WSDD = "server-deploy.wsdd";
private static final String SERVER_UNDEPLOY_WSDD = "server-undeploy.wsdd";
private static final String CLIENT_WSDD = "client.wsdd";
private static final String AXIS_DEPLOY_SERVICE = "AdminService";
public Object lookupClient(JMXServiceURL address, Map environment) throws IOException
***************
*** 56,140 ****
service.setMaintainSession(true);
! return new ClientSOAPConnection(endpoint, service);
! }
!
! public Object bindClient(Object client, Map environment) throws IOException
! {
! return client;
! }
!
! private String getEndpoint(JMXServiceURL address, Map environment)
! {
! String transport = getTransportProtocol(environment);
! return transport + getEndpointPath(address);
! }
!
! private String getTransportProtocol(Map environment)
! {
! String transport = null;
! if (environment != null) transport = (String)environment.get(SOAPConnector.SOAP_TRANSPORT_PROTOCOL);
! if (transport == null || transport.length() == 0) transport = "http";
! transport = transport.toLowerCase();
! return transport;
! }
!
! private String getEndpointPath(JMXServiceURL url)
! {
! String address = url.toString();
! return address.substring(SERVICE_JMX_SOAP.length());
! }
!
! public Object createServer(JMXServiceURL url, Map environment) throws IOException
! {
! WebContainer result = null;
! boolean useExternalWebContainer = environment == null ? false : Boolean.valueOf(String.valueOf(environment.get(SOAPConnectorServer.USE_EXTERNAL_WEB_CONTAINER))).booleanValue();
! if (!useExternalWebContainer)
! {
! // Create and start an embedded web container
! String webContainerClassName = environment == null ? null : (String)environment.get(SOAPConnectorServer.EMBEDDED_WEB_CONTAINER_CLASS);
! // Not present, by default use Jetty
! if (webContainerClassName == null || webContainerClassName.length() == 0) webContainerClassName = "mx4j.tools.remote.soap.web.jetty.JettyWebContainer";
!
! result = findWebContainer(url, webContainerClassName);
! if (result == null)
! {
! result = createWebContainer(url, webContainerClassName, environment);
! if (result != null) result.start(url, environment);
! }
!
! // Nothing present, give up
! if (result == null) throw new IOException("Could not start embedded web container");
! }
! return result;
! }
!
! private WebContainer findWebContainer(JMXServiceURL url, String webContainerClassName)
! {
! String key = createWebContainerKey(url, webContainerClassName);
! return (WebContainer)webContainers.get(key);
! }
!
! private String createWebContainerKey(JMXServiceURL url, String webContainerClassName)
! {
! return new StringBuffer(webContainerClassName).append("|").append(url.getHost()).append("|").append(url.getPort()).toString();
}
! public JMXServiceURL bindServer(Object server, JMXServiceURL url, Map environment) throws IOException
{
! WebContainer webContainer = (WebContainer)server;
! if (!isDeployed(webContainer, url))
! {
! if (webContainer != null) webContainer.deploy(AxisServlet.class.getName(), url, environment);
! if (!hasDeployed(webContainer))
! {
! // The jmxconnector web service has never been deployed, deploy it now
! deploy(url, environment);
! }
! addDeployed(webContainer, url);
! }
! return url;
}
! private void deploy(JMXServiceURL address, Map environment) throws IOException
{
String path = address.getURLPath();
--- 43,55 ----
service.setMaintainSession(true);
! return new SOAPClientInvoker(endpoint, service);
}
! protected String getServletClassName()
{
! return AxisServlet.class.getName();
}
! protected void deploy(JMXServiceURL address, Map environment) throws IOException
{
String path = address.getURLPath();
***************
*** 166,185 ****
}
! public void unbindServer(Object server, JMXServiceURL address, Map environment) throws IOException
! {
! WebContainer webContainer = (WebContainer)server;
! if (isDeployed(webContainer, address))
! {
! // First undeploy the jmxconnector web service, then undeploy the webContainer: otherwise the service cannot be undeployed
! removeDeployed(webContainer, address);
! if (!hasDeployed(webContainer))
! {
! undeploy(address, environment);
! }
! if (webContainer != null) webContainer.undeploy(AxisServlet.class.getName(), address, environment);
! }
! }
!
! private void undeploy(JMXServiceURL address, Map environment) throws IOException
{
String path = address.getURLPath();
--- 81,85 ----
}
! protected void undeploy(JMXServiceURL address, Map environment) throws IOException
{
String path = address.getURLPath();
***************
*** 206,306 ****
}
}
-
- public void destroyServer(Object server, JMXServiceURL url, Map environment) throws IOException
- {
- WebContainer webContainer = (WebContainer)server;
- if (webContainer != null && !hasDeployed(webContainer))
- {
- // No more deployed stuff here, shutdown also the web container
- String key = createWebContainerKey(url, server.getClass().getName());
- WebContainer container = (WebContainer)webContainers.remove(key);
- if (webContainer != container) throw new IOException("Trying to stop the wrong web container: " + server + " should be: " + container);
- webContainer.stop();
- }
- }
-
- private WebContainer createWebContainer(JMXServiceURL url, String webContainerClassName, Map environment)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (environment != null)
- {
- Object cl = environment.get(JMXConnectorServerFactory.PROTOCOL_PROVIDER_CLASS_LOADER);
- if (cl instanceof ClassLoader) loader = (ClassLoader)cl;
- }
-
- try
- {
- WebContainer webContainer = (WebContainer)loader.loadClass(webContainerClassName).newInstance();
- String key = createWebContainerKey(url, webContainerClassName);
- webContainers.put(key, webContainer);
- return webContainer;
- }
- catch (Exception x)
- {
- }
- return null;
- }
-
- private boolean isDeployed(WebContainer webContainer, JMXServiceURL url)
- {
- if (webContainer == null) webContainer = EXTERNAL_WEB_CONTAINER;
- Set urls = (Set)deployedURLs.get(webContainer);
- if (urls == null) return false;
- return urls.contains(url);
- }
-
- private boolean hasDeployed(WebContainer webContainer)
- {
- if (webContainer == null) webContainer = EXTERNAL_WEB_CONTAINER;
- Set urls = (Set)deployedURLs.get(webContainer);
- if (urls == null) return false;
- return !urls.isEmpty();
- }
-
- private void addDeployed(WebContainer webContainer, JMXServiceURL url)
- {
- if (webContainer == null) webContainer = EXTERNAL_WEB_CONTAINER;
- Set urls = (Set)deployedURLs.get(webContainer);
- if (urls == null)
- {
- urls = new HashSet();
- deployedURLs.put(webContainer, urls);
- }
- urls.add(url);
- }
-
- private void removeDeployed(WebContainer webContainer, JMXServiceURL url)
- {
- if (webContainer == null) webContainer = EXTERNAL_WEB_CONTAINER;
- Set urls = (Set)deployedURLs.get(webContainer);
- if (urls != null)
- {
- urls.remove(url);
- if (urls.isEmpty()) deployedURLs.remove(webContainer);
- }
- }
-
- private static class ExternalWebContainer implements WebContainer
- {
- public void start(JMXServiceURL url, Map environment) throws IOException
- {
- }
-
- public void stop() throws IOException
- {
- }
-
- public void deploy(String servletClassName, JMXServiceURL url, Map environment) throws IOException
- {
- }
-
- public void undeploy(String servletClassName, JMXServiceURL url, Map environment)
- {
- }
-
- public String toString()
- {
- return "External WebContainer";
- }
- }
}
--- 106,108 ----
Index: server-deploy.wsdd
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/resolver/soap/server-deploy.wsdd,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** server-deploy.wsdd 17 Feb 2004 11:01:08 -0000 1.6
--- server-deploy.wsdd 10 Aug 2004 09:02:28 -0000 1.7
***************
*** 4,8 ****
<service name="jmxconnector" provider="java:RPC">
<namespace>http://mx4j.sourceforge.net/remote/soap/1.0</namespace>
! <parameter name="className" value="mx4j.tools.remote.soap.SOAPConnectionPivot"/>
<parameter name="scope" value="application"/>
<parameter name="allowedMethods" value="*"/>
--- 4,8 ----
<service name="jmxconnector" provider="java:RPC">
<namespace>http://mx4j.sourceforge.net/remote/soap/1.0</namespace>
! <parameter name="className" value="mx4j.tools.remote.soap.SOAPService"/>
<parameter name="scope" value="application"/>
<parameter name="allowedMethods" value="*"/>
***************
*** 19,23 ****
deserializer="mx4j.tools.remote.soap.axis.ser.AttributeDeserFactory"
type="java:javax.management.Attribute"
! />
<typeMapping
--- 19,23 ----
deserializer="mx4j.tools.remote.soap.axis.ser.AttributeDeserFactory"
type="java:javax.management.Attribute"
! />
<typeMapping
***************
*** 28,32 ****
deserializer="mx4j.tools.remote.soap.axis.ser.AttributeListDeserFactory"
type="java:javax.management.AttributeList"
! />
<typeMapping
--- 28,32 ----
deserializer="mx4j.tools.remote.soap.axis.ser.AttributeListDeserFactory"
type="java:javax.management.AttributeList"
! />
<typeMapping
***************
*** 37,41 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanAttributeInfoDeserFactory"
type="java:javax.management.MBeanAttributeInfo"
! />
<typeMapping
--- 37,41 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanAttributeInfoDeserFactory"
type="java:javax.management.MBeanAttributeInfo"
! />
<typeMapping
***************
*** 46,50 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanConstructorInfoDeserFactory"
type="java:javax.management.MBeanConstructorInfo"
! />
<typeMapping
--- 46,50 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanConstructorInfoDeserFactory"
type="java:javax.management.MBeanConstructorInfo"
! />
<typeMapping
***************
*** 55,59 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanInfoDeserFactory"
type="java:javax.management.MBeanInfo"
! />
<typeMapping
--- 55,59 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanInfoDeserFactory"
type="java:javax.management.MBeanInfo"
! />
<typeMapping
***************
*** 64,68 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanNotificationInfoDeserFactory"
type="java:javax.management.MBeanNotificationInfo"
! />
<typeMapping
--- 64,68 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanNotificationInfoDeserFactory"
type="java:javax.management.MBeanNotificationInfo"
! />
<typeMapping
***************
*** 73,77 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanOperationInfoDeserFactory"
type="java:javax.management.MBeanOperationInfo"
! />
<typeMapping
--- 73,77 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanOperationInfoDeserFactory"
type="java:javax.management.MBeanOperationInfo"
! />
<typeMapping
***************
*** 82,86 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanParameterInfoDeserFactory"
type="java:javax.management.MBeanParameterInfo"
! />
<typeMapping
--- 82,86 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanParameterInfoDeserFactory"
type="java:javax.management.MBeanParameterInfo"
! />
<typeMapping
***************
*** 91,95 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanServerNotificationDeserFactory"
type="java:javax.management.MBeanServerNotification"
! />
<typeMapping
--- 91,95 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanServerNotificationDeserFactory"
type="java:javax.management.MBeanServerNotification"
! />
<typeMapping
***************
*** 100,104 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanServerNotificationFilterDeserFactory"
type="java:javax.management.relation.MBeanServerNotificationFilter"
! />
<typeMapping
--- 100,104 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MBeanServerNotificationFilterDeserFactory"
type="java:javax.management.relation.MBeanServerNotificationFilter"
! />
<typeMapping
***************
*** 109,113 ****
deserializer="mx4j.tools.remote.soap.axis.ser.MonitorNotificationDeserFactory"
type="java:javax.management.monitor.MonitorNotification"
! />
<typeMapping
--- 109,113 ----
deserializer="mx4j.tools.remote.soap.axis.ser.MonitorNotificationDeserFactory"
type="java:javax.management.monitor.MonitorNotification"
! />
<typeMapping
***************
*** 118,122 ****
deserializer="mx4j.tools.remote.soap.axis.ser.NotificationDeserFactory"
type="java:javax.management.Notification"
! />
<typeMapping
--- 118,122 ----
deserializer="mx4j.tools.remote.soap.axis.ser.NotificationDeserFactory"
type="java:javax.management.Notification"
! />
<typeMapping
***************
*** 127,131 ****
deserializer="mx4j.tools.remote.soap.axis.ser.NotificationFilterSupportDeserFactory"
type="java:javax.management.NotificationFilterSupport"
! />
<typeMapping
--- 127,131 ----
deserializer="mx4j.tools.remote.soap.axis.ser.NotificationFilterSupportDeserFactory"
type="java:javax.management.NotificationFilterSupport"
! />
<typeMapping
***************
*** 136,140 ****
deserializer="mx4j.tools.remote.soap.axis.ser.NotificationResultDeserFactory"
type="java:javax.management.remote.NotificationResult"
! />
<typeMapping
--- 136,140 ----
deserializer="mx4j.tools.remote.soap.axis.ser.NotificationResultDeserFactory"
type="java:javax.management.remote.NotificationResult"
! />
<typeMapping
***************
*** 145,149 ****
deserializer="mx4j.tools.remote.soap.axis.ser.ObjectInstanceDeserFactory"
type="java:javax.management.ObjectInstance"
! />
<typeMapping
--- 145,149 ----
deserializer="mx4j.tools.remote.soap.axis.ser.ObjectInstanceDeserFactory"
type="java:javax.management.ObjectInstance"
! />
<typeMapping
***************
*** 154,158 ****
deserializer="mx4j.tools.remote.soap.axis.ser.ObjectNameDeserFactory"
type="java:javax.management.ObjectName"
! />
<typeMapping
--- 154,158 ----
deserializer="mx4j.tools.remote.soap.axis.ser.ObjectNameDeserFactory"
type="java:javax.management.ObjectName"
! />
<typeMapping
***************
*** 163,177 ****
deserializer="mx4j.tools.remote.soap.axis.ser.PrincipalDeserFactory"
type="java:java.security.Principal"
! />
! <!--
! <typeMapping
! xmlns:jmx="http://mx4j.sourceforge.net/remote/soap/1.0"
! qname="jmx:RelationNotification"
! encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
! serializer="mx4j.tools.remote.soap.axis.ser.RelationNotificationSerFactory"
! deserializer="mx4j.tools.remote.soap.axis.ser.RelationNotificationDeserFactory"
! type="java:javax.management.relation.RelationNotification"
! />
! -->
<typeMapping
xmlns:jmx="http://mx4j.sourceforge.net/remote/soap/1.0"
--- 163,177 ----
deserializer="mx4j.tools.remote.soap.axis.ser.PrincipalDeserFactory"
type="java:java.security.Principal"
! />
! <!--
! <typeMapping
! xmlns:jmx="http://mx4j.sourceforge.net/remote/soap/1.0"
! qname="jmx:RelationNotification"
! encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
! serializer="mx4j.tools.remote.soap.axis.ser.RelationNotificationSerFactory"
! deserializer="mx4j.tools.remote.soap.axis.ser.RelationNotificationDeserFactory"
! type="java:javax.management.relation.RelationNotification"
! />
! -->
<typeMapping
xmlns:jmx="http://mx4j.sourceforge.net/remote/soap/1.0"
***************
*** 181,185 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RelationTypeSupportDeserFactory"
type="java:javax.management.relation.RelationTypeSupport"
! />
<typeMapping
--- 181,185 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RelationTypeSupportDeserFactory"
type="java:javax.management.relation.RelationTypeSupport"
! />
<typeMapping
***************
*** 190,194 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RoleDeserFactory"
type="java:javax.management.relation.Role"
! />
<typeMapping
--- 190,194 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RoleDeserFactory"
type="java:javax.management.relation.Role"
! />
<typeMapping
***************
*** 199,203 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RoleInfoDeserFactory"
type="java:javax.management.relation.RoleInfo"
! />
<typeMapping
--- 199,203 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RoleInfoDeserFactory"
type="java:javax.management.relation.RoleInfo"
! />
<typeMapping
***************
*** 208,212 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RoleListDeserFactory"
type="java:javax.management.relation.RoleList"
! />
<typeMapping
--- 208,212 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RoleListDeserFactory"
type="java:javax.management.relation.RoleList"
! />
<typeMapping
***************
*** 217,221 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RoleResultDeserFactory"
type="java:javax.management.relation.RoleResult"
! />
<typeMapping
--- 217,221 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RoleResultDeserFactory"
type="java:javax.management.relation.RoleResult"
! />
<typeMapping
***************
*** 226,230 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RoleUnresolvedDeserFactory"
type="java:javax.management.relation.RoleUnresolved"
! />
<typeMapping
--- 226,230 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RoleUnresolvedDeserFactory"
type="java:javax.management.relation.RoleUnresolved"
! />
<typeMapping
***************
*** 235,239 ****
deserializer="mx4j.tools.remote.soap.axis.ser.RoleUnresolvedListDeserFactory"
type="java:javax.management.relation.RoleUnresolvedList"
! />
<typeMapping
--- 235,239 ----
deserializer="mx4j.tools.remote.soap.axis.ser.RoleUnresolvedListDeserFactory"
type="java:javax.management.relation.RoleUnresolvedList"
! />
<typeMapping
***************
*** 244,248 ****
deserializer="mx4j.tools.remote.soap.axis.ser.SetDeserFactory"
type="java:java.util.Set"
! />
<typeMapping
--- 244,248 ----
deserializer="mx4j.tools.remote.soap.axis.ser.SetDeserFactory"
type="java:java.util.Set"
! />
<typeMapping
***************
*** 253,257 ****
deserializer="mx4j.tools.remote.soap.axis.ser.SubjectDeserFactory"
type="java:javax.security.auth.Subject"
! />
<typeMapping
--- 253,257 ----
deserializer="mx4j.tools.remote.soap.axis.ser.SubjectDeserFactory"
type="java:javax.security.auth.Subject"
! />
<typeMapping
***************
*** 262,266 ****
deserializer="mx4j.tools.remote.soap.axis.ser.TargetedNotificationDeserFactory"
type="java:javax.management.remote.TargetedNotification"
! />
<typeMapping
--- 262,266 ----
deserializer="mx4j.tools.remote.soap.axis.ser.TargetedNotificationDeserFactory"
type="java:javax.management.remote.TargetedNotification"
! />
<typeMapping
***************
*** 271,275 ****
deserializer="mx4j.tools.remote.soap.axis.ser.TimerNotificationDeserFactory"
type="java:javax.management.timer.TimerNotification"
! />
</deployment>
--- 271,275 ----
deserializer="mx4j.tools.remote.soap.axis.ser.TimerNotificationDeserFactory"
type="java:javax.management.timer.TimerNotification"
! />
</deployment>
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285