Modified: cxf/dosgi/trunk/discovery/local/src/test/resources/ed2-generated.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/resources/ed2-generated.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/discovery/local/src/test/resources/ed2-generated.xml (original) +++ cxf/dosgi/trunk/discovery/local/src/test/resources/ed2-generated.xml Thu Aug 15 20:40:29 2013 @@ -1,53 +1,54 @@ <?xml version="1.0" encoding="UTF-8"?> <endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0"> - <endpoint-description> - <property name="service.imported.configs" value="org.apache.cxf.ws"/> - <property name="endpoint.id" value="foo:bar"/> - <property name="objectClass"> - <array> - <value>com.acme.HelloService</value> - <value>some.other.Service</value> - </array> - </property> - - <property name="long" value-type="Long" value="9223372036854775807"/> - <property name="Long2" value-type="Long" value="-1"/> - <property name="double" value-type="Double" value="1.7976931348623157E308"/> - <property name="Double2" value-type="Double" value="1.0"/> - <property name="float" value-type="Float" value="42.24"/> - <property name="Float2" value-type="Float" value="1.0"/> - <property name="int" value-type="Integer" value="17"/> - <property name="Integer2" value-type="Integer" value="42"/> - <property name="byte" value-type="Byte" value="127"/> - <property name="Byte2" value-type="Byte" value="-128"/> - <property name="boolean" value-type="Boolean" value="true"/> - <property name="Boolean2" value-type="Boolean" value="false"/> - <property name="short" value-type="Short" value="99"/> - <property name="Short2" value-type="Short" value="-99"/> - <property name="char" value-type="Character" value="@"/> - <property name="Character2" value-type="Character" value="X"/> - - <property name="bool-list" value-type="Boolean"> - <list> - <value>true</value> - <value>false</value> - </list> - </property> - <property name="empty-set"> - <set/> - </property> - <property name="string-set"> - <set> - <value>Hello there</value> - <value>How are you?</value> - </set> - </property> - <property name="int-array" value-type="Integer"> - <array> - <value>1</value> - <value>2</value> - </array> - </property> - <property name="someXML" value="<xml>
<t1 xmlns="http://www.acme.org/xmlns/other/v1.0.0">
<foo type='bar'>haha</foo>
</t1>
</xml>"/> - </endpoint-description> + <endpoint-description> + <property name="service.imported.configs" value="org.apache.cxf.ws" /> + <property name="endpoint.id" value="foo:bar" /> + <property name="objectClass"> + <array> + <value>com.acme.HelloService</value> + <value>some.other.Service</value> + </array> + </property> + <property name="long" value-type="Long" value="9223372036854775807" /> + <property name="Long2" value-type="Long" value="-1" /> + <property name="double" value-type="Double" + value="1.7976931348623157E308" /> + <property name="Double2" value-type="Double" value="1.0" /> + <property name="float" value-type="Float" value="42.24" /> + <property name="Float2" value-type="Float" value="1.0" /> + <property name="int" value-type="Integer" value="17" /> + <property name="Integer2" value-type="Integer" value="42" /> + <property name="byte" value-type="Byte" value="127" /> + <property name="Byte2" value-type="Byte" value="-128" /> + <property name="boolean" value-type="Boolean" value="true" /> + <property name="Boolean2" value-type="Boolean" value="false" /> + <property name="short" value-type="Short" value="99" /> + <property name="Short2" value-type="Short" value="-99" /> + <property name="char" value-type="Character" value="@" /> + <property name="Character2" value-type="Character" + value="X" /> + <property name="bool-list" value-type="Boolean"> + <list> + <value>true</value> + <value>false</value> + </list> + </property> + <property name="empty-set"> + <set /> + </property> + <property name="string-set"> + <set> + <value>Hello there</value> + <value>How are you?</value> + </set> + </property> + <property name="int-array" value-type="Integer"> + <array> + <value>1</value> + <value>2</value> + </array> + </property> + <property name="someXML" + value="<xml>
<t1 xmlns="http://www.acme.org/xmlns/other/v1.0.0">
<foo type='bar'>haha</foo>
</t1>
</xml>" /> + </endpoint-description> </endpoint-descriptions>
Modified: cxf/dosgi/trunk/distribution/features/src/main/resources/features.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/features/src/main/resources/features.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/distribution/features/src/main/resources/features.xml (original) +++ cxf/dosgi/trunk/distribution/features/src/main/resources/features.xml Thu Aug 15 20:40:29 2013 @@ -25,7 +25,6 @@ <feature>cxf-databinding-aegis</feature> <feature>cxf-http-jetty</feature> <bundle>mvn:org.osgi/org.osgi.enterprise/${osgi.enterprise.version}</bundle> - <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jdom/${jdom.version}</bundle> <bundle>mvn:${project.groupId}/cxf-dosgi-ri-topology-manager/${project.version}</bundle> <bundle>mvn:${project.groupId}/cxf-dosgi-ri-dsw-cxf/${project.version}</bundle> </feature> Modified: cxf/dosgi/trunk/distribution/multi-bundle/pom.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/multi-bundle/pom.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/distribution/multi-bundle/pom.xml (original) +++ cxf/dosgi/trunk/distribution/multi-bundle/pom.xml Thu Aug 15 20:40:29 2013 @@ -80,11 +80,6 @@ <version>2.6</version> </dependency> <dependency> - <groupId>org.apache.servicemix.bundles</groupId> - <artifactId>org.apache.servicemix.bundles.jdom</artifactId> - <version>${jdom.version}</version> - </dependency> - <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> Modified: cxf/dosgi/trunk/distribution/multi-bundle/src/main/appended-resources/META-INF/NOTICE URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/multi-bundle/src/main/appended-resources/META-INF/NOTICE?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/distribution/multi-bundle/src/main/appended-resources/META-INF/NOTICE (original) +++ cxf/dosgi/trunk/distribution/multi-bundle/src/main/appended-resources/META-INF/NOTICE Thu Aug 15 20:40:29 2013 @@ -16,12 +16,6 @@ This product also includes WS-* schemas (http://www.w3.org/2005/08/addressing/ws-addr.xsd) -This product contains includes JDOM: - Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. - All rights reserved. - See the NOTICE.jdom file for additional information - - The product contains code (StaxBuilder.java) that is Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -32,10 +26,8 @@ Java classes (source and binary) under o are generated from schema available here: (http://java.sun.com/xml/ns/javaee/javaee_5.xsd) - Portions of the included XmlSchema library are Copyright 2006 International Business Machines Corp. - Portions of the included xml-apis library were originally based on the following: - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. @@ -45,5 +37,3 @@ Portions of the included xml-apis librar Portions of the included xmlbeans library were originally based on the following: - software copyright (c) 2000-2003, BEA Systems, <http://www.bea.com/>. - - Modified: cxf/dosgi/trunk/distribution/multi-bundle/src/main/assembly/assembly.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/multi-bundle/src/main/assembly/assembly.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/distribution/multi-bundle/src/main/assembly/assembly.xml (original) +++ cxf/dosgi/trunk/distribution/multi-bundle/src/main/assembly/assembly.xml Thu Aug 15 20:40:29 2013 @@ -43,13 +43,6 @@ <outputDirectory>apache-cxf-dosgi-ri-${dosgi.version}</outputDirectory> </fileSet> <fileSet> - <directory>src/main/resources/META-INF</directory> - <includes> - <include>NOTICE.jdom</include> - </includes> - <outputDirectory>apache-cxf-dosgi-ri-${dosgi.version}</outputDirectory> - </fileSet> - <fileSet> <directory>src/main/release</directory> <includes> <include>README</include> Modified: cxf/dosgi/trunk/distribution/multi-bundle/src/main/resources/distro_bundles.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/multi-bundle/src/main/resources/distro_bundles.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/distribution/multi-bundle/src/main/resources/distro_bundles.xml (original) +++ cxf/dosgi/trunk/distribution/multi-bundle/src/main/resources/distro_bundles.xml Thu Aug 15 20:40:29 2013 @@ -7,7 +7,6 @@ <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/geronimo-javamail_1.4_spec-1.7.1.jar</bundle> <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/geronimo-servlet_3.0_spec-1.0.jar</bundle> <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/geronimo-ws-metadata_2.0_spec-1.1.3.jar</bundle> - <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/org.apache.servicemix.bundles.jdom-${jdom.version}.jar</bundle> <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/commons-lang-2.6.jar</bundle> <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/spring-core-${spring.version}.jar</bundle> <bundle>cxf-dosgi-ri-multibundle-distribution-${project.version}-dir/apache-cxf-dosgi-ri-${project.version}/dosgi_bundles/spring-beans-${spring.version}.jar</bundle> Modified: cxf/dosgi/trunk/distribution/multi-bundle2/src/main/assembly/assembly.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/multi-bundle2/src/main/assembly/assembly.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/distribution/multi-bundle2/src/main/assembly/assembly.xml (original) +++ cxf/dosgi/trunk/distribution/multi-bundle2/src/main/assembly/assembly.xml Thu Aug 15 20:40:29 2013 @@ -43,13 +43,6 @@ <outputDirectory>apache-cxf-dosgi-ri-${dosgi.version}</outputDirectory> </fileSet> <fileSet> - <directory>src/main/resources/META-INF</directory> - <includes> - <include>NOTICE.jdom</include> - </includes> - <outputDirectory>apache-cxf-dosgi-ri-${dosgi.version}</outputDirectory> - </fileSet> - <fileSet> <directory>src/main/release</directory> <includes> <include>README</include> Modified: cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml (original) +++ cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml Thu Aug 15 20:40:29 2013 @@ -82,11 +82,6 @@ </dependency> <dependency> - <groupId>org.apache.servicemix.bundles</groupId> - <artifactId>org.apache.servicemix.bundles.jdom</artifactId> - <version>${jdom.version}</version> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> @@ -101,6 +96,17 @@ <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> Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java?rev=1514476&view=auto ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java (added) +++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java Thu Aug 15 20:40:29 2013 @@ -0,0 +1,79 @@ +/** + * 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.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.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.xml.sax.SAXException; +import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType; +import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationsType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class DecorationParser { + private static final Logger LOG = LoggerFactory.getLogger(ServiceDecoratorImpl.class); + 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 (JAXBException e) { + throw new RuntimeException(e.getMessage(), e); + } catch (SAXException e) { + throw new RuntimeException("Error loading decorations schema", e); + } + + } + + List<ServiceDecorationType> getDecorations(URL resourceURL) { + if (resourceURL == null) { + return new ArrayList<ServiceDecorationType>(); + } + try { + 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(); + } catch (Exception ex) { + LOG.warn("Problem parsing: " + resourceURL, ex); + return new ArrayList<ServiceDecorationType>(); + } + } +} Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java (original) +++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java Thu Aug 15 20:40:29 2013 @@ -51,7 +51,7 @@ public class InterfaceRule implements Ru public synchronized void addProperty(String name, String value, String type) { Object obj = value; - if (!String.class.getName().equals(type)) { + if (type != null && !String.class.getName().equals(type)) { try { Class<?> cls = getClass().getClassLoader().loadClass(type); Constructor<?> ctor = cls.getConstructor(new Class[] {String.class}); Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java (original) +++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java Thu Aug 15 20:40:29 2013 @@ -26,72 +26,56 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.Namespace; -import org.jdom.input.SAXBuilder; +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); } } - @SuppressWarnings("unchecked") void addDecorations(Bundle bundle) { - Namespace ns = Namespace.getNamespace("http://cxf.apache.org/xmlns/service-decoration/1.0.0"); - for (Element decoration : getDecorationElements(bundle)) { - for (Element match : (List<Element>) decoration.getChildren("match", ns)) { - InterfaceRule m = new InterfaceRule(bundle, match.getAttributeValue("interface")); - for (Element propMatch : (List<Element>) match.getChildren("match-property", ns)) { - m.addPropMatch(propMatch.getAttributeValue("name"), propMatch.getAttributeValue("value")); - } - for (Element addProp : (List<Element>) match.getChildren("add-property", ns)) { - m.addProperty(addProp.getAttributeValue("name"), - addProp.getAttributeValue("value"), - addProp.getAttributeValue("type", String.class.getName())); - } - decorations.add(m); + for (ServiceDecorationType decoration : getDecorationElements(bundle)) { + for (MatchType match : decoration.getMatch()) { + decorations.add(getRule(bundle, match)); } } } - @SuppressWarnings({ "rawtypes", "unchecked" }) - static List<Element> getDecorationElements(Bundle bundle) { - Enumeration entries = bundle.findEntries("OSGI-INF/remote-service", "*.xml", false); - return getDecorationElementsForEntries(entries); + 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; } - /** - * Only for tests - * @param entries - * @return - */ - @SuppressWarnings("unchecked") - static List<Element> getDecorationElementsForEntries(Enumeration<URL> entries) { + List<ServiceDecorationType> getDecorationElements(Bundle bundle) { + @SuppressWarnings("rawtypes") + Enumeration entries = bundle.findEntries("OSGI-INF/remote-service", "*.xml", false); if (entries == null) { return Collections.emptyList(); } - List<Element> elements = new ArrayList<Element>(); + List<ServiceDecorationType> elements = new ArrayList<ServiceDecorationType>(); while (entries.hasMoreElements()) { - URL resourceURL = entries.nextElement(); - try { - Document d = new SAXBuilder().build(resourceURL.openStream()); - Namespace ns = Namespace.getNamespace("http://cxf.apache.org/xmlns/service-decoration/1.0.0"); - elements.addAll(d.getRootElement().getChildren("service-decoration", ns)); - } catch (Exception ex) { - LOG.warn("Problem parsing: " + resourceURL, ex); - } + elements.addAll(parser.getDecorations((URL)entries.nextElement())); } return elements; } Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/service-decoration.xsd URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/service-decoration.xsd?rev=1514476&view=auto ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/service-decoration.xsd (added) +++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/service-decoration.xsd Thu Aug 15 20:40:29 2013 @@ -0,0 +1,67 @@ +<?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 Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/service-decoration.xsd ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java?rev=1514476&view=auto ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java (added) +++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java Thu Aug 15 20:40:29 2013 @@ -0,0 +1,60 @@ +/** + * 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.List; + +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() { + 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() { + List<ServiceDecorationType> elements = new DecorationParser().getDecorations(null); + Assert.assertEquals(0, elements.size()); + } +} Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java (original) +++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java Thu Aug 15 20:40:29 2013 @@ -21,9 +21,7 @@ package org.apache.cxf.dosgi.dsw.decorat import java.net.URL; import java.util.Arrays; import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; -import java.util.List; import java.util.Map; import junit.framework.Assert; @@ -31,7 +29,6 @@ import junit.framework.TestCase; import org.easymock.EasyMock; import org.easymock.IAnswer; -import org.jdom.Element; import org.osgi.framework.Bundle; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; @@ -44,20 +41,6 @@ public class ServiceDecoratorImplTest ex private static final URL RES_SD0 = getResource("/test-resources/sd0.xml"); private static final URL RES_SD_1 = getResource("/test-resources/sd-1.xml"); - public void testGetDecoratorElements() { - Enumeration<URL> urls = Collections.enumeration(Collections.singletonList(RES_SD)); - - List<Element> elements = ServiceDecoratorImpl.getDecorationElementsForEntries(urls); - assertEquals(1, elements.size()); - assertEquals("service-decoration", elements.get(0).getName()); - assertEquals("http://cxf.apache.org/xmlns/service-decoration/1.0.0", elements.get(0).getNamespaceURI()); - } - - public void testGetDecoratorElements2() { - List<Element> elements = ServiceDecoratorImpl.getDecorationElementsForEntries(null); - assertEquals(0, elements.size()); - } - public void testAddRemoveDecorations() { final Map<String, Object> serviceProps = new HashMap<String, Object>(); serviceProps.put(Constants.OBJECTCLASS, new String[] {"org.acme.foo.Bar"}); Modified: cxf/dosgi/trunk/parent/pom.xml URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/parent/pom.xml?rev=1514476&r1=1514475&r2=1514476&view=diff ============================================================================== --- cxf/dosgi/trunk/parent/pom.xml (original) +++ cxf/dosgi/trunk/parent/pom.xml Thu Aug 15 20:40:29 2013 @@ -75,8 +75,6 @@ <slf4j.version>1.6.4</slf4j.version> <felix.plugin.version>2.4.0</felix.plugin.version> <exam.version>2.6.0</exam.version> - <jdom.version>1.1.2_1</jdom.version> - <cxf.resources.base.path /> <cxf.checkstyle.extension /> </properties>
