You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/09/17 01:37:53 UTC
svn commit: r576211 [4/5] - in /incubator/tuscany/branches/sca-java-1.0:
itest/ itest/osgi-contribution/
itest/osgi-contribution/contribution-classes-v2/
itest/osgi-contribution/contribution-classes-v2/src/
itest/osgi-contribution/contribution-classes-...
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java Sun Sep 16 16:37:32 2007
@@ -20,6 +20,8 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;
@@ -30,11 +32,15 @@
import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.TargetDestructionException;
import org.apache.tuscany.sca.core.scope.TargetInitializationException;
+import org.apache.tuscany.sca.implementation.osgi.context.OSGiAnnotations;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
/**
@@ -49,16 +55,22 @@
*/
public class OSGiInstanceWrapper<T> implements InstanceWrapper<T> {
+ private OSGiAnnotations annotationProcessor;
private OSGiImplementationProvider provider;
private BundleContext bundleContext;
private Hashtable<Object,InstanceInfo<T>> instanceInfoList =
new Hashtable<Object,InstanceInfo<T>>();
+
+ // Dummy bundles are used to create a new service object for scopes other than COMPOSITE
+ private Bundle dummyReferenceBundle;
public OSGiInstanceWrapper(OSGiImplementationProvider provider,
+ OSGiAnnotations annotationProcessor,
BundleContext bundleContext) {
this.provider = provider;
+ this.annotationProcessor = annotationProcessor;
this.bundleContext = bundleContext;
}
@@ -69,19 +81,32 @@
Bundle refBundle = provider.startBundle();
- if (!provider.getImplementation().getScope().equals(Scope.COMPOSITE)) {
+ if (!annotationProcessor.getScope().equals(Scope.COMPOSITE)) {
refBundle = getDummyReferenceBundle();
}
InstanceInfo<T> instanceInfo = new InstanceInfo<T>();
- instanceInfoList.put(service, instanceInfo);
-
- instanceInfo.osgiServiceReference = provider.getOSGiServiceReference(service);
+ instanceInfo.osgiServiceReference = provider.getOSGiServiceReference(service);
instanceInfo.refBundleContext = refBundle.getBundleContext();
- instanceInfo.osgiInstance = (T)instanceInfo.refBundleContext.getService(instanceInfo.osgiServiceReference);
+
+ instanceInfo.osgiInstance = getInstanceObject(instanceInfo);
- provider.injectProperties(instanceInfo.osgiInstance);
+ try {
+
+ if (!isInitialized(instanceInfo.osgiInstance)) {
+
+ annotationProcessor.injectProperties(instanceInfo.osgiInstance);
+ callLifecycleMethod(instanceInfo.osgiInstance, Init.class);
+
+ instanceInfo.isFirstInstance = true;
+ }
+
+ instanceInfoList.put(service, instanceInfo);
+
+ } catch (Exception e) {
+ throw new TargetInitializationException(e);
+ }
return instanceInfo.osgiInstance;
}
@@ -94,18 +119,33 @@
Bundle refBundle = provider.startBundle();
- if (!provider.getImplementation().getScope().equals(Scope.COMPOSITE)) {
+ if (!annotationProcessor.getScope().equals(Scope.COMPOSITE)) {
refBundle = getDummyReferenceBundle();
}
InstanceInfo<T> instanceInfo = new InstanceInfo<T>();
- instanceInfoList.put(callbackInterface, instanceInfo);
instanceInfo.osgiServiceReference = provider.getOSGiServiceReference(from, callbackInterface);
instanceInfo.refBundleContext = refBundle.getBundleContext();
- instanceInfo.osgiInstance = (T)instanceInfo.refBundleContext.getService(instanceInfo.osgiServiceReference);
+ instanceInfo.osgiInstance = getInstanceObject(instanceInfo);
+
+
+ try {
+
+ if (!isInitialized(instanceInfo.osgiInstance)) {
+
+ annotationProcessor.injectProperties(instanceInfo.osgiInstance);
+ callLifecycleMethod(instanceInfo.osgiInstance, Init.class);
+ instanceInfo.isFirstInstance = true;
+ }
+
+ instanceInfoList.put(callbackInterface, instanceInfo);
+
+ } catch (Exception e) {
+ throw new TargetInitializationException(e);
+ }
return instanceInfo.osgiInstance;
}
@@ -129,28 +169,44 @@
public synchronized void stop() throws TargetDestructionException {
for (InstanceInfo<T> instanceInfo : instanceInfoList.values()) {
- if (instanceInfo.osgiInstance != null && instanceInfo.osgiServiceReference != null) {
+ if (instanceInfo.osgiInstance != null && instanceInfo.osgiServiceReference != null) {
+
+ try {
+
+ if (instanceInfo.isFirstInstance)
+ callLifecycleMethod(instanceInfo.osgiInstance, Destroy.class);
- instanceInfo.refBundleContext.ungetService(instanceInfo.osgiServiceReference);
+ instanceInfo.refBundleContext.ungetService(instanceInfo.osgiServiceReference);
- instanceInfo.osgiInstance = null;
- instanceInfo.osgiServiceReference = null;
+ instanceInfo.osgiInstance = null;
+ instanceInfo.osgiServiceReference = null;
- try {
- if (instanceInfo.dummyBundle != null) {
- instanceInfo.dummyBundle.uninstall();
- }
} catch (Exception e) {
throw new TargetDestructionException(e);
}
}
}
instanceInfoList.clear();
+ if (dummyReferenceBundle != null) {
+ try {
+ dummyReferenceBundle.uninstall();
+ } catch (BundleException e) {
+ throw new TargetDestructionException(e);
+ }
+ dummyReferenceBundle = null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private T getInstanceObject(InstanceInfo<T> instanceInfo) {
+ return (T)instanceInfo.refBundleContext.getService(instanceInfo.osgiServiceReference);
}
private Bundle getDummyReferenceBundle() throws TargetInitializationException {
- Bundle dummyBundle = null;
+ if (dummyReferenceBundle != null)
+ return dummyReferenceBundle;
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
String EOL = System.getProperty("line.separator");
@@ -182,23 +238,47 @@
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
- dummyBundle = bundleContext.installBundle("file://" + bundleName + ".jar", in);
+ dummyReferenceBundle = bundleContext.installBundle("file://" + bundleName + ".jar", in);
- dummyBundle.start();
+ dummyReferenceBundle.start();
} catch (Exception e) {
throw new TargetInitializationException(e);
}
- return dummyBundle;
+ return dummyReferenceBundle;
}
+ private void callLifecycleMethod(Object instance,
+ Class<? extends Annotation> annotationClass) throws Exception {
+
+ Method method = null;
+ if (annotationClass == Init.class) {
+ method = annotationProcessor.getInitMethod(instance);
+ } else if (annotationClass == Destroy.class) {
+ method = annotationProcessor.getDestroyMethod(instance);
+ }
+
+ if (method != null) {
+ method.setAccessible(true);
+ method.invoke(instance);
+ }
+ }
+
+ private boolean isInitialized(Object instance) {
+ for (InstanceInfo<?> info : instanceInfoList.values()) {
+ if (info.osgiInstance == instance)
+ return true;
+ }
+ return false;
+ }
+
private static class InstanceInfo<T> {
private T osgiInstance;
private ServiceReference osgiServiceReference;
- private Bundle dummyBundle;
private BundleContext refBundleContext;
+ private boolean isFirstInstance;
}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java Sun Sep 16 16:37:32 2007
@@ -26,11 +26,10 @@
import org.apache.tuscany.sca.databinding.DataBinding;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
-import org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.context.OSGiAnnotations;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
@@ -41,7 +40,7 @@
private DataBindingExtensionPoint registry;
private Operation operation;
- private OSGiImplementation osgiImplementation;
+ private OSGiAnnotations osgiAnnotations;
/**
* @param registry
@@ -49,13 +48,13 @@
* @param method
* @param component
*/
- public OSGiRemotableInvoker(OSGiImplementation osgiImplementation,
+ public OSGiRemotableInvoker(OSGiAnnotations osgiAnnotations,
DataBindingExtensionPoint registry,
Operation operation,
- RuntimeComponent component,
+ OSGiImplementationProvider provider,
RuntimeComponentService service) {
- super(operation, component, service);
- this.osgiImplementation = osgiImplementation;
+ super(operation, provider, service);
+ this.osgiAnnotations = osgiAnnotations;
this.registry = registry;
this.operation = operation;
}
@@ -65,7 +64,7 @@
throws InvocationTargetException {
Object result;
- if (osgiImplementation.isAllowsPassByReference(m)) {
+ if (osgiAnnotations.isAllowsPassByReference(targetObject, m)) {
result = super.invokeMethod(targetObject, m, msg);
}
else {
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTargetInvoker.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTargetInvoker.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTargetInvoker.java Sun Sep 16 16:37:32 2007
@@ -26,7 +26,6 @@
import org.apache.tuscany.sca.core.invocation.TargetInvocationException;
import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
import org.apache.tuscany.sca.core.scope.TargetResolutionException;
import org.apache.tuscany.sca.interfacedef.ConversationSequence;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -34,7 +33,7 @@
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.runtime.EndpointReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.ReferenceParameters;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
@@ -51,50 +50,93 @@
private Operation operation;
protected InstanceWrapper<T> target;
- protected boolean stateless;
- protected boolean cacheable;
+ private final OSGiImplementationProvider provider;
private final RuntimeComponentService service;
- private final ScopeContainer scopeContainer;
-
- public OSGiTargetInvoker(Operation operation, RuntimeComponent component, RuntimeComponentService service) {
+
+ // Scope container is reset by the OSGi implementation provider if @Scope
+ // annotation is used to modify the scope (default is composite)
+ // Hence this field is initialized on the first invoke.
+ private ScopeContainer scopeContainer;
+
+ public OSGiTargetInvoker(
+ Operation operation,
+ OSGiImplementationProvider provider,
+ RuntimeComponentService service) {
+
this.operation = operation;
this.service = service;
- this.scopeContainer = ((ScopedRuntimeComponent)component).getScopeContainer();
- this.cacheable = true;
- stateless = Scope.STATELESS == scopeContainer.getScope();
+ this.provider = provider;
}
/**
* Resolves the target service instance or returns a cached one
*/
- protected InstanceWrapper getInstance(ConversationSequence sequence, Object contextId)
+ @SuppressWarnings("unchecked")
+ protected InstanceWrapper getInstance(Object contextId)
throws TargetResolutionException, TargetInvocationException {
+
+ if (scopeContainer == null)
+ scopeContainer = provider.getScopeContainer();
+
+
+ return scopeContainer.getWrapper(contextId);
- if (cacheable) {
- if (target == null) {
- target = scopeContainer.getWrapper(contextId);
- }
- return target;
- } else {
- return scopeContainer.getWrapper(contextId);
- }
}
+ @SuppressWarnings("unchecked")
private Object invokeTarget(Message msg) throws InvocationTargetException {
- ConversationSequence sequence = operation.getConversationSequence();
- EndpointReference to = msg.getTo();
+ if (scopeContainer == null)
+ scopeContainer = provider.getScopeContainer();
+
+
+ Operation op = msg.getOperation();
+ if (op == null) {
+ op = this.operation;
+ }
+ ConversationSequence sequence = op.getConversationSequence();
+
Object contextId = null;
- if (scopeContainer.getScope() == Scope.CONVERSATION) {
- contextId = to.getReferenceParameters().getConversationID();
+
+ EndpointReference to = msg.getTo();
+ ReferenceParameters parameters = null;
+
+ if (to != null) {
+ parameters = to.getReferenceParameters();
}
+ // check what sort of context is required
+ if (scopeContainer != null) {
+ Scope scope = scopeContainer.getScope();
+ if (scope == Scope.REQUEST) {
+ contextId = Thread.currentThread();
+ } else if (scope == Scope.CONVERSATION && parameters != null) {
+ contextId = parameters.getConversationID();
+ }
+ }
+
try {
- OSGiInstanceWrapper wrapper = (OSGiInstanceWrapper)getInstance(sequence, contextId);
+
+ OSGiInstanceWrapper wrapper = (OSGiInstanceWrapper)getInstance(contextId);
Object instance;
+
+ // detects whether the scope container has created a conversation Id. This will
+ // happen in the case that the component has conversational scope but only the
+ // callback interface is conversational. Or in the callback case if the service interface
+ // is conversational and the callback interface isn't. If we are in this situation we need
+ // to get the contextId of this component and remove it after we have invoked the method on
+ // it. It is possible that the component instance will not go away when it is removed below
+ // because a callback conversation will still be holding a reference to it
+ boolean removeTemporaryConversationalComponentAfterCall = false;
+ if (parameters != null && (contextId == null) && (parameters.getConversationID() != null)) {
+ contextId = parameters.getConversationID();
+ removeTemporaryConversationalComponentAfterCall = true;
+ }
+
+
if (service != null) {
instance = wrapper.getInstance(service);
} else {
@@ -106,10 +148,14 @@
Object ret = invokeMethod(instance, m, msg);
scopeContainer.returnWrapper(wrapper, contextId);
- if (sequence == ConversationSequence.CONVERSATION_END) {
- // if end conversation, remove resource
+
+ if ((sequence == ConversationSequence.CONVERSATION_END) || (removeTemporaryConversationalComponentAfterCall)) {
+ // if end conversation, or we have the special case where a conversational
+ // object was created to service the stateless half of a stateful component
scopeContainer.remove(contextId);
+ parameters.setConversationID(null);
}
+
return ret;
} catch (InvocationTargetException e) {
throw e;
@@ -152,12 +198,5 @@
return msg;
}
- public boolean isCacheable() {
- return cacheable;
- }
-
- public void setCacheable(boolean cacheable) {
- this.cacheable = cacheable;
- }
}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/EquinoxRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/EquinoxRuntime.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/EquinoxRuntime.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/EquinoxRuntime.java Sun Sep 16 16:37:32 2007
@@ -1,106 +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.Field;
-import java.lang.reflect.Method;
-
-import org.osgi.framework.BundleContext;
-
-public class EquinoxRuntime extends OSGiRuntime {
-
-
- private static BundleContext bundleContext;
-
- private static EquinoxRuntime instance;
-
- private static Class eclipseStarterClass;
-
- public static OSGiRuntime getInstance() throws Exception {
- if (instance == null) {
- EquinoxRuntime runtime = new EquinoxRuntime();
- runtime.startRuntime();
- instance = runtime;
- }
- return instance;
- }
-
-
- protected BundleContext startRuntime() throws Exception {
-
- if (bundleContext != null)
- return bundleContext;
-
- eclipseStarterClass = EquinoxRuntime.class.getClassLoader().loadClass("org.eclipse.core.runtime.adaptor.EclipseStarter");
- Method startupMethod = eclipseStarterClass.getMethod("startup", String [].class, Runnable.class);
-
- // Equinox version 3.2 upwards have a startup method which returns BundleContext
- if (startupMethod.getReturnType() == BundleContext.class) {
- bundleContext = (BundleContext) startupMethod.invoke(null, new String[] {"-clean", "-console"}, null );
- }
- else {
-
- // Older versions of Equinox dont have a public method to obtain system bundlecontext
- // Extract bundleContext from the private field 'context'. We are assuming that
- // there is no access restriction
- Method mainMethod = eclipseStarterClass.getMethod("main", String [].class);
- mainMethod.invoke(null, (Object)new String[] {"-clean", "-console"});
-
- Field contextField = eclipseStarterClass.getDeclaredField("context");
- contextField.setAccessible(true);
- bundleContext = (BundleContext) contextField.get(null);
-
- }
-
-
- return bundleContext;
-
- }
-
- @Override
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- @Override
- public void shutdown() throws Exception {
-
- if (bundleContext == null)
- return;
- bundleContext = null;
- instance = null;
- if (eclipseStarterClass != null) {
- Method shutdownMethod = eclipseStarterClass.getMethod("shutdown");
- try {
- shutdownMethod.invoke(eclipseStarterClass);
- } catch (Exception e) {
- // Ignore errors.
- }
- }
- }
-
-
- @Override
- public boolean supportsBundleFragments() {
- return false;
- }
-
-
-
-}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/FelixRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/FelixRuntime.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/FelixRuntime.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/FelixRuntime.java Sun Sep 16 16:37:32 2007
@@ -1,193 +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.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.Bundle;
-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() throws Exception {
- if (instance == null) {
- FelixRuntime runtime = new FelixRuntime();
- runtime.startRuntime();
- instance = runtime;
- }
- 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();
-
- }
-
- private 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");
- 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, " +
- "org.osoa.sca.annotations; version=1.0.0, " +
- "org.osoa.sca; version=1.0.0");
-
-
- try {
- Constructor felixConstructor = felixClass.getConstructor(Map.class, List.class);
- List<BundleActivator> activators = new ArrayList<BundleActivator>();
- felix = felixConstructor.newInstance(props, activators);
- ((Bundle)felix).start();
- bundleContext = ((Bundle)felix).getBundleContext();
-
-
- } catch (Exception e) {
-
- // This is the older Felix API which has been retained temporarily to avoid build break
- // TODO: Remove these once Felix 1.0.0 is released.
-
- Class propertyResolverClass = cl.loadClass("org.apache.felix.framework.util.MutablePropertyResolver");
- Class propertyResolverImplClass = cl.loadClass("org.apache.felix.framework.util.MutablePropertyResolverImpl");
-
- Constructor implConstructor = propertyResolverImplClass.getConstructor(Map.class);
- Object mutableProps = implConstructor.newInstance(props);
-
-
- try {
- Constructor felixConstructor = felixClass.getConstructor(propertyResolverClass, List.class);
- List<BundleActivator> activators = new ArrayList<BundleActivator>();
- felix = felixConstructor.newInstance(mutableProps, activators);
- ((Bundle)felix).start();
- bundleContext = ((Bundle)felix).getBundleContext();
- } catch (Exception e1) {
-
-
- 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
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
-
- @Override
- public void shutdown() throws Exception {
-
- if (bundleContext == null)
- return;
- bundleContext = null;
- instance = null;
-
- if (felix instanceof Bundle) {
- ((Bundle)felix).stop();
- }
- else if (felix != null) {
- Method shutdownMethod = felixClass.getMethod("shutdown");
- try {
- shutdownMethod.invoke(felix);
- } catch (Exception e) {
- // Ignore errors
- }
- felix = null;
- }
- }
-
- @Override
- public boolean supportsBundleFragments() {
- return false;
- }
-
-}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/KnopflerfishRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/KnopflerfishRuntime.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/KnopflerfishRuntime.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/KnopflerfishRuntime.java Sun Sep 16 16:37:32 2007
@@ -1,156 +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.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() throws Exception {
- if (instance == null) {
- KnopflerfishRuntime runtime = new KnopflerfishRuntime();
- runtime.startRuntime();
- instance = runtime;
- }
- 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.
- //
- private 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
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- @Override
- public void shutdown() throws Exception {
-
- if (bundleContext == null)
- return;
- bundleContext = null;
- instance = null;
- if (framework != null) {
- Method shutdownMethod = frameworkClass.getMethod("shutdown");
- try {
- shutdownMethod.invoke(framework);
- } catch (Exception e) {
- // Ignore errors
- }
- framework = null;
- }
-
- }
-
- @Override
- public boolean supportsBundleFragments() {
- return true;
- }
-}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntime.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntime.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntime.java Sun Sep 16 16:37:32 2007
@@ -1,91 +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.Method;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-public abstract class OSGiRuntime {
-
- public abstract BundleContext getBundleContext();
-
- public abstract void shutdown() throws Exception;
-
- public abstract boolean supportsBundleFragments();
-
-
- /**
- * 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.
- *
- * @throws BundleException
- */
- public static OSGiRuntime getRuntime() 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");
- return (OSGiRuntime) method.invoke(null);
-
- } catch (Exception e) {
- throw new BundleException("Could not start OSGi runtime " + runtimeClassName, e);
- }
- }
-
- try {
-
- return EquinoxRuntime.getInstance();
-
- } catch (ClassNotFoundException e) {
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- try {
-
- return FelixRuntime.getInstance();
-
- } catch (ClassNotFoundException e) {
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- try {
-
- return KnopflerfishRuntime.getInstance();
-
- } catch (ClassNotFoundException e) {
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- throw new BundleException("Could not start OSGi runtime from the classpath");
- }
-
-
-
-}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementation.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementation.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementation.java Sun Sep 16 16:37:32 2007
@@ -19,15 +19,13 @@
package org.apache.tuscany.sca.implementation.osgi.xml;
-import java.lang.reflect.Method;
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.core.scope.Scope;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationInterface;
-import org.osoa.sca.annotations.AllowsPassByReference;
/**
@@ -37,61 +35,68 @@
*/
public class OSGiImplementation extends ComponentTypeImpl implements OSGiImplementationInterface {
- private String bundleName;
- private String bundleLocation;
+ private String bundleSymbolicName;
+ private String bundleVersion;
+
private String[] imports;
- private Scope scope;
- private boolean isEagerInit;
- private String[] allowsPassByRef;
- private boolean needsPropertyInjection;
private Hashtable<String, List<ComponentProperty>> referenceProperties;
private Hashtable<String, List<ComponentProperty>> serviceProperties;
private Hashtable<String, List<ComponentProperty>> referenceCallbackProperties;
private Hashtable<String, List<ComponentProperty>> serviceCallbackProperties;
-
- public OSGiImplementation(String bundleName,
- String bundleLocation,
- String[] imports,
- String scopeName,
- boolean isEagerInit,
- String[] allowsPassByRef,
+ private String[] classList;
+
+ private ModelFactoryExtensionPoint modelFactories;
+
+ private Object osgiBundle;
+
+ public OSGiImplementation(
+ ModelFactoryExtensionPoint modelFactories,
+ String bundleSymbolicName,
+ String bundleVersion,
+ String[] imports,
+ String[] classList,
Hashtable<String, List<ComponentProperty>> refProperties,
- Hashtable<String, List<ComponentProperty>> serviceProperties,
- boolean needsPropertyInjection) {
+ Hashtable<String, List<ComponentProperty>> serviceProperties) {
super();
- this.bundleName = bundleName;
- this.bundleLocation = bundleLocation;
- setURI(bundleName);
+ this.bundleSymbolicName = bundleSymbolicName;
+ this.bundleVersion = bundleVersion;
this.imports = imports;
- this.scope = new Scope(scopeName == null?"COMPOSITE":scopeName);
- this.isEagerInit = isEagerInit;
- this.allowsPassByRef = allowsPassByRef;
this.referenceProperties = refProperties;
this.serviceProperties = serviceProperties;
- this.needsPropertyInjection = needsPropertyInjection;
-
+ this.classList = classList;
+ this.modelFactories = modelFactories;
}
-
- public String getBundleName() {
- return bundleName;
+ protected void setCallbackProperties(Hashtable<String, List<ComponentProperty>> refCallbackProperties,
+ Hashtable<String, List<ComponentProperty>> serviceCallbackProperties) {
+
+ this.referenceCallbackProperties = refCallbackProperties;
+ this.serviceCallbackProperties = serviceCallbackProperties;
+
}
- public String getBundleLocation() {
- return bundleLocation;
+
+ public String getBundleSymbolicName() {
+ return bundleSymbolicName;
+ }
+
+ public String getBundleVersion() {
+ return bundleVersion;
}
-
public String[] getImports() {
return imports;
}
+ public String[] getClassList() {
+ return classList;
+ }
- public Scope getScope() {
- return scope;
+ public ModelFactoryExtensionPoint getModelFactories() {
+ return modelFactories;
}
public List<ComponentProperty> getReferenceProperties(String referenceName) {
@@ -109,60 +114,14 @@
public List<ComponentProperty> getServiceCallbackProperties(String serviceName) {
return serviceCallbackProperties.get(serviceName);
}
-
-
- public boolean isAllowsPassByReference(Method method) {
-
- if (allowsPassByRef == null || allowsPassByRef.length == 0)
- return false;
-
- String className = method.getDeclaringClass().getName();
- String methodName = className + "." + method.getName();
-
- for (String opName : allowsPassByRef) {
- if (className.equals(opName) || methodName.equals(opName))
- return true;
- }
- return false;
- }
-
- public boolean isAllowsPassByReferenceAnnotation(Method method) {
-
- if (method.getAnnotation(AllowsPassByReference.class) != null) {
- return true;
- }
- else if (method.getClass().getAnnotation(AllowsPassByReference.class) != null) {
- return true;
- }
- else
- return false;
- }
- public boolean needsPropertyInjection() {
- return needsPropertyInjection;
- }
-
-
- public boolean isEagerInit() {
- return isEagerInit;
+ public Object getOSGiBundle() {
+ return osgiBundle;
}
- public long getMaxAge() {
- return Long.MAX_VALUE;
- }
-
- public long getMaxIdleTime() {
- return Long.MAX_VALUE;
- }
-
-
- protected void setCallbackProperties(Hashtable<String, List<ComponentProperty>> refCallbackProperties,
- Hashtable<String, List<ComponentProperty>> serviceCallbackProperties) {
-
- this.referenceCallbackProperties = refCallbackProperties;
- this.serviceCallbackProperties = serviceCallbackProperties;
-
+ public void setOSGiBundle(Object osgiBundle) {
+ this.osgiBundle = osgiBundle;
}
private boolean areEqual(Object obj1, Object obj2) {
@@ -179,9 +138,9 @@
if (!(obj instanceof OSGiImplementation))
return super.equals(obj);
OSGiImplementation impl = (OSGiImplementation)obj;
- if (!areEqual(bundleName, impl.bundleName))
+ if (!areEqual(bundleSymbolicName, impl.bundleSymbolicName))
return false;
- if (!areEqual(bundleLocation, impl.bundleLocation))
+ if (!areEqual(bundleVersion, impl.bundleVersion))
return false;
if (!areEqual(serviceProperties, impl.serviceProperties))
return false;
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java Sun Sep 16 16:37:32 2007
@@ -44,7 +44,9 @@
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.osgi.BundleReference;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
@@ -55,6 +57,7 @@
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.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -72,20 +75,18 @@
public static final QName IMPLEMENTATION_OSGI = new QName(Constants.SCA10_TUSCANY_NS, "implementation.osgi");
- private static final String BUNDLE = "bundle";
- private static final String BUNDLE_LOCATION = "bundleLocation";
- private static final String SCOPE = "scope";
- private static final String EAGER_INIT = "eagerInit";
+ private static final String BUNDLE_SYMBOLICNAME= "bundleSymbolicName";
+ private static final String BUNDLE_VERSION = "bundleVersion";
+ private static final String CLASSES = "classes";
private static final String IMPORTS = "imports";
- private static final String ALLOWS_PASS_BY_REF = "allowsPassByReference";
- private static final String INJECT_PROPERTIES = "injectProperties";
-
private static final QName PROPERTIES_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "properties");
private static final QName PROPERTY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "property");
private JavaInterfaceFactory javaInterfaceFactory;
private AssemblyFactory assemblyFactory;
+ private ModelFactoryExtensionPoint modelFactories;
+
private static final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
static {
@@ -94,6 +95,7 @@
public OSGiImplementationProcessor(ModelFactoryExtensionPoint modelFactories) {
+ this.modelFactories = modelFactories;
this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
}
@@ -118,44 +120,39 @@
public OSGiImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
assert IMPLEMENTATION_OSGI.equals(reader.getName());
-
- String bundleName = reader.getAttributeValue(null, BUNDLE);
- String bundleLocation = reader.getAttributeValue(null, BUNDLE_LOCATION);
+
+ String bundleSymbolicName = reader.getAttributeValue(null, BUNDLE_SYMBOLICNAME);
+ String bundleVersion = reader.getAttributeValue(null, BUNDLE_VERSION);
String imports = reader.getAttributeValue(null, IMPORTS);
String[] importList;
if (imports != null)
importList = tokenize(imports);
else
importList = new String[0];
- String scope = reader.getAttributeValue(null, SCOPE);
- String allowsPassByRef = reader.getAttributeValue(null, ALLOWS_PASS_BY_REF);
- String[] allowsPassByRefList;
- if (allowsPassByRef != null)
- allowsPassByRefList = tokenize(allowsPassByRef);
+ String classes = reader.getAttributeValue(null, CLASSES);
+ String[] classList;
+ if (classes != null)
+ classList = tokenize(classes);
else
- allowsPassByRefList = new String[0];
-
- boolean injectProperties = !"false".equalsIgnoreCase(reader.getAttributeValue(null, INJECT_PROPERTIES));
- boolean eagerInit = "true".equalsIgnoreCase(reader.getAttributeValue(null, EAGER_INIT));
-
-
+ classList = new String[0];
+
Hashtable<String, List<ComponentProperty>> refProperties =
- new Hashtable<String, List<ComponentProperty>>();
+ new Hashtable<String, List<ComponentProperty>>();
Hashtable<String, List<ComponentProperty>> serviceProperties =
- new Hashtable<String, List<ComponentProperty>>();
+ new Hashtable<String, List<ComponentProperty>>();
Hashtable<String, List<ComponentProperty>> refCallbackProperties =
- new Hashtable<String, List<ComponentProperty>>();
+ new Hashtable<String, List<ComponentProperty>>();
Hashtable<String, List<ComponentProperty>> serviceCallbackProperties =
- new Hashtable<String, List<ComponentProperty>>();
-
- while (reader.hasNext()) {
+ 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
@@ -175,43 +172,59 @@
else if (serviceCallbackName != null)
serviceCallbackProperties.put(serviceCallbackName, props);
else
- throw new ContributionReadException("Properties in implementation.osgi should specify service or reference"); }
+ throw new ContributionReadException("Properties in implementation.osgi should specify service or reference");
+ }
+
}
OSGiImplementation implementation = new OSGiImplementation(
- bundleName,
- bundleLocation,
- importList,
- scope,
- eagerInit,
- allowsPassByRefList,
- refProperties,
- serviceProperties,
- injectProperties);
+ modelFactories,
+ bundleSymbolicName,
+ bundleVersion,
+ importList,
+ classList,
+ refProperties,
+ serviceProperties);
implementation.setCallbackProperties(refCallbackProperties, serviceCallbackProperties);
-
-
+
implementation.setUnresolved(true);
-
+
return implementation;
+
}
+
public void resolve(OSGiImplementation impl, ModelResolver resolver) throws ContributionResolveException {
try {
+
+ if (!impl.isUnresolved())
+ return;
impl.setUnresolved(false);
-
- String bundleName = impl.getBundleName();
- String ctURI = bundleName.replaceAll("\\.", "/") + ".componentType";
+ BundleReference bundleReference = new BundleReference(impl.getBundleSymbolicName(), impl.getBundleVersion());
+ BundleReference resolvedBundle = resolver.resolveModel(BundleReference.class, bundleReference);
+ Bundle bundle = (Bundle)resolvedBundle.getBundle();
+ if (bundle != null)
+ impl.setOSGiBundle(bundle);
+ else
+ throw new ContributionResolveException("Could not locate OSGi bundle " +
+ impl.getBundleSymbolicName());
+
+ String bundleName = resolvedBundle.getBundleRelativePath();
+ String ctURI = bundleName.lastIndexOf(".") > 0?
+ bundleName.substring(0, bundleName.lastIndexOf(".")) : bundleName;
+ ctURI = ctURI.replaceAll("\\.", "/");
+ ctURI = ctURI + ".componentType";
ComponentType componentType = assemblyFactory.createComponentType();
componentType.setURI(ctURI);
componentType.setUnresolved(true);
componentType = resolver.resolveModel(ComponentType.class, componentType);
if (componentType.isUnresolved()) {
- throw new ContributionResolveException("missing .componentType side file");
+
+ throw new ContributionResolveException("missing .componentType side file " + ctURI);
}
List<Service> services = componentType.getServices();
@@ -220,15 +233,14 @@
if (interfaze instanceof JavaInterface) {
JavaInterface javaInterface = (JavaInterface)interfaze;
if (javaInterface.getJavaClass() == null) {
- Class<?> javaClass = Class.forName(javaInterface.getName());
- javaInterface.setJavaClass(javaClass);
+
+ javaInterface.setJavaClass(getJavaClass(resolver, javaInterface.getName()));
}
Class<?> callback = null;
if (service.getInterfaceContract().getCallbackInterface() instanceof JavaInterface) {
JavaInterface callbackInterface = (JavaInterface)service.getInterfaceContract().getCallbackInterface();
if (callbackInterface.getJavaClass() == null) {
- Class<?> javaClass = Class.forName(javaInterface.getName());
- callbackInterface.setJavaClass(javaClass);
+ callbackInterface.setJavaClass(getJavaClass(resolver, callbackInterface.getName()));
}
callback = callbackInterface.getJavaClass();
}
@@ -244,8 +256,7 @@
if (interfaze instanceof JavaInterface) {
JavaInterface javaInterface = (JavaInterface)interfaze;
if (javaInterface.getJavaClass() == null) {
- Class<?> javaClass = Class.forName(javaInterface.getName());
- javaInterface.setJavaClass(javaClass);
+ javaInterface.setJavaClass(getJavaClass(resolver, javaInterface.getName()));
}
Reference ref = createReference(reference, javaInterface.getJavaClass());
impl.getReferences().add(ref);
@@ -259,7 +270,7 @@
impl.getProperties().add(property);
}
impl.setConstrainingType(componentType.getConstrainingType());
-
+
} catch (Exception e) {
throw new ContributionResolveException(e);
@@ -267,6 +278,13 @@
}
+
+ private Class getJavaClass(ModelResolver resolver, String className) {
+ ClassReference ref = new ClassReference(className);
+ ref = resolver.resolveModel(ClassReference.class, ref);
+ return ref.getJavaClass();
+ }
+
private Service createService(Service serv, Class<?> interfaze, Class<?> callbackInterfaze) throws InvalidInterfaceException {
Service service = assemblyFactory.createService();
JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
@@ -486,4 +504,5 @@
return properties;
}
+
}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiPropertyTestCase.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiPropertyTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiPropertyTestCase.java Sun Sep 16 16:37:32 2007
@@ -35,8 +35,9 @@
protected void setUp() throws Exception {
className = OSGiTestWithPropertyImpl.class.getName();
+ compositeName = "osgiproptest.composite";
- OSGiTestBundles.createBundle("target/OSGiTestService.jar",
+ OSGiTestBundles.createBundle("target/test-classes/OSGiTestService.jar",
OSGiTestInterface.class,
OSGiTestWithPropertyImpl.class);
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTestCase.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiTestCase.java Sun Sep 16 16:37:32 2007
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
import org.apache.tuscany.sca.host.embedded.SCADomain;
-import org.apache.tuscany.sca.implementation.osgi.runtime.OSGiRuntime;
+import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime;
import org.apache.tuscany.sca.implementation.osgi.test.OSGiTestBundles;
import org.apache.tuscany.sca.implementation.osgi.test.OSGiTestImpl;
import org.apache.tuscany.sca.implementation.osgi.test.OSGiTestInterface;
@@ -38,14 +38,16 @@
public class OSGiTestCase extends TestCase {
protected String className;
-
- @Override
+ protected String compositeName;
+
protected void setUp() throws Exception {
className = OSGiTestImpl.class.getName();
- OSGiTestBundles.createBundle("target/OSGiTestService.jar", OSGiTestInterface.class, OSGiTestImpl.class);
+ compositeName = "osgitest.composite";
+ OSGiTestBundles.createBundle("target/test-classes/OSGiTestService.jar", OSGiTestInterface.class, OSGiTestImpl.class);
}
+
@Override
protected void tearDown() throws Exception {
@@ -54,7 +56,7 @@
public void testOSGiComponent() throws Exception {
- SCADomain scaDomain = SCADomain.newInstance("osgitest.composite");
+ SCADomain scaDomain = SCADomain.newInstance(compositeName);
OSGiTestInterface testService = scaDomain.getService(OSGiTestInterface.class, "OSGiTestServiceComponent");
assert(testService != null);
@@ -62,7 +64,6 @@
String str = testService.testService();
- System.out.println("className " + className + " str " + str);
assertEquals(className, str);
scaDomain.close();
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntimeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntimeTestCase.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntimeTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRuntimeTestCase.java Sun Sep 16 16:37:32 2007
@@ -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.runtime;
-
-import org.apache.tuscany.sca.implementation.osgi.runtime.OSGiRuntime;
-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.getRuntime().getBundleContext();
-
- assertNotNull(bc1);
-
- BundleContext bc2 = OSGiRuntime.getRuntime().getBundleContext();
-
- assertNotNull(bc2);
-
- assertTrue(bc1 == bc2);
-
- OSGiRuntime.getRuntime().shutdown();
-
- BundleContext bc3 = OSGiRuntime.getRuntime().getBundleContext();
-
- assertNotNull(bc3);
-
- assertTrue(bc1 != bc3);
-
-
-
- }
-
-
-}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestWithPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestWithPropertyImpl.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestWithPropertyImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestWithPropertyImpl.java Sun Sep 16 16:37:32 2007
@@ -23,6 +23,7 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osoa.sca.annotations.Property;
/**
*
@@ -31,10 +32,12 @@
*/
public class OSGiTestWithPropertyImpl implements OSGiTestInterface, BundleActivator {
+ @Property
public double exchangeRate;
private String currency;
+ @Property
public void setCurrency(String currency) {
this.currency = currency;
}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java Sun Sep 16 16:37:32 2007
@@ -29,10 +29,12 @@
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
+import org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor;
import org.apache.tuscany.sca.assembly.xml.CompositeProcessor;
import org.apache.tuscany.sca.binding.sca.impl.SCABindingFactoryImpl;
import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
@@ -41,7 +43,6 @@
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.core.scope.Scope;
import org.apache.tuscany.sca.implementation.osgi.test.OSGiTestBundles;
import org.apache.tuscany.sca.implementation.osgi.test.OSGiTestImpl;
import org.apache.tuscany.sca.implementation.osgi.test.OSGiTestInterface;
@@ -58,9 +59,9 @@
*/
public class OSGiReadImplTestCase extends TestCase {
- XMLInputFactory inputFactory;
- DefaultStAXArtifactProcessorExtensionPoint staxProcessors;
- ExtensibleStAXArtifactProcessor staxProcessor;
+ private XMLInputFactory inputFactory;
+ private DefaultStAXArtifactProcessorExtensionPoint staxProcessors;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
private AssemblyFactory assemblyFactory;
private SCABindingFactory scaBindingFactory;
private PolicyFactory policyFactory;
@@ -115,20 +116,28 @@
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite composite = compositeProcessor.read(reader);
assertNotNull(composite);
+
+ ComponentTypeProcessor ctProcessor = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
+ is = getClass().getClassLoader().getResourceAsStream("OSGiTestService.componentType");
+ reader = inputFactory.createXMLStreamReader(is);
+ ComponentType ct = ctProcessor.read(reader);
ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
- staxProcessor.resolve(composite, resolver);
+ ctProcessor.resolve(ct, resolver);
+ resolver.addModel(ct);
+
+ compositeProcessor.resolve(composite, resolver);
CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null, null);
compositeUtil.build(composite);
}
public void testReadOSGiImplementation() throws Exception {
+
String str = "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +
"<implementation.osgi xmlns=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://osgi\" " +
- "bundle=\"OSGiTestService\" " +
- "bundleLocation=\"file:target/OSGiTestService.jar\" " +
- "scope=\"COMPOSITE\" " +
+ "bundleSymbolicName=\"OSGiTestService\" " +
+ "bundleVersion=\"2.0.0\" " +
"imports=\"import1.jar import2.jar\"" +
"/>";
ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes());
@@ -139,12 +148,11 @@
OSGiImplementation osgiImpl = osgiProcessor.read(reader);
- assertEquals(osgiImpl.getBundleName(), "OSGiTestService");
- assertEquals(osgiImpl.getBundleLocation(), "file:target/OSGiTestService.jar");
+ assertEquals(osgiImpl.getBundleSymbolicName(), "OSGiTestService");
+ assertEquals(osgiImpl.getBundleVersion(), "2.0.0");
assertTrue(osgiImpl.getImports().length == 2);
assertEquals(osgiImpl.getImports()[0], "import1.jar");
assertEquals(osgiImpl.getImports()[1], "import2.jar");
- assertEquals(osgiImpl.getScope(), Scope.COMPOSITE);
}
}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java Sun Sep 16 16:37:32 2007
@@ -21,8 +21,11 @@
import java.lang.ref.WeakReference;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.contribution.resolver.ClassReference;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
@@ -46,6 +49,20 @@
Object resolved = map.get(unresolved);
if (resolved != null) {
+ if (unresolved instanceof OSGiImplementation && !(resolved instanceof OSGiImplementation)) {
+
+ OSGiImplementation impl = ((OSGiImplementation)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);
@@ -68,7 +85,7 @@
// Return the resolved ClassReference
return modelClass.cast(resolved);
-
+
} else {
// Return the unresolved object
Modified: incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/resources/osgitest.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/resources/osgitest.composite?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/resources/osgitest.composite (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/implementation-osgi/src/test/resources/osgitest.composite Sun Sep 16 16:37:32 2007
@@ -25,9 +25,7 @@
<component name="OSGiTestServiceComponent">
<tuscany:implementation.osgi
bundle="OSGiTestService"
- bundleLocation="file:target/OSGiTestService.jar"
- scope="COMPOSITE"
- injectProperties="true"
+ bundleSymbolicName="org.apache.tuscany.sca.implementation.osgi.test.OSGiTestInterface"
/>
<property name="currency" type="xsd:string" >USD</property>
Propchange: incubator/tuscany/branches/sca-java-1.0/modules/osgi-runtime/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Sep 16 16:37:32 2007
@@ -0,0 +1,18 @@
+dojo
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+derby.log
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+.felix
+.externalToolBuilders
+maven-eclipse.xml
Copied: incubator/tuscany/branches/sca-java-1.0/modules/osgi-runtime/pom.xml (from r575799, incubator/tuscany/java/sca/modules/osgi-runtime/pom.xml)
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/osgi-runtime/pom.xml?p2=incubator/tuscany/branches/sca-java-1.0/modules/osgi-runtime/pom.xml&p1=incubator/tuscany/java/sca/modules/osgi-runtime/pom.xml&r1=575799&r2=576211&rev=576211&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/osgi-runtime/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/osgi-runtime/pom.xml Sun Sep 16 16:37:32 2007
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-modules</artifactId>
- <version>1.1-incubating-SNAPSHOT</version>
+ <version>1.0-incubating-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -42,7 +42,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
- <version>1.1-incubating-SNAPSHOT</version>
+ <version>1.0-incubating-SNAPSHOT</version>
</dependency>
<dependency>
Modified: incubator/tuscany/branches/sca-java-1.0/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/pom.xml?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/pom.xml Sun Sep 16 16:37:32 2007
@@ -49,6 +49,7 @@
<module>binding-rmi</module>
<module>binding-sca</module>
<module>binding-sca-axis2</module>
+ <module>binding-osgi</module>
<!--
<module>binding-sca-jms</module>
-->
@@ -60,6 +61,7 @@
<module>contribution-impl</module>
<module>contribution-namespace</module>
<module>contribution-java</module>
+ <module>contribution-osgi</module>
<module>core</module>
<module>core-databinding</module>
<module>core-spi</module>
@@ -103,6 +105,8 @@
<module>implementation-node-runtime</module>
<module>implementation-notification</module>
<module>implementation-osgi</module>
+ <module>osgi-runtime</module>
+
<module>implementation-resource</module>
<module>implementation-script</module>
<module>implementation-spring</module>
Modified: incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/README?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/README (original)
+++ incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/README Sun Sep 16 16:37:32 2007
@@ -30,7 +30,11 @@
The SupplyChainClient exercises this interface by calling the
purchaseGoods operation. This results in messages passing to
the Retailer, Warehouse, and Shipper components and the result returned
-to the Customer service on a separate callback thread.
+to the Customer service on a separate callback thread. The Customer
+and Shipper components are implemented as OSGi bundles which use
+implementation.osgi, while the Retailer and Warehouse components are
+implemented using implementation.java.
+
src
+---main
@@ -121,17 +125,10 @@
run:
[java] Main thread Thread[main,5,main]
- [java] Created OSGiCustomerImpl
- [java] Started bundle OSGiCustomerImpl
- [java] Customer.purchaseGoods, retailer is [Proxy - 1afae45]
- [java] Retailer.submitOrder, warehouse is [Proxy - 811c88]
- [java] Warehouse.fulfillOrder : shipper is [Proxy - 15bdc50]
- [java] Created OSGiShipperImpl
- [java] Started bundle OSGiShipperImpl
- [java] Shipper.processShipment, customer is [Proxy - 60e128]
- [java] Main thread sleeping ...
- [java] Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfi
-lled, shipped
+ [java] Main thread Started OSGi bundle with activator OSGiCustomerImpl
+ [java] Main thread Started OSGi bundle with activator OSGiShipperImpl
+ [java] Main thread Sleeping ...
+ [java] Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shipped
@@ -151,6 +148,8 @@
-------------------------------------------------------
Running supplychain.SupplyChainClientTestCase
Main thread Thread[main,5,main]
+Started OSGi bundle with activator OSGiCustomerImpl
+Started OSGi bundle with activator OSGiShipperImpl
Sleeping ...
Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shipped
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.625 sec
Modified: incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/build.xml?rev=576211&r1=576210&r2=576211&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/build.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/samples/osgi-supplychain/build.xml Sun Sep 16 16:37:32 2007
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
-->
-<project name="osgi-supplychain" default="compile">
+<project name="sample-osgi-supplychain" default="compile">
<property name="test.class" value="supplychain.SupplyChainClient" />
- <property name="test.jar" value="sample-osgi-supplychain.jar" />
-
+ <property name="test.jar" value="sample-osgi-supplychain.jar" />
+
<target name="init">
<mkdir dir="target/classes"/>
</target>
-
+
<target name="compile" depends="init">
<javac srcdir="src/main/java"
destdir="target/classes"
@@ -31,7 +31,7 @@
source="1.5"
target="1.5">
<classpath>
- <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
</classpath>
</javac>
<copy todir="target/classes">
@@ -41,29 +41,57 @@
<manifest>
<attribute name="Main-Class" value="${test.class}" />
</manifest>
- </jar>
- </target>
-
+ </jar>
+ <jar jarfile="target/classes/Customer.jar" manifest="target/classes/osgi/Customer.mf" >
+ <fileset dir="target/classes"
+ includes="supplychain/customer/Customer.class \
+ supplychain/OSGiBundleImpl.class \
+ supplychain/customer/OSGiCustomerImpl.class"
+ />
+ </jar>
+ <jar jarfile="target/classes/Retailer.jar" manifest="target/classes/osgi/Retailer.mf" >
+ <fileset dir="target/classes"
+ includes="supplychain/retailer/Retailer.class \
+ supplychain/OSGiBundleImpl.class \
+ supplychain/retailer/OSGiRetailerImpl.class"
+ />
+ </jar>
+ <jar jarfile="target/classes/Warehouse.jar" manifest="target/classes/osgi/Warehouse.mf" >
+ <fileset dir="target/classes"
+ includes="supplychain/warehouse/Warehouse.class \
+ supplychain/OSGiBundleImpl.class \
+ supplychain/warehouse/OSGiWarehouseImpl.class"
+ />
+ </jar>
+ <jar jarfile="target/classes/Shipper.jar" manifest="target/classes/osgi/Shipper.mf" >
+ <fileset dir="target/classes"
+ includes="supplychain/shipper/Shipper.class \
+ supplychain/OSGiBundleImpl.class \
+ supplychain/shipper/OSGiShipperImpl.class"
+ />
+ </jar>
+ </target>
+
<target name="run-classes">
<java classname="${test.class}"
fork="true">
<classpath>
<pathelement path="target/classes"/>
- <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
</classpath>
</java>
</target>
-
+
<target name="run">
<java classname="${test.class}"
fork="true">
<classpath>
<pathelement path="target/${test.jar}"/>
- <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
</classpath>
- </java>
- </target>
-
+ </java>
+ </target>
+
<target name="clean">
<delete quiet="true" includeemptydirs="true">
<fileset dir="target"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org