Author: mageshbk(a)jboss.com
Date: 2011-03-14 07:55:46 -0400 (Mon, 14 Mar 2011)
New Revision: 13899
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/EndpointTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorld.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorldImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/TestServlet.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/endpoint/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/endpoint/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/endpoint/WEB-INF/web.xml
Modified:
stack/cxf/trunk/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3247] - Endpoint TCCL is not updated after the enclosing deployment is redeployed.
Modified:
stack/cxf/trunk/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java
===================================================================
---
stack/cxf/trunk/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java 2011-03-14
11:16:10 UTC (rev 13898)
+++
stack/cxf/trunk/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java 2011-03-14
11:55:46 UTC (rev 13899)
@@ -102,7 +102,7 @@
{
throw new Fault(e);
}
- engine.addHandler(addr, new Handler(this));
+ engine.addHandler(addr, new Handler(this,
Thread.currentThread().getContextClassLoader()));
}
/**
@@ -124,16 +124,21 @@
class Handler extends HttpHandlerImpl implements HttpHandler
{
- public Handler(JAXWSHttpSpiDestination destination)
+ private ClassLoader classLoader;
+
+ public Handler(JAXWSHttpSpiDestination destination, ClassLoader classLoader)
{
super(destination);
+ this.classLoader = classLoader;
}
@Override
public void handle(HttpExchange ex) throws IOException
{
+ ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
try
{
+ Thread.currentThread().setContextClassLoader(this.classLoader);
this.handle(new HttpExchangeDelegate(ex));
}
catch (Exception e)
@@ -148,6 +153,10 @@
throw new RuntimeException(e);
}
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(origClassLoader);
+ }
}
}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-03-14
11:16:10 UTC (rev 13898)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-03-14
11:55:46 UTC (rev 13899)
@@ -70,6 +70,15 @@
</classes>
</war>
+ <!-- jaxws-cxf-endpoint -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-cxf-endpoint.war"
+
webxml="${tests.output.dir}/test-resources/jaxws/cxf/endpoint/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/endpoint/TestServlet.class"/>
+ <include
name="org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorld*.class"/>
+ </classes>
+ </war>
+
<!-- jaxws-cxf-gzip -->
<war warfile="${tests.output.dir}/test-libs/jaxws-cxf-gzip.war"
webxml="${tests.output.dir}/test-resources/jaxws/cxf/gzip/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/EndpointTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/EndpointTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/EndpointTestCase.java 2011-03-14
11:55:46 UTC (rev 13899)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.cxf.endpoint;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * @author Magesh Kumar B <mageshbk(a)jboss.com> (C) 2011 Red Hat Inc.
+ */
+public class EndpointTestCase extends JBossWSTest
+{
+ private static String publishURL = "http://" + getServerHost() +
":18080/HelloWorldService";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(EndpointTestCase.class, "");
+ }
+
+ public void testClassLoader() throws Exception
+ {
+ deploy("jaxws-cxf-endpoint.war");
+ HelloWorld port = this.getProxy(publishURL);
+ String classLoader1 = port.getClassLoader();
+ String deploymentClassLoader1 = port.getDeploymentClassLoader();
+ undeploy("jaxws-cxf-endpoint.war");
+ assertEquals(classLoader1, deploymentClassLoader1);
+ deploy("jaxws-cxf-endpoint.war");
+ port = this.getProxy(publishURL);
+ String classLoader2 = port.getClassLoader();
+ String deploymentClassLoader2 = port.getDeploymentClassLoader();
+ undeploy("jaxws-cxf-endpoint.war");
+ assertEquals(classLoader2, deploymentClassLoader2);
+ assertFalse(classLoader1.equals(classLoader2));
+ }
+
+ private HelloWorld getProxy(String publishURL) throws Exception
+ {
+ URL wsdlURL = new URL(publishURL + "?wsdl");
+ QName qname = new QName("http://org.jboss.ws/jaxws/cxf/endpoint",
"HelloWorldService");
+ Service service = Service.create(wsdlURL, qname);
+ return (HelloWorld)service.getPort(HelloWorld.class);
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorld.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorld.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorld.java 2011-03-14
11:55:46 UTC (rev 13899)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.cxf.endpoint;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://org.jboss.ws/jaxws/cxf/endpoint")
+public interface HelloWorld
+{
+ String getClassLoader();
+
+ String getDeploymentClassLoader();
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorldImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorldImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/HelloWorldImpl.java 2011-03-14
11:55:46 UTC (rev 13899)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.cxf.endpoint;
+
+import javax.jws.WebService;
+
+
+@WebService
+(
+ serviceName = "HelloWorldService",
+ endpointInterface = "org.jboss.test.ws.jaxws.cxf.endpoint.HelloWorld",
+ targetNamespace = "http://org.jboss.ws/jaxws/cxf/endpoint"
+)
+public class HelloWorldImpl implements HelloWorld
+{
+ private ClassLoader _deploymentClassLoader;
+
+ public HelloWorldImpl(ClassLoader classloader)
+ {
+ _deploymentClassLoader = classloader;
+ }
+
+ public String getClassLoader()
+ {
+ return Thread.currentThread().getContextClassLoader().toString();
+ }
+
+ public String getDeploymentClassLoader()
+ {
+ return _deploymentClassLoader.toString();
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/TestServlet.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/TestServlet.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/endpoint/TestServlet.java 2011-03-14
11:55:46 UTC (rev 13899)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.cxf.endpoint;
+
+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.ws.Endpoint;
+
+/**
+ * @author Magesh Kumar B <mageshbk(a)jboss.com> (C) 2011 Red Hat Inc.
+ */
+public class TestServlet extends HttpServlet
+{
+ private Endpoint _endpoint;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ String serviceURL = "http://localhost:18080/HelloWorldService";
+ _endpoint = Endpoint.publish(serviceURL, new
HelloWorldImpl(Thread.currentThread().getContextClassLoader()));
+ }
+
+ @Override
+ public void destroy()
+ {
+ _endpoint.stop();
+ }
+
+}
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/endpoint/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/endpoint/WEB-INF/web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/endpoint/WEB-INF/web.xml 2011-03-14
11:55:46 UTC (rev 13899)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
+
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.cxf.endpoint.TestServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/TestServlet</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file