cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [2/2] cxf-dosgi git commit: [DOSGI-239] Extract decorator xml support into separate bundle
Date Tue, 28 Jun 2016 11:50:16 GMT
[DOSGI-239] Extract decorator xml support into separate bundle


Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/c62f33a9
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/c62f33a9
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/c62f33a9

Branch: refs/heads/master
Commit: c62f33a946bb2079090c672848117e2eb670a2f4
Parents: 468d331
Author: Christian Schneider <chris@die-schneider.net>
Authored: Tue Jun 28 13:49:59 2016 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Jun 28 13:49:59 2016 +0200

----------------------------------------------------------------------
 cxf-dsw/pom.xml                                 |  21 ---
 .../org/apache/cxf/dosgi/dsw/Activator.java     |   7 -
 .../dosgi/dsw/decorator/DecorationParser.java   |  85 ---------
 .../cxf/dosgi/dsw/decorator/InterfaceRule.java  |  96 ----------
 .../apache/cxf/dosgi/dsw/decorator/Rule.java    |  41 ----
 .../dosgi/dsw/decorator/ServiceDecorator.java   |  28 ---
 .../ServiceDecoratorBundleListener.java         |  48 -----
 .../dsw/decorator/ServiceDecoratorImpl.java     |  97 ----------
 .../src/main/resources/service-decoration.xsd   |  67 -------
 .../dsw/decorator/DecorationParserTest.java     |  63 -------
 .../dosgi/dsw/decorator/InterfaceRuleTest.java  | 163 ----------------
 .../ServiceDecoratorBundleListenerTest.java     |  69 -------
 .../dsw/decorator/ServiceDecoratorImplTest.java | 187 -------------------
 .../remote-service/alt-remote-services.xml      |  32 ----
 .../OSGI-INF/remote-service/multi-services.xml  |  38 ----
 .../OSGI-INF/remote-service/remote-services.xml |  32 ----
 .../src/test/resources/test-resources/rs1.xml   |  31 ---
 .../src/test/resources/test-resources/rs2.xml   |  28 ---
 .../src/test/resources/test-resources/sd-1.xml  |   3 -
 .../src/test/resources/test-resources/sd.xml    |   8 -
 .../src/test/resources/test-resources/sd0.xml   |   2 -
 .../src/test/resources/test-resources/sd1.xml   |   8 -
 .../src/test/resources/test-resources/sd2.xml   |  14 --
 decorator/pom.xml                               | 153 +++++++++++++++
 .../cxf/dosgi/dsw/decorator/Activator.java      |  45 +++++
 .../dosgi/dsw/decorator/DecorationParser.java   |  85 +++++++++
 .../cxf/dosgi/dsw/decorator/InterfaceRule.java  |  96 ++++++++++
 .../apache/cxf/dosgi/dsw/decorator/Rule.java    |  41 ++++
 .../dosgi/dsw/decorator/ServiceDecorator.java   |  28 +++
 .../ServiceDecoratorBundleListener.java         |  48 +++++
 .../dsw/decorator/ServiceDecoratorImpl.java     |  97 ++++++++++
 .../src/main/resources/service-decoration.xsd   |  67 +++++++
 .../dsw/decorator/DecorationParserTest.java     |  63 +++++++
 .../dosgi/dsw/decorator/InterfaceRuleTest.java  | 163 ++++++++++++++++
 .../ServiceDecoratorBundleListenerTest.java     |  69 +++++++
 .../dsw/decorator/ServiceDecoratorImplTest.java | 187 +++++++++++++++++++
 .../remote-service/alt-remote-services.xml      |  32 ++++
 .../OSGI-INF/remote-service/multi-services.xml  |  38 ++++
 .../OSGI-INF/remote-service/remote-services.xml |  32 ++++
 .../src/test/resources/test-resources/rs1.xml   |  31 +++
 .../src/test/resources/test-resources/rs2.xml   |  28 +++
 .../src/test/resources/test-resources/sd-1.xml  |   3 +
 .../src/test/resources/test-resources/sd.xml    |   8 +
 .../src/test/resources/test-resources/sd0.xml   |   2 +
 .../src/test/resources/test-resources/sd1.xml   |   8 +
 .../src/test/resources/test-resources/sd2.xml   |  14 ++
 .../features/src/main/resources/features.xml    |   2 +-
 parent/pom.xml                                  | 136 +++-----------
 pom.xml                                         |   1 +
 49 files changed, 1371 insertions(+), 1274 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/pom.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/pom.xml b/cxf-dsw/pom.xml
index 2139252..471922a 100644
--- a/cxf-dsw/pom.xml
+++ b/cxf-dsw/pom.xml
@@ -114,17 +114,6 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.jvnet.jaxb2.maven2</groupId>
-                <artifactId>maven-jaxb2-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>generate</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
@@ -142,16 +131,6 @@
                     </instructions>
                 </configuration>
             </plugin>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>**/TestUtils*</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
index 37b6aab..0abcf7a 100644
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
@@ -24,9 +24,6 @@ import java.util.Hashtable;
 import org.apache.aries.rsa.spi.DistributionProvider;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
-import org.apache.cxf.dosgi.dsw.decorator.ServiceDecorator;
-import org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorBundleListener;
-import org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorImpl;
 import org.apache.cxf.dosgi.dsw.handlers.CXFDistributionProvider;
 import org.apache.cxf.dosgi.dsw.handlers.HttpServiceManager;
 import org.apache.cxf.dosgi.dsw.qos.DefaultIntentMapFactory;
@@ -91,10 +88,6 @@ public class Activator implements ManagedService, BundleActivator {
         props.put("remote.intents.supported", supportedIntents);
         props.put("remote.configs.supported", cxfProvider.getSupportedTypes());
         rsaFactoryReg = bc.registerService(DistributionProvider.class.getName(), cxfProvider, props);
-        ServiceDecoratorImpl serviceDecorator = new ServiceDecoratorImpl();
-        bundleListener = new ServiceDecoratorBundleListener(serviceDecorator);
-        bc.addBundleListener(bundleListener);
-        decoratorReg = bc.registerService(ServiceDecorator.class.getName(), serviceDecorator, null);
     }
 
     private synchronized void uninit() {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
deleted file mode 100644
index 82753b1..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationsType;
-
-class DecorationParser {
-    private JAXBContext jaxbContext;
-    private Schema schema;
-
-    DecorationParser() {
-        try {
-            jaxbContext = JAXBContext.newInstance(ServiceDecorationsType.class.getPackage().getName(),
-                                                  this.getClass().getClassLoader());
-            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-            URL resource = getClass().getResource("/service-decoration.xsd");
-            schema = schemaFactory.newSchema(resource);
-        } catch (Exception e) {
-            throw new RuntimeException("Error loading decorations schema", e);
-        }
-
-    }
-
-    List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException {
-        if (resourceURL == null || !decorationType(resourceURL)) {
-            return new ArrayList<ServiceDecorationType>();
-        }
-        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-        unmarshaller.setSchema(schema);
-        InputStream is = resourceURL.openStream();
-        Source source = new StreamSource(is);
-        JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class);
-        ServiceDecorationsType decorations = jaxb.getValue();
-        return decorations.getServiceDecoration();
-    }
-
-    private boolean decorationType(URL resourceURL) {
-        try {
-            InputStream is = resourceURL.openStream();
-            XMLInputFactory factory = XMLInputFactory.newInstance();
-            XMLStreamReader reader = factory.createXMLStreamReader(is);
-            reader.next();
-            String ns = reader.getNamespaceURI();
-            reader.close();
-            return ns.equals("http://cxf.apache.org/xmlns/service-decoration/1.0.0");
-        } catch (Exception e) {
-            return false;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
deleted file mode 100644
index 894d01d..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class InterfaceRule implements Rule {
-
-    private static final Logger LOG = LoggerFactory.getLogger(InterfaceRule.class);
-
-    private final Bundle bundle;
-    private final Pattern matchPattern;
-    private final Map<String, String> propMatches = new HashMap<String, String>();
-    private final Map<String, Object> addProps = new HashMap<String, Object>();
-
-    public InterfaceRule(Bundle b, String im) {
-        bundle = b;
-        matchPattern = Pattern.compile(im);
-    }
-
-    public synchronized void addPropMatch(String name, String value) {
-        propMatches.put(name, value);
-    }
-
-    public synchronized void addProperty(String name, String value, String type) {
-        Object obj = value;
-
-        if (type != null && !String.class.getName().equals(type)) {
-            try {
-                Class<?> cls = getClass().getClassLoader().loadClass(type);
-                Constructor<?> ctor = cls.getConstructor(new Class[] {String.class});
-                obj = ctor.newInstance(value);
-            } catch (Throwable th) {
-                LOG.warn("Could not handle property '" + name
-                         + "' with value '" + value + "' of type: " + type, th);
-                return;
-            }
-        }
-
-        addProps.put(name, obj);
-    }
-
-    public synchronized void apply(ServiceReference<?> sref, Map<String, Object> target) {
-        String[] objectClass = (String[]) sref.getProperty(Constants.OBJECTCLASS);
-        boolean matches = false;
-        for (String cls : objectClass) {
-            Matcher m = matchPattern.matcher(cls);
-            if (m.matches()) {
-                for (Map.Entry<String, String> pm : propMatches.entrySet()) {
-                    Object value = sref.getProperty(pm.getKey());
-                    if (value == null || !Pattern.matches(pm.getValue(), value.toString())) {
-                        return;
-                    }
-                }
-                matches = true;
-                break;
-            }
-        }
-        if (!matches) {
-            return;
-        }
-
-        LOG.info("Adding the following properties to " + sref + ": " + addProps);
-        target.putAll(addProps);
-    }
-
-    public Bundle getBundle() {
-        return bundle;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
deleted file mode 100644
index adbd1cf..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-
-public interface Rule {
-
-    /**
-     * When the ServiceReference passed in matches the rule's condition,
-     * set the additional properties in the target.
-     * @param sref The Service Reference to be checked.
-     * @param target Any additional properties are to be set in this map.
-     */
-    void apply(ServiceReference<?> sref, Map<String, Object> target);
-
-    /**
-     * Returns the bundle that provided this rule.
-     * @return The Bundle where the Rule was defined.
-     */
-    Bundle getBundle();
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
deleted file mode 100644
index 203bd1c..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.util.Map;
-
-import org.osgi.framework.ServiceReference;
-
-public interface ServiceDecorator {
-
-    void decorate(ServiceReference<?> sref, Map<String, Object> properties);
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
deleted file mode 100644
index 79c2908..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-
-public class ServiceDecoratorBundleListener implements BundleListener {
-    /**
-     * 
-     */
-    private final ServiceDecoratorImpl serviceDecorator;
-
-    /**
-     * @param serviceDecorator
-     */
-    public ServiceDecoratorBundleListener(ServiceDecoratorImpl serviceDecorator) {
-        this.serviceDecorator = serviceDecorator;
-    }
-
-    public void bundleChanged(BundleEvent be) {
-        switch(be.getType()) {
-        case BundleEvent.STARTED:
-            this.serviceDecorator.addDecorations(be.getBundle());
-            break;
-        case BundleEvent.STOPPING:
-            this.serviceDecorator.removeDecorations(be.getBundle());
-            break;
-        default:
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
deleted file mode 100644
index 20130c3..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.apache.cxf.xmlns.service_decoration._1_0.AddPropertyType;
-import org.apache.cxf.xmlns.service_decoration._1_0.MatchPropertyType;
-import org.apache.cxf.xmlns.service_decoration._1_0.MatchType;
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ServiceDecoratorImpl implements ServiceDecorator {
-    private static final Logger LOG = LoggerFactory.getLogger(ServiceDecoratorImpl.class);
-    final List<Rule> decorations = new CopyOnWriteArrayList<Rule>();
-
-    private DecorationParser parser;
-
-    public ServiceDecoratorImpl() {
-        parser = new DecorationParser();
-    }
-    
-    public void decorate(ServiceReference<?> sref, Map<String, Object> target) {
-        for (Rule matcher : decorations) {
-            matcher.apply(sref, target);
-        }
-    }
-
-    void addDecorations(Bundle bundle) {
-        for (ServiceDecorationType decoration : getDecorationElements(bundle)) {
-            for (MatchType match : decoration.getMatch()) {
-                decorations.add(getRule(bundle, match));
-            }
-        }
-    }
-
-    private Rule getRule(Bundle bundle, MatchType match) {
-        InterfaceRule m = new InterfaceRule(bundle, match.getInterface());
-        for (MatchPropertyType propMatch : match.getMatchProperty()) {
-            m.addPropMatch(propMatch.getName(), propMatch.getValue());
-        }
-        for (AddPropertyType addProp : match.getAddProperty()) {
-            m.addProperty(addProp.getName(), addProp.getValue(), addProp.getType());
-        }
-        return m;
-    }
-
-    List<ServiceDecorationType> getDecorationElements(Bundle bundle) {
-        @SuppressWarnings("rawtypes")
-        Enumeration entries = bundle.findEntries("OSGI-INF/remote-service", "*.xml", false);
-        if (entries == null) {
-            return Collections.emptyList();
-        }
-        List<ServiceDecorationType> elements = new ArrayList<ServiceDecorationType>();
-        while (entries.hasMoreElements()) {
-            try {
-                elements.addAll(parser.getDecorations((URL)entries.nextElement()));
-            } catch (Exception e) {
-                LOG.warn("Error parsing remote-service descriptions in bundle" + bundle.getSymbolicName(), e);
-            }
-        }
-        return elements;
-    }
-
-    void removeDecorations(Bundle bundle) {
-        for (Rule r : decorations) {
-            if (bundle.equals(r.getBundle())) {
-                decorations.remove(r); // the iterator doesn't support 'remove'
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/main/resources/service-decoration.xsd
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/resources/service-decoration.xsd b/cxf-dsw/src/main/resources/service-decoration.xsd
deleted file mode 100644
index 66e8d30..0000000
--- a/cxf-dsw/src/main/resources/service-decoration.xsd
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<schema targetNamespace="http://cxf.apache.org/xmlns/service-decoration/1.0.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
-    <element name="service-decorations" type="tns:ServiceDecorationsType"></element>
-
-    <complexType name="ServiceDecorationsType">
-        <sequence>
-            <element maxOccurs="unbounded" minOccurs="0"
-                ref="tns:service-decoration">
-            </element>
-        </sequence>
-    </complexType>
-
-    <complexType name="ServiceDecorationType">
-        <sequence>
-            <element maxOccurs="unbounded" minOccurs="0"
-                ref="tns:match">
-            </element>
-        </sequence>
-    </complexType>
-
-    <complexType name="MatchType">
-        <sequence>
-            <element maxOccurs="unbounded" minOccurs="0"
-                ref="tns:match-property">
-            </element>
-            <element maxOccurs="unbounded" minOccurs="0"
-                ref="tns:add-property">
-            </element>
-        </sequence>
-        <attribute name="interface" type="string"></attribute>
-    </complexType>
-
-    <complexType name="MatchPropertyType">
-        <attribute name="name" type="string"></attribute>
-        <attribute name="value" type="string"></attribute>
-    </complexType>
-
-    <complexType name="AddPropertyType">
-        <attribute name="name" type="string"></attribute>
-        <attribute name="value" type="string"></attribute>
-        <attribute name="type" type="string"></attribute>
-    </complexType>
-    <element name="service-decoration"
-        type="tns:ServiceDecorationType">
-    </element>
-    <element name="match" type="tns:MatchType"></element>
-    <element name="match-property" type="tns:MatchPropertyType"></element>
-    <element name="add-property" type="tns:AddPropertyType"></element>
-</schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
deleted file mode 100644
index 270c7fa..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-
-import javax.xml.bind.JAXBException;
-
-import org.apache.cxf.xmlns.service_decoration._1_0.AddPropertyType;
-import org.apache.cxf.xmlns.service_decoration._1_0.MatchPropertyType;
-import org.apache.cxf.xmlns.service_decoration._1_0.MatchType;
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class DecorationParserTest {
-
-    @Test
-    public void testGetDecoratorForSD() throws JAXBException, IOException {
-        URL resource = getClass().getResource("/test-resources/sd.xml");
-        List<ServiceDecorationType> elements = new DecorationParser().getDecorations(resource);
-        assertEquals(1, elements.size());
-        ServiceDecorationType decoration = elements.get(0);
-        assertEquals(1, decoration.getMatch().size());
-        MatchType match = decoration.getMatch().get(0);
-        assertEquals("org.acme.foo.*", match.getInterface());
-        assertEquals(1, match.getMatchProperty().size());
-        MatchPropertyType matchProp = match.getMatchProperty().get(0);
-        assertEquals("test.prop", matchProp.getName());
-        assertEquals("xyz", matchProp.getValue());
-        assertEquals(1, match.getAddProperty().size());
-        AddPropertyType addProp = match.getAddProperty().get(0);
-        assertEquals("test.too", addProp.getName());
-        assertEquals("ahaha", addProp.getValue());
-        assertEquals("java.lang.String", addProp.getType());
-    }
-
-    @Test
-    public void testGetDecorationForNull() throws JAXBException, IOException {
-        List<ServiceDecorationType> elements = new DecorationParser().getDecorations(null);
-        Assert.assertEquals(0, elements.size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
deleted file mode 100644
index c66642b..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-
-@SuppressWarnings("rawtypes")
-public class InterfaceRuleTest extends TestCase {
-
-    public void testDUMMY() {
-        assertTrue(true);
-    }
-
-    public void testInterfaceRuleGetBundle() {
-        Bundle b = EasyMock.createMock(Bundle.class);
-        EasyMock.replay(b);
-        InterfaceRule ir = new InterfaceRule(b, "org.apache.Foo");
-        assertSame(b, ir.getBundle());
-    }
-
-    public void testInterfaceRule1() {
-        InterfaceRule ir = new InterfaceRule(null, "org.apache.Foo");
-        ir.addProperty("x", "y", String.class.getName());
-
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"a.b.C", "org.apache.Foo"});
-        ServiceReference sref = mockServiceReference(serviceProps);
-
-        Map<String, Object> m = new HashMap<String, Object>();
-        m.put("a", "b");
-        ir.apply(sref, m);
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("a", "b");
-        expected.put("x", "y");
-        assertEquals(expected, m);
-    }
-
-    public void testInterfaceRule2() {
-        InterfaceRule ir = new InterfaceRule(null, "org.apache.F(.*)");
-        ir.addPropMatch("boo", "baah");
-        ir.addProperty("x", "1", Integer.class.getName());
-        ir.addProperty("aaa.bbb", "true", Boolean.class.getName());
-
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put("boo", "baah");
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"a.b.C", "org.apache.Foo"});
-        ServiceReference sref = mockServiceReference(serviceProps);
-
-        Map<String, Object> m = new HashMap<String, Object>();
-        ir.apply(sref, m);
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("x", 1);
-        expected.put("aaa.bbb", Boolean.TRUE);
-        assertEquals(expected, m);
-    }
-
-    public void testInterfaceRule3() {
-        InterfaceRule ir = new InterfaceRule(null, "org.apache.F(.*)");
-        ir.addProperty("x", "y", String.class.getName());
-
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put("boo", "baah");
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.apache.Boo"});
-        ServiceReference sref = mockServiceReference(serviceProps);
-
-        Map<String, Object> m = new HashMap<String, Object>();
-        ir.apply(sref, m);
-        assertEquals(0, m.size());
-    }
-
-    public void testInterfaceRule4() {
-        InterfaceRule ir = new InterfaceRule(null, "org.apache.F(.*)");
-        ir.addPropMatch("boo", "baah");
-        ir.addProperty("x", "y", String.class.getName());
-
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.apache.Foo"});
-        ServiceReference sref = mockServiceReference(serviceProps);
-
-        Map<String, Object> m = new HashMap<String, Object>();
-        ir.apply(sref, m);
-        assertEquals(0, m.size());
-    }
-
-    public void testInterfaceRule5() {
-        InterfaceRule ir = new InterfaceRule(null, "org.apache.Foo");
-        ir.addPropMatch("test.int", "42");
-        ir.addProperty("x", "1", Long.class.getName());
-
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put("test.int", 42);
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.apache.Foo"});
-        ServiceReference sref = mockServiceReference(serviceProps);
-
-        Map<String, Object> m = new HashMap<String, Object>();
-        m.put("x", "foo");
-        m.put("aaa.bbb", Boolean.TRUE);
-        ir.apply(sref, m);
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("x", 1L);
-        expected.put("aaa.bbb", Boolean.TRUE);
-        assertEquals(expected, m);
-    }
-
-    public void testInterfaceRule6() {
-        InterfaceRule ir = new InterfaceRule(null, "org.apache.Foo");
-        ir.addPropMatch("test.int", "42");
-        ir.addProperty("x", "1", Long.class.getName());
-
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put("test.int", 51);
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.apache.Foo"});
-        ServiceReference sref = mockServiceReference(serviceProps);
-
-        Map<String, Object> m = new HashMap<String, Object>();
-        m.put("x", "foo");
-        m.put("aaa.bbb", Boolean.TRUE);
-        ir.apply(sref, m);
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("x", "foo");
-        expected.put("aaa.bbb", Boolean.TRUE);
-        assertEquals(expected, m);
-    }
-
-    private ServiceReference mockServiceReference(final Map<String, Object> serviceProps) {
-        ServiceReference sref = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sref.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return serviceProps.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.expect(sref.getPropertyKeys())
-            .andReturn(serviceProps.keySet().toArray(new String[] {})).anyTimes();
-
-        EasyMock.replay(sref);
-        return sref;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListenerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListenerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListenerTest.java
deleted file mode 100644
index 1ca33fc..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListenerTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.easymock.EasyMock;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-
-import static org.junit.Assert.assertEquals;
-
-public class ServiceDecoratorBundleListenerTest {
-
-    @Test
-    public void testBundleListener() {
-        BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.replay(bc);
-
-        final List<String> called = new ArrayList<String>();
-        ServiceDecoratorImpl serviceDecorator = new ServiceDecoratorImpl() {
-            @Override
-            void addDecorations(Bundle bundle) {
-                called.add("addDecorations");
-            }
-
-            @Override
-            void removeDecorations(Bundle bundle) {
-                called.add("removeDecorations");
-            }
-        };
-
-        Bundle b = EasyMock.createMock(Bundle.class);
-        EasyMock.replay(b);
-        
-        ServiceDecoratorBundleListener listener = new ServiceDecoratorBundleListener(serviceDecorator);
-
-        assertEquals("Precondition failed", 0, called.size());
-        listener.bundleChanged(new BundleEvent(BundleEvent.INSTALLED, b));
-        assertEquals(0, called.size());
-
-        listener.bundleChanged(new BundleEvent(BundleEvent.STARTED, b));
-        assertEquals(Arrays.asList("addDecorations"), called);
-
-        listener.bundleChanged(new BundleEvent(BundleEvent.STOPPING, b));
-        assertEquals(Arrays.asList("addDecorations", "removeDecorations"), called);
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
deleted file mode 100644
index 400d793..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * 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.dosgi.dsw.decorator;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.junit.Assert;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-
-public class ServiceDecoratorImplTest extends TestCase {
-    private static final Map<String, Object> EMPTY = new HashMap<String, Object>();
-    private static final URL RES_SD = getResource("/test-resources/sd.xml");
-    private static final URL RES_SD1 = getResource("/test-resources/sd1.xml");
-    private static final URL RES_SD2 = getResource("/test-resources/sd2.xml");
-    private static final URL RES_SD0 = getResource("/test-resources/sd0.xml");
-    private static final URL RES_SD_1 = getResource("/test-resources/sd-1.xml");
-
-    @SuppressWarnings("rawtypes")
-    public void testAddRemoveDecorations() {
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.acme.foo.Bar"});
-        serviceProps.put("test.prop", "xyz");
-
-        Bundle b = createBundleContaining(RES_SD);
-        ServiceDecoratorImpl sd = new ServiceDecoratorImpl();
-        assertEquals("Precondition failed", 0, sd.decorations.size());
-        sd.addDecorations(b);
-        assertEquals(1, sd.decorations.size());
-
-        Map<String, Object> target = new HashMap<String, Object>();
-        ServiceReference sref = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sref.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return serviceProps.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(sref);
-        sd.decorate(sref, target);
-
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("test.too", "ahaha");
-        assertEquals(expected, target);
-
-        // remove it again
-        sd.removeDecorations(b);
-        assertEquals(0, sd.decorations.size());
-        Map<String, Object> target2 = new HashMap<String, Object>();
-        sd.decorate(sref, target2);
-        assertEquals(EMPTY, target2);
-    }
-
-    public void testAddDecorations() {
-        final Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.acme.foo.Bar"});
-        serviceProps.put("test.prop", "xyz");
-
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("test.too", "ahaha");
-        assertDecorate(serviceProps, expected, RES_SD);
-    }
-
-    public void testAddDecorations1() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.A"});
-
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("A", "B");
-        expected.put("C", 2);
-        assertDecorate(serviceProps, expected, RES_SD1, RES_SD2);
-    }
-
-    public void testAddDecorations2() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.D"});
-
-        assertDecorate(serviceProps, EMPTY, RES_SD1, RES_SD2);
-    }
-
-    public void testAddDecorations3() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.B"});
-        serviceProps.put("x", "y");
-
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("bool", Boolean.TRUE);
-        assertDecorate(serviceProps, expected, RES_SD1, RES_SD2);
-    }
-
-    public void testAddDecorations4() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.C"});
-        serviceProps.put("x", "z");
-
-        Map<String, Object> expected = new HashMap<String, Object>();
-        expected.put("bool", Boolean.FALSE);
-        assertDecorate(serviceProps, expected, RES_SD1, RES_SD2);
-    }
-
-    public void testAddDecorations5() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.C"});
-        serviceProps.put("x", "x");
-
-        assertDecorate(serviceProps, EMPTY, RES_SD1, RES_SD2);
-    }
-
-    public void testAddDecorations6() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.D"});
-
-        assertDecorate(serviceProps, EMPTY, RES_SD0);
-    }
-
-    public void testAddDecorations7() {
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.test.D"});
-
-        assertDecorate(serviceProps, EMPTY, RES_SD_1);
-    }
-    
-    private void assertDecorate(final Map<String, Object> serviceProps, 
-                                Map<String, Object> expected, URL ... resources) {
-        Map<String, Object> actual = testDecorate(serviceProps, resources);
-        assertEquals(expected, actual);
-    }
-
-    @SuppressWarnings("rawtypes")
-    private Map<String, Object> testDecorate(final Map<String, Object> serviceProps, URL ... resources) {
-        Bundle b = createBundleContaining(resources);
-
-        ServiceDecoratorImpl sd = new ServiceDecoratorImpl();
-        sd.addDecorations(b);
-
-        Map<String, Object> target = new HashMap<String, Object>();
-        ServiceReference sref = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sref.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return serviceProps.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(sref);
-        sd.decorate(sref, target);
-        return target;
-    }
-
-    private Bundle createBundleContaining(URL... resources) {
-        Bundle b = EasyMock.createMock(Bundle.class);
-        EasyMock.expect(b.findEntries("OSGI-INF/remote-service", "*.xml", false)).andReturn(
-            Collections.enumeration(Arrays.asList(resources))).anyTimes();
-        EasyMock.expect(b.getSymbolicName()).andReturn("bundlename");
-        EasyMock.replay(b);
-        return b;
-    }
-
-    private static URL getResource(String path) {
-        URL resource = ServiceDecoratorImplTest.class.getResource(path);
-        Assert.assertNotNull("Resource " + path + " not found!", resource);
-        return resource;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml
deleted file mode 100644
index 36409ce..0000000
--- a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
-  <service-description>
-    <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" />
-    <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" />
-
-    <property name="osgi.remote.interfaces" value="*" />
-    <property name="osgi.remote.requires.intents" value="SOAP HTTP" />
-    <property name="osgi.remote.configuration.type" value="pojo" />
-    <property name="osgi.remote.configuration.pojo.address" value="http://localhost:9000/hello" />
-  </service-description>
-</service-descriptions>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml
deleted file mode 100644
index 3d20c08..0000000
--- a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
-  <service-description>
-    <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" />
-    <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" />
-    <property name="osgi.remote.interfaces">org.apache.cxf.dosgi.dsw.hooks.TestService,org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface</property>
-    <property name="osgi.remote.requires.intents">SOAP HTTP</property>
-    <property name="osgi.remote.configuration.type">pojo</property>
-    <property name="osgi.remote.configuration.pojo.address"
-              interface="org.apache.cxf.dosgi.dsw.hooks.TestService">
-      http://localhost:9001/hello
-    </property>
-    <property name="osgi.remote.configuration.pojo.address"
-              interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface">
-      http://localhost:9002/hello
-    </property>
-  </service-description>
-</service-descriptions>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml
deleted file mode 100644
index 45b2a20..0000000
--- a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
-  <service-description>
-    <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" />
-    <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" />
-
-    <property name="osgi.remote.interfaces">*</property>
-    <property name="osgi.remote.requires.intents">SOAP HTTP</property>
-    <property name="osgi.remote.configuration.type">pojo</property>
-    <property name="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
-  </service-description>
-</service-descriptions>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/rs1.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/rs1.xml b/cxf-dsw/src/test/resources/test-resources/rs1.xml
deleted file mode 100644
index f67a833..0000000
--- a/cxf-dsw/src/test/resources/test-resources/rs1.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
-  <service-description>
-    <provide interface="SomeService" />
-    <property name="osgi.remote.requires.intents">confidentiality</property>
-  </service-description>
-  <service-description>
-    <provide interface="SomeOtherService" />
-    <provide interface="WithSomeSecondInterface" />
-  </service-description>
-</service-descriptions>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/rs2.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/rs2.xml b/cxf-dsw/src/test/resources/test-resources/rs2.xml
deleted file mode 100644
index 098aa21..0000000
--- a/cxf-dsw/src/test/resources/test-resources/rs2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
-  <service-description>
-    <provide interface="org.example.Service" />
-    <property name="deployment.intents">confidentiality.message integrity</property>
-    <property name="osgi.remote.interfaces">*</property>
-  </service-description>
-</service-descriptions>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/sd-1.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/sd-1.xml b/cxf-dsw/src/test/resources/test-resources/sd-1.xml
deleted file mode 100644
index 483b196..0000000
--- a/cxf-dsw/src/test/resources/test-resources/sd-1.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<test>
-  <some-other-tag/>
-</test>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/sd.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/sd.xml b/cxf-dsw/src/test/resources/test-resources/sd.xml
deleted file mode 100644
index c7cebfb..0000000
--- a/cxf-dsw/src/test/resources/test-resources/sd.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
-  <service-decoration>
-    <match interface="org.acme.foo.*">
-      <match-property name="test.prop" value="xyz"/>
-      <add-property name="test.too" value="ahaha" type="java.lang.String"/>
-    </match>
-  </service-decoration>
-</service-decorations>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/sd0.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/sd0.xml b/cxf-dsw/src/test/resources/test-resources/sd0.xml
deleted file mode 100644
index 0ad0ad1..0000000
--- a/cxf-dsw/src/test/resources/test-resources/sd0.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
-</service-decorations>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/sd1.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/sd1.xml b/cxf-dsw/src/test/resources/test-resources/sd1.xml
deleted file mode 100644
index 6a5e811..0000000
--- a/cxf-dsw/src/test/resources/test-resources/sd1.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
-  <service-decoration>
-    <match interface="org.test.A">
-      <add-property name="A" value="B"/>
-      <add-property name="C" value="2" type="java.lang.Integer"/>
-    </match>
-  </service-decoration>
-</service-decorations>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/cxf-dsw/src/test/resources/test-resources/sd2.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/resources/test-resources/sd2.xml b/cxf-dsw/src/test/resources/test-resources/sd2.xml
deleted file mode 100644
index fb6a93a..0000000
--- a/cxf-dsw/src/test/resources/test-resources/sd2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
-  <service-decoration>
-    <match interface="org.test.(B|C)">
-      <match-property name="x" value="y"/>
-      <add-property name="bool" value="true" type="java.lang.Boolean"/>
-    </match>
-  </service-decoration>
-  <service-decoration>
-    <match interface="org.test.(B|C)">
-      <match-property name="x" value="z"/>
-      <add-property name="bool" value="false" type="java.lang.Boolean"/>
-    </match>
-  </service-decoration>
-</service-decorations>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/pom.xml
----------------------------------------------------------------------
diff --git a/decorator/pom.xml b/decorator/pom.xml
new file mode 100644
index 0000000..fbe14a3
--- /dev/null
+++ b/decorator/pom.xml
@@ -0,0 +1,153 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>cxf-dosgi-ri-decorator</artifactId>
+    <packaging>bundle</packaging>
+    <name>CXF dOSGi Service decorator support</name>
+
+    <parent>
+        <groupId>org.apache.cxf.dosgi</groupId>
+        <artifactId>cxf-dosgi-ri-parent</artifactId>
+        <version>1.9-SNAPSHOT</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <topDirectoryLocation>..</topDirectoryLocation>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.rsa</groupId>
+            <artifactId>org.apache.aries.rsa.spi</artifactId>
+            <version>${aries.rsa.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-core</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+		<dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-databinding-aegis</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-extension-providers</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_${servlet.version}_spec</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <version>1.7.14</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.jvnet.jaxb2.maven2</groupId>
+                <artifactId>maven-jaxb2-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Export-Package>
+                            !*
+                        </Export-Package>
+                        <Bundle-Activator>org.apache.cxf.dosgi.dsw.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>**/TestUtils*</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Activator.java
----------------------------------------------------------------------
diff --git a/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Activator.java b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Activator.java
new file mode 100644
index 0000000..372d7b1
--- /dev/null
+++ b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Activator.java
@@ -0,0 +1,45 @@
+/**
+ * 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.dosgi.dsw.decorator;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+    private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
+    private ServiceDecoratorBundleListener bundleListener;
+
+    public void start(BundleContext context) throws Exception {
+        ServiceDecoratorImpl serviceDecorator = new ServiceDecoratorImpl();
+        bundleListener = new ServiceDecoratorBundleListener(serviceDecorator);
+        context.addBundleListener(bundleListener);
+        context.registerService(ServiceDecorator.class.getName(), serviceDecorator, null);
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        LOG.debug("RemoteServiceAdmin Implementation is shutting down now");
+        if (bundleListener != null) {
+            context.removeBundleListener(bundleListener);
+            bundleListener = null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
----------------------------------------------------------------------
diff --git a/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
new file mode 100644
index 0000000..82753b1
--- /dev/null
+++ b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
@@ -0,0 +1,85 @@
+/**
+ * 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.dosgi.dsw.decorator;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
+import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationsType;
+
+class DecorationParser {
+    private JAXBContext jaxbContext;
+    private Schema schema;
+
+    DecorationParser() {
+        try {
+            jaxbContext = JAXBContext.newInstance(ServiceDecorationsType.class.getPackage().getName(),
+                                                  this.getClass().getClassLoader());
+            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+            URL resource = getClass().getResource("/service-decoration.xsd");
+            schema = schemaFactory.newSchema(resource);
+        } catch (Exception e) {
+            throw new RuntimeException("Error loading decorations schema", e);
+        }
+
+    }
+
+    List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException {
+        if (resourceURL == null || !decorationType(resourceURL)) {
+            return new ArrayList<ServiceDecorationType>();
+        }
+        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+        unmarshaller.setSchema(schema);
+        InputStream is = resourceURL.openStream();
+        Source source = new StreamSource(is);
+        JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class);
+        ServiceDecorationsType decorations = jaxb.getValue();
+        return decorations.getServiceDecoration();
+    }
+
+    private boolean decorationType(URL resourceURL) {
+        try {
+            InputStream is = resourceURL.openStream();
+            XMLInputFactory factory = XMLInputFactory.newInstance();
+            XMLStreamReader reader = factory.createXMLStreamReader(is);
+            reader.next();
+            String ns = reader.getNamespaceURI();
+            reader.close();
+            return ns.equals("http://cxf.apache.org/xmlns/service-decoration/1.0.0");
+        } catch (Exception e) {
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
----------------------------------------------------------------------
diff --git a/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
new file mode 100644
index 0000000..894d01d
--- /dev/null
+++ b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
@@ -0,0 +1,96 @@
+/**
+ * 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.dosgi.dsw.decorator;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InterfaceRule implements Rule {
+
+    private static final Logger LOG = LoggerFactory.getLogger(InterfaceRule.class);
+
+    private final Bundle bundle;
+    private final Pattern matchPattern;
+    private final Map<String, String> propMatches = new HashMap<String, String>();
+    private final Map<String, Object> addProps = new HashMap<String, Object>();
+
+    public InterfaceRule(Bundle b, String im) {
+        bundle = b;
+        matchPattern = Pattern.compile(im);
+    }
+
+    public synchronized void addPropMatch(String name, String value) {
+        propMatches.put(name, value);
+    }
+
+    public synchronized void addProperty(String name, String value, String type) {
+        Object obj = value;
+
+        if (type != null && !String.class.getName().equals(type)) {
+            try {
+                Class<?> cls = getClass().getClassLoader().loadClass(type);
+                Constructor<?> ctor = cls.getConstructor(new Class[] {String.class});
+                obj = ctor.newInstance(value);
+            } catch (Throwable th) {
+                LOG.warn("Could not handle property '" + name
+                         + "' with value '" + value + "' of type: " + type, th);
+                return;
+            }
+        }
+
+        addProps.put(name, obj);
+    }
+
+    public synchronized void apply(ServiceReference<?> sref, Map<String, Object> target) {
+        String[] objectClass = (String[]) sref.getProperty(Constants.OBJECTCLASS);
+        boolean matches = false;
+        for (String cls : objectClass) {
+            Matcher m = matchPattern.matcher(cls);
+            if (m.matches()) {
+                for (Map.Entry<String, String> pm : propMatches.entrySet()) {
+                    Object value = sref.getProperty(pm.getKey());
+                    if (value == null || !Pattern.matches(pm.getValue(), value.toString())) {
+                        return;
+                    }
+                }
+                matches = true;
+                break;
+            }
+        }
+        if (!matches) {
+            return;
+        }
+
+        LOG.info("Adding the following properties to " + sref + ": " + addProps);
+        target.putAll(addProps);
+    }
+
+    public Bundle getBundle() {
+        return bundle;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
----------------------------------------------------------------------
diff --git a/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
new file mode 100644
index 0000000..adbd1cf
--- /dev/null
+++ b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
@@ -0,0 +1,41 @@
+/**
+ * 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.dosgi.dsw.decorator;
+
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+public interface Rule {
+
+    /**
+     * When the ServiceReference passed in matches the rule's condition,
+     * set the additional properties in the target.
+     * @param sref The Service Reference to be checked.
+     * @param target Any additional properties are to be set in this map.
+     */
+    void apply(ServiceReference<?> sref, Map<String, Object> target);
+
+    /**
+     * Returns the bundle that provided this rule.
+     * @return The Bundle where the Rule was defined.
+     */
+    Bundle getBundle();
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
----------------------------------------------------------------------
diff --git a/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
new file mode 100644
index 0000000..203bd1c
--- /dev/null
+++ b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
@@ -0,0 +1,28 @@
+/**
+ * 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.dosgi.dsw.decorator;
+
+import java.util.Map;
+
+import org.osgi.framework.ServiceReference;
+
+public interface ServiceDecorator {
+
+    void decorate(ServiceReference<?> sref, Map<String, Object> properties);
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/c62f33a9/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
----------------------------------------------------------------------
diff --git a/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
new file mode 100644
index 0000000..79c2908
--- /dev/null
+++ b/decorator/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
@@ -0,0 +1,48 @@
+/**
+ * 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.dosgi.dsw.decorator;
+
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+
+public class ServiceDecoratorBundleListener implements BundleListener {
+    /**
+     * 
+     */
+    private final ServiceDecoratorImpl serviceDecorator;
+
+    /**
+     * @param serviceDecorator
+     */
+    public ServiceDecoratorBundleListener(ServiceDecoratorImpl serviceDecorator) {
+        this.serviceDecorator = serviceDecorator;
+    }
+
+    public void bundleChanged(BundleEvent be) {
+        switch(be.getType()) {
+        case BundleEvent.STARTED:
+            this.serviceDecorator.addDecorations(be.getBundle());
+            break;
+        case BundleEvent.STOPPING:
+            this.serviceDecorator.removeDecorations(be.getBundle());
+            break;
+        default:
+        }
+    }
+}
\ No newline at end of file


Mime
View raw message