cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1298565 - in /cxf/trunk: osgi/karaf/features/src/main/resources/features.xml services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
Date Thu, 08 Mar 2012 20:40:03 GMT
Author: dkulp
Date: Thu Mar  8 20:40:02 2012
New Revision: 1298565

URL: http://svn.apache.org/viewvc?rev=1298565&view=rev
Log:
Add a whiteboard feature to allow feature.xml to work with Karaf 2.2.5

Added:
    cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
  (with props)
Modified:
    cxf/trunk/osgi/karaf/features/src/main/resources/features.xml

Modified: cxf/trunk/osgi/karaf/features/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/osgi/karaf/features/src/main/resources/features.xml?rev=1298565&r1=1298564&r2=1298565&view=diff
==============================================================================
--- cxf/trunk/osgi/karaf/features/src/main/resources/features.xml (original)
+++ cxf/trunk/osgi/karaf/features/src/main/resources/features.xml Thu Mar  8 20:40:02 2012
@@ -128,7 +128,10 @@
         <feature version="${project.version}">cxf-ws-addr</feature>
         <bundle start-level='40'>mvn:org.apache.cxf/cxf-rt-ws-security/${project.version}</bundle>
     </feature>
-
+    <feature name="http-whiteboard" version="2.2.5" resolver='(obr)'>
+        <feature>http</feature>
+        <bundle start-level="30">mvn:org.ops4j.pax.web/pax-web-extender-whiteboard/1.0.8</bundle>
+    </feature>
     <feature name="cxf-http" version="${project.version}" resolver='(obr)'>
         <feature version="${project.version}">cxf-core</feature>
         <feature version="[2,3)">http-whiteboard</feature>

Added: cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java?rev=1298565&view=auto
==============================================================================
--- cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
(added)
+++ cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
Thu Mar  8 20:40:02 2012
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.wsn.services;
+
+import javax.management.MBeanServer;
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.blueprint.BlueprintBus;
+import org.apache.cxf.wsn.EndpointRegistrationException;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
+/**
+ * 
+ */
+public class OSGiJaxwsEndpointManager extends JaxwsEndpointManager {
+    
+    private BundleContext bundleContext;
+    private BlueprintContainer container;
+    private Object cxfBus;
+    private boolean hasCXF = true;
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+        this.mbeanServer = (MBeanServer)bundleContext
+            .getService(bundleContext.getServiceReference(MBeanServer.class.getName()));
+    }
+    public void setBlueprintContainer(BlueprintContainer c) {
+        this.container = c;
+    }
+
+    public Endpoint register(String address, Object service) throws EndpointRegistrationException
{
+        Object o = setCXFBus();
+        try {
+            return super.register(address, service);
+        } finally {
+            restoreCXFBus(o);
+        }
+    }
+    private void restoreCXFBus(Object o) {
+        if (hasCXF) {
+            restoreCXFBusInternal(o);
+        }
+    }
+    private Object setCXFBus() {
+        if (cxfBus == null && hasCXF) {
+            try {
+                createCXFBus();
+            } catch (Throwable t) {
+                hasCXF = false;
+            }
+        }
+        if (hasCXF) {
+            return setCXFBusInternal();
+        }
+        return null;
+    }
+    
+    public void destroy() {
+        if (cxfBus != null) {
+            destroyBus();
+        }
+    }
+    
+    
+    private void destroyBus() {
+        ((Bus)cxfBus).shutdown(true);
+        cxfBus = null;
+    }
+    private void restoreCXFBusInternal(Object o) {
+        BusFactory.setThreadDefaultBus((Bus)o);
+    }
+
+    private Object setCXFBusInternal() {
+        Object o = BusFactory.getThreadDefaultBus(false);
+        BusFactory.setThreadDefaultBus((Bus)cxfBus);
+        return o;
+    }
+    private void createCXFBus() {
+        BlueprintBus bp = new BlueprintBus();
+        bp.setBundleContext(bundleContext);
+        bp.setBlueprintContainer(container);
+        bp.setId("WS-Notification");
+        bp.initialize();
+        cxfBus = bp;
+    }
+    
+}

Propchange: cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message