tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1185391 - in /openejb/trunk/openejb: ./ assembly/tomee/tomee-webapp/src/main/assembly/ assembly/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/ container/openejb-core/src/main/java/org/apache/openejb/config/ server/open...
Date Mon, 17 Oct 2011 21:50:34 GMT
Author: rmannibucau
Date: Mon Oct 17 21:50:33 2011
New Revision: 1185391

URL: http://svn.apache.org/viewvc?rev=1185391&view=rev
Log:
fixing rest service undeployment + adding custom RuntimeDelegate to override cxf one

Added:
    openejb/trunk/openejb/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBRuntimeDelegateImpl.java
    openejb/trunk/openejb/server/openejb-cxf-rs/src/main/resources/META-INF/services/
    openejb/trunk/openejb/server/openejb-cxf-rs/src/main/resources/META-INF/services/javax.ws.rs.ext.RuntimeDelegate
Modified:
    openejb/trunk/openejb/assembly/tomee/tomee-webapp/src/main/assembly/war.xml
    openejb/trunk/openejb/assembly/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
    openejb/trunk/openejb/pom.xml
    openejb/trunk/openejb/server/openejb-cxf-rs/pom.xml
    openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
    openejb/trunk/openejb/server/openejb-cxf-transport/pom.xml
    openejb/trunk/openejb/server/openejb-cxf/pom.xml
    openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
    openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
    openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
    openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java

Modified: openejb/trunk/openejb/assembly/tomee/tomee-webapp/src/main/assembly/war.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/assembly/tomee/tomee-webapp/src/main/assembly/war.xml?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/assembly/tomee/tomee-webapp/src/main/assembly/war.xml (original)
+++ openejb/trunk/openejb/assembly/tomee/tomee-webapp/src/main/assembly/war.xml Mon Oct 17
21:50:33 2011
@@ -84,6 +84,7 @@
         <!--<exclude>org.apache.openejb:openejb-rest</exclude>-->
         <!--<exclude>org.apache.openejb:openejb-cxf-transport</exclude>-->
         <!--<exclude>org.apache.cxf:cxf-bundle</exclude>-->
+        <!--<exclude>org.apache.openejb.patch:openejb-cxf-bundle</exclude>-->
         <!--<exclude>org.apache.ws.xmlschema:xmlschema-core</exclude>-->
         <!--<exclude>org.apache.openejb:openejb-cxf</exclude>-->
         <!--<exclude>org.apache.ws.security:wss4j</exclude>-->

Modified: openejb/trunk/openejb/assembly/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/assembly/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/assembly/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
(original)
+++ openejb/trunk/openejb/assembly/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatRsRegistry.java
Mon Oct 17 21:50:33 2011
@@ -28,6 +28,7 @@ import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.core.StandardServer;
 import org.apache.openejb.server.httpd.HttpListener;
+import org.apache.openejb.server.httpd.util.HttpUtil;
 import org.apache.openejb.server.rest.RsRegistry;
 import org.apache.openejb.server.rest.RsServlet;
 import org.apache.tomee.loader.TomcatHelper;
@@ -63,7 +64,7 @@ public class TomcatRsRegistry implements
     }
 
     @Override
-    public List<String> createRsHttpListener(HttpListener listener, ClassLoader classLoader,
String completePath, String virtualHost) {
+    public String createRsHttpListener(HttpListener listener, ClassLoader classLoader, String
completePath, String virtualHost) {
         String path = completePath;
         if (path == null) {
             throw new NullPointerException("contextRoot is null");
@@ -115,9 +116,6 @@ public class TomcatRsRegistry implements
         wrapper.addInitParameter(HttpListener.class.getName(), listenerId);
         context.getServletContext().setAttribute(listenerId, listener);
 
-        contexts.put(path, context);
-        listeners.put(path, listener);
-
         // register wsdl locations for service-ref resolution
         List<String> addresses = new ArrayList<String>();
         for (Connector connector : connectors) {
@@ -130,7 +128,12 @@ public class TomcatRsRegistry implements
             }
             addresses.add(address.toString());
         }
-        return addresses;
+
+        path = HttpUtil.selectSingleAddress(addresses);
+        contexts.put(path, context);
+        listeners.put(path, listener);
+
+        return path;
     }
 
     @Override
@@ -141,9 +144,11 @@ public class TomcatRsRegistry implements
         }
 
         // assure context root with a leading slash
-        if (!path.startsWith("/")) path = "/" + path;
+        if (!path.startsWith("/") && !path.startsWith("http://") && !path.startsWith("https://"))
{
+            path = "/" + path;
+        }
 
-        if (TomcatHelper.isTomcat7() && TomcatHelper.isStopping()) {
+        if (TomcatHelper.isTomcat7() && TomcatHelper.isStopping() && listeners.containsKey(path))
{
             return listeners.get(path);
         }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
Mon Oct 17 21:50:33 2011
@@ -325,6 +325,7 @@ public class DeploymentsResolver impleme
         urlSet = urlSet.exclude(".*/com\\.ibm\\.ws\\.[^/]*.jar(!/)?");
         urlSet = urlSet.exclude(".*/commons-(logging|logging-api|cli|pool|lang|collections|dbcp|dbcp-all)(-[\\d.r-]+)?.jar(!/)?");
         urlSet = urlSet.exclude(".*/cxf-bundle(-[\\d.]+)?(incubator)?.jar(!/)?");
+        urlSet = urlSet.exclude(".*/openejb-cxf-bundle(-[\\d.]+)?(incubator)?.jar(!/)?");
         urlSet = urlSet.exclude(".*/derby(-[\\d.]+)?.jar(!/)?");
         urlSet = urlSet.exclude(".*/ejb31-api-experimental(-[\\d.]+)?.jar(!/)?");
         urlSet = urlSet.exclude(".*/geronimo-(connector|transaction)(-[\\d.]+)?.jar(!/)?");

Modified: openejb/trunk/openejb/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/pom.xml?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/pom.xml (original)
+++ openejb/trunk/openejb/pom.xml Mon Oct 17 21:50:33 2011
@@ -108,7 +108,7 @@
     <tomcat.version>7.0.21</tomcat.version>
 
     <!-- used mainly by jetty modules -->
-    <cxf.version>2.4.3</cxf.version>
+    <openejb-cxf.version>2.4.3-SNAPSHOT</openejb-cxf.version>
     <jetty.version>7.4.2.v20110526</jetty.version>
 
     <!--
@@ -667,9 +667,9 @@
         </exclusions>
       </dependency>
       <dependency>
-        <groupId>org.apache.cxf</groupId>
-        <artifactId>cxf-bundle</artifactId>
-        <version>${cxf.version}</version>
+        <groupId>org.apache.openejb.patch</groupId>
+        <artifactId>openejb-cxf-bundle</artifactId>
+        <version>${openejb-cxf.version}</version>
       </dependency>
       <dependency>
         <groupId>xml-resolver</groupId>

Modified: openejb/trunk/openejb/server/openejb-cxf-rs/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-rs/pom.xml?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-cxf-rs/pom.xml (original)
+++ openejb/trunk/openejb/server/openejb-cxf-rs/pom.xml Mon Oct 17 21:50:33 2011
@@ -59,8 +59,8 @@
       <artifactId>log4j</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-bundle</artifactId>
+      <groupId>org.apache.openejb.patch</groupId>
+      <artifactId>openejb-cxf-bundle</artifactId>
       <exclusions>
         <exclusion>
           <groupId>antlr</groupId>

Added: openejb/trunk/openejb/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBRuntimeDelegateImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBRuntimeDelegateImpl.java?rev=1185391&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBRuntimeDelegateImpl.java
(added)
+++ openejb/trunk/openejb/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBRuntimeDelegateImpl.java
Mon Oct 17 21:50:33 2011
@@ -0,0 +1,74 @@
+package org.apache.openejb.server.cxf.rs;
+
+import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
+import org.apache.cxf.jaxrs.impl.UriBuilderImpl;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriBuilderException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+/**
+ * /!\ we need to load it before cxf implementation.
+ * see org.apache.geronimo.osgi.locator.ProviderLocator#locateServiceClassName(java.lang.String,
java.lang.Class<?>, java.lang.ClassLoader)
+ * which need to be overriden or we have to do something to be the first.
+ *
+ * @author rmannibucau
+ */
+public class OpenEJBRuntimeDelegateImpl extends RuntimeDelegateImpl {
+    @Override public UriBuilder createUriBuilder() {
+        return new OpenEJBUriBuilderImpl();
+    }
+
+    private static class OpenEJBUriBuilderImpl extends UriBuilderImpl {
+        private static final String[][] PREFIX = new String[][]{ { "http:/", "http://"},
{ "https:/", "https://" } };
+
+        @Override public URI build(Object... values) throws IllegalArgumentException, UriBuilderException
{
+            String uri = getFixedUri(super.build(values).toString());
+            try {
+                return new URI(uri);
+            } catch (URISyntaxException e) {
+                throw new UriBuilderException(e);
+            }
+        }
+
+        private String getFixedUri(final String s) {
+            String uri = s;
+            for (String[] prefix : PREFIX) {
+                if (uri.startsWith(prefix[0]) && !uri.startsWith(prefix[1])) {
+                    uri = uri.replaceFirst(prefix[0], prefix[1]);
+                    break;
+                }
+            }
+            return uri;
+        }
+
+        @Override public URI buildFromEncoded(Object... values) throws IllegalArgumentException,
UriBuilderException {
+            String uri = getFixedUri(super.buildFromEncoded(values).toString());
+            try {
+                return new URI(uri);
+            } catch (URISyntaxException e) {
+                throw new UriBuilderException(e);
+            }
+        }
+
+        @Override public URI buildFromEncodedMap(Map<String, ?> map) throws IllegalArgumentException,
UriBuilderException {
+            String uri = getFixedUri(super.buildFromEncodedMap(map).toString());
+            try {
+                return new URI(uri);
+            } catch (URISyntaxException e) {
+                throw new UriBuilderException(e);
+            }
+        }
+
+        @Override public URI buildFromMap(Map<String, ?> map) throws IllegalArgumentException,
UriBuilderException {
+            String uri = getFixedUri(super.buildFromMap(map).toString());
+            try {
+                return new URI(uri);
+            } catch (URISyntaxException e) {
+                throw new UriBuilderException(e);
+            }
+        }
+    }
+}

Added: openejb/trunk/openejb/server/openejb-cxf-rs/src/main/resources/META-INF/services/javax.ws.rs.ext.RuntimeDelegate
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-rs/src/main/resources/META-INF/services/javax.ws.rs.ext.RuntimeDelegate?rev=1185391&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-cxf-rs/src/main/resources/META-INF/services/javax.ws.rs.ext.RuntimeDelegate
(added)
+++ openejb/trunk/openejb/server/openejb-cxf-rs/src/main/resources/META-INF/services/javax.ws.rs.ext.RuntimeDelegate
Mon Oct 17 21:50:33 2011
@@ -0,0 +1 @@
+org.apache.openejb.server.cxf.rs.OpenEJBRuntimeDelegateImpl

Modified: openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
Mon Oct 17 21:50:33 2011
@@ -41,19 +41,19 @@ import static junit.framework.Assert.ass
  * @author Romain Manni-Bucau
  */
 public class EjbDeploymentTest {
-    private static Context context;
+    private static EJBContainer container;
     private static RESTIsCool service;
 
     @BeforeClass public static void start() throws Exception {
         Properties properties = new Properties();
         properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
-        context = EJBContainer.createEJBContainer(properties).getContext();
-        service = (RESTIsCool) context.lookup("java:/global/openejb-cxf-rs/RESTIsCool");
+        container = EJBContainer.createEJBContainer(properties);
+        service = (RESTIsCool) container.getContext().lookup("java:/global/openejb-cxf-rs/RESTIsCool");
     }
 
     @AfterClass public static void close() throws Exception {
-        if (context != null) {
-            context.close();
+        if (container != null) {
+            container.close();
         }
     }
 

Modified: openejb/trunk/openejb/server/openejb-cxf-transport/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-transport/pom.xml?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-cxf-transport/pom.xml (original)
+++ openejb/trunk/openejb/server/openejb-cxf-transport/pom.xml Mon Oct 17 21:50:33 2011
@@ -33,8 +33,8 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-bundle</artifactId>
+      <groupId>org.apache.openejb.patch</groupId>
+      <artifactId>openejb-cxf-bundle</artifactId>
       <exclusions>
         <exclusion>
           <groupId>antlr</groupId>

Modified: openejb/trunk/openejb/server/openejb-cxf/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf/pom.xml?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-cxf/pom.xml (original)
+++ openejb/trunk/openejb/server/openejb-cxf/pom.xml Mon Oct 17 21:50:33 2011
@@ -92,8 +92,8 @@
       <artifactId>log4j</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-bundle</artifactId>
+      <groupId>org.apache.openejb.patch</groupId>
+      <artifactId>openejb-cxf-bundle</artifactId>
       <exclusions>
         <exclusion>
           <groupId>antlr</groupId>

Modified: openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
(original)
+++ openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
Mon Oct 17 21:50:33 2011
@@ -80,7 +80,7 @@ public class OpenEJBHttpRegistry {
         return  addresses;
     }
 
-    private static class ClassLoaderHttpListener implements HttpListener {
+    protected static class ClassLoaderHttpListener implements HttpListener {
         private final HttpListener delegate;
         private final ClassLoader classLoader;
 
@@ -98,5 +98,9 @@ public class OpenEJBHttpRegistry {
                 Thread.currentThread().setContextClassLoader(oldCl);
             }
         }
+
+        public HttpListener getDelegate() {
+            return delegate;
+        }
     }
 }

Modified: openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
(original)
+++ openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
Mon Oct 17 21:50:33 2011
@@ -17,25 +17,6 @@
 
 package org.apache.openejb.server.rest;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.Socket;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import javax.naming.Context;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.UriBuilder;
 import org.apache.openejb.BeanContext;
 import org.apache.openejb.Injection;
 import org.apache.openejb.assembler.classic.AppInfo;
@@ -50,12 +31,32 @@ import org.apache.openejb.loader.SystemI
 import org.apache.openejb.server.SelfManaging;
 import org.apache.openejb.server.ServerService;
 import org.apache.openejb.server.ServiceException;
+import org.apache.openejb.server.httpd.HttpListener;
 import org.apache.openejb.server.httpd.HttpListenerRegistry;
-import org.apache.openejb.server.httpd.util.HttpUtil;
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 
+import javax.naming.Context;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
 /**
  * @author Romain Manni-Bucau
  */
@@ -226,8 +227,7 @@ public abstract class RESTService implem
     private void deploySingleton(String contextRoot, Object o, Application appInstance, ClassLoader
classLoader) {
         final String nopath = getAddress(contextRoot, o.getClass()) + "/.*";
         final RsHttpListener listener = createHttpListener();
-        final List<String> addresses = rsRegistry.createRsHttpListener(listener, classLoader,
nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
-        final String address = HttpUtil.selectSingleAddress(addresses);
+        final String address = rsRegistry.createRsHttpListener(listener, classLoader, nopath.substring(NOPATH_PREFIX.length()
- 1), virtualHost);
 
         services.add(address);
         listener.deploySingleton(getFullContext(address, contextRoot), o, appInstance);
@@ -236,8 +236,7 @@ public abstract class RESTService implem
     private void deployPojo(String contextRoot, Class<?> loadedClazz, Application app,
ClassLoader classLoader, Collection<Injection> injections, Context context) {
         final String nopath = getAddress(contextRoot, loadedClazz) + "/.*";
         final RsHttpListener listener = createHttpListener();
-        final List<String> addresses = rsRegistry.createRsHttpListener(listener, classLoader,
nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
-        final String address = HttpUtil.selectSingleAddress(addresses);
+        final String address = rsRegistry.createRsHttpListener(listener, classLoader, nopath.substring(NOPATH_PREFIX.length()
- 1), virtualHost);
 
         services.add(address);
         listener.deployPojo(getFullContext(address, contextRoot), loadedClazz, app, injections,
context);
@@ -246,8 +245,7 @@ public abstract class RESTService implem
     private void deployEJB(String context, BeanContext beanContext) {
         final String nopath = getAddress(context, beanContext.getBeanClass()) + "/.*";
         final RsHttpListener listener = createHttpListener();
-        final List<String> addresses = rsRegistry.createRsHttpListener(listener, beanContext.getClassLoader(),
nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
-        final String address = HttpUtil.selectSingleAddress(addresses);
+        final String address = rsRegistry.createRsHttpListener(listener, beanContext.getClassLoader(),
nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
 
         services.add(address);
         listener.deployEJB(getFullContext(address, context), beanContext);
@@ -288,7 +286,10 @@ public abstract class RESTService implem
     }
 
     private void undeployRestObject(String context) {
-        RsHttpListener.class.cast(rsRegistry.removeListener(context)).undeploy();
+        HttpListener listener = rsRegistry.removeListener(context);
+        if (listener != null) {
+            RsHttpListener.class.cast(listener).undeploy();
+        }
     }
 
     private static ClassLoader getClassLoader(ClassLoader classLoader) {
@@ -338,6 +339,10 @@ public abstract class RESTService implem
     }
 
     @Override public void stop() throws ServiceException {
+        for (String address : services) {
+            undeployRestObject(address);
+        }
+
         if (assembler != null) {
             assembler.removeDeploymentListener(this);
             for (AppInfo appInfo : new ArrayList<AppInfo>(deployedApplications)) {

Modified: openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
(original)
+++ openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistry.java
Mon Oct 17 21:50:33 2011
@@ -25,6 +25,6 @@ import java.util.List;
  * @author Romain Manni-Bucau
  */
 public interface RsRegistry {
-    List<String> createRsHttpListener(HttpListener listener, ClassLoader classLoader,
String path, String virtualHost);
+    String createRsHttpListener(HttpListener listener, ClassLoader classLoader, String path,
String virtualHost);
     HttpListener removeListener(String context);
 }

Modified: openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java?rev=1185391&r1=1185390&r2=1185391&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
(original)
+++ openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsRegistryImpl.java
Mon Oct 17 21:50:33 2011
@@ -19,19 +19,31 @@ package org.apache.openejb.server.rest;
 
 import org.apache.openejb.server.httpd.HttpListener;
 import org.apache.openejb.server.httpd.OpenEJBHttpRegistry;
+import org.apache.openejb.server.httpd.util.HttpUtil;
 
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author Romain Manni-Bucau
  */
 public class RsRegistryImpl extends OpenEJBHttpRegistry implements RsRegistry {
-    @Override public List<String> createRsHttpListener(HttpListener listener, ClassLoader
classLoader, String path, String virtualHost) {
+    private Map<String, String> addresses = new HashMap<String, String>();
+
+    @Override public String createRsHttpListener(HttpListener listener, ClassLoader classLoader,
String path, String virtualHost) {
+        String address = HttpUtil.selectSingleAddress(getResolvedAddresses(path));
         addWrappedHttpListener(listener, classLoader, path);
-        return getResolvedAddresses(path);
+        addresses.put(address, path);
+        return address;
     }
 
     @Override public HttpListener removeListener(String context) {
-        return registry.removeHttpListener(context);
+        String regex = addresses.get(context);
+        if (regex != null) {
+            HttpListener listener = registry.removeHttpListener(regex);
+            if (listener instanceof ClassLoaderHttpListener)
+            return ((ClassLoaderHttpListener) listener).getDelegate();
+        }
+        return null;
     }
 }



Mime
View raw message