cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1232037 - /cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/
Date Mon, 16 Jan 2012 15:43:59 GMT
Author: cschneider
Date: Mon Jan 16 15:43:58 2012
New Revision: 1232037

URL: http://svn.apache.org/viewvc?rev=1232037&view=rev
Log:
CXF-3983 Backport to 2.5.x

Added:
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
      - copied, changed from r1231980, cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/WorkQueueSingleConfig.java
Removed:
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
Modified:
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java

Copied: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java (from r1231980, cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java?p2=cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java&p1=cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java&r1=1231980&r2=1232037&rev=1232037&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java (original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java Mon Jan 16 15:43:58 2012
@@ -19,101 +19,78 @@
 
 package org.apache.cxf.bus.osgi;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
 import java.util.List;
 import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.bus.extension.Extension;
-import org.apache.cxf.bus.extension.ExtensionFragmentParser;
-import org.apache.cxf.bus.extension.ExtensionManagerImpl;
 import org.apache.cxf.bus.extension.ExtensionRegistry;
-import org.apache.cxf.buslifecycle.BusCreationListener;
-import org.apache.cxf.buslifecycle.BusLifeCycleListener;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.configuration.ConfiguredBeanLocator;
-import org.apache.cxf.endpoint.ClientLifeCycleListener;
-import org.apache.cxf.endpoint.ClientLifeCycleManager;
-import org.apache.cxf.endpoint.ServerLifeCycleListener;
-import org.apache.cxf.endpoint.ServerLifeCycleManager;
-import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
-import org.apache.cxf.workqueue.WorkQueueManager;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
 import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.SynchronousBundleListener;
-import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ManagedService;
 import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
- * 
+ * Is called in OSGi on start and stop of the cxf bundle.
+ * Manages 
+ * - CXFBundleListener
+ * - Attaching ManagedWorkqueues tio config admin service
+ * - OsgiBusListener
  */
-public class OSGiExtensionLocator implements BundleActivator, SynchronousBundleListener {
-    private static final Logger LOG = LogUtils.getL7dLogger(OSGiExtensionLocator.class);
-    private ConcurrentMap<Long, List<Extension>> extensions 
-        = new ConcurrentHashMap<Long, List<Extension>>();
-    private long id;
-    private Extension listener;
-
+public class CXFActivator implements BundleActivator {
+    private List<Extension> extensions;
     private ManagedWorkQueueList workQueues = new ManagedWorkQueueList();
     private ServiceTracker configAdminTracker;
-    
-    /** {@inheritDoc}*/
-    public void bundleChanged(BundleEvent event) {
-        if (event.getType() == BundleEvent.RESOLVED && id != event.getBundle().getBundleId()) {
-            try {
-                register(event.getBundle());
-            } catch (Exception ex) {
-                //ignore
-            }
-        } else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
-            unregister(event.getBundle().getBundleId());
-        }
-    }
+    private CXFExtensionBundleListener cxfBundleListener;
+    private ServiceRegistration workQueueServiceRegistration;
+    private ServiceRegistration wqSingleConfigRegistratin;
 
     /** {@inheritDoc}*/
+    @SuppressWarnings("deprecation")
     public void start(BundleContext context) throws Exception {
-        context.addBundleListener(this);
-        id = context.getBundle().getBundleId();
-        registerBusListener(context);
-        for (Bundle bundle : context.getBundles()) {
-            if ((bundle.getState() == Bundle.RESOLVED 
-                || bundle.getState() == Bundle.STARTING 
-                || bundle.getState() == Bundle.ACTIVE 
-                || bundle.getState() == Bundle.STOPPING)
-                && bundle.getBundleId() != context.getBundle().getBundleId()) {
-                register(bundle);
-            }
-        }
-        
+        cxfBundleListener = new CXFExtensionBundleListener(context.getBundle().getBundleId());
+        context.addBundleListener(cxfBundleListener);
+        cxfBundleListener.registerExistingBundles(context);
+
         configAdminTracker = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null);
         configAdminTracker.open();
         workQueues.setConfigAdminTracker(configAdminTracker);
+        workQueueServiceRegistration = registerManagedServiceFactory(context, ManagedServiceFactory.class, 
+                                                                     workQueues,
+                                                                     ManagedWorkQueueList.FACTORY_PID);
+        
+        WorkQueueSingleConfig wqSingleConfig = new WorkQueueSingleConfig(workQueues);
+        wqSingleConfigRegistratin = registerManagedServiceFactory(context, ManagedService.class, 
+                                                                  wqSingleConfig,
+                                                                  WorkQueueSingleConfig.SERVICE_PID);
+        
+        extensions = new ArrayList<Extension>();
+        extensions.add(createOsgiBusListenerExtension(context));
+        extensions.add(createManagedWorkQueueListExtension(workQueues));
+        ExtensionRegistry.addExtensions(extensions);
+    }
 
+    private ServiceRegistration registerManagedServiceFactory(BundleContext context,
+                                                              Class<?> serviceClass,
+                                                              Object service, 
+                                                              String servicePid) {
         Properties props = new Properties();
-        props.put(Constants.SERVICE_PID, workQueues.getName());  
-        context.registerService(ManagedServiceFactory.class.getName(), workQueues, props);
+        props.put(Constants.SERVICE_PID, servicePid);  
+        return context.registerService(serviceClass.getName(), service, props);
+    }
+
+    private Extension createOsgiBusListenerExtension(BundleContext context) {
+        Extension busListener = new Extension(OSGIBusListener.class);
+        busListener.setArgs(new Object[] {context});
+        return busListener;
+    }
 
-        Extension ext = new Extension(ManagedWorkQueueList.class) {
+    private static Extension createManagedWorkQueueListExtension(final ManagedWorkQueueList workQueues) {
+        return new Extension(ManagedWorkQueueList.class) {
             public Object getLoadedObject() {
                 return workQueues;
             }
@@ -122,268 +99,17 @@ public class OSGiExtensionLocator implem
                 return this;
             }
         };
-        ExtensionRegistry.addExtensions(Collections.singletonList(ext));
-
     }
 
     /** {@inheritDoc}*/
     public void stop(BundleContext context) throws Exception {
-        context.removeBundleListener(this);
-        unregisterBusListener();
-        while (!extensions.isEmpty()) {
-            unregister(extensions.keySet().iterator().next());
-        }
-        for (AutomaticWorkQueueImpl wq : workQueues.queues.values()) {
-            wq.setShared(false);
-            wq.shutdown(true);
-        }
-        workQueues.queues.clear();
+        context.removeBundleListener(cxfBundleListener);
+        cxfBundleListener.shutdown();
+        workQueues.shutDown();
+        workQueueServiceRegistration.unregister();
+        wqSingleConfigRegistratin.unregister();
         configAdminTracker.close();
-    }
-    private void registerBusListener(final BundleContext context) {
-        listener = new Extension(OSGIBusListener.class);
-        listener.setArgs(new Object[] {context});
-        ExtensionRegistry.addExtensions(Collections.singletonList(listener));
-    }
-    private void unregisterBusListener() {
-        ExtensionRegistry.removeExtensions(Collections.singletonList(listener));
-        listener = null;
-    }
-    
-    protected void register(final Bundle bundle) throws IOException {
-        List<Extension> list = extensions.get(bundle.getBundleId());
-        Enumeration e = bundle.findEntries("META-INF/cxf/", "bus-extensions.txt", false);
-        if (e != null) {
-            while (e.hasMoreElements()) {
-                final URL u = (URL)e.nextElement();
-                InputStream ins = u.openStream();
-                List<Extension> orig = new ExtensionFragmentParser()
-                    .getExtensionsFromText(ins);
-                ins.close();
-                LOG.info("Loading the extension from bundle " + bundle.getBundleId());
-                if (orig != null && !orig.isEmpty()) {
-                    if (list == null) {
-                        list = new CopyOnWriteArrayList<Extension>();
-                        extensions.put(bundle.getBundleId(), list);
-                    }
-                    for (Extension ext : orig) {
-                        list.add(new OSGiExtension(ext, bundle));
-                    }
-                    ExtensionRegistry.addExtensions(list);
-                }
-            }
-        }
-    }
-    protected void unregister(final long bundleId) {
-        List<Extension> list = extensions.remove(bundleId);
-        if (list != null) {
-            LOG.info("Removed the extensions for bundle " + bundleId);
-            ExtensionRegistry.removeExtensions(list);
-        }
-    }
-    
-    public static class OSGIBusListener implements BusLifeCycleListener {
-        public static final String CONTEXT_SYMBOLIC_NAME_PROPERTY = "cxf.context.symbolicname";
-        public static final String CONTEXT_VERSION_PROPERTY = "cxf.context.version";
-        public static final String CONTEXT_NAME_PROPERTY = "cxf.bus.id";
-        
-        Bus bus;
-        ServiceRegistration service;
-        BundleContext defaultContext;
- 
-        public OSGIBusListener(Bus b) {
-            this(b, null);
-        }
-        public OSGIBusListener(Bus b, Object args[]) {
-            bus = b;
-            if (args != null && args.length > 0 
-                && args[0] instanceof BundleContext) {
-                defaultContext = (BundleContext)args[0];
-            }
-            BusLifeCycleManager manager = bus.getExtension(BusLifeCycleManager.class);
-            manager.registerLifeCycleListener(this);
-            final ConfiguredBeanLocator cbl = bus.getExtension(ConfiguredBeanLocator.class);
-            if (cbl instanceof ExtensionManagerImpl) {
-                // wire in the OSGi things
-                bus.setExtension(new OSGiBeanLocator(cbl, defaultContext), 
-                                 ConfiguredBeanLocator.class);
-            }
-            
-            try {
-                ServiceReference refs[] = defaultContext
-                    .getServiceReferences(ClientLifeCycleListener.class.getName(), null);
-                if (refs != null) {
-                    ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
-                    for (ServiceReference ref : refs) {
-                        if (allowService(ref)) {
-                            ClientLifeCycleListener listener 
-                                = (ClientLifeCycleListener)defaultContext.getService(ref);
-                            clcm.registerListener(listener);
-                        }
-                    }
-                }
-            } catch (InvalidSyntaxException e) {
-                //ignore
-            }
-            try {
-                ServiceReference refs[] = defaultContext
-                    .getServiceReferences(ServerLifeCycleListener.class.getName(), null);
-                if (refs != null) {
-                    ServerLifeCycleManager clcm = bus.getExtension(ServerLifeCycleManager.class);
-                    for (ServiceReference ref : refs) {
-                        if (allowService(ref)) {
-                            ServerLifeCycleListener listener 
-                                = (ServerLifeCycleListener)defaultContext.getService(ref);
-                            clcm.registerListener(listener);
-                        }
-                    }
-                }
-                
-            } catch (InvalidSyntaxException e) {
-                //ignore
-            }
-            try {
-                ServiceReference refs[] = defaultContext
-                    .getServiceReferences(BusCreationListener.class.getName(), null);
-                if (refs != null) {
-                    for (ServiceReference ref : refs) {
-                        if (allowService(ref)) {
-                            BusCreationListener listener 
-                                = (BusCreationListener)defaultContext.getService(ref);
-                            listener.busCreated(bus);
-                        }
-                    }
-                }
-            } catch (InvalidSyntaxException e) {
-                //ignore
-            }
-
-        }
-        
-        private boolean allowService(ServiceReference ref) {
-            Object o = ref.getProperty("org.apache.cxf.bus.private.extension");
-            Boolean pvt = Boolean.FALSE;
-            if (o == null) {
-                pvt = Boolean.FALSE;
-            } else if (o instanceof String) {
-                pvt = Boolean.parseBoolean((String)o);
-            } else if (o instanceof Boolean) {
-                pvt = (Boolean)o;
-            }
-            return !pvt.booleanValue();
-        }
-        private Version getBundleVersion(Bundle bundle) {
-            Dictionary headers = bundle.getHeaders();
-            String version = (String) headers.get(Constants.BUNDLE_VERSION);
-            return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
-        }
- 
-        public void initComplete() {
-            WorkQueueManager m = bus.getExtension(WorkQueueManager.class);
-            ManagedWorkQueueList l = bus.getExtension(ManagedWorkQueueList.class);
-            if (l != null && m != null) {
-                for (AutomaticWorkQueueImpl wq : l.queues.values()) {
-                    if (m.getNamedWorkQueue(wq.getName()) == null) {
-                        m.addNamedWorkQueue(wq.getName(), wq);
-                    }
-                }
-            }
-            
-            BundleContext context = bus.getExtension(BundleContext.class);
-            if (context != null) {
-                Properties props = new Properties();
-                props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, context.getBundle().getSymbolicName());
-                props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(context.getBundle()));
-                props.put(CONTEXT_NAME_PROPERTY, bus.getId());
-    
-                service = context.registerService(Bus.class.getName(), bus, props);
-            }
-        }
-        public void preShutdown() {
-        }
-        public void postShutdown() {
-            if (service != null) {
-                service.unregister();
-                service = null;
-            }
-        }
-    }
-    
-    public static class OSGiBeanLocator implements ConfiguredBeanLocator {
-        final ConfiguredBeanLocator cbl;
-        final BundleContext context;
-        public OSGiBeanLocator(ConfiguredBeanLocator c, BundleContext ctx) {
-            cbl = c;
-            context = ctx;
-        }
-        public <T> T getBeanOfType(String name, Class<T> type) {
-            return cbl.getBeanOfType(name, type);
-        }
-        public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
-            Collection<? extends T> ret = cbl.getBeansOfType(type);
-            
-            if (ret == null || ret.isEmpty()) {
-                List<T> list = new ArrayList<T>();
-                try {
-                    ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
-                    if (refs != null) {
-                        for (ServiceReference r : refs) {
-                            list.add(type.cast(context.getService(r)));
-                        }
-                    }
-                    if (!list.isEmpty()) {
-                        return list;
-                    }
-                } catch (Exception ex) {
-                    //ignore, just don't support the OSGi services
-                    LOG.info("Try to find the Bean with type:" + type 
-                        + " from OSGi services and get error: " + ex);  
-                }
-            }
-            return ret;
-        }
-        public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
-            return cbl.loadBeansOfType(type, listener);
-        }
-        public boolean hasConfiguredPropertyValue(String beanName, String propertyName,
-                                                  String value) {
-            return cbl.hasConfiguredPropertyValue(beanName, propertyName, value);
-        }
-        public List<String> getBeanNamesOfType(Class<?> type) {
-            return cbl.getBeanNamesOfType(type);
-        }
-    }
-    
-    public class OSGiExtension extends Extension {
-        final Bundle bundle;
-        public OSGiExtension(Extension e, Bundle b) {
-            super(e);
-            bundle = b;
-        }
-        public Class<?> getClassObject(ClassLoader cl) {
-            if (clazz == null) {
-                try {
-                    clazz = bundle.loadClass(className);
-                } catch (ClassNotFoundException e) {
-                    //ignore, fall to super
-                }
-            }
-            return super.getClassObject(cl);
-        }
-        public Class<?> loadInterface(ClassLoader cl) {
-            try {
-                return bundle.loadClass(interfaceName);
-            } catch (ClassNotFoundException e) {
-                //ignore, fall to super
-            }
-            return super.loadInterface(cl);
-        }
-        public Extension cloneNoObject() {
-            OSGiExtension ext = new OSGiExtension(this, bundle);
-            ext.obj = null;
-            return ext;
-        }
-
+        ExtensionRegistry.removeExtensions(extensions);
     }
 
 }

Added: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java?rev=1232037&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java (added)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java Mon Jan 16 15:43:58 2012
@@ -0,0 +1,149 @@
+/**
+ * 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.bus.osgi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Logger;
+
+import org.apache.cxf.bus.extension.Extension;
+import org.apache.cxf.bus.extension.ExtensionFragmentParser;
+import org.apache.cxf.bus.extension.ExtensionRegistry;
+import org.apache.cxf.common.logging.LogUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.SynchronousBundleListener;
+
+public class CXFExtensionBundleListener implements SynchronousBundleListener {
+    private static final Logger LOG = LogUtils.getL7dLogger(CXFActivator.class);
+    private long id;
+    private ConcurrentMap<Long, List<Extension>> extensions = new ConcurrentHashMap<Long, List<Extension>>();
+    
+    public CXFExtensionBundleListener(long bundleId) {
+        this.id = bundleId;
+    }
+    
+    public void registerExistingBundles(BundleContext context) throws IOException {
+        for (Bundle bundle : context.getBundles()) {
+            if ((bundle.getState() == Bundle.RESOLVED 
+                || bundle.getState() == Bundle.STARTING 
+                || bundle.getState() == Bundle.ACTIVE 
+                || bundle.getState() == Bundle.STOPPING)
+                && bundle.getBundleId() != context.getBundle().getBundleId()) {
+                register(bundle);
+            }
+        }
+    }
+
+    /** {@inheritDoc}*/
+    public void bundleChanged(BundleEvent event) {
+        if (event.getType() == BundleEvent.RESOLVED && id != event.getBundle().getBundleId()) {
+            register(event.getBundle());
+        } else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
+            unregister(event.getBundle().getBundleId());
+        }
+    }
+    
+    protected void register(final Bundle bundle) {
+        Enumeration<?> e = bundle.findEntries("META-INF/cxf/", "bus-extensions.txt", false);
+        while (e != null && e.hasMoreElements()) {
+            final URL u = (URL)e.nextElement();
+            try {
+                InputStream ins = u.openStream();
+                List<Extension> orig = new ExtensionFragmentParser().getExtensionsFromText(ins);
+                ins.close();
+                addExtensions(bundle, orig);
+            } catch (IOException ex) {
+                LOG.severe("Error installing extension " + u + " " + ex.getMessage());
+            }
+        }
+    }
+
+    private void addExtensions(final Bundle bundle, List<Extension> orig) {
+        if (orig.isEmpty()) {
+            return;
+        }
+        LOG.info("Adding the extension from bundle " + bundle.getBundleId());
+        List<Extension> list = extensions.get(bundle.getBundleId());
+        if (list == null) {
+            list = new CopyOnWriteArrayList<Extension>();
+            extensions.put(bundle.getBundleId(), list);
+        }
+        for (Extension ext : orig) {
+            list.add(new OSGiExtension(ext, bundle));
+        }
+        ExtensionRegistry.addExtensions(list);
+    }
+
+    protected void unregister(final long bundleId) {
+        List<Extension> list = extensions.remove(bundleId);
+        if (list != null) {
+            LOG.info("Removing the extensions for bundle " + bundleId);
+            ExtensionRegistry.removeExtensions(list);
+        }
+    }
+
+    public void shutdown() {
+        while (!extensions.isEmpty()) {
+            unregister(extensions.keySet().iterator().next());
+        }
+    }
+    
+    public class OSGiExtension extends Extension {
+        final Bundle bundle;
+        public OSGiExtension(Extension e, Bundle b) {
+            super(e);
+            bundle = b;
+        }
+
+        public Class<?> getClassObject(ClassLoader cl) {
+            if (clazz == null) {
+                try {
+                    clazz = bundle.loadClass(className);
+                } catch (ClassNotFoundException e) {
+                    //ignore, fall to super
+                }
+            }
+            return super.getClassObject(cl);
+        }
+
+        public Class<?> loadInterface(ClassLoader cl) {
+            try {
+                return bundle.loadClass(interfaceName);
+            } catch (ClassNotFoundException e) {
+                //ignore, fall to super
+            }
+            return super.loadInterface(cl);
+        }
+
+        public Extension cloneNoObject() {
+            OSGiExtension ext = new OSGiExtension(this, bundle);
+            ext.obj = null;
+            return ext;
+        }
+
+    }
+}

Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java?rev=1232037&r1=1232036&r2=1232037&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java (original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java Mon Jan 16 15:43:58 2012
@@ -1,106 +1,132 @@
-/**
- * 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.bus.osgi;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.service.factory.AbstractServiceFactoryBean;
-import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * List of work queues that cane be managed using the OSGi config admin service
- */
-public class ManagedWorkQueueList implements ManagedServiceFactory, PropertyChangeListener {
-    public static final String FACTORY_PID = "org.apache.cxf.workqueues";    
-    private static final Logger LOG = LogUtils.getL7dLogger(AbstractServiceFactoryBean.class);
-    
-    Map<String, AutomaticWorkQueueImpl> queues = new ConcurrentHashMap<String, AutomaticWorkQueueImpl>();
-    private ServiceTracker configAdminTracker;
-    
-    public String getName() {
-        return FACTORY_PID;
-    }
-
-    public void updated(String pid, Dictionary properties) throws ConfigurationException {
-        if (pid == null) {
-            return;
-        }
-        String queueName = (String)properties.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
-        if (queues.containsKey(queueName)) {
-            queues.get(queueName).update(properties);
-        } else {
-            AutomaticWorkQueueImpl wq = new AutomaticWorkQueueImpl(queueName);
-            wq.setShared(true);
-            wq.update(properties);
-            wq.addChangeListener(this);
-            queues.put(pid, wq);
-        }
-    }
-
-    public void deleted(String pid) {
-        queues.remove(pid);
-    }
-
-    public void propertyChange(PropertyChangeEvent evt) {
-        try {
-            AutomaticWorkQueueImpl queue = (AutomaticWorkQueueImpl)evt.getSource();
-            ConfigurationAdmin configurationAdmin = (ConfigurationAdmin)configAdminTracker.getService();
-            if (configurationAdmin != null) {
-                Configuration selectedConfig = findConfigForQueueName(queue, configurationAdmin);
-                if (selectedConfig != null) {
-                    Dictionary properties = queue.getProperties();
-                    selectedConfig.update(properties);
-                }
-            }
-        } catch (Exception e) {
-            LOG.log(Level.WARNING, e.getMessage(), e);
-        }
-    }
-
-    private Configuration findConfigForQueueName(AutomaticWorkQueueImpl queue,
-                                                 ConfigurationAdmin configurationAdmin) throws Exception {
-        Configuration selectedConfig = null;
-        String filter = "(service.factoryPid=" + ManagedWorkQueueList.FACTORY_PID + ")";
-        Configuration[] configs = configurationAdmin.listConfigurations(filter);
-        for (Configuration configuration : configs) {
-            Dictionary props = configuration.getProperties();
-            String name = (String)props.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
-            if (queue.getName().equals(name)) {
-                selectedConfig = configuration;
-            }
-        }
-        return selectedConfig;
-    }
-
-    public void setConfigAdminTracker(ServiceTracker configAdminTracker) {
-        this.configAdminTracker = configAdminTracker;
-    }
+/**
+ * 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.bus.osgi;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Dictionary;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
+import org.apache.cxf.workqueue.WorkQueueManager;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * List of work queues that can be managed using the OSGi configuration admin service
+ */
+public class ManagedWorkQueueList implements ManagedServiceFactory, PropertyChangeListener {
+    public static final String FACTORY_PID = "org.apache.cxf.workqueues";    
+    private static final Logger LOG = LogUtils.getL7dLogger(ManagedWorkQueueList.class);
+    
+    private Map<String, AutomaticWorkQueueImpl> queues = 
+        new ConcurrentHashMap<String, AutomaticWorkQueueImpl>();
+    private ServiceTracker configAdminTracker;
+    
+    public String getName() {
+        return FACTORY_PID;
+    }
+
+    public void updated(String pid, @SuppressWarnings("rawtypes") Dictionary props) 
+        throws ConfigurationException {
+        if (pid == null) {
+            return;
+        }
+        Dictionary<String, String> properties = CastUtils.cast(props);
+        String queueName = properties.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
+        if (queues.containsKey(queueName)) {
+            queues.get(queueName).update(properties);
+        } else {
+            AutomaticWorkQueueImpl wq = new AutomaticWorkQueueImpl(queueName);
+            wq.setShared(true);
+            wq.update(properties);
+            wq.addChangeListener(this);
+            queues.put(pid, wq);
+        }
+    }
+
+    public void deleted(String pid) {
+        queues.remove(pid);
+    }
+
+    /*
+     * On property changes of queue settings we update the config admin service pid of the queue
+     */
+    public void propertyChange(PropertyChangeEvent evt) {
+        try {
+            AutomaticWorkQueueImpl queue = (AutomaticWorkQueueImpl)evt.getSource();
+            ConfigurationAdmin configurationAdmin = (ConfigurationAdmin)configAdminTracker.getService();
+            if (configurationAdmin != null) {
+                Configuration selectedConfig = findConfigForQueueName(queue, configurationAdmin);
+                if (selectedConfig != null) {
+                    Dictionary<String, String> properties = queue.getProperties();
+                    selectedConfig.update(properties);
+                }
+            }
+        } catch (Exception e) {
+            LOG.log(Level.WARNING, e.getMessage(), e);
+        }
+    }
+
+    private Configuration findConfigForQueueName(AutomaticWorkQueueImpl queue,
+                                                 ConfigurationAdmin configurationAdmin) throws Exception {
+        Configuration selectedConfig = null;
+        String filter = "(service.factoryPid=" + ManagedWorkQueueList.FACTORY_PID + ")";
+        Configuration[] configs = configurationAdmin.listConfigurations(filter);
+        for (Configuration configuration : configs) {
+            @SuppressWarnings("rawtypes")
+            Dictionary props = configuration.getProperties();
+            String name = (String)props.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
+            if (queue.getName().equals(name)) {
+                selectedConfig = configuration;
+            }
+        }
+        return selectedConfig;
+    }
+    
+    public void addAllToWorkQueueManager(WorkQueueManager manager) {
+        if (manager != null) {
+            for (AutomaticWorkQueueImpl wq : queues.values()) {
+                if (manager.getNamedWorkQueue(wq.getName()) == null) {
+                    manager.addNamedWorkQueue(wq.getName(), wq);
+                }
+            }
+        }
+    }
+
+    public void setConfigAdminTracker(ServiceTracker configAdminTracker) {
+        this.configAdminTracker = configAdminTracker;
+    }
+
+    public void shutDown() {
+        for (AutomaticWorkQueueImpl wq : queues.values()) {
+            wq.setShared(false);
+            wq.shutdown(true);
+        }
+        queues.clear();
+    }
 }
\ No newline at end of file

Added: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java?rev=1232037&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java (added)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java Mon Jan 16 15:43:58 2012
@@ -0,0 +1,177 @@
+/**
+ * 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.bus.osgi;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.extension.ExtensionManagerImpl;
+import org.apache.cxf.buslifecycle.BusCreationListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+import org.apache.cxf.endpoint.ClientLifeCycleListener;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
+import org.apache.cxf.endpoint.ServerLifeCycleListener;
+import org.apache.cxf.endpoint.ServerLifeCycleManager;
+import org.apache.cxf.workqueue.WorkQueueManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
+
+public class OSGIBusListener implements BusLifeCycleListener {
+    public static final String CONTEXT_SYMBOLIC_NAME_PROPERTY = "cxf.context.symbolicname";
+    public static final String CONTEXT_VERSION_PROPERTY = "cxf.context.version";
+    public static final String CONTEXT_NAME_PROPERTY = "cxf.bus.id";
+    
+    private static final String SERVICE_PROPERTY_PRIVATE = "org.apache.cxf.bus.private.extension";
+    
+    Bus bus;
+    ServiceRegistration service;
+    BundleContext defaultContext;
+
+    public OSGIBusListener(Bus b) {
+        this(b, null);
+    }
+    public OSGIBusListener(Bus b, Object args[]) {
+        bus = b;
+        if (args != null && args.length > 0 
+            && args[0] instanceof BundleContext) {
+            defaultContext = (BundleContext)args[0];
+        }
+        BusLifeCycleManager manager = bus.getExtension(BusLifeCycleManager.class);
+        manager.registerLifeCycleListener(this);
+        registerConfiguredBeanLocator();
+        registerClientLifeCycleListeners();
+        registerServerLifecycleListeners();
+        sendBusCreatedToBusCreationListeners();
+
+    }
+    private void registerConfiguredBeanLocator() {
+        final ConfiguredBeanLocator cbl = bus.getExtension(ConfiguredBeanLocator.class);
+        if (cbl instanceof ExtensionManagerImpl) {
+            // wire in the OSGi things
+            bus.setExtension(new OSGiBeanLocator(cbl, defaultContext), 
+                             ConfiguredBeanLocator.class);
+        }
+    }
+    
+    public void initComplete() {
+        WorkQueueManager manager = bus.getExtension(WorkQueueManager.class);
+        ManagedWorkQueueList wqList = bus.getExtension(ManagedWorkQueueList.class);
+        if (wqList != null) {
+            wqList.addAllToWorkQueueManager(manager);
+        }
+        registerBusAsService();
+    }
+    
+
+    public void preShutdown() {
+    }
+
+    public void postShutdown() {
+        if (service != null) {
+            service.unregister();
+            service = null;
+        }
+    }
+    
+    private static ServiceReference[] getServiceReferences(BundleContext context, Class<?> serviceClass) {
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(serviceClass.getName(), null);
+        } catch (InvalidSyntaxException e) {
+            // ignore
+        }
+        if (refs == null) {
+            refs = new ServiceReference[]{};
+        }
+        return refs;
+    }
+
+    private void sendBusCreatedToBusCreationListeners() {
+        ServiceReference refs[] = getServiceReferences(defaultContext, BusCreationListener.class);
+        for (ServiceReference ref : refs) {
+            if (!isPrivate(ref)) {
+                BusCreationListener listener = (BusCreationListener)defaultContext.getService(ref);
+                listener.busCreated(bus);
+            }
+        }
+    }
+
+    private void registerServerLifecycleListeners() {
+        ServiceReference refs[] = getServiceReferences(defaultContext, ServerLifeCycleListener.class);
+        ServerLifeCycleManager clcm = bus.getExtension(ServerLifeCycleManager.class);
+        for (ServiceReference ref : refs) {
+            if (!isPrivate(ref)) {
+                ServerLifeCycleListener listener = (ServerLifeCycleListener)defaultContext.getService(ref);
+                clcm.registerListener(listener);
+            }
+        }
+    }
+    private void registerClientLifeCycleListeners() {
+        ServiceReference refs[] = getServiceReferences(defaultContext, ClientLifeCycleListener.class);
+        ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
+        for (ServiceReference ref : refs) {
+            if (!isPrivate(ref)) {
+                ClientLifeCycleListener listener = (ClientLifeCycleListener)defaultContext.getService(ref);
+                clcm.registerListener(listener);
+            }
+        }
+    }
+    
+    private boolean isPrivate(ServiceReference ref) {
+        Object o = ref.getProperty(SERVICE_PROPERTY_PRIVATE);
+        Boolean pvt = Boolean.FALSE;
+        if (o == null) {
+            pvt = Boolean.FALSE;
+        } else if (o instanceof String) {
+            pvt = Boolean.parseBoolean((String)o);
+        } else if (o instanceof Boolean) {
+            pvt = (Boolean)o;
+        }
+        return pvt.booleanValue();
+    }
+
+    private Version getBundleVersion(Bundle bundle) {
+        Dictionary<?, ?> headers = bundle.getHeaders();
+        String version = (String) headers.get(Constants.BUNDLE_VERSION);
+        return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
+    }
+
+
+
+    private void registerBusAsService() {
+        BundleContext context = bus.getExtension(BundleContext.class);
+        if (context != null) {
+            Properties props = new Properties();
+            props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, context.getBundle().getSymbolicName());
+            props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(context.getBundle()));
+            props.put(CONTEXT_NAME_PROPERTY, bus.getId());
+
+            service = context.registerService(Bus.class.getName(), bus, props);
+        }
+    }
+
+}
\ No newline at end of file

Added: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java?rev=1232037&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java (added)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java Mon Jan 16 15:43:58 2012
@@ -0,0 +1,82 @@
+/**
+ * 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.bus.osgi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class OSGiBeanLocator implements ConfiguredBeanLocator {
+    private static final Logger LOG = LogUtils.getL7dLogger(OSGiBeanLocator.class);
+    
+    final ConfiguredBeanLocator cbl;
+    final BundleContext context;
+    public OSGiBeanLocator(ConfiguredBeanLocator c, BundleContext ctx) {
+        cbl = c;
+        context = ctx;
+    }
+
+    public <T> T getBeanOfType(String name, Class<T> type) {
+        return cbl.getBeanOfType(name, type);
+    }
+
+    public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
+        Collection<? extends T> ret = cbl.getBeansOfType(type);
+        if (ret == null || ret.isEmpty()) {
+            return getBeansFromOsgiService(type);
+        } else {
+            return ret;
+        }
+    }
+
+    private <T> List<T> getBeansFromOsgiService(Class<T> type) {
+        List<T> list = new ArrayList<T>();
+        try {
+            ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
+            if (refs != null) {
+                for (ServiceReference r : refs) {
+                    list.add(type.cast(context.getService(r)));
+                }
+            }
+        } catch (Exception ex) {
+            //ignore, just don't support the OSGi services
+            LOG.info("Tried to find the Bean with type:" + type 
+                + " from OSGi services and get error: " + ex);  
+        }
+        return list;
+    }
+    public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
+        return cbl.loadBeansOfType(type, listener);
+    
+    }
+    public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
+        return cbl.hasConfiguredPropertyValue(beanName, propertyName, value);
+    }
+    
+    public List<String> getBeanNamesOfType(Class<?> type) {
+        return cbl.getBeanNamesOfType(type);
+    }
+
+}

Added: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/WorkQueueSingleConfig.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/WorkQueueSingleConfig.java?rev=1232037&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/WorkQueueSingleConfig.java (added)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/WorkQueueSingleConfig.java Mon Jan 16 15:43:58 2012
@@ -0,0 +1,69 @@
+/**
+ * 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.bus.osgi;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+/**
+ * Use the ManagedWorkQueueList config style instead
+ */
+@Deprecated
+public class WorkQueueSingleConfig implements ManagedService {
+    public static final String SERVICE_PID = "org.apache.cxf.workqueue";
+    public static final String PROPERTY_PREFIX = "org.apache.cxf.workqueue";
+    ManagedWorkQueueList workQueueList;
+    
+    public WorkQueueSingleConfig(ManagedWorkQueueList workQueueList) {
+        this.workQueueList = workQueueList;
+    }
+
+    public void updated(@SuppressWarnings("rawtypes") Dictionary properties) throws ConfigurationException {
+        Dictionary<String, String> p = CastUtils.cast(properties);
+        String names = (String)properties.get(PROPERTY_PREFIX + ".names");
+        String[] nameAr = names.split(",");
+        for (String name : nameAr) {
+            updateQueue(name.trim(), p);
+        }
+    }
+
+    private void updateQueue(String name, Dictionary<String, String> properties) 
+        throws ConfigurationException {
+        Dictionary<String, String> queueProperties = new Hashtable<String, String>();
+        Enumeration<?> it = properties.keys();
+        while (it.hasMoreElements()) {
+            String key = (String)it.nextElement();
+            String prefix = PROPERTY_PREFIX + "." + name + ".";
+            if (key.startsWith(prefix)) {
+                String newKey = (String)key.substring(prefix.length());
+                queueProperties.put(newKey, (String)properties.get(key));
+            }
+        }
+        queueProperties.put(AutomaticWorkQueueImpl.PROPERTY_NAME, name);
+        workQueueList.updated(name, queueProperties);
+    }
+
+    
+}



Mime
View raw message