diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-09 22:01:43 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-09 22:01:43 +0000 |
commit | b92698dff171642b1e7944a53acefd08d0324460 (patch) | |
tree | 70923050a486771188463c6870c74b1a04a72c2b /java/sca | |
parent | ab419e5683bdce60404608b9b75b0b94e2940437 (diff) |
Separate ServiceDescription as interfaces
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@751863 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r-- | java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java | 45 | ||||
-rw-r--r-- | java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java | 29 | ||||
-rw-r--r-- | java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java (renamed from java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java) | 19 | ||||
-rw-r--r-- | java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java | 36 | ||||
-rw-r--r-- | java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java | 38 | ||||
-rw-r--r-- | java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java | 1 |
6 files changed, 148 insertions, 20 deletions
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 new file mode 100644 index 0000000000..96ad202b31 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.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.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 new file mode 100644 index 0000000000..e96aca650d --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.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; + +import java.util.List; + + +/** + * OSGi RFC 119 service descriptions + */ +public interface ServiceDescriptions extends List<ServiceDescription> { +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java index 72cc014506..66c703f55f 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java @@ -17,29 +17,22 @@ * under the License. */ -package org.apache.tuscany.sca.implementation.osgi.xml; +package org.apache.tuscany.sca.implementation.osgi.impl; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.xml.namespace.QName; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; /** * The OSGi RFC 119 description of a remote OSGi service */ -public class ServiceDescription { - public final static String REMOTE_SERVICE_FOLDER = "OSGI-INF/remote-service"; - public final static String SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0"; - public final static QName SERVICE_DESCRIPTIONS_QNAME = new QName(SD_NS, "service-descriptions"); - public final static QName SERVICE_DESCRIPTION_QNAME = new QName(SD_NS, "service-description"); - public final static String REMOTE_SERVICE_HEADER = "Remote-Service"; - public final static String PROP_SERVICE_INTENTS = "service.intents"; - public final static String PROP_REQUIRES_INTENTS = "osgi.remote.requires.intents"; - public final static String PROP_CONFIGURATION_TYPE = "osgi.remote.configuration.type"; - public final static String CONFIGURATION_TYPE_SCA = "sca"; - public final static String PROP_CONFIGURATION_SCA_BINDINGS = "osgi.remote.configuration.sca.bindings"; +public class ServiceDescriptionImpl implements ServiceDescription { + public ServiceDescriptionImpl() { + super(); + } private List<String> interfaces = new ArrayList<String>(); private Map<String, Object> properties = new HashMap<String, Object>(); 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 new file mode 100644 index 0000000000..6573c04c96 --- /dev/null +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java @@ -0,0 +1,36 @@ +/* + * 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 java.util.ArrayList; + +import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; + +/** + * + */ +public class ServiceDescriptionsImpl extends ArrayList<ServiceDescription> implements ServiceDescriptions { + private static final long serialVersionUID = 6205649013621747968L; + + public ServiceDescriptionsImpl() { + super(); + } +} 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 313f17adf8..d2006205ea 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 @@ -19,13 +19,20 @@ package org.apache.tuscany.sca.implementation.osgi.xml; -import java.util.ArrayList; -import java.util.List; - import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +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.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; /* <?xml version="1.0" encoding="UTF-8"?> @@ -48,18 +55,18 @@ import javax.xml.stream.XMLStreamReader; </service-description> </service-descriptions> */ -public class ServiceDescriptionsProcessor { +public class ServiceDescriptionsProcessor implements StAXArtifactProcessor<ServiceDescriptions> { - public List<ServiceDescription> read(XMLStreamReader reader) throws XMLStreamException { + public ServiceDescriptions read(XMLStreamReader reader) throws XMLStreamException { int event = reader.getEventType(); - List<ServiceDescription> sds = new ArrayList<ServiceDescription>(); + ServiceDescriptions sds = new ServiceDescriptionsImpl(); ServiceDescription sd = null; while (true) { switch (event) { case XMLStreamConstants.START_ELEMENT: QName name = reader.getName(); if (ServiceDescription.SERVICE_DESCRIPTION_QNAME.equals(name)) { - sd = new ServiceDescription(); + sd = new ServiceDescriptionImpl(); sds.add(sd); } else if ("provide".equals(name.getLocalPart())) { String interfaceName = reader.getAttributeValue(null, "interface"); @@ -118,4 +125,21 @@ public class ServiceDescriptionsProcessor { } } } + + public QName getArtifactType() { + return ServiceDescription.SERVICE_DESCRIPTIONS_QNAME; + } + + public void write(ServiceDescriptions model, XMLStreamWriter writer) throws ContributionWriteException, + XMLStreamException { + // TODO: To be implemented + } + + public Class<ServiceDescriptions> getModelType() { + return ServiceDescriptions.class; + } + + public void resolve(ServiceDescriptions model, ModelResolver resolver) throws ContributionResolveException { + // TODO: To be implemented + } } 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 88b6227204..39aa491ad7 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,7 @@ import java.util.List; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamReader; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; |