cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r806234 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers: HttpServiceConfigurationTypeHandler.java JaxRSHttpServiceConfigurationTypeHandler.java
Date Thu, 20 Aug 2009 16:06:23 GMT
Author: sergeyb
Date: Thu Aug 20 16:06:23 2009
New Revision: 806234

URL: http://svn.apache.org/viewvc?rev=806234&view=rev
Log:
CXF-2288 : applying a patch on behalf of Josh Holtzman

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java?rev=806234&r1=806233&r2=806234&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
Thu Aug 20 16:06:23 2009
@@ -33,6 +33,8 @@
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerLifeCycleListener;
+import org.apache.cxf.endpoint.ServerLifeCycleManager;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
@@ -82,7 +84,7 @@
                                ServiceEndpointDescription sd, 
                                Class<?> iClass, 
                                Object serviceBean) {
-        String contextRoot = getServletContextRoot(sd, iClass);
+        final String contextRoot = getServletContextRoot(sd, iClass);
         if (contextRoot == null) {
             LOG.warning("Remote address is unavailable");
             return null;
@@ -95,7 +97,7 @@
             LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
         } catch (Exception e) {
             throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet",
e);
-        }        
+        }
         Bus bus = cxf.getBus();
         DataBinding databinding;
         String dataBindingImpl = (String) serviceReference.getProperty(Constants.WS_DATABINDING_PROP_KEY);
@@ -120,6 +122,7 @@
 
             Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
             Server server = factory.create();
+            registerStopHook(bus, httpService, server, contextRoot, Constants.WS_HTTP_SERVICE_CONTEXT);
             getDistributionProvider().addExposedService(serviceReference, registerPublication(server,
intents, address));
             addAddressProperty(sd.getProperties(), address);
             return server;
@@ -182,4 +185,26 @@
         }
         return context;
     }
+    
+    protected void registerStopHook(Bus bus, final HttpService httpService, 
+                                    Server theServer, final String contextRoot,
+                                    final String propertyName) {
+        if(bus != null) {
+            theServer.getEndpoint().put(propertyName, contextRoot);
+            ServerLifeCycleListener stopHook = new ServerLifeCycleListener() {
+                public void stopServer(Server s) {
+                    Object contextProperty = s.getEndpoint().get(propertyName);
+                    if (contextProperty != null && contextProperty.equals(contextRoot))
{
+                        httpService.unregister(contextRoot);
+                    }
+                }
+                public void startServer(Server s) {
+                }
+            };
+            ServerLifeCycleManager mgr = bus.getExtension(ServerLifeCycleManager.class);
+            if (mgr != null) {
+                mgr.registerListener(stopHook);
+            }
+        }
+    }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java?rev=806234&r1=806233&r2=806234&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
Thu Aug 20 16:06:23 2009
@@ -72,13 +72,14 @@
             throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet",
e);
         }        
         Bus bus = cxf.getBus();
+        
         JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
         factory.setBus(bus);
         
         List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
         if (resources != null) {
-        	factory.setModelBeansWithServiceClass(resources, iClass);
-        	factory.setServiceBeans(serviceBean);
+            factory.setModelBeansWithServiceClass(resources, iClass);
+            factory.setServiceBeans(serviceBean);
         } else {
             factory.setServiceClass(iClass);
             factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
@@ -93,6 +94,7 @@
             String [] intents = new String[] {"HTTP"};
             Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
             Server server = factory.create();
+            registerStopHook(bus, httpService, server, contextRoot, Constants.RS_HTTP_SERVICE_CONTEXT);
             getDistributionProvider().addExposedService(serviceReference, registerPublication(server,
intents, address));
             addAddressProperty(sd.getProperties(), address);
             return server;



Mime
View raw message