diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-30 08:00:47 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-30 08:00:47 +0000 |
commit | fb3dd9a9095abc40027318b1712d0184f6d60e73 (patch) | |
tree | 03fcf33e2b10b43834d2ca88fe0b00641fbcd762 /branches/sca-java-2.0-M4/modules/implementation-osgi | |
parent | ccfd2c4b4f2b2bb0346cd0be71f290b122b14cd9 (diff) |
Delete old M4 branch and start again to pick up all the recent trunk changes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@831223 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
61 files changed, 0 insertions, 4573 deletions
diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/LICENSE deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/LICENSE +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF deleted file mode 100644 index 986e931927..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF +++ /dev/null @@ -1,30 +0,0 @@ -Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.apache.tuscany.sca.implementation.osgi.runtime
-Bundle-Version: 2.0.0
-Bundle-ActivationPolicy: lazy
-Bundle-Name: Apache Tuscany SCA OSGi Implementation Runtime
-Bundle-Vendor: The Apache Software Foundation
-Eclipse-LazyStart: true
-Bundle-Activator: org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationRuntimeActivator
-Bundle-Description: Apache Tuscany SCA OSGi Implementation
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
-Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
- org.apache.tuscany.sca.core;version="2.0.0",
- org.apache.tuscany.sca.core.factory;version="2.0.0",
- org.apache.tuscany.sca.core.invocation;version="2.0.0",
- org.apache.tuscany.sca.implementation.osgi;version="2.0.0",
- org.apache.tuscany.sca.interfacedef;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
- org.apache.tuscany.sca.invocation;version="2.0.0",
- org.apache.tuscany.sca.monitor;version="2.0.0",
- org.apache.tuscany.sca.policy;version="2.0.0",
- org.apache.tuscany.sca.provider;version="2.0.0",
- org.apache.tuscany.sca.runtime;version="2.0.0",
- org.oasisopen.sca;version="2.0.0",
- org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
- org.osgi.framework;version="1.4.0",
- org.osgi.util.tracker;version="1.3.0"
-Bundle-DocURL: http://www.apache.org/
-Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/NOTICE deleted file mode 100644 index 25bb89c9b2..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2009 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/pom.xml deleted file mode 100644 index 355ca4b4f1..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<project> - - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>2.0-M4-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>tuscany-implementation-osgi-runtime</artifactId> - <name>Apache Tuscany SCA OSGi Implementation Extension Runtime</name> - - <packaging>jar</packaging> - - <dependencies> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-implementation-osgi</artifactId> - <version>2.0-M4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-contribution-osgi</artifactId> - <version>2.0-M4-SNAPSHOT</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.eclipse</groupId> - <artifactId>osgi</artifactId> - <version>3.5.0-v20090520</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core</artifactId> - <version>2.0-M4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-java</artifactId> - <version>2.0-M4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - - </dependencies> - -</project> diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java deleted file mode 100644 index e54d2eee7b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.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.runtime; - -import java.util.Dictionary; -import java.util.Hashtable; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; - -/** - * OSGi distribution provider for remote services - */ -public class OSGiDistributionProvider { - /** - * Registered by the distribution provider on one of its services to indicate the - * supported configuration types. - */ - public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported"; // String+ - - /** - * Registered by the distribution provider on one of its services to indicate the vocabulary - * of implemented intents. - */ - public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported"; // String+ - - /** - * Service Registration property for the name of the Distribution Provider - * product. - * <p> - * The value of this property is of type String. - */ - static final String PRODUCT_NAME = "osgi.remote.distribution.product"; - - /** - * Service Registration property for the version of the Distribution - * Provider product. - * <p> - * The value of this property is of type String. - */ - static final String PRODUCT_VERSION = "osgi.remote.distribution.product.version"; - - /** - * Service Registration property for the Distribution Provider product - * vendor name. - * <p> - * The value of this property is of type String. - */ - static final String VENDOR_NAME = "osgi.remote.distribution.vendor"; - - private BundleContext bundleContext; - - public OSGiDistributionProvider(BundleContext bundleContext) { - super(); - this.bundleContext = bundleContext; - } - - public Dictionary<String, Object> getProperties() { - Dictionary headers = bundleContext.getBundle().getHeaders(); - Hashtable<String, Object> props = new Hashtable<String, Object>(); - props.put(PRODUCT_NAME, "Apache Tuscany SCA"); - props.put(PRODUCT_VERSION, headers.get(Constants.BUNDLE_VERSION)); - props.put(VENDOR_NAME, headers.get(Constants.BUNDLE_VENDOR)); - props.put(REMOTE_CONFIGS_SUPPORTED, new String[] {"org.osgi.sca"}); - // FIXME: We need to populate the list of intents from the SCA definitions - props.put(REMOTE_INTENTS_SUPPORTED, new String[] {}); - return props; - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java deleted file mode 100644 index 7c2b90e601..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java +++ /dev/null @@ -1,227 +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.runtime; - -import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.REMOTE_CONFIG_SCA; -import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SCA_REFERENCE; -import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_IMPORTED; -import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_IMPORTED_CONFIGS; -import static org.osgi.framework.Constants.SERVICE_RANKING; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; -import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.oasisopen.sca.ServiceRuntimeException; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleException; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceFactory; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -/** - * - */ -public class OSGiImplementationProvider implements ImplementationProvider { - private RuntimeComponent component; - private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint; - private Bundle osgiBundle; - private OSGiImplementation implementation; - private List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>(); - - public OSGiImplementationProvider(RuntimeComponent component, - OSGiImplementation impl, - ProxyFactoryExtensionPoint proxyFactoryExtensionPoint) throws BundleException { - this.component = component; - this.proxyFactoryExtensionPoint = proxyFactoryExtensionPoint; - this.implementation = impl; - this.osgiBundle = impl.getBundle(); - } - - public Invoker createInvoker(RuntimeComponentService service, Operation operation) { - return new OSGiTargetInvoker(operation, this, service); - } - - public void start() { - // First try to start the osgi bundle - try { - int state = osgiBundle.getState(); - if ((state & Bundle.STARTING) == 0 && (state & Bundle.ACTIVE) == 0) { - osgiBundle.start(); - } - } catch (BundleException e) { - throw new ServiceRuntimeException(e); - } - - for (ComponentReference ref : component.getReferences()) { - RuntimeComponentReference reference = (RuntimeComponentReference)ref; - InterfaceContract interfaceContract = reference.getInterfaceContract(); - JavaInterface javaInterface = (JavaInterface)interfaceContract.getInterface(); - final Class<?> interfaceClass = javaInterface.getJavaClass(); - - // final Hashtable<String, Object> props = new Hashtable<String, Object>(); - // props.put(FILTER_MATCH_CRITERIA, ""); - // Collection<String> interfaceNames = new ArrayList<String>(); - // props.put(INTERFACE_MATCH_CRITERIA, interfaceNames); - // interfaceNames.add(interfaceClass.getName()); - - final Hashtable<String, Object> osgiProps = getOSGiProperties(reference); - osgiProps.put(SERVICE_RANKING, Integer.MAX_VALUE); - osgiProps.put(SCA_REFERENCE, component.getURI() + "#reference(" + ref.getName() + ")"); - osgiProps.put(SERVICE_IMPORTED, "true"); - osgiProps.put(SERVICE_IMPORTED_CONFIGS, new String[] {REMOTE_CONFIG_SCA}); - - for (RuntimeWire wire : reference.getRuntimeWires()) { - final OSGiServiceFactory serviceFactory = new OSGiServiceFactory(interfaceClass.getName(), wire); - ServiceRegistration registration = - AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() { - public ServiceRegistration run() { - // Register the proxy as OSGi service - BundleContext context = osgiBundle.getBundleContext(); - ServiceRegistration registration = - context.registerService(interfaceClass.getName(), serviceFactory, osgiProps); - return registration; - } - }); - registrations.add(registration); - } - } - } - - public void stop() { - for (ServiceRegistration registration : registrations) { - registration.unregister(); - } - registrations.clear(); - try { - int state = osgiBundle.getState(); - if ((state & Bundle.STOPPING) == 0 && (state & Bundle.ACTIVE) != 0) { - osgiBundle.stop(); - } - } catch (BundleException e) { - throw new ServiceRuntimeException(e); - } - } - - public boolean supportsOneWayInvocation() { - return false; - } - - /** - * Get all the OSGi properties from the extension list - * @param extensible - * @return - */ - protected Hashtable<String, Object> getOSGiProperties(Extensible extensible) { - Hashtable<String, Object> props = new Hashtable<String, Object>(); - for (Object ext : extensible.getExtensions()) { - if (ext instanceof OSGiProperty) { - OSGiProperty p = (OSGiProperty)ext; - props.put(p.getName(), p.getValue()); - } - } - return props; - } - - protected Object getOSGiService(ComponentService service) { - JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getInterface(); - // String filter = getOSGiFilter(provider.getOSGiProperties(service)); - // FIXME: What is the filter? - String filter = "(!(" + SERVICE_IMPORTED + "=*))"; - // "(sca.service=" + component.getURI() + "#service-name\\(" + service.getName() + "\\))"; - BundleContext bundleContext = osgiBundle.getBundleContext(); - ServiceReference ref; - try { - ref = bundleContext.getServiceReferences(javaInterface.getName(), filter)[0]; - } catch (InvalidSyntaxException e) { - throw new ServiceRuntimeException(e); - } - if (ref != null) { - Object instance = bundleContext.getService(ref); - return instance; - } else { - return null; - } - } - - RuntimeComponent getComponent() { - return component; - } - - OSGiImplementation getImplementation() { - return implementation; - } - - public class OSGiServiceFactory implements ServiceFactory { - private RuntimeWire wire; - private String interfaceName; - - /** - * @param interfaceName - * @param wire - */ - public OSGiServiceFactory(String interfaceName, RuntimeWire wire) { - super(); - this.interfaceName = interfaceName; - this.wire = wire; - } - - public Object getService(Bundle bundle, ServiceRegistration registration) { - Class<?> interfaceClass = null; - try { - interfaceClass = bundle.loadClass(interfaceName); - } catch (ClassNotFoundException e) { - return null; - } - ProxyFactory proxyService = proxyFactoryExtensionPoint.getInterfaceProxyFactory(); - if (!interfaceClass.isInterface()) { - proxyService = proxyFactoryExtensionPoint.getClassProxyFactory(); - } - Object proxy = proxyService.createProxy(interfaceClass, wire); - return proxy; - } - - public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { - // Do we need to release the proxy? - } - - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java deleted file mode 100644 index 0e4a3ef995..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java +++ /dev/null @@ -1,59 +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.runtime; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; -import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.osgi.framework.BundleException; - -/** - * Builds a OSGi-based implementation provider from a component definition - * - * @version $Rev$ $Date$ - */ -public class OSGiImplementationProviderFactory implements ImplementationProviderFactory<OSGiImplementation> { - - private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint; - - public OSGiImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { - proxyFactoryExtensionPoint = extensionPoints.getExtensionPoint(ProxyFactoryExtensionPoint.class); - } - - public ImplementationProvider createImplementationProvider(RuntimeComponent component, - OSGiImplementation implementation) { - - try { - - return new OSGiImplementationProvider(component, implementation, proxyFactoryExtensionPoint); - - } catch (BundleException e) { - throw new RuntimeException(e); - } - - } - - public Class<OSGiImplementation> getModelType() { - return OSGiImplementation.class; - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java deleted file mode 100644 index 8bbfc19323..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.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.runtime; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -/** - * Bundle activator to receive the BundleContext - */ -public class OSGiImplementationRuntimeActivator implements BundleActivator { - private static BundleContext bundleContext; - private ServiceRegistration distributionProvider; - - public void start(BundleContext context) throws Exception { - bundleContext = context; - OSGiDistributionProvider provider = new OSGiDistributionProvider(bundleContext); - distributionProvider = - bundleContext.registerService(OSGiDistributionProvider.class.getName(), provider, provider.getProperties()); - } - - public void stop(BundleContext context) throws Exception { - if (distributionProvider != null) { - distributionProvider.unregister(); - } - bundleContext = null; - } - - static BundleContext getBundleContext() { - return bundleContext; - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java deleted file mode 100644 index a9a2fdbd0b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java +++ /dev/null @@ -1,210 +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.runtime; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaOperation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.osgi.framework.Constants; - -/** - * The Invoker looks up the corresponding OSGi service from the OSGi service registry - * and delegate the call to it. - * - * @version $Rev$ $Date$ - */ -public class OSGiTargetInvoker implements Invoker { - - private Operation operation; - - private final OSGiImplementationProvider provider; - private final RuntimeComponent component; - private final RuntimeComponentService service; - - public OSGiTargetInvoker(Operation operation, OSGiImplementationProvider provider, RuntimeComponentService service) { - - this.operation = operation; - this.service = service; - this.provider = provider; - this.component = provider.getComponent(); - - } - - private Object invokeTarget(Message msg) throws InvocationTargetException { - - Operation op = msg.getOperation(); - if (op == null) { - op = this.operation; - } - - try { - Object instance = provider.getOSGiService(service); - Method m = findMethod(instance.getClass(), operation); - - Object ret = invokeMethod(instance, m, msg); - - return ret; - } catch (InvocationTargetException e) { - throw e; - } catch (Exception e) { - throw new InvocationTargetException(e); - } - } - - protected Object invokeMethod(Object instance, Method m, Message msg) throws InvocationTargetException { - - try { - - Object payload = msg.getBody(); - - if (payload != null && !payload.getClass().isArray()) { - return m.invoke(instance, payload); - } else { - return m.invoke(instance, (Object[])payload); - } - - } catch (InvocationTargetException e) { - throw e; - } catch (Exception e) { - throw new InvocationTargetException(e); - } - } - - public Message invoke(Message msg) { - try { - Object resp = invokeTarget(msg); - msg.setBody(resp); - } catch (InvocationTargetException e) { - msg.setFaultBody(e.getCause()); - } - return msg; - } - - private String getOSGiFilter(Hashtable<String, Object> props) { - Object serviceID = props.get(Constants.SERVICE_ID); - if (serviceID != null) { - return "(" + Constants.SERVICE_ID + "=" + serviceID + ")"; - } - - String filter = ""; - - if (props != null && props.size() > 0) { - int propCount = 0; - for (String propName : props.keySet()) { - String value = String.valueOf(props.get(propName)); - StringBuffer buf = new StringBuffer(); - for (char c : value.toCharArray()) { - if (c == '(' || c == ')') { - buf.append("\\" + c); - } else { - buf.append(c); - } - } - filter = filter + "(" + propName + "=" + buf.toString() + ")"; - propCount++; - } - - if (propCount > 1) { - filter = "(&" + filter + ")"; - } - } else { - filter = null; - } - return filter; - } - - /** - * @Deprecated - */ - private static Class<?>[] getPhysicalTypes(Operation operation) { - DataType<List<DataType>> inputType = operation.getInputType(); - if (inputType == null) { - return new Class<?>[] {}; - } - List<DataType> types = inputType.getLogical(); - Class<?>[] javaTypes = new Class<?>[types.size()]; - for (int i = 0; i < javaTypes.length; i++) { - Type physical = types.get(i).getPhysical(); - if (physical instanceof Class<?>) { - javaTypes[i] = (Class<?>)physical; - } else { - throw new UnsupportedOperationException(); - } - } - return javaTypes; - } - - /** - * Return the method on the implementation class that matches the operation. - * - * @param implClass the implementation class or interface - * @param operation the operation to match - * @return the method described by the operation - * @throws NoSuchMethodException if no such method exists - * @Deprecated - */ - public static Method findMethod(Class<?> implClass, Operation operation) throws NoSuchMethodException { - String name = operation.getName(); - if (operation instanceof JavaOperation) { - name = ((JavaOperation)operation).getJavaMethod().getName(); - } - Interface interface1 = operation.getInterface(); - int numParams = operation.getInputType().getLogical().size(); - if (interface1 != null && interface1.isRemotable()) { - List<Method> matchingMethods = new ArrayList<Method>(); - for (Method m : implClass.getMethods()) { - if (m.getName().equals(name) && m.getParameterTypes().length == numParams) { - matchingMethods.add(m); - } - } - - // TUSCANY-2180 If there is only one method then we just match on the name - // (this is the same as the existing behaviour) - if (matchingMethods.size() == 1) { - return matchingMethods.get(0); - } - if (matchingMethods.size() > 1) { - // TUSCANY-2180 We need to check the parameter types too - Class<?>[] paramTypes = getPhysicalTypes(operation); - return implClass.getMethod(name, paramTypes); - } - - // No matching method found - throw new NoSuchMethodException("No matching method for operation " + operation.getName() - + " is found on " - + implClass); - } - Class<?>[] paramTypes = getPhysicalTypes(operation); - return implClass.getMethod(name, paramTypes); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml deleted file mode 100644 index f531c2c4ed..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" - targetNamespace="http://www.osgi.org/xmlns/sca/intents/v1.0.0"> - - <intent name="passByReference" constrains="sca:implementation" - intentType="implementation"> - <description> - An OSGi intent to pass data by reference - </description> - </intent> - - <intent name="passByValue" constrains="sca:implementation" - intentType="implementation"> - <description> - An OSGi intent to pass data by value - </description> - </intent> - -</sca:definitions>
\ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory deleted file mode 100644 index c2cd957351..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory +++ /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 implementation extension
-org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.osgi.OSGiImplementation
diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties b/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties deleted file mode 100644 index 2503be0b13..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties +++ /dev/null @@ -1,25 +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}
\ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/LICENSE b/branches/sca-java-2.0-M4/modules/implementation-osgi/LICENSE deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/LICENSE +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/implementation-osgi/META-INF/MANIFEST.MF deleted file mode 100755 index 9956060457..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/META-INF/MANIFEST.MF +++ /dev/null @@ -1,36 +0,0 @@ -Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.apache.tuscany.sca.implementation.osgi
-Bundle-Version: 2.0.0
-Bundle-ActivationPolicy: lazy
-Bundle-Name: Apache Tuscany SCA OSGi Implementation
-Bundle-Vendor: The Apache Software Foundation
-Eclipse-LazyStart: true
-Bundle-Activator: org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationActivator
-Bundle-Description: Apache Tuscany SCA OSGi Implementation
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
-Import-Package: javax.xml.namespace,
- javax.xml.stream,
- org.apache.tuscany.sca.assembly;version="2.0.0",
- org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional,
- org.apache.tuscany.sca.assembly.impl;version="2.0.0",
- org.apache.tuscany.sca.contribution;version="2.0.0",
- org.apache.tuscany.sca.contribution.processor;version="2.0.0",
- org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
- org.apache.tuscany.sca.core;version="2.0.0",
- org.apache.tuscany.sca.definitions;version="2.0.0",
- org.apache.tuscany.sca.implementation.osgi;version="2.0.0",
- org.apache.tuscany.sca.interfacedef;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
- org.apache.tuscany.sca.monitor;version="2.0.0",
- org.apache.tuscany.sca.policy;version="2.0.0",
- org.oasisopen.sca;version="2.0.0",
- org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
- org.osgi.framework;version="1.4.0",
- org.osgi.service.packageadmin;version="1.2.0",
- org.osgi.util.tracker;version="1.3.0"
-Bundle-DocURL: http://www.apache.org/
-Export-Package: org.apache.tuscany.sca.implementation.osgi;version="2.0.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/NOTICE b/branches/sca-java-2.0-M4/modules/implementation-osgi/NOTICE deleted file mode 100644 index 25bb89c9b2..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2009 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/pom.xml b/branches/sca-java-2.0-M4/modules/implementation-osgi/pom.xml deleted file mode 100644 index 882792aa81..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<project> - - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>2.0-M4-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>tuscany-implementation-osgi</artifactId> - <name>Apache Tuscany SCA OSGi Implementation Extension</name> - - <packaging>jar</packaging> - - <dependencies> - - <dependency> - <groupId>org.eclipse</groupId> - <artifactId>osgi</artifactId> - <version>3.5.0-v20090520</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core-spi</artifactId> - <version>2.0-M4-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-java</artifactId> - <version>2.0-M4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-assembly-xml</artifactId> - <version>2.0-M4-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - - </dependencies> - -</project> diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java deleted file mode 100644 index 20c7e8d60a..0000000000 --- a/branches/sca-java-2.0-M4/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.ExtensionPointRegistry; -import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationFactoryImpl; - -/** - * - */ -public class DefaultOSGiImplementationFactory extends OSGiImplementationFactoryImpl { - - public DefaultOSGiImplementationFactory(ExtensionPointRegistry registry) { - super(registry); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java deleted file mode 100644 index ba5e5284be..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.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; - -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 BUNDLE_SYMBOLICNAME = "bundleSymbolicName"; - String BUNDLE_VERSION = "bundleVersion"; - QName IMPLEMENTATION_OSGI = new QName(SCA11_TUSCANY_NS, "implementation.osgi"); - QName TYPE = 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-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java deleted file mode 100644 index e0b7f43add..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java +++ /dev/null @@ -1,179 +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; - -/** - * <tuscany:osgi.property> - */ -public interface OSGiProperty { - String NAME = "name"; - QName PROPERTY_QNAME = new QName(OSGiImplementation.SCA11_TUSCANY_NS, "osgi.property"); - - String REMOTE_CONFIG_SCA = "org.osgi.sca"; - String SCA_BINDINGS = "org.osgi.sca.bindings"; - String SCA_REFERENCE = "sca.reference"; - String SCA_SERVICE = "sca.service"; - String SCA_REFERENCE_BINDING = "sca.reference.binding"; - String SCA_SERVICE_BINDING = "sca.service.binding"; - - /** - * The configuration types supported by this Distribution Provider. - * - * Services that are suitable for distribution list the configuration types - * that describe the configuration information for that service in the - * {@link #SERVICE_EXPORTED_CONFIGS} or {@link #SERVICE_IMPORTED_CONFIGS} - * property. - * - * A distribution provider must register a service that has this property - * and enumerate all configuration types that it supports. - * - * The type of this property <code>String+</code> - * - * @see #SERVICE_EXPORTED_CONFIGS - * @see #SERVICE_IMPORTED_CONFIGS - */ - public final static String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported"; - /** - * Service property that lists the intents supported by the distribution - * provider. - * - * Each distribution provider must register a service that has this property - * and enumerate all the supported intents, having any qualified intents - * expanded. - * - * The value of this property is of type <code>String+</code>. - * - * @see #SERVICE_INTENTS - * @see #SERVICE_EXPORTED_INTENTS - * @see #SERVICE_EXPORTED_INTENTS_EXTRA - */ - public final static String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported"; - /** - * A list of configuration types that should be used to export the service. - * - * Configuration types can be <em>synonymous</em> or <em>alternatives</em>. - * In principle, a distribution provider should create an endpoint for each - * recognized configuration type, the deployer is responsible that synonyms - * do not clash. - * - * Each configuration type has an associated specification that describes - * how the configuration data for the exported service is represented in an - * OSGi framework. - * - * The value of this property is of type <code>String+</code>. - */ - public final static String SERVICE_EXPORTED_CONFIGS = "service.exported.configs"; - /** - * A list of intents that the distribution provider must implement to - * distribute the service. Intents listed in this property are reserved for - * intents that are critical for the code to function correctly, for - * example, ordering of messages. These intents should not be configurable. - * - * The value of this property is of type <code>String+</code>. - */ - public final static String SERVICE_EXPORTED_INTENTS = "service.exported.intents"; - /** - * Extra intents configured in addition to the the intents specified in - * {@link #SERVICE_EXPORTED_INTENTS}. - * - * These intents are merged with the service.exported.intents and therefore - * have the same semantics. They are extra, so that the - * {@link #SERVICE_EXPORTED_INTENTS} can be set by the bundle developer and - * this property is then set by the administrator/deployer. Bundles should - * make this property configurable, for example through the Configuration - * Admin service. - * - * The value of this property is of type <code>String+</code>. - */ - public final static String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra"; - /** - * Defines the interfaces under which this service can be exported. - * - * This list must be a subset of the types listed in the objectClass service - * property. The single value of an asterisk ('*' \u002A) indicates all - * interfaces in the registration's objectClass property (not classes). It - * is highly recommended to only export interfaces and not concrete classes - * due to the complexity of creating proxies for some type of classes. - * - * The value of this property is of type String+. - */ - public final static String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces"; - /** - * Must be set by a distribution provider to <code>true</code> when it - * registers the end-point proxy as an imported service. Can be used by a - * bundle to prevent it from getting an imported service. - * - * The value of this property is not defined, setting it is sufficient. - */ - public final static String SERVICE_IMPORTED = "service.imported"; - /** - * A list of intents that this service implements. This property has dual - * purpose. A bundle can use this service property to notify the - * distribution provider that these intents are already implemented by the - * exported service object. For an imported service, a distribution provider - * must use this property to convey the combined intents of the exporting - * service and the intents that the distribution providers add. To export a - * service, a distribution provider must recognize all these intents and - * expand any qualified intents. - * - * The value of this property is of type <code>String+</code>. - */ - public final static String SERVICE_INTENTS = "service.intents"; - /** - * The property key for the endpoint service id. This is a unique id for a - * service based on the framework id '.' service id or another model. As far as this specification is - * concerned, this unique id is opaque. - */ - final public static String SERVICE_REMOTE_FRAMEWORK_UUID = "service.remote.framework.id"; - /** - * The property key for the endpoint service id. This is a unique id for a - * service based on the framework id '.' service id or another model. As far as this specification is - * concerned, this unique id is opaque. - */ - final public static String SERVICE_REMOTE_ID = "service.remote.id"; - /** - * The property key for the endpoint URI. This is a unique id for an - * endpoint following the URI syntax. As far as this specification is - * concerned, this unique id is opaque. - */ - final public static String SERVICE_REMOTE_URI = "service.remote.uri"; - /** - * The configuration type used to import this services, as described in - * {@link #SERVICE_EXPORTED_CONFIGS}. Any associated properties for this - * configuration types must be properly mapped to the importing system. For - * example, a URL in these properties must point to a valid resource when - * used in the importing framework. Configuration types in this property - * must be synonymous. - * - * The value of this property is of type <code>String+</code>. - */ - public final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs"; - - - String getValue(); - - void setValue(String value); - - String getName(); - - void setName(String name); -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java deleted file mode 100644 index a54324b027..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java +++ /dev/null @@ -1,65 +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 org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * - */ -public interface SCAConfig { - /** - * Returns the target namespace for this SCA Definition - * @return the target namespace - */ - String getTargetNamespace(); - - /** - * Sets the target names for this SCA Definition. - * - * @param ns the target namespace for this SCA Definition - */ - void setTargetNamespace(String ns); - - /** - * Returns a list of domain wide Policy Intents - * - * @return a list of domain wide Policy Intents - */ - List<Intent> getIntents(); - - /** - * Returns a list of domain wide PolicySets - * - * @return a list of domain wide PolicySets - */ - List<PolicySet> getPolicySets(); - - /** - * Returns a list of domain wide binding definition objects - * - * @return a list of domain wide binding definition objects - */ - List<Binding> getBindings(); -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java b/branches/sca-java-2.0-M4/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-M4/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<String> getInterfaces(); - - /** - * Get a list of properties - * @return - */ - Map<String, Object> getProperties(); -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java b/branches/sca-java-2.0-M4/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-M4/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<ServiceDescription> { - - String REMOTE_SERVICE_FOLDER = "OSGI-INF/remote-service"; - String OSGI_SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0"; - QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "service-descriptions"); - QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "service-description"); - String REMOTE_SERVICE_HEADER = "Remote-Service"; -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java deleted file mode 100644 index 535bef2b6b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.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 org.apache.tuscany.sca.implementation.osgi; - -/** - * The factory interface to create OSGi RFC 119 service descriptions - */ -public interface ServiceDescriptionsFactory { - ServiceDescriptions createServiceDescriptions(); - - ServiceDescription createServiceDescription(); - - SCAConfig createSCAConfig(); -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java deleted file mode 100644 index 9fab65272f..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.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.core.ExtensionPointRegistry; -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 { - public OSGiImplementationFactoryImpl(ExtensionPointRegistry registry) { - super(); - } - - public OSGiImplementation createOSGiImplementation() { - return new OSGiImplementationImpl(); - } - - public OSGiProperty createOSGiProperty() { - return new OSGiPropertyImpl(); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java deleted file mode 100644 index 51e1e69b5d..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java +++ /dev/null @@ -1,107 +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.implementation.osgi.OSGiImplementation; -import org.osgi.framework.Bundle; -import org.osgi.framework.Constants; - -/** - * OSGi implementation - * All attributes from <implementation.osgi> 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; - - protected OSGiImplementationImpl() { - super(TYPE); - } - - public OSGiImplementationImpl(String bundleSymbolicName, String bundleVersion) { - super(TYPE); - this.bundleSymbolicName = bundleSymbolicName; - this.bundleVersion = bundleVersion; - } - - public String getBundleSymbolicName() { - return bundleSymbolicName; - } - - public String getBundleVersion() { - return bundleVersion; - } - - /** - * 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-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java deleted file mode 100644 index 4bb1b2340f..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.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.impl; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.implementation.osgi.SCAConfig; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * - */ -public class SCAConfigImpl implements SCAConfig { - private String targetNamespace = null; - private List<Intent> intents = new CopyOnWriteArrayList<Intent>(); - private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>(); - private List<Binding> bindings = new CopyOnWriteArrayList<Binding>(); - - public List<Intent> getIntents() { - return intents; - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public String getTargetNamespace() { - return targetNamespace; - } - - public void setTargetNamespace(String ns) { - this.targetNamespace = ns; - } - - public List<Binding> getBindings() { - return bindings; - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java b/branches/sca-java-2.0-M4/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-M4/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<String> interfaces = new ArrayList<String>(); - private Map<String, Object> properties = new HashMap<String, Object>(); - - protected ServiceDescriptionImpl() { - super(); - } - - public List<String> getInterfaces() { - return interfaces; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public String toString() { - return "service-description: interfaces=" + interfaces + " properties=" + properties; - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java deleted file mode 100644 index 716984a13b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.implementation.osgi.impl; - -import org.apache.tuscany.sca.implementation.osgi.SCAConfig; -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(); - } - - public SCAConfig createSCAConfig() { - return new SCAConfigImpl(); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java b/branches/sca-java-2.0-M4/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-M4/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<ServiceDescription> implements ServiceDescriptions { - private static final long serialVersionUID = 6205649013621747968L; - - protected ServiceDescriptionsImpl() { - super(); - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java deleted file mode 100644 index ca6b0b70e1..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java +++ /dev/null @@ -1,144 +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.ProcessorContext; -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; - -/* -<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) --> -<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> - <component id="CalculatorComponent" class="calculator.dosgi.impl.CalculatorServiceImpl"> - <property name="addService" ref="AddService" /> - <property name="subtractService" ref="SubtractService" /> - <property name="multiplyService" ref="MultiplyService" /> - <property name="divideService" ref="DivideService" /> - </component> - - <!-- We can derive the SCA services for the implementation.osgi --> - <service id="CalculatorService" ref="CalculatorComponent" interface="calculator.dosgi.CalculatorService"> - </service> - - <!-- We can derive the SCA references for the implementation.osgi --> - <reference id="AddService" interface="calculator.dosgi.operations.AddService"> - </reference> - <reference id="SubtractService" interface="calculator.dosgi.operations.SubtractService"> - </reference> - <reference id="MultiplyService" interface="calculator.dosgi.operations.MultiplyService"> - </reference> - <reference id="DivideService" interface="calculator.dosgi.operations.DivideService"> - </reference> - -</components> -*/ -public class BluePrintComponentsProcessor implements StAXArtifactProcessor<ComponentType> { - 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; - - public BluePrintComponentsProcessor(FactoryExtensionPoint modelFactories) { - this.factory = modelFactories.getFactory(AssemblyFactory.class); - this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - } - - public ComponentType read(XMLStreamReader reader, ProcessorContext context) 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, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - // TODO: To be implemented - } - - public Class<ComponentType> getModelType() { - return ComponentType.class; - } - - public void resolve(ComponentType model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java deleted file mode 100644 index 860d3f6f45..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java +++ /dev/null @@ -1,174 +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.ProcessorContext; -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; - -/* -<scr:component name="CalculatorComponent" - xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0"> - <implementation class="calculator.dosgi.CalculatorServiceDSImpl" /> - <service> - <provide interface="calculator.dosgi.CalculatorService" /> - </service> - - <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService" - policy="dynamic" /> - <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService" - unbind="unsetSubtractService" policy="dynamic" /> - <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService" - unbind="unsetMultiplyService" policy="dynamic" /> - <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService" - unbind="unsetDivideService" policy="dynamic" /> - -</scr:component> -*/ -public class OSGiComponentProcessor implements StAXArtifactProcessor<ComponentType> { - 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; - - - public OSGiComponentProcessor(FactoryExtensionPoint modelFactories) { - this.factory = modelFactories.getFactory(AssemblyFactory.class); - this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - } - - public ComponentType read(XMLStreamReader reader, ProcessorContext context) 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, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - // TODO: To be implemented - } - - public Class<ComponentType> getModelType() { - return ComponentType.class; - } - - public void resolve(ComponentType model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java deleted file mode 100644 index d98616cbc2..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java +++ /dev/null @@ -1,342 +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.ProcessorContext; -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 <implementation.osgi/> 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<OSGiImplementation> { - 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 ExtensionPointRegistry registry; - private StAXArtifactProcessor artifactProcessor; - - protected OSGiImplementationProcessor(FactoryExtensionPoint modelFactories) { - 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) { - this(registry.getExtensionPoint(FactoryExtensionPoint.class)); - this.artifactProcessor = processor; - this.registry = registry; - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(Monitor monitor, 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<OSGiImplementation> getModelType() { - return OSGiImplementation.class; - } - - public OSGiImplementation read(XMLStreamReader reader, ProcessorContext context) 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 <implementation.osgi> - 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, ProcessorContext context) throws ContributionResolveException { - - if (impl == null || !impl.isUnresolved()) - return; - Monitor monitor = context.getMonitor(); - 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(monitor, "CouldNotLocateOSGiBundle", impl, impl.getBundleSymbolicName()); - //throw new ContributionResolveException("Could not locate OSGi bundle " + - //impl.getBundleSymbolicName()); - return; - } - - try { - if (introspect(impl, resolver, context, 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, context); - 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>, T) - componentType = assemblyFactory.createComponentType(); - // Try a generic one - componentType.setURI(BUNDLE_COMPONENT_TYPE); - componentType = resolver.resolveModel(ComponentType.class, componentType, context); - } - if (componentType.isUnresolved()) { - // Try to derive it from the service descriptions - if (!deriveFromServiceDescriptions(impl, resolver, context)) { - error(monitor, "MissingComponentTypeFile", impl, componentType.getURI()); - } - //throw new ContributionResolveException("missing .componentType side file " + ctURI); - return; - } else { - mergeFromComponentType(impl, componentType, resolver, context); - } - } - - private boolean deriveFromServiceDescriptions(OSGiImplementation impl, ModelResolver resolver, ProcessorContext context) - 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, context); - 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, context); - 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, context); - return true; - } - return false; - } - - private void mergeFromComponentType(OSGiImplementation impl, ComponentType componentType, ModelResolver resolver, ProcessorContext context) { - List<Service> 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(), context)); - } - if (service.getInterfaceContract().getCallbackInterface() instanceof JavaInterface) { - JavaInterface callbackInterface = - (JavaInterface)service.getInterfaceContract().getCallbackInterface(); - if (callbackInterface.getJavaClass() == null) { - callbackInterface.setJavaClass(getJavaClass(resolver, callbackInterface.getName(), context)); - } - } - - impl.getServices().add(service); - } - } - - List<Reference> 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(), context)); - } - impl.getReferences().add(reference); - } else - impl.getReferences().add(reference); - } - - List<Property> properties = componentType.getProperties(); - for (Property property : properties) { - impl.getProperties().add(property); - } - } - - private Class<?> getJavaClass(ModelResolver resolver, String className, ProcessorContext context) { - ClassReference ref = new ClassReference(className); - ref = resolver.resolveModel(ClassReference.class, ref, context); - return ref.getJavaClass(); - } - - public void write(OSGiImplementation model, XMLStreamWriter writer, ProcessorContext context) 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, ProcessorContext context, 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<ComponentType> processor = processors.getProcessor(ComponentType.class); - ComponentType componentType = processor.read(null, URI.create(BUNDLE_COMPONENT_TYPE), url, context); - artifactProcessor.resolve(componentType, resolver, context); - mergeFromComponentType(implementation, componentType, resolver, context); - return true; - } - return false; - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java deleted file mode 100644 index 9bd469df06..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.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 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.ProcessorContext; -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; - -/** - * A processor for <tuscany:osgi.property> - */ -public class OSGiPropertyProcessor implements StAXArtifactProcessor<OSGiProperty> { - private OSGiImplementationFactory factory; - - - public OSGiPropertyProcessor(FactoryExtensionPoint modelFactories) { - this.factory = modelFactories.getFactory(OSGiImplementationFactory.class); - } - - public OSGiProperty read(XMLStreamReader reader, ProcessorContext context) 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, ProcessorContext context) throws ContributionWriteException, XMLStreamException { - writer.writeStartElement(PROPERTY_QNAME.getNamespaceURI(), PROPERTY_QNAME.getLocalPart()); - writer.writeAttribute(NAME, model.getName()); - writer.writeCharacters(model.getValue()); - writer.writeEndElement(); - } - - public Class<OSGiProperty> getModelType() { - return OSGiProperty.class; - } - - public void resolve(OSGiProperty model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java deleted file mode 100644 index 9c529eecfc..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java +++ /dev/null @@ -1,190 +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.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -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.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -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.SCAConfig; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/* -<?xml version="1.0" encoding="UTF-8"?> -<scact:sca-config targetNamespace="http://www.foocorp.com/definitions" - xmlns:scact="http://www.osgi.org/xmlns/scact/v1.0.0" - xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" - xmlns:foocorp="http://www.foocorp.com/definitions" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.osgi.org/xmlns/scact/v1.0.0 http://www.osgi.org/xmlns/scact/v1.0.0/sca-config.xsd"> - - <sca:binding.ws name="com.foocorp.FooOrderWebServiceBinding" - uri="http://www.foocorp.com/FooOrderService" requires="sca:soap.1_2" /> - <foocorp:binding.rmi name="com.foocorp.FooOrderRMIBinding" - host="www.foocorp.com" port="8099" serviceName="FooOrderService" /> -</scact:sca-config> -*/ -public class SCAConfigProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SCAConfig> { - private static final QName SCA_CONFIG_QNAME = new QName("http://www.osgi.org/xmlns/scact/v1.0.0", "sca-config"); - private ServiceDescriptionsFactory factory; - private StAXArtifactProcessor processor; - - public SCAConfigProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) { - this.processor = processor; - FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class); - } - - public SCAConfig read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException, - ContributionReadException { - int event = reader.getEventType(); - SCAConfig definitions = factory.createSCAConfig(); - String targetNamespace = null; - while (true) { - switch (event) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - if (SCA_CONFIG_QNAME.equals(name)) { - targetNamespace = reader.getAttributeValue(null, "targetNamespace"); - definitions.setTargetNamespace(targetNamespace); - } else { - Object extension = processor.read(reader, context); - if (extension != null) { - if (extension instanceof Intent) { - Intent intent = (Intent)extension; - intent.setName(new QName(targetNamespace, intent.getName().getLocalPart())); - definitions.getIntents().add(intent); - for (Intent i : intent.getQualifiedIntents()) { - i.setName(new QName(targetNamespace, i.getName().getLocalPart())); - } - } else if (extension instanceof PolicySet) { - PolicySet policySet = (PolicySet)extension; - policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart())); - definitions.getPolicySets().add(policySet); - } else if (extension instanceof Binding) { - Binding binding = (Binding)extension; - definitions.getBindings().add(binding); - } - } - } - break; - case XMLStreamConstants.END_ELEMENT: - name = reader.getName(); - if (SCA_CONFIG_QNAME.equals(name)) { - return definitions; - } - break; - } - if (reader.hasNext()) { - event = reader.next(); - } else { - return definitions; - } - } - } - - public QName getArtifactType() { - return SCA_CONFIG_QNAME; - } - - public void write(SCAConfig definitions, XMLStreamWriter writer, ProcessorContext context) - throws ContributionWriteException, XMLStreamException { - - writeStartDocument(writer, - SCA_CONFIG_QNAME.getNamespaceURI(), - SCA_CONFIG_QNAME.getLocalPart(), - new XAttr("targetNamespace", definitions.getTargetNamespace())); - - for (Intent policyIntent : definitions.getIntents()) { - processor.write(policyIntent, writer, context); - } - - for (PolicySet policySet : definitions.getPolicySets()) { - processor.write(policySet, writer, context); - } - - writeEndDocument(writer); - } - - public void resolve(SCAConfig scaDefns, ModelResolver resolver, ProcessorContext context) - throws ContributionResolveException { - // start by adding all of the top level artifacts into the resolver as there - // are many cross artifact references in a definitions file and we don't want - // to be dependent on the order things appear - - List<Intent> intents = new ArrayList<Intent>(); - List<PolicySet> policySets = new ArrayList<PolicySet>(); - List<PolicySet> referredPolicySets = new ArrayList<PolicySet>(); - - for (Intent intent : scaDefns.getIntents()) { - intents.add(intent); - resolver.addModel(intent, context); - for (Intent i : intent.getQualifiedIntents()) { - intents.add(i); - resolver.addModel(i, context); - } - } - - for (PolicySet policySet : scaDefns.getPolicySets()) { - if (policySet.getReferencedPolicySets().isEmpty()) { - policySets.add(policySet); - } else { - referredPolicySets.add(policySet); - } - - resolver.addModel(policySet, context); - } - - // now resolve everything to ensure that any references between - // artifacts are satisfied - - for (Intent policyIntent : intents) - processor.resolve(policyIntent, resolver, context); - - for (PolicySet policySet : policySets) - processor.resolve(policySet, resolver, context); - - for (PolicySet policySet : referredPolicySets) - processor.resolve(policySet, resolver, context); - - } - - public Class<SCAConfig> getModelType() { - return SCAConfig.class; - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java deleted file mode 100644 index ad175e009c..0000000000 --- a/branches/sca-java-2.0-M4/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.ProcessorContext; -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; - -/** - * The service descriptions document processor - */ -public class ServiceDescriptionsDocumentProcessor implements URLArtifactProcessor<ServiceDescriptions> { - private XMLInputFactory inputFactory; - private StAXArtifactProcessor extensionProcessor; - - public ServiceDescriptionsDocumentProcessor(FactoryExtensionPoint modelFactories, - StAXArtifactProcessor staxProcessor) { - 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, ProcessorContext context) - 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); - ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor()); - Object result = extensionProcessor.read(reader, context); - 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<ServiceDescriptions> getModelType() { - return ServiceDescriptions.class; - } - - public void resolve(ServiceDescriptions model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java deleted file mode 100644 index cd62d5cfaf..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java +++ /dev/null @@ -1,59 +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.processor.ProcessorContext; -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, ProcessorContext context) { - // Merge the service descriptions - if (resolved instanceof ServiceDescriptions) { - serviceDescriptions.addAll((ServiceDescriptions)resolved); - } - } - - public Object removeModel(Object resolved, ProcessorContext context) { - // Remove the service descriptions - if (resolved instanceof ServiceDescriptions) { - serviceDescriptions.removeAll((ServiceDescriptions)resolved); - } - return resolved; - } - - public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) { - // Always return the aggregated service descriptions - return modelClass.cast(serviceDescriptions); - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java deleted file mode 100644 index fc6e44d8d6..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java +++ /dev/null @@ -1,191 +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.util.StringTokenizer; - -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.BaseStAXArtifactProcessor; -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.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -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.ServiceDescription; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions; -import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; - -/* -<?xml version="1.0" encoding="UTF-8"?> -<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> - <service-description> - <provide interface="com.iona.soa.pojo.hello.HelloService"/> - <property name="service.intents">SOAP HTTP</property> - <property name="osgi.remote.configuration.type">pojo</property> - <property name="osgi.remote.configuration.pojo.address"> - http://localhost:9000/hello - </property> - </service-description> - <service-description> - <provide interface="com.iona.soa.pojo.hello.GreeterService"/> - <property name="service.intents">SOAP HTTP</property> - <property name="osgi.remote.configuration.type">pojo</property> - <property name="osgi.remote.configuration.pojo.address"> - http://localhost:9005/greeter - </property> - </service-description> -</service-descriptions> -*/ -public class ServiceDescriptionsProcessor extends BaseStAXArtifactProcessor implements - StAXArtifactProcessor<ServiceDescriptions> { - private ServiceDescriptionsFactory factory; - private StAXArtifactProcessor processor; - - - public ServiceDescriptionsProcessor(ExtensionPointRegistry registry, - StAXArtifactProcessor processor) { - this.processor = processor; - FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class); - } - - public ServiceDescriptions read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException, ContributionReadException { - 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); - } - if (propName.endsWith(".intents")) { - prop = toQNames(reader, propValue); - } - sd.getProperties().put(propName, prop); - } else { - name = reader.getName(); - if (!ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) { - Object ext = processor.read(reader, context); - if (sd != null) { - sd.getProperties().put(name.toString(), ext); - } - } - } - 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; - } - } - } - - /** - * Convert ns1:e1 ns2:e2 to {http://ns1}e1 {http://ns2}e2 - * @param reader - * @param value - * @return - */ - private String toQNames(XMLStreamReader reader, String value) { - if (value == null) { - return null; - } - StringBuffer sb = new StringBuffer(); - for (StringTokenizer tokens = new StringTokenizer(value, " \t\n\r\f,"); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - sb.append(qname.toString()).append(' '); - } - return sb.toString().trim(); - } - - public QName getArtifactType() { - return ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME; - } - - public void write(ServiceDescriptions model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - // TODO: To be implemented - } - - public Class<ServiceDescriptions> getModelType() { - return ServiceDescriptions.class; - } - - public void resolve(ServiceDescriptions model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - // TODO: To be implemented - } -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml deleted file mode 100644 index f531c2c4ed..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" - targetNamespace="http://www.osgi.org/xmlns/sca/intents/v1.0.0"> - - <intent name="passByReference" constrains="sca:implementation" - intentType="implementation"> - <description> - An OSGi intent to pass data by reference - </description> - </intent> - - <intent name="passByValue" constrains="sca:implementation" - intentType="implementation"> - <description> - An OSGi intent to pass data by value - </description> - </intent> - -</sca:definitions>
\ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index cc5e78c4cf..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,22 +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 -org.apache.tuscany.sca.implementation.osgi.xml.SCAConfigProcessor;qname=http://www.osgi.org/xmlns/scact/v1.0.0#sca-config,model=org.apache.tuscany.sca.implementation.osgi.SCAConfig
\ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory b/branches/sca-java-2.0-M4/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-M4/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-M4/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties deleted file mode 100644 index a406ea21c3..0000000000 --- a/branches/sca-java-2.0-M4/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-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java deleted file mode 100644 index 656b78b717..0000000000 --- a/branches/sca-java-2.0-M4/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-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java deleted file mode 100644 index 971500782f..0000000000 --- a/branches/sca-java-2.0-M4/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-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java deleted file mode 100644 index 49b8a1c0bf..0000000000 --- a/branches/sca-java-2.0-M4/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-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java deleted file mode 100644 index f4e59d12ea..0000000000 --- a/branches/sca-java-2.0-M4/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-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java deleted file mode 100644 index bfb9b820f7..0000000000 --- a/branches/sca-java-2.0-M4/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-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java deleted file mode 100644 index 224467181b..0000000000 --- a/branches/sca-java-2.0-M4/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.contribution.processor.ProcessorContext; -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 = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<components xmlns=\"http://www.osgi.org/xmlns/blueprint/v1.0.0\">" - + "<component id=\"CalculatorComponent\" class=\"calculator.dosgi.impl.CalculatorServiceImpl\">" - + "<property name=\"addService\" ref=\"AddService\" />" - + "<property name=\"subtractService\" ref=\"SubtractService\" />" - + "<property name=\"multiplyService\" ref=\"MultiplyService\" />" - + "<property name=\"divideService\" ref=\"DivideService\" />" - + "</component>" - + "<service id=\"CalculatorService\" ref=\"CalculatorComponent\" interface=\"calculator.dosgi.CalculatorService\">" - + "</service>" - + "<reference id=\"AddService\" interface=\"calculator.dosgi.operations.AddService\">" - + "</reference>" - + "<reference id=\"SubtractService\" interface=\"calculator.dosgi.operations.SubtractService\">" - + "</reference>" - + "<reference id=\"MultiplyService\" interface=\"calculator.dosgi.operations.MultiplyService\">" - + "</reference>" - + "<reference id=\"DivideService\" interface=\"calculator.dosgi.operations.DivideService\">" - + "</reference>" - + "</components>"; - 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())); - ComponentType ct = processor.read(reader, new ProcessorContext()); - 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-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java deleted file mode 100644 index ef49121c2c..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.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.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class OSGiComponentProcessorTestCase { - private static final String xml = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<scr:component name=\"CalculatorComponent\"" - + " xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.0.0\">" - + "<implementation class=\"calculator.dosgi.CalculatorServiceDSImpl\" />" - + "<service>" - + "<provide interface=\"calculator.dosgi.CalculatorService\" />" - + "</service>" - + "<reference name=\"addService\" interface=\"calculator.dosgi.operations.AddService\"" - + " bind=\"setAddService\" unbind=\"unsetAddService\" policy=\"dynamic\" />" - + "<reference name=\"subtractService\" interface=\"calculator.dosgi.operations.SubtractService\"" - + " bind=\"setSubtractService\" unbind=\"unsetSubtractService\" policy=\"dynamic\" />" - + "<reference name=\"multiplyService\" interface=\"calculator.dosgi.operations.MultiplyService\"" - + " bind=\"setMultiplyService\" unbind=\"unsetMultiplyService\" policy=\"dynamic\" />" - + "<reference name=\"divideService\" interface=\"calculator.dosgi.operations.DivideService\"" - + " bind=\"setDivideService\" unbind=\"unsetDivideService\" policy=\"dynamic\" />" - + "</scr:component>"; - - 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 { - ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); - OSGiComponentProcessor processor = - new OSGiComponentProcessor(new DefaultFactoryExtensionPoint(registry)); - ComponentType ct = processor.read(reader, new ProcessorContext(registry)); - 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-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java deleted file mode 100644 index 6b59b498fc..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java +++ /dev/null @@ -1,139 +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.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -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<Object> staxProcessor; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - 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); - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader, context); - 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, context); - assertNotNull(composite); - - is = getClass().getClassLoader().getResourceAsStream("OSGI-INF/sca/bundle.componentType"); - reader = inputFactory.createXMLStreamReader(is); - ComponentType componentType = (ComponentType)staxProcessor.read(reader, context); - - 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, context); - resolver.addModel(componentType, context); - - staxProcessor.resolve(composite, resolver, context); - } - - @Test - public void testReadOSGiImplementation() throws Exception { - - String str = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<implementation.osgi xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" targetNamespace=\"http://test\" " - + "bundleSymbolicName=\"osgi.test\" " - + "bundleVersion=\"1.0.0\" " - + "/>"; - ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes()); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - reader.nextTag(); - - OSGiImplementation osgiImpl = (OSGiImplementation)staxProcessor.read(reader, context); - - assertEquals(osgiImpl.getBundleSymbolicName(), "osgi.test"); - assertEquals(osgiImpl.getBundleVersion(), "1.0.0"); - - StringWriter sw = new StringWriter(); - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw); - staxProcessor.write(osgiImpl, writer, context); - writer.flush(); - Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\"")); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java deleted file mode 100644 index 1b28373f5b..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java +++ /dev/null @@ -1,108 +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.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -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 = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" - + "<service-descriptions xmlns=\"http://www.osgi.org/xmlns/sd/v1.0.0\" " - + "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\">" - + "<service-description>" - + "<provide interface=\"calculator.operations.AddService\"/>" - + "<property name=\"service.intents\">sca:SOAP sca:HTTP</property>" - + "<property name=\"osgi.remote.configuration.type\">sca</property>" - + "<property name=\"osgi.remote.configuration.sca.componentType\">" - + "OSGI-INF/sca/bundle.componentType" - + "</property>" - + "<property name=\"osgi.remote.configuration.sca.reference\">" - + "addService" - + "</property>" - + "</service-description>" - + "<service-description>" - + "<provide interface=\"calculator.operations.SubtractService\"/>" - + "<property name=\"service.intents\">sca:SOAP sca:HTTP</property>" - + "<property name=\"osgi.remote.configuration.type\">sca</property>" - + "<property name=\"osgi.remote.configuration.sca.componentType\">" - + "OSGI-INF/sca/bundle.componentType" - + "</property>" - + "<property name=\"osgi.remote.configuration.sca.reference\">" - + "subtractService" - + "</property>" - + "</service-description>" - + "</service-descriptions>"; - - private static ServiceDescriptionsProcessor processor; - private static XMLStreamReader reader; - - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - - XMLInputFactory factory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = - extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - StAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, factory, null); - - processor = new ServiceDescriptionsProcessor(extensionPoints, staxProcessor); - - reader = factory.createXMLStreamReader(new StringReader(xml)); - } - - @Test - public void testLoad() throws Exception { - List<ServiceDescription> descriptions = processor.read(reader, context); - 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-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java deleted file mode 100644 index 17fef8a05c..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.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 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.processor.ProcessorContext; -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<Object, Object> map = new HashMap<Object, Object>(); - - private WeakReference<ClassLoader> classLoader; - - public TestModelResolver(ClassLoader classLoader) { - this.classLoader = new WeakReference<ClassLoader>(classLoader); - } - - public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - if (unresolved instanceof OSGiImplementationImpl && !(resolved instanceof OSGiImplementationImpl)) { - - OSGiImplementationImpl impl = ((OSGiImplementationImpl)unresolved); - ComponentType componentType = (ComponentType)resolved; - - List<Property> 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, ProcessorContext context) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved, ProcessorContext context) { - return map.remove(resolved); - } - -} diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml deleted file mode 100644 index 3e537df732..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<scr:component name="CalculatorComponent" - xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0"> - <implementation class="calculator.dosgi.CalculatorServiceDSImpl" /> - <service> - <provide interface="calculator.dosgi.CalculatorService" /> - </service> - - <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService" - policy="dynamic" /> - <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService" - unbind="unsetSubtractService" policy="dynamic" /> - <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService" - unbind="unsetMultiplyService" policy="dynamic" /> - <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService" - unbind="unsetDivideService" policy="dynamic" /> - -</scr:component> diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType deleted file mode 100644 index bc9e4f6aaf..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"> - <!-- The service elment defines an SCA view of the OSGi service --> - <service name="Calculator"> - <!-- The interface will be mapped into the OSGi service class --> - <interface.java interface="calculator.dosgi.CalculatorService"/> - <!-- The list of OSGi properties --> - <t:osgi.property name="prop1">1</t:osgi.property> - <t:osgi.property name="prop2">ABC</t:osgi.property> - </service> - - <!-- The reference elment defines an SCA proxy to a remote OSGi service --> - <reference name="addService"> - <interface.java interface="calculator.dosgi.operations.AddService"/> - <t:osgi.property name="prop1">1</t:osgi.property> - <t:osgi.property name="prop2">ABC</t:osgi.property> - </reference> - <reference name="subtractService"> - <interface.java interface="calculator.dosgi.operations.SubtractService"/> - <t:osgi.property name="prop1">1</t:osgi.property> - <t:osgi.property name="prop2">ABC</t:osgi.property> - </reference> - <reference name="multiplyService"> - <interface.java interface="calculator.dosgi.operations.MultiplyService"/> - <t:osgi.property name="prop1">1</t:osgi.property> - <t:osgi.property name="prop2">ABC</t:osgi.property> - </reference> - <reference name="divideService"> - <interface.java interface="calculator.dosgi.operations.DivideService"/> - <t:osgi.property name="prop1">1</t:osgi.property> - <t:osgi.property name="prop2">ABC</t:osgi.property> - </reference> - -</componentType> diff --git a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/osgitest.composite b/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/osgitest.composite deleted file mode 100644 index 8c59703724..0000000000 --- a/branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/osgitest.composite +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://test" - name="OSGiTestComposite"> - - <component name="OSGiTestServiceComponent"> - <tuscany:implementation.osgi bundleVersion="1.0.0" - bundleSymbolicName="osgi.test" /> - - <property name="currency" type="xsd:string">USD</property> - <property name="exchangeRate" type="xsd:double">2.0</property> - - </component> - -</composite> |