From a7c1a39d8c3c4ef4d5878dbff726085082a17e8a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:09:31 +0000 Subject: Moving 2.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835136 13f79535-47bb-0310-9956-ffa450edef68 --- .../osgi/DefaultOSGiImplementationFactory.java | 34 -- .../osgi/DefaultServiceDescriptionsFactory.java | 33 -- .../implementation/osgi/OSGiImplementation.java | 53 ---- .../osgi/OSGiImplementationFactory.java | 37 --- .../sca/implementation/osgi/OSGiProperty.java | 53 ---- .../implementation/osgi/ServiceDescription.java | 40 --- .../implementation/osgi/ServiceDescriptions.java | 36 --- .../osgi/ServiceDescriptionsFactory.java | 29 -- .../osgi/impl/OSGiImplementationFactoryImpl.java | 46 --- .../osgi/impl/OSGiImplementationImpl.java | 116 ------- .../implementation/osgi/impl/OSGiPropertyImpl.java | 51 --- .../osgi/impl/ServiceDescriptionImpl.java | 51 --- .../osgi/impl/ServiceDescriptionsFactoryImpl.java | 43 --- .../osgi/impl/ServiceDescriptionsImpl.java | 36 --- .../osgi/xml/BluePrintComponentsProcessor.java | 146 --------- .../osgi/xml/OSGiComponentProcessor.java | 175 ----------- .../osgi/xml/OSGiImplementationActivator.java | 47 --- .../osgi/xml/OSGiImplementationProcessor.java | 343 --------------------- .../osgi/xml/OSGiPropertyProcessor.java | 105 ------- .../xml/ServiceDescriptionsDocumentProcessor.java | 99 ------ .../osgi/xml/ServiceDescriptionsModelResolver.java | 58 ---- .../osgi/xml/ServiceDescriptionsProcessor.java | 153 --------- .../src/main/resources/META-INF/definitions.xml | 37 --- ...ca.contribution.processor.StAXArtifactProcessor | 21 -- ...sca.contribution.processor.URLArtifactProcessor | 19 -- ...tuscany.sca.contribution.resolver.ModelResolver | 17 - ...a.implementation.osgi.OSGiImplementationFactory | 18 -- ....implementation.osgi.ServiceDescriptionsFactory | 17 - .../impl-osgi-validation-messages.properties | 26 -- .../java/calculator/dosgi/CalculatorService.java | 39 --- .../calculator/dosgi/operations/AddService.java | 31 -- .../calculator/dosgi/operations/DivideService.java | 31 -- .../dosgi/operations/MultiplyService.java | 31 -- .../dosgi/operations/SubtractService.java | 31 -- .../xml/BluePrintComponentsProcessorTestCase.java | 89 ------ .../osgi/xml/OSGiComponentProcessorTestCase.java | 86 ------ .../osgi/xml/OSGiReadImplTestCase.java | 138 --------- .../osgi/xml/ServiceDescriptionsTestCase.java | 99 ------ .../implementation/osgi/xml/TestModelResolver.java | 104 ------- .../resources/OSGI-INF/calculator-component.xml | 36 --- .../resources/OSGI-INF/sca/bundle.componentType | 54 ---- .../src/test/resources/osgitest.composite | 35 --- 42 files changed, 2743 deletions(-) delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType delete mode 100644 branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/osgitest.composite (limited to 'branches/sca-java-2.0-M3/modules/implementation-osgi/src') diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java deleted file mode 100644 index 545898fe5f..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java +++ /dev/null @@ -1,34 +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.tuscany.sca.implementation.osgi; - -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationFactoryImpl; - -/** - * - */ -public class DefaultOSGiImplementationFactory extends OSGiImplementationFactoryImpl { - - public DefaultOSGiImplementationFactory(FactoryExtensionPoint factoryExtensionPoint) { - super(factoryExtensionPoint); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java deleted file mode 100644 index d7296e24bb..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java +++ /dev/null @@ -1,33 +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.tuscany.sca.implementation.osgi; - -import org.apache.tuscany.sca.implementation.osgi.impl.ServiceDescriptionsFactoryImpl; - -/** - * - */ -public class DefaultServiceDescriptionsFactory extends ServiceDescriptionsFactoryImpl { - - public DefaultServiceDescriptionsFactory() { - super(); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java deleted file mode 100644 index 4551821f5a..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java +++ /dev/null @@ -1,53 +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.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; - -/** - * - * The model representing an OSGi implementation in an SCA assembly model. - * - * @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"); - - String getBundleSymbolicName(); - - void setBundleSymbolicName(String name); - - String getBundleVersion(); - - void setBundleVersion(String version); - - Bundle getBundle(); - - void setBundle(Bundle bundle); - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java deleted file mode 100644 index 0a83624e76..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java +++ /dev/null @@ -1,37 +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.tuscany.sca.implementation.osgi; - -/** - * The factory interface to create OSGiImplementation instances - */ -public interface OSGiImplementationFactory { - /** - * Create a new instance of OSGiImplementation - * @return - */ - OSGiImplementation createOSGiImplementation(); - - /** - * - * @return - */ - OSGiProperty createOSGiProperty(); -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java deleted file mode 100644 index 26b588a099..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java +++ /dev/null @@ -1,53 +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.tuscany.sca.implementation.osgi; - -import javax.xml.namespace.QName; - -/** - * - */ -public interface OSGiProperty { - String NAME = "name"; - QName PROPERTY_QNAME = new QName(OSGiImplementation.SCA11_TUSCANY_NS, "osgi.property"); - - /** - * Standard OSGi property names - */ - String OSGI_REMOTE = "osgi.remote"; - String SERVICE_INTENTS = "service.intents"; - String OSGI_REMOTE_INTERFACES = "osgi.remote.interfaces"; - String OSGI_REMOTE_INTENTS = "osgi.remote.requires.intents"; - String OSGI_REMOTE_CONFIGURATION_TYPE = "osgi.remote.configuration.type"; - String SCA_BINDINGS = "osgi.remote.configuration.sca.bindings"; - String SCA_REFERENCE = "osgi.remote.configuration.sca.reference"; - String SCA_SERVICE = "osgi.remote.configuration.sca.service"; - String SCA_REFERENCE_BINDING = "osgi.remote.configuration.sca.reference.binding"; - String SCA_SERVICE_BINDING = "osgi.remote.configuration.sca.service.binding"; - String OSGI_REMOTE_CONFIGURATION_TYPE_SCA = "sca"; - - String getValue(); - - void setValue(String value); - - String getName(); - - void setName(String name); -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java deleted file mode 100644 index 119d7ed657..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java +++ /dev/null @@ -1,40 +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.tuscany.sca.implementation.osgi; - -import java.util.List; -import java.util.Map; - -/** - * The OSGi RFC 119 description of a remote OSGi service - */ -public interface ServiceDescription { - /** - * Get a list of interfaces - * @return - */ - List getInterfaces(); - - /** - * Get a list of properties - * @return - */ - Map getProperties(); -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java deleted file mode 100644 index 35866938d6..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java +++ /dev/null @@ -1,36 +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.tuscany.sca.implementation.osgi; - -import java.util.List; - -import javax.xml.namespace.QName; - -/** - * OSGi RFC 119 service descriptions - */ -public interface ServiceDescriptions extends List { - - 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"; -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java deleted file mode 100644 index 0e4c51b1f9..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java +++ /dev/null @@ -1,29 +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.tuscany.sca.implementation.osgi; - -/** - * The factory interface to create OSGi RFC 119 service descriptions - */ -public interface ServiceDescriptionsFactory { - ServiceDescriptions createServiceDescriptions(); - - ServiceDescription createServiceDescription(); -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java deleted file mode 100644 index 80b68d1728..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java +++ /dev/null @@ -1,46 +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.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; - -/** - * - */ -public class OSGiImplementationFactoryImpl implements OSGiImplementationFactory { - private final FactoryExtensionPoint factoryExtensionPoint; - - public OSGiImplementationFactoryImpl(FactoryExtensionPoint factoryExtensionPoint) { - super(); - this.factoryExtensionPoint = factoryExtensionPoint; - } - - public OSGiImplementation createOSGiImplementation() { - return new OSGiImplementationImpl(factoryExtensionPoint); - } - - public OSGiProperty createOSGiProperty() { - return new OSGiPropertyImpl(); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java deleted file mode 100644 index 41deef131f..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java +++ /dev/null @@ -1,116 +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.tuscany.sca.implementation.osgi.impl; - -import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; -import org.osgi.framework.Bundle; -import org.osgi.framework.Constants; - -/** - * OSGi implementation - * All attributes from have getters in this class - * This class implements OSGiImplementationInterface which is associated with OSGiImplementationProvider. - * - * @version $Rev$ $Date$ - */ -public class OSGiImplementationImpl extends ImplementationImpl implements OSGiImplementation { - - private String bundleSymbolicName; - private String bundleVersion; - private Bundle osgiBundle; - - private FactoryExtensionPoint modelFactories; - - protected OSGiImplementationImpl(FactoryExtensionPoint modelFactories) { - this.modelFactories = modelFactories; - } - - public OSGiImplementationImpl(FactoryExtensionPoint modelFactories, String bundleSymbolicName, String bundleVersion) { - - super(); - this.bundleSymbolicName = bundleSymbolicName; - this.bundleVersion = bundleVersion; - this.modelFactories = modelFactories; - } - - public String getBundleSymbolicName() { - return bundleSymbolicName; - } - - public String getBundleVersion() { - return bundleVersion; - } - - public FactoryExtensionPoint getModelFactories() { - return modelFactories; - } - - /** - * Since OSGi implementation annotations may not be processed until much later, leave it to - * the OSGi invoker to decide whether pass-by-reference is allowed. - * @return - */ - public boolean isAllowsPassByReference() { - return true; - } - - public Bundle getBundle() { - return osgiBundle; - } - - public void setBundle(Bundle osgiBundle) { - this.osgiBundle = osgiBundle; - if (osgiBundle != null) { - this.bundleSymbolicName = osgiBundle.getSymbolicName(); - this.bundleVersion = (String)osgiBundle.getHeaders().get(Constants.BUNDLE_VERSION); - } - } - - private boolean areEqual(Object obj1, Object obj2) { - if (obj1 == obj2) - return true; - if (obj1 == null || obj2 == null) - return false; - return obj1.equals(obj2); - } - - @Override - public boolean equals(Object obj) { - - if (!(obj instanceof OSGiImplementationImpl)) - return super.equals(obj); - OSGiImplementationImpl impl = (OSGiImplementationImpl)obj; - if (!areEqual(bundleSymbolicName, impl.bundleSymbolicName)) - return false; - if (!areEqual(bundleVersion, impl.bundleVersion)) - return false; - return super.equals(obj); - } - - public void setBundleSymbolicName(String bundleSymbolicName) { - this.bundleSymbolicName = bundleSymbolicName; - } - - public void setBundleVersion(String bundleVersion) { - this.bundleVersion = bundleVersion; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java deleted file mode 100644 index ec8b98f53f..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java +++ /dev/null @@ -1,51 +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.tuscany.sca.implementation.osgi.impl; - -import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; - -/** - * Implementation of OSGiProperty - */ -public class OSGiPropertyImpl implements OSGiProperty { - public 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/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java deleted file mode 100644 index b990cf5980..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java +++ /dev/null @@ -1,51 +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.tuscany.sca.implementation.osgi.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; - -/** - * The OSGi RFC 119 description of a remote OSGi service - */ -public class ServiceDescriptionImpl implements ServiceDescription { - private List interfaces = new ArrayList(); - private Map properties = new HashMap(); - - protected ServiceDescriptionImpl() { - super(); - } - - public List getInterfaces() { - return interfaces; - } - - public Map getProperties() { - return properties; - } - - public String toString() { - return "service-description: interfaces=" + interfaces + " properties=" + properties; - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java deleted file mode 100644 index 8cd3867610..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java +++ /dev/null @@ -1,43 +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.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/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java deleted file mode 100644 index c249c053a4..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java +++ /dev/null @@ -1,36 +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.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 implements ServiceDescriptions { - private static final long serialVersionUID = 6205649013621747968L; - - protected ServiceDescriptionsImpl() { - super(); - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java deleted file mode 100644 index 92b0316b9c..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java +++ /dev/null @@ -1,146 +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.tuscany.sca.implementation.osgi.xml; - -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.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -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.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.monitor.Monitor; - -/* - - - - - - - - - - - - - - - - - - - - - - - - -*/ -public class BluePrintComponentsProcessor implements StAXArtifactProcessor { - private static final String BLUE_PRINT_NS = "http://www.osgi.org/xmlns/blueprint/v1.0.0"; - private static final String COMPOMENTS = "components"; - private static final QName COMPONENTS_QNAME = new QName(BLUE_PRINT_NS, COMPOMENTS); - - private AssemblyFactory factory; - private JavaInterfaceFactory javaInterfaceFactory; - private Monitor monitor; - - public BluePrintComponentsProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.monitor = monitor; - this.factory = modelFactories.getFactory(AssemblyFactory.class); - this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - } - - public ComponentType read(XMLStreamReader reader) throws XMLStreamException { - int event = reader.getEventType(); - ComponentType componentType = factory.createComponentType(); - while (true) { - switch (event) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - if (COMPONENTS_QNAME.equals(name)) { - // - } else if ("reference".equals(name.getLocalPart())) { - Reference ref = factory.createReference(); - ref.setName(reader.getAttributeValue(null, "id")); - String interfaceName = reader.getAttributeValue(null, "interface"); - InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); - ref.setInterfaceContract(interfaceContract); - JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(); - javaInterface.setUnresolved(true); - javaInterface.setName(interfaceName); - interfaceContract.setInterface(javaInterface); - componentType.getReferences().add(ref); - } else if ("service".equals(name.getLocalPart())) { - Service service = factory.createService(); - String interfaceName = reader.getAttributeValue(null, "interface"); - InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); - service.setInterfaceContract(interfaceContract); - JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(); - javaInterface.setUnresolved(true); - javaInterface.setName(interfaceName); - interfaceContract.setInterface(javaInterface); - componentType.getServices().add(service); - } - break; - case XMLStreamConstants.END_ELEMENT: - name = reader.getName(); - if (COMPONENTS_QNAME.equals(name)) { - return componentType; - } - break; - } - if (reader.hasNext()) { - event = reader.next(); - } else { - return componentType; - } - } - } - - public QName getArtifactType() { - return COMPONENTS_QNAME; - } - - public void write(ComponentType model, XMLStreamWriter writer) throws ContributionWriteException, - XMLStreamException { - // TODO: To be implemented - } - - public Class getModelType() { - return ComponentType.class; - } - - public void resolve(ComponentType model, ModelResolver resolver) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java deleted file mode 100644 index d70458053e..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java +++ /dev/null @@ -1,175 +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.tuscany.sca.implementation.osgi.xml; - -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.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -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.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.monitor.Monitor; - -/* - - - - - - - - - - - - -*/ -public class OSGiComponentProcessor implements StAXArtifactProcessor { - private static final String OSGI_SCR_NS = "http://www.osgi.org/xmlns/scr/v1.0.0"; - private static final String COMPOMENT = "component"; - private static final QName COMPONENT_QNAME = new QName(OSGI_SCR_NS, COMPOMENT); - - private AssemblyFactory factory; - private JavaInterfaceFactory javaInterfaceFactory; - private Monitor monitor; - - public OSGiComponentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.monitor = monitor; - this.factory = modelFactories.getFactory(AssemblyFactory.class); - this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - } - - public ComponentType read(XMLStreamReader reader) throws XMLStreamException { - int event = reader.getEventType(); - ComponentType componentType = factory.createComponentType(); - while (true) { - switch (event) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - if (COMPONENT_QNAME.equals(name)) { - // - } else if ("reference".equals(name.getLocalPart())) { - Reference ref = factory.createReference(); - ref.setName(reader.getAttributeValue(null, "name")); - String interfaceName = reader.getAttributeValue(null, "interface"); - InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); - ref.setInterfaceContract(interfaceContract); - JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(); - javaInterface.setUnresolved(true); - javaInterface.setName(interfaceName); - interfaceContract.setInterface(javaInterface); - componentType.getReferences().add(ref); - } else if ("provide".equals(name.getLocalPart())) { - Service service = factory.createService(); - String interfaceName = reader.getAttributeValue(null, "interface"); - InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); - service.setInterfaceContract(interfaceContract); - JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(); - javaInterface.setUnresolved(true); - javaInterface.setName(interfaceName); - interfaceContract.setInterface(javaInterface); - componentType.getServices().add(service); - } else if ("property".equals(name.getLocalPart())) { - String propName = reader.getAttributeValue(null, "name"); - String propValue = reader.getAttributeValue(null, "value"); - String propType = reader.getAttributeValue(null, "type"); - if (propType == null) { - propType = "String"; - } - if (propValue == null) { - propValue = reader.getElementText(); - } - if (propValue != null) { - propValue = propValue.trim(); - } - Object prop = propValue; - if ("Integer".equals(propType)) { - prop = Integer.valueOf(propValue); - } else if ("Long".equals(propType)) { - prop = Long.valueOf(propValue); - } else if ("Float".equals(propType)) { - prop = Float.valueOf(propValue); - } else if ("Double".equals(propType)) { - prop = Double.valueOf(propValue); - } else if ("Short".equals(propType)) { - prop = Short.valueOf(propValue); - } else if ("Character".equals(propType)) { - prop = propValue.charAt(0); - } else if ("Byte".equals(propType)) { - prop = Byte.valueOf(propValue); - } else if ("Boolean".equals(propType)) { - prop = Boolean.valueOf(propValue); - } - Property property = factory.createProperty(); - property.setName(propName); - property.setValue(prop); - componentType.getProperties().add(property); - } - break; - case XMLStreamConstants.END_ELEMENT: - name = reader.getName(); - if (COMPONENT_QNAME.equals(name)) { - return componentType; - } - break; - } - if (reader.hasNext()) { - event = reader.next(); - } else { - return componentType; - } - } - } - - public QName getArtifactType() { - return COMPONENT_QNAME; - } - - public void write(ComponentType model, XMLStreamWriter writer) throws ContributionWriteException, - XMLStreamException { - // TODO: To be implemented - } - - public Class getModelType() { - return ComponentType.class; - } - - public void resolve(ComponentType model, ModelResolver resolver) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java deleted file mode 100644 index b604447696..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java +++ /dev/null @@ -1,47 +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.tuscany.sca.implementation.osgi.xml; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -/** - * Bundle activator to receive the BundleContext - */ -public class OSGiImplementationActivator implements BundleActivator { - private static BundleContext bundleContext; - - public void start(BundleContext context) throws Exception { - bundleContext = context; - } - - public void stop(BundleContext context) throws Exception { - bundleContext = null; - } - - public static BundleContext getBundleContext() { - return bundleContext; - } - - static void setBundleContext(BundleContext bundleContext) { - OSGiImplementationActivator.bundleContext = bundleContext; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java deleted file mode 100644 index c3b293ab5d..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java +++ /dev/null @@ -1,343 +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.tuscany.sca.implementation.osgi.xml; - -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.net.URI; -import java.net.URL; -import java.util.List; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -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.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -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; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; -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; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.Version; - -/** - * - * Process an element in a component definition. An instance of - * OSGiImplementation is created. - * Also associates the component type file with the implementation. - * - * @version $Rev$ $Date$ - */ -public class OSGiImplementationProcessor implements StAXArtifactProcessor { - private static final String BUNDLE_COMPONENT_TYPE = "OSGI-INF/sca/bundle.componentType"; - private static final String COMPONENT_TYPE_HEADER = "SCA-ComponentType"; - - private AssemblyFactory assemblyFactory; - private ServiceDescriptionsFactory serviceDescriptionsFactory; - private OSGiImplementationFactory osgiImplementationFactory; - private JavaInterfaceFactory javaInterfaceFactory; - private Monitor monitor; - private ExtensionPointRegistry registry; - private StAXArtifactProcessor artifactProcessor; - - protected OSGiImplementationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.monitor = monitor; - this.serviceDescriptionsFactory = modelFactories.getFactory(ServiceDescriptionsFactory.class); - this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - this.osgiImplementationFactory = modelFactories.getFactory(OSGiImplementationFactory.class); - this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - } - - public OSGiImplementationProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor, Monitor monitor) { - this(registry.getExtensionPoint(FactoryExtensionPoint.class), monitor); - this.artifactProcessor = processor; - this.registry = registry; - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - "impl-osgi-validation-messages", - Severity.ERROR, - model, - message, - (Object[])messageParameters); - monitor.problem(problem); - } - } - - public QName getArtifactType() { - return IMPLEMENTATION_OSGI; - } - - public Class getModelType() { - return OSGiImplementation.class; - } - - public OSGiImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - assert IMPLEMENTATION_OSGI.equals(reader.getName()); - - String bundleSymbolicName = reader.getAttributeValue(null, BUNDLE_SYMBOLICNAME); - String bundleVersion = reader.getAttributeValue(null, BUNDLE_VERSION); - - OSGiImplementation implementation = osgiImplementationFactory.createOSGiImplementation(); - implementation.setBundleSymbolicName(bundleSymbolicName); - implementation.setBundleVersion(bundleVersion); - - implementation.setUnresolved(true); - - // Skip to the end of - while (reader.hasNext()) { - int next = reader.next(); - switch (next) { - case START_ELEMENT: - break; - case END_ELEMENT: - if (IMPLEMENTATION_OSGI.equals(reader.getName())) { - return implementation; - } - break; - } - } - return implementation; - } - - public void resolve(OSGiImplementation impl, ModelResolver resolver) throws ContributionResolveException { - - if (impl == null || !impl.isUnresolved()) - return; - - impl.setUnresolved(false); - - BundleContext bundleContext = OSGiImplementationActivator.getBundleContext(); - if (bundleContext == null) { - // FIXME: What if the OSGi is not started - return; - } - Bundle bundle = null; - for (Bundle b : bundleContext.getBundles()) { - String sn = b.getSymbolicName(); - String ver = (String)b.getHeaders().get(Constants.BUNDLE_VERSION); - if (!impl.getBundleSymbolicName().equals(sn)) { - continue; - } - Version v1 = Version.parseVersion(ver); - Version v2 = Version.parseVersion(impl.getBundleVersion()); - if (v1.equals(v2)) { - bundle = b; - break; - } - } - if (bundle != null) { - impl.setBundle(bundle); - } else { - error("CouldNotLocateOSGiBundle", impl, impl.getBundleSymbolicName()); - //throw new ContributionResolveException("Could not locate OSGi bundle " + - //impl.getBundleSymbolicName()); - return; - } - - try { - if (introspect(impl, resolver, bundle)) { - return; - } - } catch (ContributionReadException e) { - throw new ContributionResolveException(e); - } - - // The bundle may be different from the current contribution - ComponentType componentType = assemblyFactory.createComponentType(); - // Try to find a bundle.componentType for the target bundle - componentType.setURI("OSGI-INF/sca/" + bundle.getSymbolicName() + "/bundle.componentType"); - componentType.setUnresolved(true); - componentType = resolver.resolveModel(ComponentType.class, componentType); - if (componentType.isUnresolved()) { - // Create a new instance to prevent it being treated as reentry - // See org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver.resolveModel(Class, T) - componentType = assemblyFactory.createComponentType(); - // Try a generic one - componentType.setURI(BUNDLE_COMPONENT_TYPE); - componentType = resolver.resolveModel(ComponentType.class, componentType); - } - if (componentType.isUnresolved()) { - // Try to derive it from the service descriptions - if (!deriveFromServiceDescriptions(impl, resolver)) { - error("MissingComponentTypeFile", impl, componentType.getURI()); - } - //throw new ContributionResolveException("missing .componentType side file " + ctURI); - return; - } else { - mergeFromComponentType(impl, componentType, resolver); - } - } - - private boolean deriveFromServiceDescriptions(OSGiImplementation impl, ModelResolver resolver) - throws ContributionResolveException { - // FIXME: How to find the RFC 119 service descriptions in the contribution and - // derive the SCA component type from them? - ServiceDescriptions descriptions = serviceDescriptionsFactory.createServiceDescriptions(); - descriptions = resolver.resolveModel(ServiceDescriptions.class, descriptions); - if (descriptions != null && !descriptions.isEmpty()) { - ComponentType ct = assemblyFactory.createComponentType(); - int index = 0; - for (ServiceDescription ds : descriptions) { - for (String i : ds.getInterfaces()) { - Class cls = getJavaClass(resolver, i); - JavaInterface javaInterface; - try { - javaInterface = javaInterfaceFactory.createJavaInterface(cls); - } catch (InvalidInterfaceException e) { - throw new ContributionResolveException(e); - } - Reference reference = assemblyFactory.createReference(); - JavaInterfaceContract contract = javaInterfaceFactory.createJavaInterfaceContract(); - contract.setInterface(javaInterface); - reference.setInterfaceContract(contract); - String refName = (String)ds.getProperties().get(OSGiProperty.SCA_REFERENCE); - if (refName == null) { - refName = "ref" + (index++); - } - reference.setName(refName); - reference.setUnresolved(false); - ct.getReferences().add(reference); - } - } - mergeFromComponentType(impl, ct, resolver); - return true; - } - return false; - } - - private void mergeFromComponentType(OSGiImplementation impl, ComponentType componentType, ModelResolver resolver) { - List services = componentType.getServices(); - for (Service service : services) { - Interface interfaze = service.getInterfaceContract().getInterface(); - if (interfaze instanceof JavaInterface) { - JavaInterface javaInterface = (JavaInterface)interfaze; - if (javaInterface.getJavaClass() == null) { - javaInterface.setJavaClass(getJavaClass(resolver, javaInterface.getName())); - } - if (service.getInterfaceContract().getCallbackInterface() instanceof JavaInterface) { - JavaInterface callbackInterface = - (JavaInterface)service.getInterfaceContract().getCallbackInterface(); - if (callbackInterface.getJavaClass() == null) { - callbackInterface.setJavaClass(getJavaClass(resolver, callbackInterface.getName())); - } - } - - impl.getServices().add(service); - } - } - - List references = componentType.getReferences(); - for (Reference reference : references) { - Interface interfaze = reference.getInterfaceContract().getInterface(); - if (interfaze instanceof JavaInterface) { - JavaInterface javaInterface = (JavaInterface)interfaze; - if (javaInterface.getJavaClass() == null) { - javaInterface.setJavaClass(getJavaClass(resolver, javaInterface.getName())); - } - impl.getReferences().add(reference); - } else - impl.getReferences().add(reference); - } - - List properties = componentType.getProperties(); - for (Property property : properties) { - impl.getProperties().add(property); - } - impl.setConstrainingType(componentType.getConstrainingType()); - } - - private Class getJavaClass(ModelResolver resolver, String className) { - ClassReference ref = new ClassReference(className); - ref = resolver.resolveModel(ClassReference.class, ref); - return ref.getJavaClass(); - } - - public void write(OSGiImplementation model, XMLStreamWriter writer) throws ContributionWriteException, - XMLStreamException { - String ns = IMPLEMENTATION_OSGI.getNamespaceURI(); - writer.writeStartElement(ns, IMPLEMENTATION_OSGI.getLocalPart()); - writer.writeAttribute(BUNDLE_SYMBOLICNAME, model.getBundleSymbolicName()); - if (model.getBundleVersion() != null) { - writer.writeAttribute(BUNDLE_VERSION, model.getBundleVersion()); - } - writer.writeEndElement(); - } - - private boolean introspect(OSGiImplementation implementation, ModelResolver resolver, Bundle bundle) - throws ContributionReadException, ContributionResolveException { - String componentTypeFile = (String)bundle.getHeaders().get(COMPONENT_TYPE_HEADER); - if (componentTypeFile == null) { - componentTypeFile = BUNDLE_COMPONENT_TYPE; - } - URL url = bundle.getEntry(componentTypeFile); - if (url != null) { - URLArtifactProcessorExtensionPoint processors = - registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - URLArtifactProcessor processor = processors.getProcessor(ComponentType.class); - ComponentType componentType = processor.read(null, URI.create(BUNDLE_COMPONENT_TYPE), url); - artifactProcessor.resolve(componentType, resolver); - mergeFromComponentType(implementation, componentType, resolver); - return true; - } - return false; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java deleted file mode 100644 index 5a8f5c4694..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java +++ /dev/null @@ -1,105 +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.tuscany.sca.implementation.osgi.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.NAME; -import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.PROPERTY_QNAME; - -import javax.xml.namespace.QName; -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.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory; -import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A processor for - */ -public class OSGiPropertyProcessor implements StAXArtifactProcessor { - private OSGiImplementationFactory factory; - private Monitor monitor; - - public OSGiPropertyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.monitor = monitor; - this.factory = modelFactories.getFactory(OSGiImplementationFactory.class); - } - - public OSGiProperty read(XMLStreamReader reader) throws XMLStreamException { - int event = reader.getEventType(); - OSGiProperty prop = null; - while (true) { - switch (event) { - case START_ELEMENT: - QName name = reader.getName(); - if (PROPERTY_QNAME.equals(name)) { - prop = factory.createOSGiProperty(); - prop.setName(reader.getAttributeValue(null, NAME)); - // After the following call, the reader will be positioned at END_ELEMENT - String text = reader.getElementText(); - if (text != null) { - text = text.trim(); - } - prop.setValue(text); - return prop; - } - break; - case END_ELEMENT: - name = reader.getName(); - if (PROPERTY_QNAME.equals(name)) { - return prop; - } - break; - } - if (reader.hasNext()) { - event = reader.next(); - } else { - return prop; - } - } - } - - public QName getArtifactType() { - return PROPERTY_QNAME; - } - - public void write(OSGiProperty model, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - writer.writeStartElement(PROPERTY_QNAME.getNamespaceURI(), PROPERTY_QNAME.getLocalPart()); - writer.writeAttribute(NAME, model.getName()); - writer.writeCharacters(model.getValue()); - writer.writeEndElement(); - } - - public Class getModelType() { - return OSGiProperty.class; - } - - public void resolve(OSGiProperty model, ModelResolver resolver) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java deleted file mode 100644 index b692531a38..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java +++ /dev/null @@ -1,99 +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.tuscany.sca.implementation.osgi.xml; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * The service descriptions document processor - */ -public class ServiceDescriptionsDocumentProcessor implements URLArtifactProcessor { - private XMLInputFactory inputFactory; - private StAXArtifactProcessor extensionProcessor; - - public ServiceDescriptionsDocumentProcessor(FactoryExtensionPoint modelFactories, - StAXArtifactProcessor staxProcessor, - Monitor monitor) { - super(); - this.extensionProcessor = staxProcessor; - this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); - } - - public String getArtifactType() { - return "/OSGI-INF/remote-service/*.xml"; - } - - public ServiceDescriptions read(URL contributionURL, URI artifactURI, URL artifactURL) - throws ContributionReadException { - InputStream is = null; - try { - URLConnection connection = artifactURL.openConnection(); - connection.setUseCaches(false); - is = connection.getInputStream(); - } catch (IOException e) { - ContributionReadException ce = new ContributionReadException(e); - throw ce; - } - try { - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Object result = extensionProcessor.read(reader); - return (ServiceDescriptions)result; - } catch (XMLStreamException e) { - ContributionReadException ce = new ContributionReadException(e); - throw ce; - } finally { - try { - if (is != null) { - is.close(); - is = null; - } - } catch (IOException ioe) { - //ignore - } - } - - } - - public Class getModelType() { - return ServiceDescriptions.class; - } - - public void resolve(ServiceDescriptions model, ModelResolver resolver) throws ContributionResolveException { - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java deleted file mode 100644 index deafe8ccc9..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java +++ /dev/null @@ -1,58 +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.tuscany.sca.implementation.osgi.xml; - -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; - -/** - * - */ -public class ServiceDescriptionsModelResolver implements ModelResolver { - private ServiceDescriptions serviceDescriptions; - - public ServiceDescriptionsModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) { - ServiceDescriptionsFactory factory = modelFactories.getFactory(ServiceDescriptionsFactory.class); - this.serviceDescriptions = factory.createServiceDescriptions(); - } - - public void addModel(Object resolved) { - // Merge the service descriptions - if (resolved instanceof ServiceDescriptions) { - serviceDescriptions.addAll((ServiceDescriptions)resolved); - } - } - - public Object removeModel(Object resolved) { - // Remove the service descriptions - if (resolved instanceof ServiceDescriptions) { - serviceDescriptions.removeAll((ServiceDescriptions)resolved); - } - return resolved; - } - - public T resolveModel(Class modelClass, T unresolved) { - // Always return the aggregated service descriptions - return modelClass.cast(serviceDescriptions); - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java deleted file mode 100644 index bef07d159d..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java +++ /dev/null @@ -1,153 +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.tuscany.sca.implementation.osgi.xml; - -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.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.ServiceDescriptionsFactory; -import org.apache.tuscany.sca.monitor.Monitor; - -/* - - - - - SOAP HTTP - pojo - - http://localhost:9000/hello - - - - - SOAP HTTP - pojo - - http://localhost:9005/greeter - - - -*/ -public class ServiceDescriptionsProcessor implements StAXArtifactProcessor { - 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 = factory.createServiceDescriptions(); - ServiceDescription sd = null; - while (true) { - switch (event) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - 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"); - if (interfaceName != null) { - sd.getInterfaces().add(interfaceName); - } - } else if ("property".equals(name.getLocalPart())) { - String propName = reader.getAttributeValue(null, "name"); - String propValue = reader.getAttributeValue(null, "value"); - String propType = reader.getAttributeValue(null, "type"); - if (propType == null) { - propType = "String"; - } - if (propValue == null) { - propValue = reader.getElementText(); - } - if (propValue != null) { - propValue = propValue.trim(); - } - Object prop = propValue; - if ("Integer".equals(propType)) { - prop = Integer.valueOf(propValue); - } else if ("Long".equals(propType)) { - prop = Long.valueOf(propValue); - } else if ("Float".equals(propType)) { - prop = Float.valueOf(propValue); - } else if ("Double".equals(propType)) { - prop = Double.valueOf(propValue); - } else if ("Short".equals(propType)) { - prop = Short.valueOf(propValue); - } else if ("Character".equals(propType)) { - prop = propValue.charAt(0); - } else if ("Byte".equals(propType)) { - prop = Byte.valueOf(propValue); - } else if ("Boolean".equals(propType)) { - prop = Boolean.valueOf(propValue); - } - sd.getProperties().put(propName, prop); - } - break; - case XMLStreamConstants.END_ELEMENT: - name = reader.getName(); - if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) { - // Reset the sd - sd = null; - } - if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) { - return sds; - } - break; - } - if (reader.hasNext()) { - event = reader.next(); - } else { - return sds; - } - } - } - - public QName getArtifactType() { - return ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME; - } - - public void write(ServiceDescriptions model, XMLStreamWriter writer) throws ContributionWriteException, - XMLStreamException { - // TODO: To be implemented - } - - public Class getModelType() { - return ServiceDescriptions.class; - } - - public void resolve(ServiceDescriptions model, ModelResolver resolver) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml deleted file mode 100644 index f531c2c4ed..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - An OSGi intent to pass data by reference - - - - - - An OSGi intent to pass data by value - - - - \ No newline at end of file diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index 6407305a77..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,21 +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. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#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 -org.apache.tuscany.sca.implementation.osgi.xml.OSGiPropertyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#osgi.property,model=org.apache.tuscany.sca.implementation.osgi.OSGiProperty diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor deleted file mode 100644 index d4b5dd8dce..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor +++ /dev/null @@ -1,19 +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. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsDocumentProcessor;type=/OSGI-INF/remote-service/*.xml,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver deleted file mode 100644 index 57bf18d9ce..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver +++ /dev/null @@ -1,17 +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. -org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsModelResolver;model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory deleted file mode 100644 index 6ec156ae81..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory +++ /dev/null @@ -1,18 +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. - -org.apache.tuscany.sca.implementation.osgi.DefaultOSGiImplementationFactory diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory deleted file mode 100644 index 0d01b7d6a5..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory +++ /dev/null @@ -1,17 +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. -org.apache.tuscany.sca.implementation.osgi.DefaultServiceDescriptionsFactory diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties deleted file mode 100644 index a406ea21c3..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties +++ /dev/null @@ -1,26 +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. -# -# -ContributionReadException = ContributionReadException occured due to: -ContributionResolveException = ContributionResolveException occured due to: -PropertyShouldSpecifySR = Properties in implementation.osgi should specify service or reference -CouldNotLocateOSGiBundle = Could not locate OSGi bundle: {0} -MissingComponentTypeFile = Missing .componentType side file: {0} -OSGiFrameworkNotStarted = OSGi Framework is not started \ No newline at end of file diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java deleted file mode 100644 index 656b78b717..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java +++ /dev/null @@ -1,39 +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 calculator.dosgi; - -import java.rmi.Remote; -import java.rmi.RemoteException; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * The Calculator service interface. - */ -@Remotable -public interface CalculatorService extends Remote { - - double add(double n1, double n2) throws RemoteException; - - double subtract(double n1, double n2) throws RemoteException; - - double multiply(double n1, double n2) throws RemoteException; - - double divide(double n1, double n2) throws RemoteException; -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java deleted file mode 100644 index 971500782f..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java +++ /dev/null @@ -1,31 +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 calculator.dosgi.operations; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * The interface for the add service - */ -@Remotable -public interface AddService { - - double add(double n1, double n2); - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java deleted file mode 100644 index 49b8a1c0bf..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java +++ /dev/null @@ -1,31 +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 calculator.dosgi.operations; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * The interface for the divide service - */ -@Remotable -public interface DivideService { - - double divide(double n1, double n2); - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java deleted file mode 100644 index f4e59d12ea..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java +++ /dev/null @@ -1,31 +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 calculator.dosgi.operations; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * The interface for the multiply service - */ -@Remotable -public interface MultiplyService { - - double multiply(double n1, double n2); - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java deleted file mode 100644 index bfb9b820f7..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java +++ /dev/null @@ -1,31 +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 calculator.dosgi.operations; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * The interface for the subtract service - */ -@Remotable -public interface SubtractService { - - double subtract(double n1, double n2); - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java deleted file mode 100644 index fd1a89ccf3..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java +++ /dev/null @@ -1,89 +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.tuscany.sca.implementation.osgi.xml; - -import java.io.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class BluePrintComponentsProcessorTestCase { - private static final String xml = - "" + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + ""; - private static XMLStreamReader reader; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - XMLInputFactory factory = XMLInputFactory.newInstance(); - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - BluePrintComponentsProcessor processor = - new BluePrintComponentsProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()), - null); - ComponentType ct = processor.read(reader); - Assert.assertEquals(1, ct.getServices().size()); - Assert.assertEquals(4, ct.getReferences().size()); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (reader != null) { - reader.close(); - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java deleted file mode 100644 index 5f2a7d690c..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java +++ /dev/null @@ -1,86 +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.tuscany.sca.implementation.osgi.xml; - -import java.io.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class OSGiComponentProcessorTestCase { - private static final String xml = - "" + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + ""; - - private static XMLStreamReader reader; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - XMLInputFactory factory = XMLInputFactory.newInstance(); - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - OSGiComponentProcessor processor = - new OSGiComponentProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()), null); - ComponentType ct = processor.read(reader); - Assert.assertEquals(1, ct.getServices().size()); - Assert.assertEquals(4, ct.getReferences().size()); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (reader != null) { - reader.close(); - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java deleted file mode 100644 index 43cca15341..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java +++ /dev/null @@ -1,138 +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.tuscany.sca.implementation.osgi.xml; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.StringWriter; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; -import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test reading OSGi implementations. - * - * @version $Rev$ $Date$ - */ -public class OSGiReadImplTestCase { - - private static XMLInputFactory inputFactory; - private static XMLOutputFactory outputFactory; - private static StAXArtifactProcessor staxProcessor; - private static CompositeBuilder compositeBuilder; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE); - StAXArtifactProcessorExtensionPoint staxProcessors = - new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader); - assertNotNull(composite); - } - - @Test - public void testReadAndResolveComposite() throws Exception { - InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader); - assertNotNull(composite); - - is = getClass().getClassLoader().getResourceAsStream("OSGI-INF/sca/bundle.componentType"); - reader = inputFactory.createXMLStreamReader(is); - ComponentType componentType = (ComponentType)staxProcessor.read(reader); - - assertEquals(1, componentType.getServices().size()); - Object prop1 = componentType.getServices().get(0).getExtensions().get(0); - assertTrue(prop1 instanceof OSGiProperty); - OSGiProperty osgiProp1 = (OSGiProperty)prop1; - assertEquals("1", osgiProp1.getValue()); - assertEquals("prop1", osgiProp1.getName()); - - assertEquals(4, componentType.getReferences().size()); - Object prop2 = componentType.getReferences().get(0).getExtensions().get(1); - assertTrue(prop2 instanceof OSGiProperty); - OSGiProperty osgiProp2 = (OSGiProperty)prop2; - assertEquals("ABC", osgiProp2.getValue()); - assertEquals("prop2", osgiProp2.getName()); - - ModelResolver resolver = new TestModelResolver(getClass().getClassLoader()); - staxProcessor.resolve(componentType, resolver); - resolver.addModel(componentType); - - staxProcessor.resolve(composite, resolver); - } - - @Test - public void testReadOSGiImplementation() throws Exception { - - String str = - "" + ""; - ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes()); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - reader.nextTag(); - - OSGiImplementation osgiImpl = (OSGiImplementation)staxProcessor.read(reader); - - assertEquals(osgiImpl.getBundleSymbolicName(), "osgi.test"); - assertEquals(osgiImpl.getBundleVersion(), "1.0.0"); - - StringWriter sw = new StringWriter(); - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw); - staxProcessor.write(osgiImpl, writer); - writer.flush(); - Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\"")); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java deleted file mode 100644 index d6728f8e1f..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java +++ /dev/null @@ -1,99 +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.tuscany.sca.implementation.osgi.xml; - -import java.io.StringReader; -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; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class ServiceDescriptionsTestCase { - private static final String xml = - "" - + "" - + "" - + "" - + "sca:SOAP sca:HTTP" - + "sca" - + "" - + "OSGI-INF/sca/bundle.componentType" - + "" - + "" - + "addService" - + "" - + "" - + "" - + "" - + "sca:SOAP sca:HTTP" - + "sca" - + "" - + "OSGI-INF/sca/bundle.componentType" - + "" - + "" - + "subtractService" - + "" - + "" - + ""; - - private static XMLStreamReader reader; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - XMLInputFactory factory = XMLInputFactory.newInstance(); - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - ServiceDescriptionsProcessor processor = - new ServiceDescriptionsProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()), - null); - List descriptions = processor.read(reader); - Assert.assertEquals(2, descriptions.size()); - System.out.println(descriptions); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (reader != null) { - reader.close(); - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java deleted file mode 100644 index 7cae6abda2..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java +++ /dev/null @@ -1,104 +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.tuscany.sca.implementation.osgi.xml; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationImpl; - -/** - * A default implementation of an artifact resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map map = new HashMap(); - - private WeakReference classLoader; - - public TestModelResolver(ClassLoader classLoader) { - this.classLoader = new WeakReference(classLoader); - } - - public T resolveModel(Class modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - if (unresolved instanceof OSGiImplementationImpl && !(resolved instanceof OSGiImplementationImpl)) { - - OSGiImplementationImpl impl = ((OSGiImplementationImpl)unresolved); - ComponentType componentType = (ComponentType)resolved; - - List properties = componentType.getProperties(); - for (Property property : properties) { - impl.getProperties().add(property); - } - impl.setUnresolved(false); - return unresolved; - } - - // Return the resolved object - return modelClass.cast(resolved); - - } else if (unresolved instanceof ClassReference) { - - // Load a class on demand - ClassReference classReference = (ClassReference)unresolved; - Class clazz; - try { - clazz = Class.forName(classReference.getClassName(), true, classLoader.get()); - } catch (ClassNotFoundException e) { - - // Return the unresolved object - return unresolved; - } - - // Store a new ClassReference wrapping the loaded class - resolved = new ClassReference(clazz); - map.put(resolved, resolved); - - // Return the resolved ClassReference - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved) { - return map.remove(resolved); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml deleted file mode 100644 index 3e537df732..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType deleted file mode 100644 index 7860094626..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - 1 - ABC - - - - - - 1 - ABC - - - - 1 - ABC - - - - 1 - ABC - - - - 1 - ABC - - - diff --git a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/osgitest.composite b/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/osgitest.composite deleted file mode 100644 index 24c5716abd..0000000000 --- a/branches/sca-java-2.0-M3/modules/implementation-osgi/src/test/resources/osgitest.composite +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - USD - 2.0 - - - - -- cgit v1.2.3