You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/06/20 16:58:26 UTC
svn commit: r549122 [2/2] - in
/incubator/tuscany/java/sca/modules/implementation-osgi: ./
src/main/java/org/apache/tuscany/implementation/
src/main/java/org/apache/tuscany/implementation/osgi/
src/main/java/org/apache/tuscany/implementation/osgi/conte...
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/FelixRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/FelixRuntime.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/FelixRuntime.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/FelixRuntime.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,146 @@
+/*
+ * 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.implementation.osgi.runtime;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class FelixRuntime extends OSGiRuntime implements BundleActivator {
+
+ private static BundleContext bundleContext;
+
+ private static FelixRuntime instance;
+
+ private static Class felixClass;
+ private static Object felix;
+
+ public static OSGiRuntime getInstance() {
+ if (instance == null)
+ instance = new FelixRuntime();
+ return instance;
+ }
+
+
+ private static void deleteDirectory(File dir) {
+
+ File[] files = dir.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory())
+ deleteDirectory(files[i]);
+ else
+ files[i].delete();
+ }
+ dir.delete();
+
+ }
+
+ protected BundleContext startRuntime() throws Exception {
+
+ if (bundleContext != null)
+ return bundleContext;
+
+
+ ClassLoader cl = FelixRuntime.class.getClassLoader();
+
+ Class felixMainClass = cl.loadClass("org.apache.felix.main.Main");
+ felixClass = cl.loadClass("org.apache.felix.framework.Felix");
+ Class propertyResolverClass = cl.loadClass("org.apache.felix.framework.util.MutablePropertyResolver");
+ Class propertyResolverImplClass = cl.loadClass("org.apache.felix.framework.util.MutablePropertyResolverImpl");
+
+ Method propsMethod = felixMainClass.getMethod("loadConfigProperties");
+ Properties props = (Properties)propsMethod.invoke(null);
+
+ File profileDir = new File(".felix");
+ if (profileDir.isDirectory())
+ deleteDirectory(profileDir);
+ else
+ profileDir.delete();
+ profileDir.mkdir();
+ profileDir.deleteOnExit();
+
+ props.put("felix.cache.profiledir", profileDir.getAbsolutePath());
+ props.put("felix.embedded.execution", "true");
+ props.put("org.osgi.framework.system.packages",
+ "org.osgi.framework; version=1.3.0," +
+ "org.osgi.service.packageadmin; version=1.2.0, " +
+ "org.osgi.service.startlevel; version=1.0.0, " +
+ "org.osgi.service.url; version=1.0.0 ");
+
+
+
+ Constructor implConstructor = propertyResolverImplClass.getConstructor(Map.class);
+ Object mutableProps = implConstructor.newInstance(props);
+
+ felix = felixClass.newInstance();
+ Method startMethod = felixClass.getMethod("start", propertyResolverClass, List.class);
+ List<BundleActivator> activators = new ArrayList<BundleActivator>();
+ BundleActivator activator = new FelixRuntime();
+ activators.add(activator);
+ startMethod.invoke(felix, mutableProps, activators);
+
+ synchronized (activator) {
+ int retries = 0;
+ while (bundleContext == null && retries++ < 10) {
+ activator.wait(1000);
+ }
+ }
+
+ return bundleContext;
+
+ }
+
+ public void start(BundleContext context) throws Exception {
+
+ bundleContext = context;
+ synchronized (this) {
+ this.notify();
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ bundleContext = null;
+ }
+
+
+ @Override
+ protected void shutdownRuntime() throws Exception {
+
+ if (bundleContext == null)
+ return;
+ bundleContext = null;
+ if (felix != null) {
+ Method shutdownMethod = felixClass.getMethod("shutdown");
+ try {
+ shutdownMethod.invoke(felix);
+ } catch (Exception e) {
+ // Ignore errors
+ }
+ felix = null;
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/FelixRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/FelixRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/KnopflerfishRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/KnopflerfishRuntime.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/KnopflerfishRuntime.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/KnopflerfishRuntime.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,144 @@
+/*
+ * 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.implementation.osgi.runtime;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+public class KnopflerfishRuntime extends OSGiRuntime {
+
+ private static BundleContext bundleContext;
+
+ private static KnopflerfishRuntime instance;
+
+
+ private static Class frameworkClass;
+
+ private static Object framework;
+
+ public static OSGiRuntime getInstance() {
+ if (instance == null)
+ instance = new KnopflerfishRuntime();
+ return instance;
+ }
+
+
+
+ // FIXME: Knopflerfish does not expose the methods used for configuration as public methods
+ // It may be worth using the private methods in org.knopflerfish.framework.Main for
+ // configuring using reflection if security policies allow it.
+ // For now, a simple configuration routine reads sca.xargs from the directory in
+ // the classpath which contains framework.jar. The entries in init.xargs starting with
+ // -install are assumed to be single-line entries with full bundle location.
+ //
+ protected BundleContext startRuntime() throws Exception {
+
+ if (bundleContext != null)
+ return bundleContext;
+
+
+
+ System.setProperty("org.knopflerfish.framework.bundlestorage", "memory");
+
+ frameworkClass = KnopflerfishRuntime.class.getClassLoader().loadClass("org.knopflerfish.framework.Framework");
+ Constructor frameworkConstructor = frameworkClass.getConstructor(Object.class);
+ framework = frameworkConstructor.newInstance(new KnopflerfishRuntime());
+ Method launchMethod = frameworkClass.getMethod("launch", long.class);
+ launchMethod.invoke(framework, 0);
+ Method getContextMethod = frameworkClass.getMethod("getSystemBundleContext");
+ bundleContext = (BundleContext)getContextMethod.invoke(framework);
+
+ System.setProperty("com.gatespace.bundle.cm.store", "knopflerfish.store");
+ File xargsFile = null;
+ String classpath = System.getProperty("java.class.path");
+ String[] classpathEntries = classpath.split(System.getProperty("path.separator"));
+ for (int i = 0; i < classpathEntries.length; i++) {
+ if (classpathEntries[i].endsWith("framework.jar")) {
+ String path = classpathEntries[i].substring(0, classpathEntries[i].length() - "framework.jar".length());
+ path = path + "sca.xargs";
+ xargsFile = new File(path);
+ if (!xargsFile.exists())
+ xargsFile = null;
+ break;
+ }
+ }
+ if (xargsFile != null) {
+ BufferedReader reader = new BufferedReader(new FileReader(xargsFile));
+ String line;
+ Hashtable<String, Bundle> bundles = new Hashtable<String, Bundle>();
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ if (line.startsWith("-install")) {
+ try {
+
+ String bundleLocation = line.substring("-install".length()).trim();
+ Bundle bundle = bundleContext.installBundle(bundleLocation);
+ bundles.put(bundleLocation, bundle);
+
+ } catch (BundleException e) {
+ e.printStackTrace();
+ }
+
+ }
+ if (line.startsWith("-start")) {
+
+ try {
+ String bundleLocation = line.substring("-start".length()).trim();
+ Bundle bundle = bundles.get(bundleLocation);
+ bundle.start();
+ } catch (BundleException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+
+ return bundleContext;
+
+ }
+
+
+
+ @Override
+ protected void shutdownRuntime() throws Exception {
+
+ if (bundleContext == null)
+ return;
+ bundleContext = null;
+ if (framework != null) {
+ Method shutdownMethod = frameworkClass.getMethod("shutdown");
+ try {
+ shutdownMethod.invoke(framework);
+ } catch (Exception e) {
+ // Ignore errors
+ }
+ framework = null;
+ }
+
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/KnopflerfishRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/KnopflerfishRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntime.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntime.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntime.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.implementation.osgi.runtime;
+
+
+import java.lang.reflect.Method;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+public abstract class OSGiRuntime {
+
+ protected abstract BundleContext startRuntime() throws Exception;
+
+ protected abstract void shutdownRuntime() throws Exception;
+
+
+ /**
+ * System property org.apache.tuscany.implementation.osgi.runtime.OSGiRuntime can be set to the
+ * name of the OSGiRuntime class (eg. EquinoxRuntime). If set, start this runtime and return the
+ * system bundlecontext. If not set, start Equinox/Felix/Knopflerfish (in that order) from the
+ * classpath.
+ *
+ * @return
+ * @throws BundleException
+ */
+ public static BundleContext startAndGetBundleContext() throws BundleException {
+
+ String runtimeClassName = System.getProperty(OSGiRuntime.class.getName());
+ if (runtimeClassName != null) {
+ try {
+ Class<?> runtimeClass = OSGiRuntime.class.getClassLoader().loadClass(runtimeClassName);
+ Method method = runtimeClass.getMethod("getInstance");
+ OSGiRuntime runtime = (OSGiRuntime) method.invoke(null);
+ return runtime.startRuntime();
+
+ } catch (Exception e) {
+ throw new BundleException("Could not start OSGi runtime " + runtimeClassName, e);
+ }
+ }
+
+ try {
+
+ return EquinoxRuntime.getInstance().startRuntime();
+
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+ try {
+
+ return FelixRuntime.getInstance().startRuntime();
+
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+ try {
+
+ return KnopflerfishRuntime.getInstance().startRuntime();
+
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+ throw new BundleException("Could not start OSGi runtime from the classpath");
+ }
+
+
+ public static void shutdown() throws BundleException {
+
+ try {
+ String runtimeClassName = System.getProperty(OSGiRuntime.class.getName());
+ if (runtimeClassName != null) {
+
+ Class<?> runtimeClass = OSGiRuntime.class.getClassLoader().loadClass(runtimeClassName);
+ Method method = runtimeClass.getMethod("getInstance");
+ OSGiRuntime runtime = (OSGiRuntime) method.invoke(null);
+ runtime.shutdownRuntime();
+
+ }
+
+ try {
+
+ EquinoxRuntime.getInstance().shutdownRuntime();
+
+ } catch (ClassNotFoundException e) {
+ }
+
+ try {
+
+ FelixRuntime.getInstance().shutdownRuntime();
+
+ } catch (ClassNotFoundException e) {
+ }
+ try {
+
+ KnopflerfishRuntime.getInstance().shutdownRuntime();
+
+ } catch (ClassNotFoundException e) {
+ }
+ } catch (Exception e) {
+ throw new BundleException("Could not shutdown OSGi runtime", e);
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementation.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementation.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementation.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,125 @@
+/*
+ * 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.implementation.osgi.xml;
+
+
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.impl.ComponentTypeImpl;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.implementation.osgi.OSGiImplementationInterface;
+import org.apache.tuscany.sca.scope.Scope;
+
+
+/**
+ * OSGi implementation
+ * All attributes from <implementation.osgi> have getters in this class
+ * This class implements OSGiImplementationInterface which is associated with OSGiImplementationProvider.
+ */
+public class OSGiImplementation extends ComponentTypeImpl implements OSGiImplementationInterface {
+
+ private String bundleName;
+ private String bundleLocation;
+ private String[] imports;
+ private Scope scope;
+ private String[] allowsPassByRef;
+ Hashtable<String, List<ComponentProperty>> referenceProperties;
+ Hashtable<String, List<ComponentProperty>> serviceProperties;
+
+ public OSGiImplementation(String bundleName,
+ String bundleLocation,
+ String[] imports,
+ String scopeName,
+ String[] allowsPassByRef,
+ Hashtable<String, List<ComponentProperty>> refProperties,
+ Hashtable<String, List<ComponentProperty>> serviceProperties) {
+
+ super();
+ this.bundleName = bundleName;
+ this.bundleLocation = bundleLocation;
+ this.imports = imports;
+ this.scope = new Scope(scopeName == null?"COMPOSITE":scopeName);
+ this.allowsPassByRef = allowsPassByRef;
+ this.referenceProperties = refProperties;
+ this.serviceProperties = serviceProperties;
+
+ }
+
+
+ public String getBundleName() {
+ return bundleName;
+ }
+
+ public String getBundleLocation() {
+ return bundleLocation;
+ }
+
+
+ public String[] getImports() {
+ return imports;
+ }
+
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public List<ComponentProperty> getReferenceProperties(String referenceName) {
+ return referenceProperties.get(referenceName);
+ }
+
+ public List<ComponentProperty> getServiceProperties(String serviceName) {
+ return serviceProperties.get(serviceName);
+ }
+
+
+ public boolean isAllowsPassByReference(Operation operation) {
+ if (allowsPassByRef == null || allowsPassByRef.length == 0)
+ return false;
+ Interface interfaze = operation.getInterface();
+ if (!(interfaze instanceof JavaInterface))
+ return false;
+ String className = ((JavaInterface)interfaze).getJavaClass().getName();
+ String operationName = className + "." + operation.getName();
+
+ for (String opName : allowsPassByRef) {
+ if (className.equals(opName) || operationName.equals(opName))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isEagerInit() {
+ return false;
+ }
+
+ public long getMaxAge() {
+ return Long.MAX_VALUE;
+ }
+
+ public long getMaxIdleTime() {
+ return Long.MAX_VALUE;
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementationProcessor.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementationProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementationProcessor.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,458 @@
+/*
+ * 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.implementation.osgi.xml;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.osoa.sca.Constants.SCA_NS;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+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.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+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.interfacedef.java.introspect.JavaInterfaceIntrospector;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * Process an <implementation.osgi/> element in a component definition. An instance of
+ * OSGiImplementation is created.
+ * Also associates the component type file with the implementation.
+ *
+ *
+ */
+public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiImplementation> {
+
+ public static final QName IMPLEMENTATION_OSGI = new QName(SCA_NS, "implementation.osgi");
+
+ private JavaInterfaceIntrospector interfaceIntrospector;
+ private JavaInterfaceFactory javaInterfaceFactory;
+ private AssemblyFactory assemblyFactory;
+ private PolicyFactory policyFactory;
+ private QName PROPERTIES_QNAME = new QName(SCA_NS, "properties");
+ private QName PROPERTY_QNAME = new QName(SCA_NS, "property");
+ private static final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+ static {
+ domFactory.setNamespaceAware(true);
+ }
+
+ public OSGiImplementationProcessor(JavaInterfaceIntrospector interfaceIntrospector,
+ JavaInterfaceFactory javaInterfaceFactory,
+ AssemblyFactory assemblyFactory,
+ PolicyFactory policyFactory) {
+
+ this.interfaceIntrospector = interfaceIntrospector;
+ this.assemblyFactory = assemblyFactory;
+ this.javaInterfaceFactory = javaInterfaceFactory;
+ this.policyFactory = policyFactory;
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_OSGI;
+ }
+
+ public Class<OSGiImplementation> getModelType() {
+ return OSGiImplementation.class;
+ }
+
+
+ public OSGiImplementation read(XMLStreamReader reader) throws ContributionReadException {
+ assert IMPLEMENTATION_OSGI.equals(reader.getName());
+ try {
+ String bundleName = reader.getAttributeValue(null, "bundle");
+ String bundleLocation = reader.getAttributeValue(null, "bundleLocation");
+ String imports = reader.getAttributeValue(null, "imports");
+ String[] importList;
+ if (imports != null)
+ importList = imports.split("[ \\t\\n]");
+ else
+ importList = new String[0];
+ String scope = reader.getAttributeValue(null, "scope");
+ String allowsPassByRef = reader.getAttributeValue(null, "allowsPassByReference");
+ String[] allowsPassByRefList;
+ if (allowsPassByRef != null)
+ allowsPassByRefList = allowsPassByRef.split("[ \\t\\n]");
+ else
+ allowsPassByRefList = new String[0];
+
+ Hashtable<String, List<ComponentProperty>> refProperties =
+ new Hashtable<String, List<ComponentProperty>>();
+ Hashtable<String, List<ComponentProperty>> serviceProperties =
+ new Hashtable<String, List<ComponentProperty>>();
+
+ while (reader.hasNext()) {
+
+ int next = reader.next();
+ if (next == END_ELEMENT && IMPLEMENTATION_OSGI.equals(reader.getName())) {
+ break;
+ }
+ else if (next == START_ELEMENT && PROPERTIES_QNAME.equals(reader.getName())) {
+
+ // FIXME: This is temporary code which allows reference and service properties used
+ // for filtering OSGi services to be specified in <implementation.osgi/>
+ // This should really be provided in the component type file since these
+ // properties are associated with an implementation rather than a configured
+ // instance of an implementation.
+ String refName = reader.getAttributeValue(null, "reference");
+ String serviceName = reader.getAttributeValue(null, "service");
+ List<ComponentProperty> props = readProperties(reader);
+ if (refName != null)
+ refProperties.put(refName, props);
+ else if (serviceName != null)
+ serviceProperties.put(serviceName, props);
+ else
+ throw new ContributionReadException("Properties in implementation.osgi should specify service or reference"); }
+ }
+
+ OSGiImplementation implementation = new OSGiImplementation(
+ bundleName,
+ bundleLocation,
+ importList,
+ scope,
+ allowsPassByRefList,
+ refProperties,
+ serviceProperties);
+
+
+ processComponentType(bundleName, implementation);
+
+ implementation.setUnresolved(true);
+
+ return implementation;
+
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public void resolve(OSGiImplementation impl, ModelResolver resolver) throws ContributionResolveException {
+
+ try {
+
+ impl.setUnresolved(false);
+
+ // FIXME: Tuscany will only process the component type file if it is visible
+ // to its classloader. So it can't really be located anywhere in the
+ // directory structure like the bundle. So even though the bundle name
+ // is used to find the relative pathname of the component type file,
+ // its absolute location is obtained from the classloader. This doesn't
+ // seem right, since the bundle could potentially be located anywhere.
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ String bundleName = impl.getBundleName();
+ String ctName = bundleName + ".componentType";
+ String ctURI = cl.getResource(ctName).toString();
+
+ impl.setURI(ctURI);
+ ComponentType componentType = resolver.resolveModel(ComponentType.class, impl);
+ if (componentType.isUnresolved()) {
+ throw new ContributionResolveException("missing .componentType side file");
+ }
+
+ 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) {
+ Class<?> javaClass = Class.forName(javaInterface.getName());
+ javaInterface.setJavaClass(javaClass);
+ }
+ Service serv = createService(service, javaInterface.getJavaClass());
+ impl.getServices().add(serv);
+ }
+ }
+
+ 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) {
+ Class<?> javaClass = Class.forName(javaInterface.getName());
+ javaInterface.setJavaClass(javaClass);
+ }
+ Reference ref = createReference(reference, javaInterface.getJavaClass());
+ impl.getReferences().add(ref);
+ }
+ else
+ impl.getReferences().add(reference);
+ }
+
+ List<Property> properties = componentType.getProperties();
+ for (Property property : properties) {
+ impl.getProperties().add(property);
+ }
+ impl.setConstrainingType(componentType.getConstrainingType());
+
+
+ } catch (Exception e) {
+ throw new ContributionResolveException(e);
+ }
+
+ }
+
+ private Service createService(Service serv, Class<?> interfaze) throws InvalidInterfaceException {
+ Service service = assemblyFactory.createService();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+
+ // create a relative URI
+ service.setName(serv.getName());
+
+ JavaInterface callInterface = interfaceIntrospector.introspect(interfaze);
+ service.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = interfaceIntrospector.introspect(callInterface.getCallbackClass());
+ service.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ return service;
+ }
+
+ private Reference createReference(Reference ref, Class<?> clazz) throws InvalidInterfaceException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+
+ reference.setName(ref.getName());
+ reference.setMultiplicity(ref.getMultiplicity());
+
+ JavaInterface callInterface = interfaceIntrospector.introspect(clazz);
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = interfaceIntrospector.introspect(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+
+ return reference;
+ }
+
+ public void write(OSGiImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException {
+ }
+
+ private void processComponentType(String serviceName, OSGiImplementation implementation) {
+
+ // Form the URI of the expected .componentType file;
+ String ctName = serviceName.replaceAll("\\.", "/") + ".componentType";
+ String uri = ctName;
+
+
+ implementation.setURI(uri);
+ implementation.setUnresolved(true);
+ }
+
+ private QName getQNameValue(XMLStreamReader reader, String value) {
+ if (value != null) {
+ int index = value.indexOf(':');
+ String prefix = index == -1 ? "" : value.substring(0, index);
+ String localName = index == -1 ? value : value.substring(index + 1);
+ String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ } else {
+ return null;
+ }
+ }
+
+ private void declareNamespace(Element element, String prefix, String ns) {
+ String qname = null;
+ if ("".equals(prefix)) {
+ qname = "xmlns";
+ } else {
+ qname = "xmlns:" + prefix;
+ }
+ Node node = element;
+ boolean declared = false;
+ while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ NamedNodeMap attrs = node.getAttributes();
+ if (attrs == null) {
+ break;
+ }
+ Node attr = attrs.getNamedItem(qname);
+ if (attr != null) {
+ declared = ns.equals(attr.getNodeValue());
+ break;
+ }
+ node = node.getParentNode();
+ }
+ if (!declared) {
+ org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
+ attr.setValue(ns);
+ element.setAttributeNodeNS(attr);
+ }
+ }
+
+ private Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname = (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name
+ .getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+ private void loadElement(XMLStreamReader reader, Element root) throws XMLStreamException {
+ Document document = root.getOwnerDocument();
+ Node current = root;
+ while (true) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ Element child = createElement(document, name);
+
+ // push the new element and make it the current one
+ current.appendChild(child);
+ current = child;
+
+ declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
+
+ int count = reader.getNamespaceCount();
+ for (int i = 0; i < count; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ declareNamespace(child, prefix, ns);
+ }
+
+ // add the attributes for this element
+ count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String localPart = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+ child.setAttributeNS(ns, localPart, value);
+ declareNamespace(child, prefix, ns);
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ current.appendChild(document.createCDATASection(reader.getText()));
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ current.appendChild(document.createTextNode(reader.getText()));
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ // if we are back at the root then we are done
+ if (current == root) {
+ return;
+ }
+
+ // pop the element off the stack
+ current = current.getParentNode();
+ }
+ }
+ }
+
+ private Document readPropertyValue(XMLStreamReader reader, QName type)
+ throws XMLStreamException, ParserConfigurationException {
+
+ Document doc = domFactory.newDocumentBuilder().newDocument();
+
+ // root element has no namespace and local name "value"
+ Element root = doc.createElementNS(null, "value");
+ if (type != null) {
+ org.w3c.dom.Attr xsi = doc.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+ xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ root.setAttributeNodeNS(xsi);
+
+ String prefix = type.getPrefix();
+ if (prefix == null || prefix.length() == 0) {
+ prefix = "ns";
+ }
+
+ declareNamespace(root, prefix, type.getNamespaceURI());
+
+ org.w3c.dom.Attr xsiType = doc.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+ xsiType.setValue(prefix + ":" + type.getLocalPart());
+ root.setAttributeNodeNS(xsiType);
+ }
+ doc.appendChild(root);
+
+ loadElement(reader, root);
+ return doc;
+ }
+
+ private void readProperty(ComponentProperty prop, XMLStreamReader reader)
+ throws XMLStreamException, ContributionReadException {
+
+
+ prop.setName(reader.getAttributeValue(null, "name"));
+ prop.setXSDType(getQNameValue(reader, reader.getAttributeValue(null, "type")));
+
+ try {
+ Document value = readPropertyValue(reader, prop.getXSDType());
+ prop.setValue(value);
+ } catch (ParserConfigurationException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ private List<ComponentProperty> readProperties(XMLStreamReader reader)
+ throws XMLStreamException, ContributionReadException {
+
+ List<ComponentProperty> properties = new ArrayList<ComponentProperty>();
+
+ while (reader.hasNext()) {
+
+ int next = reader.next();
+ if (next == END_ELEMENT && PROPERTIES_QNAME.equals(reader.getName())) {
+ break;
+ }
+ else if (next == START_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
+
+ ComponentProperty componentProperty = assemblyFactory.createComponentProperty();
+ readProperty(componentProperty, reader);
+ properties.add(componentProperty);
+ }
+ }
+
+ return properties;
+
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/implementation/osgi/xml/OSGiImplementationProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator?view=diff&rev=549122&r1=549121&r2=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator Wed Jun 20 07:58:18 2007
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
# Implementation class for the ExtensionActivator
-org.apache.tuscany.sca.implementation.osgi.XxxxModuleActivator
+org.apache.tuscany.implementation.osgi.module.OSGiModuleActivator
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/invocation/OSGiTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/invocation/OSGiTestCase.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/invocation/OSGiTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/invocation/OSGiTestCase.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.implementation.osgi.invocation;
+
+import java.lang.reflect.Proxy;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.implementation.osgi.test.OSGiTestBundles;
+import org.apache.tuscany.implementation.osgi.test.OSGiTestImpl;
+import org.apache.tuscany.implementation.osgi.test.OSGiTestInterface;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+
+/**
+ *
+ * Test the execution of an OSGi implementation type
+ *
+ */
+public class OSGiTestCase extends TestCase {
+
+
+ protected void setUp() throws Exception {
+
+ OSGiTestBundles.createBundle("target/OSGiTestService.jar", OSGiTestInterface.class, OSGiTestImpl.class);
+
+ }
+
+
+ public void testOSGiComponent() {
+
+ SCADomain scaDomain = SCADomain.newInstance("osgitest.composite");
+ OSGiTestInterface testService = scaDomain.getService(OSGiTestInterface.class, "OSGiTestServiceComponent");
+ assert(testService != null);
+
+ assert(testService instanceof Proxy);
+
+ String str = testService.testService();
+
+ assert(OSGiTestImpl.class.getName().equals(str));
+
+ scaDomain.close();
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/invocation/OSGiTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/invocation/OSGiTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntimeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntimeTestCase.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntimeTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntimeTestCase.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,57 @@
+/*
+ * 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.implementation.osgi.runtime;
+
+import org.osgi.framework.BundleContext;
+
+import junit.framework.TestCase;
+
+/**
+ * Test OSGi runtime.
+ *
+ */
+public class OSGiRuntimeTestCase extends TestCase {
+
+ public void testRuntime() throws Exception {
+
+ BundleContext bc1 = OSGiRuntime.startAndGetBundleContext();
+
+ assertNotNull(bc1);
+
+ BundleContext bc2 = OSGiRuntime.startAndGetBundleContext();
+
+ assertNotNull(bc2);
+
+ assertTrue(bc1 == bc2);
+
+ OSGiRuntime.shutdown();
+
+ BundleContext bc3 = OSGiRuntime.startAndGetBundleContext();
+
+ assertNotNull(bc3);
+
+ assertTrue(bc1 != bc3);
+
+
+
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntimeTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/runtime/OSGiRuntimeTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestBundles.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestBundles.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestBundles.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestBundles.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,110 @@
+/*
+ * 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.implementation.osgi.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ */
+public class OSGiTestBundles {
+
+ public static void createBundle(String jarName,
+ Class<?> interfaceClass, Class<?> implClass) throws Exception {
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ String EOL = "\n";
+
+ String packageName = interfaceClass.getPackage().getName();
+ String bundleName = interfaceClass.getName();
+
+ String manifestStr = "Manifest-Version: 1.0" + EOL
+ + "Bundle-ManifestVersion: 2" + EOL + "Bundle-Name: "
+ + bundleName + EOL + "Bundle-SymbolicName: " + bundleName + EOL
+ + "Bundle-Version: " + "1.0.0" + EOL
+ + "Bundle-Localization: plugin" + EOL;
+
+ StringBuilder manifestBuf = new StringBuilder();
+ manifestBuf.append(manifestStr);
+ manifestBuf.append("Export-Package: " + packageName + EOL);
+ manifestBuf.append("Import-Package: org.osgi.framework" + EOL);
+ manifestBuf.append("Bundle-Activator: " + implClass.getName() + EOL);
+
+ ByteArrayInputStream manifestStream = new ByteArrayInputStream(manifestBuf.toString().getBytes());
+ Manifest manifest = new Manifest();
+ manifest.read(manifestStream);
+
+
+ JarOutputStream jarOut = new JarOutputStream(out, manifest);
+
+ String interfaceClassName = interfaceClass.getName().replaceAll("\\.",
+ "/")
+ + ".class";
+
+ URL url = interfaceClass.getClassLoader().getResource(
+ interfaceClassName);
+ String path = url.getPath();
+
+ ZipEntry ze = new ZipEntry(interfaceClassName);
+
+ jarOut.putNextEntry(ze);
+ FileInputStream file = new FileInputStream(path);
+ byte[] fileContents = new byte[file.available()];
+ file.read(fileContents);
+ jarOut.write(fileContents);
+
+ String implClassName = implClass.getName().replaceAll("\\.",
+ "/")
+ + ".class";
+
+ url = implClass.getClassLoader().getResource(implClassName);
+ path = url.getPath();
+
+ ze = new ZipEntry(implClassName);
+
+ jarOut.putNextEntry(ze);
+ file = new FileInputStream(path);
+ fileContents = new byte[file.available()];
+ file.read(fileContents);
+ jarOut.write(fileContents);
+
+ file.close();
+
+ jarOut.close();
+ out.close();
+
+ FileOutputStream fileOut = new FileOutputStream(jarName);
+ fileOut.write(out.toByteArray());
+ fileOut.close();
+
+
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestBundles.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestBundles.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestImpl.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestImpl.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestImpl.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,50 @@
+/*
+ * 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.implementation.osgi.test;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * Test class - Implementation of an OSGi service
+ *
+ */
+public class OSGiTestImpl implements OSGiTestInterface, BundleActivator {
+
+ public String testService() {
+
+ return OSGiTestImpl.class.getName();
+
+ }
+
+ public void start(BundleContext bc) throws Exception {
+
+ bc.registerService(OSGiTestInterface.class.getName(), this, new Hashtable<String, Object>());
+
+ }
+
+ public void stop(BundleContext bc) throws Exception {
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestInterface.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestInterface.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestInterface.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestInterface.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.implementation.osgi.test;
+
+/**
+ *
+ * Test class - Interface for an OSGi service
+ *
+ */
+public interface OSGiTestInterface {
+
+ public String testService();
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/test/OSGiTestInterface.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/OSGiReadImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/OSGiReadImplTestCase.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/OSGiReadImplTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/OSGiReadImplTestCase.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,154 @@
+/*
+ * 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.implementation.osgi.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.implementation.osgi.test.OSGiTestBundles;
+import org.apache.tuscany.implementation.osgi.test.OSGiTestImpl;
+import org.apache.tuscany.implementation.osgi.test.OSGiTestInterface;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultSCABindingFactory;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
+import org.apache.tuscany.sca.assembly.xml.CompositeProcessor;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.introspect.DefaultJavaInterfaceIntrospectorExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.java.introspect.ExtensibleJavaInterfaceIntrospector;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint;
+import org.apache.tuscany.sca.policy.DefaultPolicyFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.scope.Scope;
+
+/**
+ * Test reading OSGi implementations.
+ *
+ */
+public class OSGiReadImplTestCase extends TestCase {
+
+ XMLInputFactory inputFactory;
+ DefaultStAXArtifactProcessorExtensionPoint staxProcessors;
+ ExtensibleStAXArtifactProcessor staxProcessor;
+ private AssemblyFactory assemblyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private PolicyFactory policyFactory;
+ private InterfaceContractMapper mapper;
+ private OSGiImplementationProcessor osgiProcessor;
+
+ public void setUp() throws Exception {
+ assemblyFactory = new DefaultAssemblyFactory();
+ scaBindingFactory = new DefaultSCABindingFactory();
+ policyFactory = new DefaultPolicyFactory();
+ mapper = new InterfaceContractMapperImpl();
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ JavaInterfaceFactory javaInterfaceFactory = new DefaultJavaInterfaceFactory();
+
+ JavaInterfaceIntrospectorExtensionPoint interfaceVisitors = new DefaultJavaInterfaceIntrospectorExtensionPoint();
+ JavaInterfaceIntrospector interfaceIntrospector =
+ new ExtensibleJavaInterfaceIntrospector(javaInterfaceFactory, interfaceVisitors);
+
+ osgiProcessor = new OSGiImplementationProcessor(
+ interfaceIntrospector,
+ javaInterfaceFactory,
+ assemblyFactory,
+ policyFactory);
+ staxProcessors.addArtifactProcessor(osgiProcessor);
+
+ OSGiTestBundles.createBundle("target/OSGiTestService.jar", OSGiTestInterface.class, OSGiTestImpl.class);
+
+ }
+
+ public void tearDown() throws Exception {
+ inputFactory = null;
+ staxProcessors = null;
+ policyFactory = null;
+ assemblyFactory = null;
+ mapper = null;
+ }
+
+ public void testReadComposite() throws Exception {
+ CompositeProcessor compositeProcessor = new CompositeProcessor(assemblyFactory, policyFactory, mapper, staxProcessor);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader);
+ assertNotNull(composite);
+
+ CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null);
+ compositeUtil.build(composite);
+
+ }
+
+ public void testReadAndResolveComposite() throws Exception {
+ CompositeProcessor compositeProcessor = new CompositeProcessor(assemblyFactory, policyFactory, mapper, staxProcessor);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader);
+ assertNotNull(composite);
+
+ ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
+ staxProcessor.resolve(composite, resolver);
+
+ CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null);
+ compositeUtil.build(composite);
+ }
+
+ public void testReadOSGiImplementation() throws Exception {
+
+ String str = "<implementation.osgi xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" " +
+ "bundle=\"OSGiTestService\" " +
+ "bundleLocation=\"file:target/OSGiTestService.jar\" " +
+ "scope=\"COMPOSITE\" " +
+ "imports=\"import1.jar import2.jar\"" +
+ "/>";
+ ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes());
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ reader.next();
+
+
+ OSGiImplementation osgiImpl = osgiProcessor.read(reader);
+
+ assertEquals(osgiImpl.getBundleName(), "OSGiTestService");
+ assertEquals(osgiImpl.getBundleLocation(), "file:target/OSGiTestService.jar");
+ assertTrue(osgiImpl.getImports().length == 2);
+ assertEquals(osgiImpl.getImports()[0], "import1.jar");
+ assertEquals(osgiImpl.getImports()[1], "import2.jar");
+ assertEquals(osgiImpl.getScope(), Scope.COMPOSITE);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/OSGiReadImplTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/OSGiReadImplTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/TestModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/TestModelResolver.java?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/TestModelResolver.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/TestModelResolver.java Wed Jun 20 07:58:18 2007
@@ -0,0 +1,87 @@
+/*
+ * 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.implementation.osgi.xml;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ */
+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) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // 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 wrappering the loaded class
+ resolved = new ClassReference(clazz);
+ map.put(resolved, resolved);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(resolved);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/TestModelResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/implementation/osgi/xml/TestModelResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType Wed Jun 20 07:58:18 2007
@@ -0,0 +1,25 @@
+<?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://www.osoa.org/xmlns/sca/1.0">
+ <service name="OSGiTestService">
+ <interface.java interface="org.apache.tuscany.implementation.osgi.test.OSGiTestInterface"/>
+ </service>
+
+</componentType>
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/OSGiTestService.componentType
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgitest.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgitest.composite?view=auto&rev=549122
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgitest.composite (added)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgitest.composite Wed Jun 20 07:58:18 2007
@@ -0,0 +1,31 @@
+<?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://www.osoa.org/xmlns/sca/1.0" name="OSGiTestComposite">
+
+ <component name="OSGiTestServiceComponent">
+ <implementation.osgi
+ bundle="OSGiTestService"
+ bundleLocation="file:target/OSGiTestService.jar"
+ scope="COMPOSITE"
+ />
+
+ </component>
+
+</composite>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org