[jboss-svn-commits] JBossWS SVN: r596 - in trunk/src: main/java/javax/jws/soap main/java/javax/xml/ws/soap main/java/org/jboss/ws/deployment main/java/org/jboss/ws/integration/jboss main/java/org/jboss/ws/integration/tomcat main/java/org/jboss/ws/jaxws/spi main/java/org/jboss/ws/server main/java/org/jboss/ws/tools test test/ant test/java/org/jboss/test/ws test/java/org/jboss/test/ws/jaxws test/java/org/jboss/test/ws/jaxws/endpoint test/resources/jaxws test/resources/jaxws/endpoint test/resources/jaxws/endpoint/WEB-INF test/resources/jaxws/endpoint/WEB-INF/wsdl
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 13 06:03:41 EDT 2006
Author: thomas.diesler at jboss.com
Date: 2006-07-13 06:03:14 -0400 (Thu, 13 Jul 2006)
New Revision: 596
Added:
trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB.java
trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatServiceEndpointPublisher.java
trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatServiceEndpointServlet.java
trunk/src/main/java/org/jboss/ws/server/HttpContext.java
trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/
trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java
trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java
trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java
trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java
trunk/src/test/resources/jaxws/endpoint/
trunk/src/test/resources/jaxws/endpoint/WEB-INF/
trunk/src/test/resources/jaxws/endpoint/WEB-INF/web.xml
trunk/src/test/resources/jaxws/endpoint/WEB-INF/wsdl/
trunk/src/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl
Removed:
trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGenerator.java
trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointPublisher.java
trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointServlet.java
trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatHttpServer.java
Modified:
trunk/src/main/java/javax/jws/soap/SOAPBinding.java
trunk/src/main/java/javax/xml/ws/soap/SOAPBinding.java
trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/integration/jboss/DeployerInterceptor.java
trunk/src/main/java/org/jboss/ws/integration/jboss/JBossHttpServer.java
trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB21.java
trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB3.java
trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java
trunk/src/main/java/org/jboss/ws/jaxws/spi/ProviderImpl.java
trunk/src/main/java/org/jboss/ws/server/HttpServer.java
trunk/src/main/java/org/jboss/ws/tools/wspublish.java
trunk/src/test/ant/build-jars.xml
trunk/src/test/build.xml
trunk/src/test/java/org/jboss/test/ws/JBossTestDeployer.java
trunk/src/test/java/org/jboss/test/ws/JBossWSTest.java
trunk/src/test/java/org/jboss/test/ws/JBossWSTestDeployer.java
trunk/src/test/java/org/jboss/test/ws/JBossWSTestHelper.java
trunk/src/test/java/org/jboss/test/ws/JBossWSTestSetup.java
trunk/src/test/java/org/jboss/test/ws/TomcatTestDeployer.java
Log:
[JBWS-1021] Implement javax.xml.ws.Endpoint
Modified: trunk/src/main/java/javax/jws/soap/SOAPBinding.java
===================================================================
--- trunk/src/main/java/javax/jws/soap/SOAPBinding.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/javax/jws/soap/SOAPBinding.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package javax.jws.soap;
// $Id$
@@ -35,17 +35,15 @@
* @since 26-Apr-2005
*/
@Retention(value = RetentionPolicy.RUNTIME)
- @Target(value = {ElementType.TYPE})
- public @interface SOAPBinding
-{
+ at Target(value = { ElementType.TYPE })
+public @interface SOAPBinding {
/**
* The SOAP binding style
*/
public enum Style
{
- DOCUMENT,
- RPC
+ DOCUMENT, RPC
};
/**
@@ -53,8 +51,7 @@
*/
public enum Use
{
- LITERAL,
- ENCODED
+ LITERAL, ENCODED
};
/**
@@ -62,8 +59,7 @@
*/
public enum ParameterStyle
{
- BARE,
- WRAPPED
+ BARE, WRAPPED
}
/**
Modified: trunk/src/main/java/javax/xml/ws/soap/SOAPBinding.java
===================================================================
--- trunk/src/main/java/javax/xml/ws/soap/SOAPBinding.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/javax/xml/ws/soap/SOAPBinding.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -36,8 +36,11 @@
*/
public interface SOAPBinding extends Binding
{
- public static final String SOAP11HTTP_BINDING = "http://schemas.xmlsoap.org/wsdl/soap/http";
- public static final String SOAP12HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
+ /** A constant representing the identity of the SOAP 1.1 over HTTP binding. */
+ public static String SOAP11HTTP_BINDING = "http://schemas.xmlsoap.org/wsdl/soap/http";
+
+ /** A constant representing the identity of the SOAP 1.2 over HTTP binding. */
+ public static String SOAP12HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
public abstract Set<URI> getRoles();
Modified: trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -72,6 +72,9 @@
*/
public ServiceMetaData buildMetaData(QName serviceQName, URL wsdlURL)
{
+ if (wsdlURL == null)
+ throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);
+
log.debug("START buildMetaData: [service=" + serviceQName + "]");
try
{
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss/DeployerInterceptor.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/DeployerInterceptor.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/DeployerInterceptor.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -24,13 +24,11 @@
//$Id: WebServiceDeployer.java 377 2006-05-18 13:57:29Z thomas.diesler at jboss.com $
import org.jboss.deployment.DeploymentInfo;
-import org.jboss.deployment.MainDeployerMBean;
import org.jboss.deployment.SubDeployerInterceptorSupport;
import org.jboss.kernel.spi.registry.KernelRegistry;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.metadata.WebMetaData;
import org.jboss.mx.server.Invocation;
-import org.jboss.mx.util.MBeanProxy;
import org.jboss.ws.deployment.ServiceEndpointDeployer;
import org.jboss.ws.deployment.ServiceEndpointPublisher;
import org.jboss.ws.deployment.UnifiedDeploymentInfo;
@@ -47,14 +45,10 @@
*/
public abstract class DeployerInterceptor extends SubDeployerInterceptorSupport
{
- // The main deployer
- private MainDeployerMBean mainDeployer;
-
/** Create the deployer service
*/
protected void createService() throws Exception
{
- mainDeployer = (MainDeployerMBean)MBeanProxy.get(MainDeployerMBean.class, MainDeployerMBean.OBJECT_NAME, server);
super.attach();
}
@@ -161,24 +155,4 @@
{
return (UnifiedDeploymentInfo)di.context.get(UnifiedDeploymentInfo.class.getName());
}
-
- /** Handle all webservice deployment exceptions.
- * You can either simply logs the problem and keep the EJB/WAR module
- * alive or undeploy properly.
- */
- protected void handleStartupException(DeploymentInfo di, Throwable th)
- {
- log.error("Cannot startup webservice for: " + di.shortName, th);
- mainDeployer.undeploy(di);
- }
-
- /** Handle all webservice deployment exceptions.
- *
- * You can either simply logs the problem and keep the EJB/WAR module
- * alive or undeploy properly.
- */
- protected void handleShutdownException(String moduleName, Throwable th)
- {
- log.error("Cannot shutdown webservice for: " + moduleName, th);
- }
}
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss/JBossHttpServer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/JBossHttpServer.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/JBossHttpServer.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -23,13 +23,26 @@
//$Id$
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.xml.ws.Endpoint;
+import org.jboss.util.xml.DOMUtils;
+import org.jboss.util.xml.DOMWriter;
import org.jboss.ws.WSException;
+import org.jboss.ws.server.HttpContext;
import org.jboss.ws.server.HttpServer;
+import org.jboss.ws.server.ServerConfig;
+import org.jboss.ws.server.ServerConfigFactory;
+import org.w3c.dom.Element;
/**
* A Tomcat HTTP Server
@@ -40,40 +53,111 @@
public class JBossHttpServer extends HttpServer
{
private static final String MAIN_DEPLOYER = "jboss.system:service=MainDeployer";
-
+
/** Start an instance of this HTTP server */
@Override
public void start()
{
// verify required properties
}
-
+
+ /** Create an HTTP context */
+ public HttpContext createContext(String contextRoot)
+ {
+ return new HttpContext(this, contextRoot);
+ }
+
/** Publish an JAXWS endpoint to the HTTP server */
@Override
- public void publish(Endpoint endpoint)
+ public void publish(HttpContext context, Endpoint endpoint)
{
+ Class implClass = getImplementorClass(endpoint);
+ String implName = implClass.getName();
+
try
{
+ Element webDoc = createWebAppDescriptor(context, endpoint);
+ Element jbossDoc = createJBossWebAppDescriptor(context, endpoint);
+
+ File tmpWar = null;
+ try
+ {
+ ServerConfigFactory factory = ServerConfigFactory.getInstance();
+ ServerConfig serverConfig = factory.getServerConfig();
+ File tmpDir = new File(serverConfig.getServerTempDir().getCanonicalPath() + "/jbossws");
+
+ String deploymentName = implName.substring(implName.lastIndexOf(".") + 1);
+ tmpWar = File.createTempFile(deploymentName, ".war", tmpDir);
+ tmpWar.delete();
+ File webInf = new File(tmpWar, "WEB-INF");
+ webInf.mkdirs();
+
+ File webXml = new File(webInf, "web.xml");
+ FileWriter fw = new FileWriter(webXml);
+ new DOMWriter(fw).setPrettyprint(true).print(webDoc);
+ fw.close();
+
+ File jbossWebXml = new File(webInf, "jboss-web.xml");
+ fw = new FileWriter(jbossWebXml);
+ new DOMWriter(fw).setPrettyprint(true).print(jbossDoc);
+ fw.close();
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Failed to create webservice war", e);
+ }
+
+ Map<String, Object> epProps = endpoint.getProperties();
+ epProps.put("jbossws-endpoint-war-url", tmpWar);
+
+ URL tmpURL = tmpWar.toURL();
MBeanServerConnection server = getServer();
- //server.invoke(new ObjectName(MAIN_DEPLOYER), "deploy", new Object[] { url }, new String[] { "java.net.URL" });
+ server.invoke(new ObjectName(MAIN_DEPLOYER), "deploy", new Object[] { tmpURL }, new String[] { "java.net.URL" });
}
catch (RuntimeException rte)
{
throw rte;
- }
+ }
catch (Exception ex)
{
throw new WSException(ex);
- }
+ }
}
+ /** Destroys an JAXWS endpoint on the HTTP server */
@Override
- public void destroy(Endpoint endpoint)
+ public void destroy(HttpContext context, Endpoint endpoint)
{
- // TODO Auto-generated method stub
-
+ Map<String, Object> epProps = endpoint.getProperties();
+ File tmpWar = (File)epProps.get("jbossws-endpoint-war-url");
+ if (tmpWar == null)
+ throw new IllegalStateException("Cannot find endpoint war property");
+
+ try
+ {
+ URL tmpURL = tmpWar.toURL();
+ MBeanServerConnection server = getServer();
+ server.invoke(new ObjectName(MAIN_DEPLOYER), "undeploy", new Object[] { tmpURL }, new String[] { "java.net.URL" });
+
+ tmpWar.delete();
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new WSException(ex);
+ }
}
-
+
+ private Class getImplementorClass(Endpoint endpoint)
+ {
+ Object implementor = endpoint.getImplementor();
+ Class implClass = (implementor instanceof Class ? (Class)implementor : implementor.getClass());
+ return implClass;
+ }
+
private MBeanServerConnection getServer() throws NamingException
{
InitialContext iniCtx = new InitialContext();
@@ -81,4 +165,66 @@
return server;
}
+ private Element createWebAppDescriptor(HttpContext context, Endpoint endpoint)
+ {
+ Class implClass = getImplementorClass(endpoint);
+ String implName = implClass.getName();
+
+ Element webApp = DOMUtils.createElement("web-app");
+
+ /*
+ <servlet>
+ <servlet-name>
+ <servlet-class>
+ </servlet>
+ */
+ Element servlet = (Element)webApp.appendChild(DOMUtils.createElement("servlet"));
+ Element servletName = (Element)servlet.appendChild(DOMUtils.createElement("servlet-name"));
+ servletName.appendChild(DOMUtils.createTextNode("JAXWSEndpoint"));
+ Element servletClass = (Element)servlet.appendChild(DOMUtils.createElement("servlet-class"));
+ servletClass.appendChild(DOMUtils.createTextNode(implName));
+
+ /*
+ <servlet-mapping>
+ <servlet-name>
+ <url-pattern>
+ </servlet-mapping>
+ */
+ Element servletMapping = (Element)webApp.appendChild(DOMUtils.createElement("servlet-mapping"));
+ servletName = (Element)servletMapping.appendChild(DOMUtils.createElement("servlet-name"));
+ servletName.appendChild(DOMUtils.createTextNode("JAXWSEndpoint"));
+ Element urlPatternElement = (Element)servletMapping.appendChild(DOMUtils.createElement("url-pattern"));
+
+ String urlPattern = "/*";
+ urlPatternElement.appendChild(DOMUtils.createTextNode(urlPattern));
+
+ // Add security-constraint in generated web.xml for Endpoint API
+ // FIXME: JBWS-1069
+
+ return webApp;
+ }
+
+ private Element createJBossWebAppDescriptor(HttpContext context, Endpoint endpoint)
+ {
+ /* Create a jboss-web
+ <jboss-web>
+ <security-domain>java:/jaas/cts</security-domain>
+ <context-root>/ws/ejbN/</context-root>
+ </jboss-web>
+ */
+ Element jbossWeb = DOMUtils.createElement("jboss-web");
+
+ // Get the context root for this deployment
+ String contextRoot = context.getContextRoot();
+ if (contextRoot == null)
+ throw new WSException("Cannot obtain context root");
+
+ Element root = (Element)jbossWeb.appendChild(DOMUtils.createElement("context-root"));
+ root.appendChild(DOMUtils.createTextNode(contextRoot));
+
+ // Add security-constraint in generated web.xml for Endpoint API
+ // FIXME: JBWS-1069
+
+ return jbossWeb;
+ }
}
Deleted: trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGenerator.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGenerator.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -1,274 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.integration.jboss;
-
-//$Id: WebServiceDeployer.java 312 2006-05-11 10:49:22Z thomas.diesler at jboss.com $
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.logging.Logger;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.system.server.ServerConfigLocator;
-import org.jboss.util.xml.DOMUtils;
-import org.jboss.util.xml.DOMWriter;
-import org.jboss.ws.WSException;
-import org.jboss.ws.metadata.EndpointMetaData;
-import org.jboss.ws.metadata.ServerEndpointMetaData;
-import org.jboss.ws.metadata.ServiceMetaData;
-import org.jboss.ws.metadata.UnifiedMetaData;
-import org.w3c.dom.Element;
-
-/**
- * Generate a web deployment for EJB endpoints
- *
- * @author Thomas.Diesler at jboss.org
- * @since 12-May-2006
- */
-public abstract class ServiceEndpointGenerator
-{
- // logging support
- protected Logger log = Logger.getLogger(ServiceEndpointGenerator.class);
-
- public URL generatWebDeployment(DeploymentInfo di, UnifiedMetaData wsMetaData) throws IOException
- {
- // Collect the list of PortComponentMetaData
- List<EndpointMetaData> epMetaDataList = new ArrayList<EndpointMetaData>();
- for (ServiceMetaData serviceMetaData : wsMetaData.getServices())
- {
- for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
- {
- epMetaDataList.add(epMetaData);
- }
- }
-
- Element webDoc = createWebAppDescriptor(di, epMetaDataList);
- Element jbossDoc = createJBossWebAppDescriptor(di, epMetaDataList);
-
- File tmpWar = null;
- try
- {
- ServerConfig config = ServerConfigLocator.locate();
- File tmpdir = new File(config.getServerTempDir().getCanonicalPath() + "/deploy");
-
- String deploymentName = di.getCanonicalName().replace('/', '-') + "-ws";
- tmpWar = File.createTempFile(deploymentName, ".war", tmpdir);
- tmpWar.delete();
- File webInf = new File(tmpWar, "WEB-INF");
- webInf.mkdirs();
-
- File webXml = new File(webInf, "web.xml");
- FileWriter fw = new FileWriter(webXml);
- new DOMWriter(fw).setPrettyprint(true).print(webDoc);
- fw.close();
-
- File jbossWebXml = new File(webInf, "jboss-web.xml");
- fw = new FileWriter(jbossWebXml);
- new DOMWriter(fw).setPrettyprint(true).print(jbossDoc);
- fw.close();
- }
- catch (IOException e)
- {
- throw new WSException("Failed to create webservice.war", e);
- }
-
- return tmpWar.toURL();
- }
-
- private Element createWebAppDescriptor(DeploymentInfo di, List<EndpointMetaData> epMetaDataList)
- {
- Element webApp = DOMUtils.createElement("web-app");
-
- /*
- <servlet>
- <servlet-name>
- <servlet-class>
- </servlet>
- */
- for (EndpointMetaData epMetaData : epMetaDataList)
- {
- ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
- String ejbName = sepMetaData.getLinkName();
- Element servlet = (Element)webApp.appendChild(DOMUtils.createElement("servlet"));
- Element servletName = (Element)servlet.appendChild(DOMUtils.createElement("servlet-name"));
- servletName.appendChild(DOMUtils.createTextNode(ejbName));
- Element servletClass = (Element)servlet.appendChild(DOMUtils.createElement("servlet-class"));
- String targetBean = sepMetaData.getServiceEndpointImplName();
- String seiName = sepMetaData.getServiceEndpointInterfaceName();
- String servletClassName = (targetBean != null ? targetBean : seiName);
- servletClass.appendChild(DOMUtils.createTextNode(servletClassName));
- }
-
- /*
- <servlet-mapping>
- <servlet-name>
- <url-pattern>
- </servlet-mapping>
- */
- ArrayList urlPatters = new ArrayList();
- for (EndpointMetaData epMetaData : epMetaDataList)
- {
- ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
- String ejbName = sepMetaData.getLinkName();
- Element servletMapping = (Element)webApp.appendChild(DOMUtils.createElement("servlet-mapping"));
- Element servletName = (Element)servletMapping.appendChild(DOMUtils.createElement("servlet-name"));
- servletName.appendChild(DOMUtils.createTextNode(ejbName));
- Element urlPatternElement = (Element)servletMapping.appendChild(DOMUtils.createElement("url-pattern"));
-
- String urlPattern = "/*";
- if (sepMetaData.getURLPattern() != null)
- {
- urlPattern = sepMetaData.getURLPattern();
- }
-
- if (urlPatters.contains(urlPattern))
- throw new IllegalArgumentException("Cannot use the same url-pattern with different endpoints, " + "check your <port-component-uri> in jboss.xml");
-
- urlPatternElement.appendChild(DOMUtils.createTextNode(urlPattern));
- urlPatters.add(urlPattern);
- }
-
- String authMethod = null;
-
- // Add web-app/security-constraint for each port component
- for (EndpointMetaData epMetaData : epMetaDataList)
- {
- ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
- String ejbName = sepMetaData.getLinkName();
- if (sepMetaData.getAuthMethod() != null || sepMetaData.getTransportGuarantee() != null)
- {
- /*
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>TestUnAuthPort</web-resource-name>
- <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>*</role-name>
- </auth-constraint>
- <user-data-constraint>
- <transport-guarantee>NONE</transport-guarantee>
- </user-data-constraint>
- </security-constraint>
- */
- Element securityConstraint = (Element)webApp.appendChild(DOMUtils.createElement("security-constraint"));
- Element wrc = (Element)securityConstraint.appendChild(DOMUtils.createElement("web-resource-collection"));
- Element wrName = (Element)wrc.appendChild(DOMUtils.createElement("web-resource-name"));
- wrName.appendChild(DOMUtils.createTextNode(ejbName));
- Element pattern = (Element)wrc.appendChild(DOMUtils.createElement("url-pattern"));
- String uri = sepMetaData.getURLPattern();
- pattern.appendChild(DOMUtils.createTextNode(uri));
- Element method = (Element)wrc.appendChild(DOMUtils.createElement("http-method"));
- method.appendChild(DOMUtils.createTextNode("GET"));
- method = (Element)wrc.appendChild(DOMUtils.createElement("http-method"));
- method.appendChild(DOMUtils.createTextNode("POST"));
-
- // Optional auth-constraint
- if (sepMetaData.getAuthMethod() != null)
- {
- // Only the first auth-method gives the war login-config/auth-method
- if (authMethod == null)
- authMethod = sepMetaData.getAuthMethod();
-
- Element authConstraint = (Element)securityConstraint.appendChild(DOMUtils.createElement("auth-constraint"));
- Element roleName = (Element)authConstraint.appendChild(DOMUtils.createElement("role-name"));
- roleName.appendChild(DOMUtils.createTextNode("*"));
- }
- // Optional user-data-constraint
- if (sepMetaData.getTransportGuarantee() != null)
- {
- Element userData = (Element)securityConstraint.appendChild(DOMUtils.createElement("user-data-constraint"));
- Element transport = (Element)userData.appendChild(DOMUtils.createElement("transport-guarantee"));
- transport.appendChild(DOMUtils.createTextNode(sepMetaData.getTransportGuarantee()));
- }
- }
- }
-
- // Optional login-config/auth-method
- if (authMethod != null)
- {
- Element loginConfig = (Element)webApp.appendChild(DOMUtils.createElement("login-config"));
- Element method = (Element)loginConfig.appendChild(DOMUtils.createElement("auth-method"));
- method.appendChild(DOMUtils.createTextNode(authMethod));
- Element realm = (Element)loginConfig.appendChild(DOMUtils.createElement("realm-name"));
- realm.appendChild(DOMUtils.createTextNode("EJBServiceEndpointServlet Realm"));
-
- addEJBSecurityRoles(di, webApp);
- }
-
- return webApp;
- }
-
- private Element createJBossWebAppDescriptor(DeploymentInfo di, List<EndpointMetaData> epMetaDataList)
- {
- /* Create a jboss-web
- <jboss-web>
- <security-domain>java:/jaas/cts</security-domain>
- <context-root>/ws/ejbN/</context-root>
- </jboss-web>
- */
- Element jbossWeb = DOMUtils.createElement("jboss-web");
-
- UnifiedMetaData wsMetaData = epMetaDataList.get(0).getServiceMetaData().getUnifiedMetaData();
- String securityDomain = wsMetaData.getSecurityDomain();
- if (securityDomain != null)
- {
- Element secDomain = (Element)jbossWeb.appendChild(DOMUtils.createElement("security-domain"));
- secDomain.appendChild(DOMUtils.createTextNode("java:/jaas/" + securityDomain));
- }
-
- // Get the context root for this deployment
- String contextRoot = null;
- for (EndpointMetaData epMetaData : epMetaDataList)
- {
- ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
- String next = sepMetaData.getContextRoot();
- if (next != null)
- {
- if (contextRoot == null)
- {
- contextRoot = next;
- }
- else if (contextRoot.equals(next) == false)
- {
- throw new WSException("Multiple context root not supported");
- }
- }
- }
- if (contextRoot == null)
- throw new WSException("Cannot obtain context root");
-
- Element root = (Element)jbossWeb.appendChild(DOMUtils.createElement("context-root"));
- root.appendChild(DOMUtils.createTextNode(contextRoot));
-
- return jbossWeb;
- }
-
- /** Add the roles from ejb-jar.xml to the security roles
- */
- protected abstract void addEJBSecurityRoles(DeploymentInfo di, Element webApp);
-}
Copied: trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB.java (from rev 594, trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGenerator.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGenerator.java 2006-07-12 16:00:22 UTC (rev 594)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.integration.jboss;
+
+//$Id: WebServiceDeployer.java 312 2006-05-11 10:49:22Z thomas.diesler at jboss.com $
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.logging.Logger;
+import org.jboss.system.server.ServerConfig;
+import org.jboss.system.server.ServerConfigLocator;
+import org.jboss.util.xml.DOMUtils;
+import org.jboss.util.xml.DOMWriter;
+import org.jboss.ws.WSException;
+import org.jboss.ws.metadata.EndpointMetaData;
+import org.jboss.ws.metadata.ServerEndpointMetaData;
+import org.jboss.ws.metadata.ServiceMetaData;
+import org.jboss.ws.metadata.UnifiedMetaData;
+import org.w3c.dom.Element;
+
+/**
+ * Generate a web deployment for EJB endpoints
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public abstract class ServiceEndpointGeneratorEJB
+{
+ // logging support
+ protected Logger log = Logger.getLogger(ServiceEndpointGeneratorEJB.class);
+
+ public URL generatWebDeployment(DeploymentInfo di, UnifiedMetaData wsMetaData) throws IOException
+ {
+ // Collect the list of PortComponentMetaData
+ List<EndpointMetaData> epMetaDataList = new ArrayList<EndpointMetaData>();
+ for (ServiceMetaData serviceMetaData : wsMetaData.getServices())
+ {
+ for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
+ {
+ epMetaDataList.add(epMetaData);
+ }
+ }
+
+ Element webDoc = createWebAppDescriptor(di, epMetaDataList);
+ Element jbossDoc = createJBossWebAppDescriptor(di, epMetaDataList);
+
+ File tmpWar = null;
+ try
+ {
+ ServerConfig config = ServerConfigLocator.locate();
+ File tmpdir = new File(config.getServerTempDir().getCanonicalPath() + "/deploy");
+
+ String deploymentName = di.getCanonicalName().replace('/', '-') + "-ws";
+ tmpWar = File.createTempFile(deploymentName, ".war", tmpdir);
+ tmpWar.delete();
+ File webInf = new File(tmpWar, "WEB-INF");
+ webInf.mkdirs();
+
+ File webXml = new File(webInf, "web.xml");
+ FileWriter fw = new FileWriter(webXml);
+ new DOMWriter(fw).setPrettyprint(true).print(webDoc);
+ fw.close();
+
+ File jbossWebXml = new File(webInf, "jboss-web.xml");
+ fw = new FileWriter(jbossWebXml);
+ new DOMWriter(fw).setPrettyprint(true).print(jbossDoc);
+ fw.close();
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Failed to create webservice.war", e);
+ }
+
+ return tmpWar.toURL();
+ }
+
+ private Element createWebAppDescriptor(DeploymentInfo di, List<EndpointMetaData> epMetaDataList)
+ {
+ Element webApp = DOMUtils.createElement("web-app");
+
+ /*
+ <servlet>
+ <servlet-name>
+ <servlet-class>
+ </servlet>
+ */
+ for (EndpointMetaData epMetaData : epMetaDataList)
+ {
+ ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+ String ejbName = sepMetaData.getLinkName();
+ Element servlet = (Element)webApp.appendChild(DOMUtils.createElement("servlet"));
+ Element servletName = (Element)servlet.appendChild(DOMUtils.createElement("servlet-name"));
+ servletName.appendChild(DOMUtils.createTextNode(ejbName));
+ Element servletClass = (Element)servlet.appendChild(DOMUtils.createElement("servlet-class"));
+ String targetBean = sepMetaData.getServiceEndpointImplName();
+ String seiName = sepMetaData.getServiceEndpointInterfaceName();
+ String servletClassName = (targetBean != null ? targetBean : seiName);
+ servletClass.appendChild(DOMUtils.createTextNode(servletClassName));
+ }
+
+ /*
+ <servlet-mapping>
+ <servlet-name>
+ <url-pattern>
+ </servlet-mapping>
+ */
+ ArrayList urlPatters = new ArrayList();
+ for (EndpointMetaData epMetaData : epMetaDataList)
+ {
+ ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+ String ejbName = sepMetaData.getLinkName();
+ Element servletMapping = (Element)webApp.appendChild(DOMUtils.createElement("servlet-mapping"));
+ Element servletName = (Element)servletMapping.appendChild(DOMUtils.createElement("servlet-name"));
+ servletName.appendChild(DOMUtils.createTextNode(ejbName));
+ Element urlPatternElement = (Element)servletMapping.appendChild(DOMUtils.createElement("url-pattern"));
+
+ String urlPattern = "/*";
+ if (sepMetaData.getURLPattern() != null)
+ {
+ urlPattern = sepMetaData.getURLPattern();
+ }
+
+ if (urlPatters.contains(urlPattern))
+ throw new IllegalArgumentException("Cannot use the same url-pattern with different endpoints, " + "check your <port-component-uri> in jboss.xml");
+
+ urlPatternElement.appendChild(DOMUtils.createTextNode(urlPattern));
+ urlPatters.add(urlPattern);
+ }
+
+ String authMethod = null;
+
+ // Add web-app/security-constraint for each port component
+ for (EndpointMetaData epMetaData : epMetaDataList)
+ {
+ ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+ String ejbName = sepMetaData.getLinkName();
+ if (sepMetaData.getAuthMethod() != null || sepMetaData.getTransportGuarantee() != null)
+ {
+ /*
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>TestUnAuthPort</web-resource-name>
+ <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+ */
+ Element securityConstraint = (Element)webApp.appendChild(DOMUtils.createElement("security-constraint"));
+ Element wrc = (Element)securityConstraint.appendChild(DOMUtils.createElement("web-resource-collection"));
+ Element wrName = (Element)wrc.appendChild(DOMUtils.createElement("web-resource-name"));
+ wrName.appendChild(DOMUtils.createTextNode(ejbName));
+ Element pattern = (Element)wrc.appendChild(DOMUtils.createElement("url-pattern"));
+ String uri = sepMetaData.getURLPattern();
+ pattern.appendChild(DOMUtils.createTextNode(uri));
+ Element method = (Element)wrc.appendChild(DOMUtils.createElement("http-method"));
+ method.appendChild(DOMUtils.createTextNode("GET"));
+ method = (Element)wrc.appendChild(DOMUtils.createElement("http-method"));
+ method.appendChild(DOMUtils.createTextNode("POST"));
+
+ // Optional auth-constraint
+ if (sepMetaData.getAuthMethod() != null)
+ {
+ // Only the first auth-method gives the war login-config/auth-method
+ if (authMethod == null)
+ authMethod = sepMetaData.getAuthMethod();
+
+ Element authConstraint = (Element)securityConstraint.appendChild(DOMUtils.createElement("auth-constraint"));
+ Element roleName = (Element)authConstraint.appendChild(DOMUtils.createElement("role-name"));
+ roleName.appendChild(DOMUtils.createTextNode("*"));
+ }
+ // Optional user-data-constraint
+ if (sepMetaData.getTransportGuarantee() != null)
+ {
+ Element userData = (Element)securityConstraint.appendChild(DOMUtils.createElement("user-data-constraint"));
+ Element transport = (Element)userData.appendChild(DOMUtils.createElement("transport-guarantee"));
+ transport.appendChild(DOMUtils.createTextNode(sepMetaData.getTransportGuarantee()));
+ }
+ }
+ }
+
+ // Optional login-config/auth-method
+ if (authMethod != null)
+ {
+ Element loginConfig = (Element)webApp.appendChild(DOMUtils.createElement("login-config"));
+ Element method = (Element)loginConfig.appendChild(DOMUtils.createElement("auth-method"));
+ method.appendChild(DOMUtils.createTextNode(authMethod));
+ Element realm = (Element)loginConfig.appendChild(DOMUtils.createElement("realm-name"));
+ realm.appendChild(DOMUtils.createTextNode("EJBServiceEndpointServlet Realm"));
+
+ addEJBSecurityRoles(di, webApp);
+ }
+
+ return webApp;
+ }
+
+ private Element createJBossWebAppDescriptor(DeploymentInfo di, List<EndpointMetaData> epMetaDataList)
+ {
+ /* Create a jboss-web
+ <jboss-web>
+ <security-domain>java:/jaas/cts</security-domain>
+ <context-root>/ws/ejbN/</context-root>
+ </jboss-web>
+ */
+ Element jbossWeb = DOMUtils.createElement("jboss-web");
+
+ UnifiedMetaData wsMetaData = epMetaDataList.get(0).getServiceMetaData().getUnifiedMetaData();
+ String securityDomain = wsMetaData.getSecurityDomain();
+ if (securityDomain != null)
+ {
+ Element secDomain = (Element)jbossWeb.appendChild(DOMUtils.createElement("security-domain"));
+ secDomain.appendChild(DOMUtils.createTextNode("java:/jaas/" + securityDomain));
+ }
+
+ // Get the context root for this deployment
+ String contextRoot = null;
+ for (EndpointMetaData epMetaData : epMetaDataList)
+ {
+ ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+ String next = sepMetaData.getContextRoot();
+ if (next != null)
+ {
+ if (contextRoot == null)
+ {
+ contextRoot = next;
+ }
+ else if (contextRoot.equals(next) == false)
+ {
+ throw new WSException("Multiple context root not supported");
+ }
+ }
+ }
+ if (contextRoot == null)
+ throw new WSException("Cannot obtain context root");
+
+ Element root = (Element)jbossWeb.appendChild(DOMUtils.createElement("context-root"));
+ root.appendChild(DOMUtils.createTextNode(contextRoot));
+
+ return jbossWeb;
+ }
+
+ /** Add the roles from ejb-jar.xml to the security roles
+ */
+ protected abstract void addEJBSecurityRoles(DeploymentInfo di, Element webApp);
+}
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB21.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB21.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB21.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -39,7 +39,7 @@
* @author Thomas.Diesler at jboss.org
* @since 12-May-2006
*/
-public class ServiceEndpointGeneratorEJB21 extends ServiceEndpointGenerator
+public class ServiceEndpointGeneratorEJB21 extends ServiceEndpointGeneratorEJB
{
// logging support
protected Logger log = Logger.getLogger(ServiceEndpointGeneratorEJB21.class);
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB3.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB3.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointGeneratorEJB3.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -44,7 +44,7 @@
* @author Thomas.Diesler at jboss.org
* @since 12-May-2006
*/
-public class ServiceEndpointGeneratorEJB3 extends ServiceEndpointGenerator
+public class ServiceEndpointGeneratorEJB3 extends ServiceEndpointGeneratorEJB
{
// logging support
protected Logger log = Logger.getLogger(ServiceEndpointGeneratorEJB3.class);
Deleted: trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointPublisher.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointPublisher.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointPublisher.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.integration.tomcat;
-
-// $Id: WebServiceDeployer.java 312 2006-05-11 10:49:22Z thomas.diesler at jboss.com $
-
-import java.io.File;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
-import org.jboss.ws.deployment.ServiceEndpointPublisher;
-import org.jboss.ws.deployment.UnifiedDeploymentInfo;
-import org.jboss.ws.tools.wspublish;
-
-/**
- * Publish the HTTP service endpoint to Tomcat
- *
- * @author Thomas.Diesler at jboss.org
- * @since 12-May-2006
- */
-public class GenericServiceEndpointPublisher extends ServiceEndpointPublisher
-{
- // logging support
- private static Logger log = Logger.getLogger(GenericServiceEndpointPublisher.class);
-
- private boolean isRunning;
- private File targetDir;
- private File deployDir;
- private long interval;
-
- private Set<File> deployedFiles = new HashSet<File>();
-
- public void setDeployDir(String dirName)
- {
- this.deployDir = new File(dirName);
- if (deployDir.exists() == false)
- {
- System.out.println("create directory: " + deployDir);
- deployDir.mkdirs();
- }
- }
-
- public void setTargetDir(String dirName)
- {
- this.targetDir = new File(dirName);
- if (targetDir.isDirectory() == false)
- throw new IllegalArgumentException ("Target dir does not exist: " + targetDir);
- }
-
- public void setInterval(long interval)
- {
- this.interval = interval;
- }
-
- public String publishServiceEndpoint(URL warURL) throws Exception
- {
- new wspublish().process(warURL, targetDir, servletName);
- return "OK";
- }
-
- public String destroyServiceEndpoint(URL warURL) throws Exception
- {
- File targetFile = new File(targetDir.getAbsolutePath() + "/" + new File(warURL.getFile()).getName());
- if (targetFile.delete())
- return "OK";
- else
- return "NOT FOUND";
- }
-
- public String publishServiceEndpoint(UnifiedDeploymentInfo udi) throws Exception
- {
- throw new NotImplementedException();
- }
-
- public String destroyServiceEndpoint(UnifiedDeploymentInfo udi) throws Exception
- {
- throw new NotImplementedException();
- }
-
- private void scanDeployDir()
- {
- List<File> fileList = Arrays.asList(deployDir.listFiles());
-
- // deploy new files
- for (File file : fileList)
- {
- if (deployedFiles.contains(file) == false)
- {
- deployFile(file);
- deployedFiles.add(file);
- }
- }
-
- // undeploy files
- for (File file : deployedFiles)
- {
- if (fileList.contains(file) == false)
- {
- undeployFile(file);
- deployedFiles.remove(file);
- }
- }
- }
-
- private void deployFile(File file)
- {
- try
- {
- if (new File(targetDir.getAbsolutePath() + "/" + file.getName()).exists() == false)
- {
- System.out.println("Deploy file: " + file);
- publishServiceEndpoint(file.toURL());
- }
- else
- {
- System.out.println("Ignore file: " + file);
- }
- }
- catch (Exception ex)
- {
- log.error("Cannot deploy file: " + file, ex);
- }
- }
-
- private void undeployFile(File file)
- {
- try
- {
- if (new File(targetDir.getAbsolutePath() + "/" + file.getName()).exists())
- {
- System.out.println("Undeploy file: " + file);
- destroyServiceEndpoint(file.toURL());
- }
- else
- {
- System.out.println("Ignore file: " + file);
- }
- }
- catch (Exception ex)
- {
- log.error("Cannot undeploy file: " + file, ex);
- }
- }
-
- // bean lifecycle start
- public void start()
- {
- System.out.println("Start scanning: " + deployDir);
- Scanner s = new Scanner();
- new Thread(s).start();
- }
-
- // bean lifecycle stop
- public void stop()
- {
- System.out.println("Stop scanning: " + deployDir);
- isRunning = false;
- }
-
- class Scanner implements Runnable
- {
- public void run()
- {
- isRunning = true;
- try
- {
- while (isRunning)
- {
- scanDeployDir();
- Thread.sleep(Math.max(100, interval));
- }
- }
- catch (InterruptedException ex)
- {
- // ignore
- }
- }
- }
-}
Deleted: trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointServlet.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointServlet.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointServlet.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.integration.tomcat;
-
-// $Id: ServiceEndpointServlet.java 296 2006-05-08 19:45:49Z thomas.diesler at jboss.com $
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.kernel.spi.registry.KernelRegistry;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
-import org.jboss.ws.deployment.JSR109Deployment;
-import org.jboss.ws.deployment.JSR181Deployment;
-import org.jboss.ws.deployment.ServiceEndpointDeployer;
-import org.jboss.ws.deployment.UnifiedDeploymentInfo;
-import org.jboss.ws.server.KernelLocator;
-import org.jboss.ws.server.StandardEndpointServlet;
-
-/**
- * A servlet that is installed for every web service endpoint.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 16-May-2006
- */
-public class GenericServiceEndpointServlet extends StandardEndpointServlet
-{
- // provide logging
- private static final Logger log = Logger.getLogger(GenericServiceEndpointServlet.class);
-
- public void init(ServletConfig config) throws ServletException
- {
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- CrossContextLoader jbwsLoader = CrossContextLoader.newInstance(config.getServletContext());
- Thread.currentThread().setContextClassLoader(jbwsLoader);
-
- super.init(config);
- deployServiceEndpoints(getServletContext());
- }
- catch (Exception e)
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
- }
-
- public void destroy()
- {
- undeployServiceEndpoints(getServletContext());
- super.destroy();
- }
-
- public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
- {
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- if ((ctxLoader instanceof CrossContextLoader) == false)
- {
- CrossContextLoader jbwsLoader = CrossContextLoader.newInstance(getServletContext());
- Thread.currentThread().setContextClassLoader(jbwsLoader);
- }
- super.service(req, res);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
- }
-
- /**
- * Bootstrap the Microkernel and initialize the
- * ServiceEndpointManager
- */
- protected void initServiceEndpointManager()
- {
- // bootstrap the microkernel
- URLClassLoader ctxLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
- URL beansXML = ctxLoader.findResource("META-INF/jboss-beans.xml");
- if (beansXML == null)
- throw new IllegalStateException("Invalid null kernel deployment");
-
- try
- {
- new KernelBootstrap().bootstrap(beansXML);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new WSException("Cannot bootstrap kernel", ex);
- }
-
- // init the service endpoint manager
- super.initServiceEndpointManager();
- }
-
- private void deployServiceEndpoints(ServletContext servletContext)
- {
- UnifiedDeploymentInfo udi = (UnifiedDeploymentInfo)servletContext.getAttribute(UnifiedDeploymentInfo.class.getName());
- if (udi == null)
- {
- ServiceEndpointDeployer deployer = getServiceEndpointDeployer();
- try
- {
- udi = createDeploymentInfo(servletContext);
- servletContext.setAttribute(UnifiedDeploymentInfo.class.getName(), udi);
-
- deployer.create(udi);
- deployer.start(udi);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Throwable th)
- {
- throw new WSException("Cannot deploy service endpoint", th);
- }
- }
- }
-
- private UnifiedDeploymentInfo createDeploymentInfo(ServletContext servletContext) throws Exception
- {
- UnifiedDeploymentInfo udi;
-
- URLClassLoader ctxLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
- URL webservices109URL = ctxLoader.findResource("WEB-INF/webservices.xml");
- if (webservices109URL != null)
- {
- udi = new JSR109Deployment(UnifiedDeploymentInfo.DeploymentType.JSR109_JSE, webservices109URL);
- }
- else
- {
- udi = new JSR181Deployment(UnifiedDeploymentInfo.DeploymentType.JSR181_JSE);
- }
-
- DeploymentInfoAdaptor.buildDeploymentInfo(udi, ctxLoader, servletContext);
- return udi;
- }
-
- private void undeployServiceEndpoints(ServletContext servletContext)
- {
- UnifiedDeploymentInfo udi = (UnifiedDeploymentInfo)servletContext.getAttribute(UnifiedDeploymentInfo.class.getName());
- if (udi != null)
- {
- ServiceEndpointDeployer deployer = getServiceEndpointDeployer();
- try
- {
- deployer.stop(udi);
- deployer.destroy(udi);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Throwable th)
- {
- throw new WSException("Cannot deploy service endpoint", th);
- }
- }
- }
-
- private ServiceEndpointDeployer getServiceEndpointDeployer()
- {
- KernelRegistry registry = KernelLocator.getKernel().getRegistry();
- KernelRegistryEntry entry = registry.getEntry(ServiceEndpointDeployer.BEAN_NAME);
- return (ServiceEndpointDeployer)entry.getTarget();
- }
-}
Deleted: trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatHttpServer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatHttpServer.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatHttpServer.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.integration.tomcat;
-
-//$Id$
-
-import javax.xml.ws.Endpoint;
-
-import org.jboss.ws.server.HttpServer;
-
-/**
- * A Tomcat HTTP Server
- *
- * @author Thomas.Diesler at jboss.org
- * @since 07-Jul-2006
- */
-public class TomcatHttpServer extends HttpServer
-{
- /** Start an instance of this HTTP server */
- @Override
- public void start()
- {
- // verify required properties
- }
-
- /** Publish an JAXWS endpoint to the HTTP server */
- @Override
- public void publish(Endpoint endpoint)
- {
-
- }
-
- @Override
- public void destroy(Endpoint endpoint)
- {
-
- }
-}
Copied: trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatServiceEndpointPublisher.java (from rev 589, trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointPublisher.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointPublisher.java 2006-07-11 17:42:41 UTC (rev 589)
+++ trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatServiceEndpointPublisher.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.integration.tomcat;
+
+// $Id: WebServiceDeployer.java 312 2006-05-11 10:49:22Z thomas.diesler at jboss.com $
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.NotImplementedException;
+import org.jboss.ws.deployment.ServiceEndpointPublisher;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.tools.wspublish;
+
+/**
+ * Publish the HTTP service endpoint to Tomcat
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class TomcatServiceEndpointPublisher extends ServiceEndpointPublisher
+{
+ // logging support
+ private static Logger log = Logger.getLogger(TomcatServiceEndpointPublisher.class);
+
+ private boolean isRunning;
+ private File targetDir;
+ private File deployDir;
+ private long interval;
+
+ private Set<File> deployedFiles = new HashSet<File>();
+
+ public void setDeployDir(String dirName)
+ {
+ this.deployDir = new File(dirName);
+ if (deployDir.exists() == false)
+ {
+ System.out.println("create directory: " + deployDir);
+ deployDir.mkdirs();
+ }
+ }
+
+ public void setTargetDir(String dirName)
+ {
+ this.targetDir = new File(dirName);
+ if (targetDir.isDirectory() == false)
+ throw new IllegalArgumentException ("Target dir does not exist: " + targetDir);
+ }
+
+ public void setInterval(long interval)
+ {
+ this.interval = interval;
+ }
+
+ public String publishServiceEndpoint(URL warURL) throws Exception
+ {
+ new wspublish().process(warURL, targetDir, servletName);
+ return "OK";
+ }
+
+ public String destroyServiceEndpoint(URL warURL) throws Exception
+ {
+ File targetFile = new File(targetDir.getAbsolutePath() + "/" + new File(warURL.getFile()).getName());
+ if (targetFile.delete())
+ return "OK";
+ else
+ return "NOT FOUND";
+ }
+
+ public String publishServiceEndpoint(UnifiedDeploymentInfo udi) throws Exception
+ {
+ throw new NotImplementedException();
+ }
+
+ public String destroyServiceEndpoint(UnifiedDeploymentInfo udi) throws Exception
+ {
+ throw new NotImplementedException();
+ }
+
+ private void scanDeployDir()
+ {
+ List<File> fileList = Arrays.asList(deployDir.listFiles());
+
+ // deploy new files
+ for (File file : fileList)
+ {
+ if (deployedFiles.contains(file) == false)
+ {
+ deployFile(file);
+ deployedFiles.add(file);
+ }
+ }
+
+ // undeploy files
+ for (File file : deployedFiles)
+ {
+ if (fileList.contains(file) == false)
+ {
+ undeployFile(file);
+ deployedFiles.remove(file);
+ }
+ }
+ }
+
+ private void deployFile(File file)
+ {
+ try
+ {
+ if (new File(targetDir.getAbsolutePath() + "/" + file.getName()).exists() == false)
+ {
+ System.out.println("Deploy file: " + file);
+ publishServiceEndpoint(file.toURL());
+ }
+ else
+ {
+ System.out.println("Ignore file: " + file);
+ }
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot deploy file: " + file, ex);
+ }
+ }
+
+ private void undeployFile(File file)
+ {
+ try
+ {
+ if (new File(targetDir.getAbsolutePath() + "/" + file.getName()).exists())
+ {
+ System.out.println("Undeploy file: " + file);
+ destroyServiceEndpoint(file.toURL());
+ }
+ else
+ {
+ System.out.println("Ignore file: " + file);
+ }
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot undeploy file: " + file, ex);
+ }
+ }
+
+ // bean lifecycle start
+ public void start()
+ {
+ System.out.println("Start scanning: " + deployDir);
+ Scanner s = new Scanner();
+ new Thread(s).start();
+ }
+
+ // bean lifecycle stop
+ public void stop()
+ {
+ System.out.println("Stop scanning: " + deployDir);
+ isRunning = false;
+ }
+
+ class Scanner implements Runnable
+ {
+ public void run()
+ {
+ isRunning = true;
+ try
+ {
+ while (isRunning)
+ {
+ scanDeployDir();
+ Thread.sleep(Math.max(100, interval));
+ }
+ }
+ catch (InterruptedException ex)
+ {
+ // ignore
+ }
+ }
+ }
+}
Copied: trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatServiceEndpointServlet.java (from rev 589, trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointServlet.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/tomcat/GenericServiceEndpointServlet.java 2006-07-11 17:42:41 UTC (rev 589)
+++ trunk/src/main/java/org/jboss/ws/integration/tomcat/TomcatServiceEndpointServlet.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.integration.tomcat;
+
+// $Id: ServiceEndpointServlet.java 296 2006-05-08 19:45:49Z thomas.diesler at jboss.com $
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.ws.deployment.JSR109Deployment;
+import org.jboss.ws.deployment.JSR181Deployment;
+import org.jboss.ws.deployment.ServiceEndpointDeployer;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.server.KernelLocator;
+import org.jboss.ws.server.StandardEndpointServlet;
+
+/**
+ * A servlet that is installed for every web service endpoint.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 16-May-2006
+ */
+public class TomcatServiceEndpointServlet extends StandardEndpointServlet
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(TomcatServiceEndpointServlet.class);
+
+ public void init(ServletConfig config) throws ServletException
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ CrossContextLoader jbwsLoader = CrossContextLoader.newInstance(config.getServletContext());
+ Thread.currentThread().setContextClassLoader(jbwsLoader);
+
+ super.init(config);
+ deployServiceEndpoints(getServletContext());
+ }
+ catch (Exception e)
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+
+ public void destroy()
+ {
+ undeployServiceEndpoints(getServletContext());
+ super.destroy();
+ }
+
+ public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ if ((ctxLoader instanceof CrossContextLoader) == false)
+ {
+ CrossContextLoader jbwsLoader = CrossContextLoader.newInstance(getServletContext());
+ Thread.currentThread().setContextClassLoader(jbwsLoader);
+ }
+ super.service(req, res);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+
+ /**
+ * Bootstrap the Microkernel and initialize the
+ * ServiceEndpointManager
+ */
+ protected void initServiceEndpointManager()
+ {
+ // bootstrap the microkernel
+ URLClassLoader ctxLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
+ URL beansXML = ctxLoader.findResource("META-INF/jboss-beans.xml");
+ if (beansXML == null)
+ throw new IllegalStateException("Invalid null kernel deployment");
+
+ try
+ {
+ new KernelBootstrap().bootstrap(beansXML);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new WSException("Cannot bootstrap kernel", ex);
+ }
+
+ // init the service endpoint manager
+ super.initServiceEndpointManager();
+ }
+
+ private void deployServiceEndpoints(ServletContext servletContext)
+ {
+ UnifiedDeploymentInfo udi = (UnifiedDeploymentInfo)servletContext.getAttribute(UnifiedDeploymentInfo.class.getName());
+ if (udi == null)
+ {
+ ServiceEndpointDeployer deployer = getServiceEndpointDeployer();
+ try
+ {
+ udi = createDeploymentInfo(servletContext);
+ servletContext.setAttribute(UnifiedDeploymentInfo.class.getName(), udi);
+
+ deployer.create(udi);
+ deployer.start(udi);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Throwable th)
+ {
+ throw new WSException("Cannot deploy service endpoint", th);
+ }
+ }
+ }
+
+ private UnifiedDeploymentInfo createDeploymentInfo(ServletContext servletContext) throws Exception
+ {
+ UnifiedDeploymentInfo udi;
+
+ URLClassLoader ctxLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
+ URL webservices109URL = ctxLoader.findResource("WEB-INF/webservices.xml");
+ if (webservices109URL != null)
+ {
+ udi = new JSR109Deployment(UnifiedDeploymentInfo.DeploymentType.JSR109_JSE, webservices109URL);
+ }
+ else
+ {
+ udi = new JSR181Deployment(UnifiedDeploymentInfo.DeploymentType.JSR181_JSE);
+ }
+
+ DeploymentInfoAdaptor.buildDeploymentInfo(udi, ctxLoader, servletContext);
+ return udi;
+ }
+
+ private void undeployServiceEndpoints(ServletContext servletContext)
+ {
+ UnifiedDeploymentInfo udi = (UnifiedDeploymentInfo)servletContext.getAttribute(UnifiedDeploymentInfo.class.getName());
+ if (udi != null)
+ {
+ ServiceEndpointDeployer deployer = getServiceEndpointDeployer();
+ try
+ {
+ deployer.stop(udi);
+ deployer.destroy(udi);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Throwable th)
+ {
+ throw new WSException("Cannot deploy service endpoint", th);
+ }
+ }
+ }
+
+ private ServiceEndpointDeployer getServiceEndpointDeployer()
+ {
+ KernelRegistry registry = KernelLocator.getKernel().getRegistry();
+ KernelRegistryEntry entry = registry.getEntry(ServiceEndpointDeployer.BEAN_NAME);
+ return (ServiceEndpointDeployer)entry.getTarget();
+ }
+}
Modified: trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -23,16 +23,22 @@
// $Id$
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import java.util.concurrent.Executor;
import javax.xml.transform.Source;
import javax.xml.ws.Binding;
import javax.xml.ws.Endpoint;
+import org.jboss.logging.Logger;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.jaxws.client.BindingImpl;
+import org.jboss.ws.server.HttpContext;
import org.jboss.ws.server.HttpServer;
/**
@@ -43,10 +49,13 @@
*/
public class EndpointImpl extends Endpoint
{
+ // provide logging
+ private final Logger log = Logger.getLogger(EndpointImpl.class);
+
private Object implementor;
private Binding binding = new BindingImpl();
- private Map<String, Object> properties;
- private HttpServer httpServer;
+ private Map<String, Object> properties = new HashMap<String, Object>();
+ private HttpContext serverContext;
private boolean isPublished;
private boolean isDestroyed;
@@ -77,14 +86,26 @@
@Override
public void publish(String address)
{
- if (isDestroyed)
- throw new IllegalStateException("Endpoint already destroyed");
-
- httpServer = HttpServer.create();
+ URI addrURI;
+ try
+ {
+ addrURI = new URI (address);
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IllegalArgumentException("Invalid address: " + address);
+ }
+
+ // Create and start the HTTP server
+ HttpServer httpServer = HttpServer.create();
httpServer.setProperties(properties);
httpServer.start();
- httpServer.publish(this);
- isPublished = true;
+
+ String path = addrURI.getPath();
+ String contextRoot = "/" + new StringTokenizer(path, "/").nextToken();
+ HttpContext context = httpServer.createContext(contextRoot);
+
+ publish(context);
}
/**
@@ -95,15 +116,16 @@
* @param serverContext An object representing a server context to be used for publishing the endpoint.
*/
@Override
- public void publish(Object serverContext)
+ public void publish(Object context)
{
if (isDestroyed)
throw new IllegalStateException("Endpoint already destroyed");
- if (serverContext instanceof HttpServer)
+ if (context instanceof HttpContext)
{
- httpServer = (HttpServer)serverContext;
- httpServer.publish(this);
+ serverContext = (HttpContext)context;
+ HttpServer httpServer = serverContext.getHttpServer();
+ httpServer.publish(serverContext, this);
isPublished = true;
}
}
@@ -111,10 +133,22 @@
@Override
public void stop()
{
- if (httpServer == null || isPublished == false)
- throw new IllegalStateException("Endpoint not published");
+ if (serverContext == null || isPublished == false)
+ log.error("Endpoint not published");
- httpServer.destroy(this);
+ try
+ {
+ if (serverContext != null)
+ {
+ HttpServer httpServer = serverContext.getHttpServer();
+ httpServer.destroy(serverContext, this);
+ }
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot stop endpoint", ex);
+ }
+
isPublished = false;
isDestroyed = true;
}
Modified: trunk/src/main/java/org/jboss/ws/jaxws/spi/ProviderImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/spi/ProviderImpl.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/jaxws/spi/ProviderImpl.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -30,6 +30,8 @@
import javax.xml.ws.spi.Provider;
import javax.xml.ws.spi.ServiceDelegate;
+import org.jboss.ws.annotation.PortComponent;
+import org.jboss.ws.server.HttpContext;
import org.jboss.ws.server.HttpServer;
/**
@@ -58,8 +60,18 @@
public Endpoint createAndPublishEndpoint(String bindingId, Object implementor)
{
EndpointImpl endpoint = new EndpointImpl(bindingId, implementor);
+
HttpServer server = HttpServer.create();
- server.publish(endpoint);
+ server.start();
+
+ String contextRoot = "/jaxws-default-context";
+ PortComponent anPortComponent = implementor.getClass().getAnnotation(PortComponent.class);
+ if (anPortComponent != null && anPortComponent.contextRoot().length() > 0)
+ contextRoot = anPortComponent.contextRoot();
+
+ HttpContext context = server.createContext(contextRoot);
+ endpoint.publish(context);
+
return endpoint;
}
}
\ No newline at end of file
Added: trunk/src/main/java/org/jboss/ws/server/HttpContext.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/HttpContext.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/server/HttpContext.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.server;
+
+// $Id$
+
+/**
+ * An abstract HTTP Context
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 07-Jul-2006
+ */
+public class HttpContext
+{
+ private HttpServer server;
+ private String contextRoot;
+
+ public HttpContext(HttpServer server, String contextRoot)
+ {
+ this.server = server;
+ this.contextRoot = contextRoot;
+ }
+
+ public HttpServer getHttpServer()
+ {
+ return server;
+ }
+
+ public String getContextRoot()
+ {
+ return contextRoot;
+ }
+}
Property changes on: trunk/src/main/java/org/jboss/ws/server/HttpContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/src/main/java/org/jboss/ws/server/HttpServer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/HttpServer.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/server/HttpServer.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -24,12 +24,11 @@
// $Id$
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import javax.xml.ws.Endpoint;
-import org.jboss.ws.integration.tomcat.TomcatHttpServer;
+import org.jboss.ws.integration.jboss.JBossHttpServer;
import org.jboss.ws.jaxws.util.FactoryFinder;
/**
@@ -41,7 +40,7 @@
public abstract class HttpServer
{
public static String HTTP_SERVER_PROPERTY = HttpServer.class.getName();
- public static String DEFAULT_HTTP_SERVER_PROPERTY = TomcatHttpServer.class.getName();
+ public static String DEFAULT_HTTP_SERVER_PROPERTY = JBossHttpServer.class.getName();
private Map<String, Object> properties = new HashMap<String, Object>();
@@ -63,11 +62,14 @@
/** Start an instance of this HTTP server */
public abstract void start();
+ /** Create an HTTP context */
+ public abstract HttpContext createContext(String string);
+
/** Publish an JAXWS endpoint to the HTTP server */
- public abstract void publish(Endpoint endpoint);
+ public abstract void publish(HttpContext context, Endpoint endpoint);
- /** Removes an JAXWS endpoint from the HTTP server */
- public abstract void destroy(Endpoint endpoint);
+ /** Destroys an JAXWS endpoint on the HTTP server */
+ public abstract void destroy(HttpContext context, Endpoint endpoint);
public Map<String, Object> getProperties()
{
@@ -88,4 +90,5 @@
{
return properties.get(key);
}
+
}
Modified: trunk/src/main/java/org/jboss/ws/tools/wspublish.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/wspublish.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/main/java/org/jboss/ws/tools/wspublish.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -33,8 +33,8 @@
import org.jboss.logging.Logger;
import org.jboss.util.file.JarUtils;
import org.jboss.ws.deployment.ServiceEndpointPublisher;
-import org.jboss.ws.integration.tomcat.GenericServiceEndpointPublisher;
-import org.jboss.ws.integration.tomcat.GenericServiceEndpointServlet;
+import org.jboss.ws.integration.tomcat.TomcatServiceEndpointPublisher;
+import org.jboss.ws.integration.tomcat.TomcatServiceEndpointServlet;
/**
* Publish a standard portable J2EE web service endpoint
@@ -48,7 +48,7 @@
// provide logging
protected final Logger log = Logger.getLogger(wspublish.class);
- public static final String DEFAULT_TOMCAT_SERVICE_ENDPOINT_SERVLET = GenericServiceEndpointServlet.class.getName();
+ public static final String DEFAULT_TOMCAT_SERVICE_ENDPOINT_SERVLET = TomcatServiceEndpointServlet.class.getName();
public URL process(URL warURL, File destDir, String servletName) throws IOException
{
@@ -70,7 +70,7 @@
JarUtils.unjar(in, tmpDir);
in.close();
- ServiceEndpointPublisher publisher = new GenericServiceEndpointPublisher();
+ ServiceEndpointPublisher publisher = new TomcatServiceEndpointPublisher();
publisher.setServiceEndpointServlet(servletName);
publisher.rewriteWebXML(tmpDir.toURL());
Modified: trunk/src/test/ant/build-jars.xml
===================================================================
--- trunk/src/test/ant/build-jars.xml 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/ant/build-jars.xml 2006-07-13 10:03:14 UTC (rev 596)
@@ -309,6 +309,18 @@
</metainf>
</jar>
+ <!-- jbossws-jaxws-endpoint -->
+ <war warfile="${build.test.dir}/libs/jbossws-jaxws-endpoint.war" webxml="${build.test.dir}/resources/jaxws/endpoint/WEB-INF/web.xml">
+ <classes dir="${build.test.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/endpoint/EndpointServlet.class"/>
+ <include name="org/jboss/test/ws/jaxws/endpoint/EndpointBean.class"/>
+ <include name="org/jboss/test/ws/jaxws/endpoint/EndpointInterface.class"/>
+ </classes>
+ <webinf dir="${build.test.dir}/resources/jaxws/endpoint/WEB-INF">
+ <include name="wsdl/**"/>
+ </webinf>
+ </war>
+
<!-- jbossws-jaxws-provider-jaxb -->
<war warfile="${build.test.dir}/libs/jbossws-jaxws-provider-jaxb.war" webxml="${build.test.dir}/resources/jaxws/provider/jaxb/WEB-INF/web.xml">
<classes dir="${build.test.dir}/classes">
Modified: trunk/src/test/build.xml
===================================================================
--- trunk/src/test/build.xml 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/build.xml 2006-07-13 10:03:14 UTC (rev 596)
@@ -119,8 +119,6 @@
<!-- The jbossws client classpath -->
<path id="jbossws.client.classpath">
- <!-- override jbossxb in jbossall-client.jar -->
- <pathelement location="${thirdparty.dir}/jboss-xml-binding.jar"/>
<pathelement location="${jboss.client}/activation.jar"/>
<pathelement location="${jboss.client}/commons-logging.jar"/>
<pathelement location="${jboss.client}/javassist.jar"/>
@@ -128,6 +126,7 @@
<pathelement location="${jboss.client}/jbossall-client.jar"/>
<pathelement location="${jboss.client}/jbossretro-rt.jar"/>
<pathelement location="${jboss.client}/jboss-backport-concurrent.jar"/>
+ <pathelement location="${jboss.client}/jboss-xml-binding.jar"/>
<pathelement location="${jboss.client}/${jbossws.client.jar}"/>
<pathelement location="${jboss.client}/log4j.jar"/>
<pathelement location="${jboss.client}/mail.jar"/>
@@ -147,8 +146,6 @@
<!-- The test client classpath -->
<path id="test.client.classpath">
- <pathelement location="${thirdparty.dir}/jaxb-api.jar"/>
- <pathelement location="${thirdparty.dir}/jaxb-impl.jar"/>
<path refid="library.classpath"/>
<path refid="jbossws.client.classpath"/>
<pathelement location="${build.lib.dir}/jbossws-jboss-integration.jar"/>
Modified: trunk/src/test/java/org/jboss/test/ws/JBossTestDeployer.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/JBossTestDeployer.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/JBossTestDeployer.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -27,13 +27,7 @@
import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.spi.Provider;
-import org.jboss.util.NotImplementedException;
-import org.jboss.ws.integration.jboss.JBossHttpServer;
-import org.jboss.ws.server.HttpServer;
-
/**
* A JBossWS test helper that deals with test deployment/undeployment, etc.
*
@@ -62,20 +56,4 @@
MBeanServerConnection server = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
return server;
}
-
- public Endpoint deployEndpoint(Class endpointImpl) throws Exception
- {
- Provider provider = Provider.provider();
-
- Endpoint endpoint = provider.createEndpoint(null, endpointImpl);
- HttpServer httpServer = new JBossHttpServer();
- httpServer.start();
- httpServer.publish(endpoint);
- return endpoint;
- }
-
- public void undeployEndpoint(Endpoint endpoint) throws Exception
- {
- endpoint.stop();
- }
}
Modified: trunk/src/test/java/org/jboss/test/ws/JBossWSTest.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/JBossWSTest.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/JBossWSTest.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.ws;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
@@ -34,10 +33,8 @@
import junit.framework.TestCase;
-import org.apache.xerces.xs.XSModel;
import org.jboss.logging.Logger;
import org.jboss.util.xml.DOMWriter;
-import org.jboss.ws.tools.JavaToXSD;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -72,7 +69,7 @@
{
return delegate.isTargetServerTomcat();
}
-
+
/** Deploy the given archive
*/
public void deploy(String archive) throws Exception
@@ -115,9 +112,9 @@
catch (ClassNotFoundException ex)
{
return false;
- }
+ }
}
-
+
/**
* Get the JBoss server host from system property "jbosstest.server.host"
* This defaults to "" + getServerHost() + ""
Modified: trunk/src/test/java/org/jboss/test/ws/JBossWSTestDeployer.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/JBossWSTestDeployer.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/JBossWSTestDeployer.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -23,8 +23,6 @@
import java.net.URL;
-import javax.xml.ws.Endpoint;
-
/**
* WS test deployer
*
@@ -40,12 +38,4 @@
/** Undeploy the given archive
*/
void undeploy(URL archive) throws Exception;
-
- /** Deploy the given endpoint
- */
- Endpoint deployEndpoint(Class endpointImpl) throws Exception;
-
- /** Undeploy the given endpoint
- */
- void undeployEndpoint(Endpoint endpoint) throws Exception;
}
\ No newline at end of file
Modified: trunk/src/test/java/org/jboss/test/ws/JBossWSTestHelper.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/JBossWSTestHelper.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/JBossWSTestHelper.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -24,10 +24,13 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import javax.management.MBeanServerConnection;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.xml.ws.Endpoint;
/**
* A JBossWS test helper that deals with test deployment/undeployment, etc.
Modified: trunk/src/test/java/org/jboss/test/ws/JBossWSTestSetup.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/JBossWSTestSetup.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/JBossWSTestSetup.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -21,11 +21,11 @@
*/
package org.jboss.test.ws;
+import java.util.StringTokenizer;
+
import junit.extensions.TestSetup;
import junit.framework.TestSuite;
-import java.util.StringTokenizer;
-
/**
* A test setup that deploys/undeploys archives
*
Modified: trunk/src/test/java/org/jboss/test/ws/TomcatTestDeployer.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/TomcatTestDeployer.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/TomcatTestDeployer.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -32,12 +32,7 @@
import java.util.HashMap;
import java.util.Map;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.spi.Provider;
-
import org.jboss.util.Base64;
-import org.jboss.ws.integration.tomcat.TomcatHttpServer;
-import org.jboss.ws.server.HttpServer;
import org.jboss.ws.tools.wspublish;
/**
@@ -110,22 +105,6 @@
}
}
-
- public Endpoint deployEndpoint(Class endpointImpl) throws Exception
- {
- Provider provider = Provider.provider();
- Endpoint endpoint = provider.createEndpoint(null, endpointImpl);
- HttpServer httpServer = new TomcatHttpServer();
- httpServer.start();
- httpServer.publish(endpoint);
- return endpoint;
- }
-
- public void undeployEndpoint(Endpoint endpoint) throws Exception
- {
- endpoint.stop();
- }
-
private String getManagerPath() throws MalformedURLException
{
String hostName = System.getProperty("jbosstest.server.host", "localhost");
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.endpoint;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * Test Endpoint deployment
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Apr-2005
+ */
+ at WebService(name = "EndpointInterface", targetNamespace = "http://org.jboss.ws/jaxws/endpoint", serviceName = "TestService")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public class EndpointBean
+{
+ @WebMethod
+ public String echo(String input)
+ {
+ return input;
+ }
+}
Property changes on: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.endpoint;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Test the JSR-181 annotation: javax.jws.WebService
+ * This interface is only used in the client deployment.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Apr-2005
+ */
+public interface EndpointInterface extends Remote
+{
+ String echo(String input) throws RemoteException;
+}
Property changes on: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.endpoint;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.jboss.ws.server.HttpContext;
+import org.jboss.ws.server.HttpServer;
+
+/**
+ * Test Endpoint deployment
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-Jul-2006
+ */
+public class EndpointServlet extends HttpServlet
+{
+ private Endpoint endpoint;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+
+ // Create the endpoint
+ EndpointBean epImpl = new EndpointBean();
+ endpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, epImpl);
+
+ // Create and start the HTTP server
+ HttpServer server = HttpServer.create();
+ server.start();
+
+ // Create the context and publish the endpoint
+ HttpContext context = server.createContext("/jaxws-endpoint");
+ endpoint.publish(context);
+ }
+
+ @Override
+ public void destroy()
+ {
+ // Stop the endpoint
+ endpoint.stop();
+
+ super.destroy();
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ // Create the port
+ URL wsdlURL = getServletContext().getResource("/WEB-INF/wsdl/TestService.wsdl");
+ QName qname = new QName("http://org.jboss.ws/jaxws/endpoint", "TestService");
+ Service service = Service.create(wsdlURL, qname);
+ EndpointInterface port = (EndpointInterface)service.getPort(EndpointInterface.class);
+
+ // Invoke the endpoint
+ String param = req.getParameter("param");
+ String retStr = port.echo(param);
+
+ // Return the result
+ PrintWriter pw = new PrintWriter(res.getWriter());
+ pw.print(retStr);
+ }
+}
Property changes on: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.endpoint;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.test.ws.JBossWSTest;
+import org.jboss.test.ws.JBossWSTestSetup;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory;
+
+/**
+ * Test JAXWS Endpoint deployment
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Apr-2005
+ */
+public class EndpointTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return JBossWSTestSetup.newTestSetup(EndpointTestCase.class, "jbossws-jaxws-endpoint.war");
+ }
+
+ public void testWSDLAccess() throws MalformedURLException
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-endpoint?wsdl");
+ WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
+ WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
+ assertNotNull(wsdlDefinitions);
+ }
+
+ public void testClientAccess() throws Exception
+ {
+ // Create the port
+ URL wsdlURL = new File("resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl").toURL();
+ QName qname = new QName("http://org.jboss.ws/jaxws/endpoint", "TestService");
+ Service service = Service.create(wsdlURL, qname);
+ EndpointInterface port = (EndpointInterface)service.getPort(EndpointInterface.class);
+
+ String helloWorld = "Hello world!";
+ Object retObj = port.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+
+ public void testServletAccess() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() + ":8080/jbossws-jaxws-endpoint?param=hello-world");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("hello-world", br.readLine());
+
+ }
+}
Property changes on: trunk/src/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/test/resources/jaxws/endpoint/WEB-INF/web.xml
===================================================================
--- trunk/src/test/resources/jaxws/endpoint/WEB-INF/web.xml 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/resources/jaxws/endpoint/WEB-INF/web.xml 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.endpoint.EndpointServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
Property changes on: trunk/src/test/resources/jaxws/endpoint/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl
===================================================================
--- trunk/src/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl 2006-07-13 09:56:30 UTC (rev 595)
+++ trunk/src/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl 2006-07-13 10:03:14 UTC (rev 596)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<definitions name="TestService" targetNamespace="http://org.jboss.ws/jaxws/endpoint" xmlns:tns="http://org.jboss.ws/jaxws/endpoint"
+ xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types/>
+ <message name="EndpointInterface_echo">
+ <part name="String_1" type="xsd:string"/>
+ </message>
+ <message name="EndpointInterface_echoResponse">
+ <part name="result" type="xsd:string"/>
+ </message>
+ <portType name="EndpointInterface">
+ <operation name="echo" parameterOrder="String_1">
+ <input message="tns:EndpointInterface_echo"/>
+ <output message="tns:EndpointInterface_echoResponse"/>
+ </operation>
+ </portType>
+ <binding name="EndpointInterfaceBinding" type="tns:EndpointInterface">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="echo">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://org.jboss.ws/jaxws/endpoint"/>
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://org.jboss.ws/jaxws/endpoint"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="TestService">
+ <port name="EndpointInterfacePort" binding="tns:EndpointInterfaceBinding">
+ <soap:address location="http://@jbosstest.host.name@:8080/jaxws-endpoint"/>
+ </port>
+ </service>
+</definitions>
Property changes on: trunk/src/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-svn-commits
mailing list