diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-09 22:25:59 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-09 22:25:59 +0000 |
commit | fb958a75b99c50cfd90d3d6dd22c5e55447558b5 (patch) | |
tree | 55a209c1dcc1658de8c3a006f681f66ffe697455 /java/sca/modules/implementation-osgi/src | |
parent | b92698dff171642b1e7944a53acefd08d0324460 (diff) |
Hook the model and processors with the Tuscany StAX processing pattern
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@751884 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-osgi/src')
17 files changed, 271 insertions, 46 deletions
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java new file mode 100644 index 0000000000..d7296e24bb --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java @@ -0,0 +1,33 @@ +/* + * 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.tuscany.sca.implementation.osgi; + +import org.apache.tuscany.sca.implementation.osgi.impl.ServiceDescriptionsFactoryImpl; + +/** + * + */ +public class DefaultServiceDescriptionsFactory extends ServiceDescriptionsFactoryImpl { + + public DefaultServiceDescriptionsFactory() { + super(); + } + +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java index 964ec6e92d..1b393a5ac0 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.implementation.osgi; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.assembly.Implementation; import org.osgi.framework.Bundle; @@ -29,6 +31,13 @@ import org.osgi.framework.Bundle; * @version $Rev$ $Date$ */ public interface OSGiImplementation extends Implementation, Extensible { + String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; + String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; + + String BUNDLE_SYMBOLICNAME = "bundleSymbolicName"; + String BUNDLE_VERSION = "bundleVersion"; + QName IMPLEMENTATION_OSGI = new QName(SCA11_TUSCANY_NS, "implementation.osgi"); + QName PROPERTY_QNAME = new QName(SCA11_TUSCANY_NS, "osgi.property"); String getBundleSymbolicName(); diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java index 8521c9e7d4..0a83624e76 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java @@ -28,4 +28,10 @@ public interface OSGiImplementationFactory { * @return */ OSGiImplementation createOSGiImplementation(); + + /** + * + * @return + */ + OSGiProperty createOSGiProperty(); } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java new file mode 100644 index 0000000000..9a000af031 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java @@ -0,0 +1,37 @@ +/* + * 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.tuscany.sca.implementation.osgi; + +import javax.xml.namespace.QName; + +/** + * <tuscany:osgi.property> + */ +public interface OSGiProperty { + QName OSGI_PROPERTY_QNAME = new QName(OSGiImplementation.SCA11_TUSCANY_NS, "property"); + + String getValue(); + + void setValue(String value); + + String getName(); + + void setName(String name); +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java index 96ad202b31..832e26a48f 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java @@ -22,23 +22,11 @@ package org.apache.tuscany.sca.implementation.osgi; import java.util.List; import java.util.Map; -import javax.xml.namespace.QName; /** * The OSGi RFC 119 description of a remote OSGi service */ public interface ServiceDescription { - String REMOTE_SERVICE_FOLDER = "OSGI-INF/remote-service"; - String SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0"; - QName SERVICE_DESCRIPTIONS_QNAME = new QName(SD_NS, "service-descriptions"); - QName SERVICE_DESCRIPTION_QNAME = new QName(SD_NS, "service-description"); - String REMOTE_SERVICE_HEADER = "Remote-Service"; - String PROP_SERVICE_INTENTS = "service.intents"; - String PROP_REQUIRES_INTENTS = "osgi.remote.requires.intents"; - String PROP_CONFIGURATION_TYPE = "osgi.remote.configuration.type"; - String CONFIGURATION_TYPE_SCA = "sca"; - String PROP_CONFIGURATION_SCA_BINDINGS = "osgi.remote.configuration.sca.bindings"; - List<String> getInterfaces(); Map<String, Object> getProperties(); diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java index e96aca650d..36968615c0 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java @@ -21,9 +21,22 @@ package org.apache.tuscany.sca.implementation.osgi; import java.util.List; +import javax.xml.namespace.QName; + /** * OSGi RFC 119 service descriptions */ public interface ServiceDescriptions extends List<ServiceDescription> { + + String REMOTE_SERVICE_FOLDER = "OSGI-INF/remote-service"; + String OSGI_SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0"; + QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "service-descriptions"); + QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "service-description"); + String REMOTE_SERVICE_HEADER = "Remote-Service"; + String PROP_SERVICE_INTENTS = "service.intents"; + String PROP_REQUIRES_INTENTS = "osgi.remote.requires.intents"; + String PROP_CONFIGURATION_TYPE = "osgi.remote.configuration.type"; + String CONFIGURATION_TYPE_SCA = "sca"; + String PROP_CONFIGURATION_SCA_BINDINGS = "osgi.remote.configuration.sca.bindings"; } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java new file mode 100644 index 0000000000..0e4c51b1f9 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java @@ -0,0 +1,29 @@ +/* + * 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.tuscany.sca.implementation.osgi; + +/** + * The factory interface to create OSGi RFC 119 service descriptions + */ +public interface ServiceDescriptionsFactory { + ServiceDescriptions createServiceDescriptions(); + + ServiceDescription createServiceDescription(); +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java index 79da7708a9..80b68d1728 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.implementation.osgi.impl; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory; +import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; /** * @@ -38,4 +39,8 @@ public class OSGiImplementationFactoryImpl implements OSGiImplementationFactory return new OSGiImplementationImpl(factoryExtensionPoint); } + public OSGiProperty createOSGiProperty() { + return new OSGiPropertyImpl(); + } + } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java new file mode 100644 index 0000000000..a3944c66c0 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java @@ -0,0 +1,51 @@ +/* + * 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.tuscany.sca.implementation.osgi.impl; + +import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; + +/** + * Implementation of OSGiProperty + */ +public class OSGiPropertyImpl implements OSGiProperty { + protected OSGiPropertyImpl() { + super(); + } + + private String name; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java index 66c703f55f..eeacdb9702 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java @@ -30,7 +30,7 @@ import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; * The OSGi RFC 119 description of a remote OSGi service */ public class ServiceDescriptionImpl implements ServiceDescription { - public ServiceDescriptionImpl() { + protected ServiceDescriptionImpl() { super(); } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java new file mode 100644 index 0000000000..8cd3867610 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java @@ -0,0 +1,43 @@ +/* + * 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.tuscany.sca.implementation.osgi.impl; + +import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; + +/** + * The factory implementation + */ +public class ServiceDescriptionsFactoryImpl implements ServiceDescriptionsFactory { + + protected ServiceDescriptionsFactoryImpl() { + super(); + } + + public ServiceDescription createServiceDescription() { + return new ServiceDescriptionImpl(); + } + + public ServiceDescriptions createServiceDescriptions() { + return new ServiceDescriptionsImpl(); + } + +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java index 6573c04c96..c249c053a4 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java @@ -30,7 +30,7 @@ import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; public class ServiceDescriptionsImpl extends ArrayList<ServiceDescription> implements ServiceDescriptions { private static final long serialVersionUID = 6205649013621747968L; - public ServiceDescriptionsImpl() { + protected ServiceDescriptionsImpl() { super(); } } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java index 3113c1d5be..f5fc2e3747 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java @@ -18,19 +18,17 @@ */ package org.apache.tuscany.sca.implementation.osgi.xml; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI; -import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import static org.apache.tuscany.sca.implementation.osgi.OSGiImplementation.BUNDLE_SYMBOLICNAME; +import static org.apache.tuscany.sca.implementation.osgi.OSGiImplementation.BUNDLE_VERSION; +import static org.apache.tuscany.sca.implementation.osgi.OSGiImplementation.IMPLEMENTATION_OSGI; -import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.StringTokenizer; import javax.xml.namespace.QName; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; @@ -48,14 +46,12 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ClassReference; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl; import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationImpl; import org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationActivator; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; @@ -63,10 +59,6 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.Version; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; /** * @@ -77,17 +69,6 @@ import org.w3c.dom.Node; * @version $Rev$ $Date$ */ public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiImplementation> { - public final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; - public final static String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - - public static final QName IMPLEMENTATION_OSGI = new QName(SCA11_TUSCANY_NS, "implementation.osgi"); - - private static final String BUNDLE_SYMBOLICNAME = "bundleSymbolicName"; - private static final String BUNDLE_VERSION = "bundleVersion"; - - private static final QName PROPERTIES_QNAME = new QName(SCA11_TUSCANY_NS, "properties"); - private static final QName PROPERTY_QNAME = new QName(SCA11_TUSCANY_NS, "property"); - private JavaInterfaceFactory javaInterfaceFactory; private AssemblyFactory assemblyFactory; private FactoryExtensionPoint modelFactories; @@ -176,7 +157,7 @@ public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiIm int next = reader.next(); if (next == END_ELEMENT && IMPLEMENTATION_OSGI.equals(reader.getName())) { break; - } else if (next == START_ELEMENT && PROPERTIES_QNAME.equals(reader.getName())) { + } else if (next == START_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) { // FIXME: This is temporary code which allows reference and service properties used // for filtering OSGi services to be specified in <implementation.osgi/> diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java index d2006205ea..bef07d159d 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java @@ -29,10 +29,11 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; -import org.apache.tuscany.sca.implementation.osgi.impl.ServiceDescriptionImpl; -import org.apache.tuscany.sca.implementation.osgi.impl.ServiceDescriptionsImpl; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; +import org.apache.tuscany.sca.monitor.Monitor; /* <?xml version="1.0" encoding="UTF-8"?> @@ -56,17 +57,24 @@ import org.apache.tuscany.sca.implementation.osgi.impl.ServiceDescriptionsImpl; </service-descriptions> */ public class ServiceDescriptionsProcessor implements StAXArtifactProcessor<ServiceDescriptions> { + private ServiceDescriptionsFactory factory; + private Monitor monitor; + + public ServiceDescriptionsProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { + this.monitor = monitor; + this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class); + } public ServiceDescriptions read(XMLStreamReader reader) throws XMLStreamException { int event = reader.getEventType(); - ServiceDescriptions sds = new ServiceDescriptionsImpl(); + ServiceDescriptions sds = factory.createServiceDescriptions(); ServiceDescription sd = null; while (true) { switch (event) { case XMLStreamConstants.START_ELEMENT: QName name = reader.getName(); - if (ServiceDescription.SERVICE_DESCRIPTION_QNAME.equals(name)) { - sd = new ServiceDescriptionImpl(); + if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) { + sd = factory.createServiceDescription(); sds.add(sd); } else if ("provide".equals(name.getLocalPart())) { String interfaceName = reader.getAttributeValue(null, "interface"); @@ -109,11 +117,11 @@ public class ServiceDescriptionsProcessor implements StAXArtifactProcessor<Servi break; case XMLStreamConstants.END_ELEMENT: name = reader.getName(); - if (ServiceDescription.SERVICE_DESCRIPTION_QNAME.equals(name)) { + if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) { // Reset the sd sd = null; } - if (ServiceDescription.SERVICE_DESCRIPTIONS_QNAME.equals(name)) { + if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) { return sds; } break; @@ -127,7 +135,7 @@ public class ServiceDescriptionsProcessor implements StAXArtifactProcessor<Servi } public QName getArtifactType() { - return ServiceDescription.SERVICE_DESCRIPTIONS_QNAME; + return ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME; } public void write(ServiceDescriptions model, XMLStreamWriter writer) throws ContributionWriteException, diff --git a/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index 9ecff71874..b1b37932ab 100644 --- a/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -17,3 +17,4 @@ # Implementation class for the artifact processor extension org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.osgi,model=org.apache.tuscany.sca.implementation.osgi.OSGiImplementation +org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsProcessor;qname=http://www.osgi.org/xmlns/sd/v1.0.0#service-descriptions;model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions diff --git a/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory b/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory new file mode 100644 index 0000000000..0d01b7d6a5 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory @@ -0,0 +1,17 @@ +# 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.
+org.apache.tuscany.sca.implementation.osgi.DefaultServiceDescriptionsFactory
diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java index 39aa491ad7..7a4ae3e6de 100644 --- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java +++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java @@ -25,6 +25,8 @@ import java.util.List; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamReader; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; import org.junit.AfterClass; import org.junit.Assert; @@ -68,7 +70,9 @@ public class ServiceDescriptionsTestCase { @Test public void testLoad() throws Exception { - ServiceDescriptionsProcessor processor = new ServiceDescriptionsProcessor(); + ServiceDescriptionsProcessor processor = + new ServiceDescriptionsProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()), + null); List<ServiceDescription> descriptions = processor.read(reader); Assert.assertEquals(2, descriptions.size()); System.out.println(descriptions); |