Author: rfeng
Date: Fri Mar 6 18:44:52 2009
New Revision: 751031
URL: http://svn.apache.org/viewvc?rev=751031&view=rev
Log:
Work in progress, not compiling yet
Removed:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiInstanceWrapper.java
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiRemotableInvoker.java
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiPropertyTestCase.java
Modified:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
Modified:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java?rev=751031&r1=751030&r2=751031&view=diff
==============================================================================
---
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
(original)
+++
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
Fri Mar 6 18:44:52 2009
@@ -40,15 +40,12 @@
private String bundleVersion;
private Bundle osgiBundle;
- private String[] imports;
private Hashtable<String, List<ComponentProperty>> referenceProperties;
private Hashtable<String, List<ComponentProperty>> serviceProperties;
private Hashtable<String, List<ComponentProperty>>
referenceCallbackProperties;
private Hashtable<String, List<ComponentProperty>>
serviceCallbackProperties;
- private String[] classList;
-
private FactoryExtensionPoint modelFactories;
@@ -59,18 +56,14 @@
public OSGiImplementationImpl(FactoryExtensionPoint modelFactories,
String bundleSymbolicName,
String bundleVersion,
- String[] imports,
- String[] classList,
Hashtable<String, List<ComponentProperty>>
refProperties,
Hashtable<String, List<ComponentProperty>>
serviceProperties) {
super();
this.bundleSymbolicName = bundleSymbolicName;
this.bundleVersion = bundleVersion;
- this.imports = imports;
this.referenceProperties = refProperties;
this.serviceProperties = serviceProperties;
- this.classList = classList;
this.modelFactories = modelFactories;
}
Modified:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java?rev=751031&r1=751030&r2=751031&view=diff
==============================================================================
---
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
(original)
+++
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
Fri Mar 6 18:44:52 2009
@@ -42,7 +42,6 @@
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Multiplicity;
-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.context.RequestContextFactory;
@@ -57,11 +56,8 @@
import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
-import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import
org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
-import org.apache.tuscany.sca.implementation.osgi.context.OSGiAnnotations;
import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationImpl;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
@@ -102,8 +98,7 @@
// Maximum milliseconds to wait for services to be registered into OSGi
service registry
private static final long SERVICE_TIMEOUT_MILLIS = 300000;
- private OSGiImplementationImpl implementation;
- private OSGiAnnotations osgiAnnotations;
+ private OSGiImplementation implementation;
private Hashtable<RuntimeWire, Reference> referenceWires = new
Hashtable<RuntimeWire, Reference>();
private Hashtable<RuntimeWire, ComponentReference> componentReferenceWires
=
new Hashtable<RuntimeWire, ComponentReference>();
@@ -113,8 +108,6 @@
private AtomicInteger startBundleEntryCount = new AtomicInteger();
private AtomicInteger processAnnotationsEntryCount = new AtomicInteger();
- private JavaPropertyValueObjectFactory propertyValueFactory;
-
private Hashtable<String, Object> componentProperties = new
Hashtable<String, Object>();
private RuntimeComponent runtimeComponent;
@@ -183,29 +176,10 @@
return runtimeComponent;
}
- protected OSGiImplementationImpl getImplementation() {
+ protected OSGiImplementation getImplementation() {
return implementation;
}
- // Create a property table from the list of properties
- // The source properties are properties read from <property/> elements
- // Create property values in the table of the appropriate class based
- // on the property type specified.
- private void processProperties(List<?> props, Hashtable<String, Object>
propsTable) {
-
- if (props != null) {
- for (Object p : props) {
-
- Property prop = (Property)p;
- Class javaType =
SimpleTypeMapperImpl.getJavaType(prop.getXSDType());
- ObjectFactory<?> objFactory =
propertyValueFactory.createValueFactory(prop, prop.getValue(), javaType);
- Object value = objFactory.getInstance();
-
- propsTable.put(prop.getName(), value);
- }
- }
- }
-
private String getOSGiFilter(Hashtable<String, Object> props) {
String filter = "";
@@ -1008,19 +982,19 @@
}
public Scope getScope() {
- return osgiAnnotations.getScope();
+ return Scope.COMPOSITE;
}
public boolean isEagerInit() {
- return osgiAnnotations.isEagerInit();
+ return false;
}
public long getMaxAge() {
- return osgiAnnotations.getMaxAge();
+ return 0l;
}
public long getMaxIdleTime() {
- return osgiAnnotations.getMaxIdleTime();
+ return 0l;
}
protected ScopeContainer<?> getScopeContainer() {
@@ -1034,12 +1008,7 @@
boolean isRemotable = serviceInterface.isRemotable();
Invoker invoker = new OSGiTargetInvoker(operation, this, service);
- if (isRemotable) {
- return new OSGiRemotableInvoker(osgiAnnotations,
dataBindingRegistry, operation, this, service);
- } else {
- return invoker;
- }
-
+ return invoker;
}
public Invoker createInvoker(RuntimeComponentService service, Operation
operation) {
Modified:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java?rev=751031&r1=751030&r2=751031&view=diff
==============================================================================
---
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
(original)
+++
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
Fri Mar 6 18:44:52 2009
@@ -22,7 +22,6 @@
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.apache.tuscany.sca.assembly.xml.Constants.SCA11_TUSCANY_NS;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -61,7 +60,6 @@
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
@@ -79,13 +77,13 @@
* @version $Rev$ $Date$
*/
public class OSGiImplementationProcessor implements
StAXArtifactProcessor<OSGiImplementation> {
+ public final static String SCA11_NS =
"http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ public final static String SCA11_TUSCANY_NS =
"http://tuscany.apache.org/xmlns/sca/1.1";
public static final QName IMPLEMENTATION_OSGI = new
QName(SCA11_TUSCANY_NS, "implementation.osgi");
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 QName PROPERTIES_QNAME = new QName(SCA11_TUSCANY_NS,
"properties");
private static final QName PROPERTY_QNAME = new QName(SCA11_TUSCANY_NS,
"property");
@@ -112,8 +110,12 @@
private void error(String message, Object model, Exception ex) {
if (monitor != null) {
Problem problem =
- new ProblemImpl(this.getClass().getName(),
"impl-osgi-validation-messages", Severity.ERROR, model,
- message, ex);
+ monitor.createProblem(this.getClass().getName(),
+ "impl-osgi-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
monitor.problem(problem);
}
}
@@ -128,8 +130,12 @@
private void error(String message, Object model, Object...
messageParameters) {
if (monitor != null) {
Problem problem =
- new ProblemImpl(this.getClass().getName(),
"impl-osgi-validation-messages", Severity.ERROR, model,
- message, (Object[])messageParameters);
+ monitor.createProblem(this.getClass().getName(),
+ "impl-osgi-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
monitor.problem(problem);
}
}
@@ -157,18 +163,6 @@
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 classes = reader.getAttributeValue(null, CLASSES);
- String[] classList;
- if (classes != null)
- classList = tokenize(classes);
- else
- classList = new String[0];
Hashtable<String, List<ComponentProperty>> refProperties = new
Hashtable<String, List<ComponentProperty>>();
Hashtable<String, List<ComponentProperty>> serviceProperties = new
Hashtable<String, List<ComponentProperty>>();
@@ -211,7 +205,7 @@
}
OSGiImplementationImpl implementation =
- new OSGiImplementationImpl(modelFactories, bundleSymbolicName,
bundleVersion, importList, classList,
+ new OSGiImplementationImpl(modelFactories, bundleSymbolicName,
bundleVersion,
refProperties, serviceProperties);
implementation.setCallbackProperties(refCallbackProperties,
serviceCallbackProperties);
Modified:
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java?rev=751031&r1=751030&r2=751031&view=diff
==============================================================================
---
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java
(original)
+++
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java
Fri Mar 6 18:44:52 2009
@@ -19,13 +19,19 @@
package org.apache.tuscany.sca.implementation.osgi.runtime;
+import java.io.File;
import java.lang.reflect.Proxy;
-import junit.framework.TestCase;
-
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;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
*
@@ -33,39 +39,46 @@
*
* @version $Rev$ $Date$
*/
-public class OSGiTestCase extends TestCase {
-
- protected String className;
- protected String compositeName;
-
- protected void setUp() throws Exception {
-
+public class OSGiTestCase {
+ private static NodeLauncher host;
+ private static Node node;
+ protected static String className;
+ protected static String compositeName;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ host = NodeLauncher.newInstance();
className = OSGiTestImpl.class.getName();
compositeName = "osgitest.composite";
OSGiTestBundles.createBundle("target/test-classes/OSGiTestService.jar",
OSGiTestInterface.class,
OSGiTestImpl.class);
+ node =
+ host.createNode("osgitest.composite", new Contribution("c1", new
File("target/test-classes").toURI()
+ .toString()));
+ node.start();
}
- @Override
- protected void tearDown() throws Exception {
- OSGiRuntime.stop();
+ @AfterClass
+ public static void tearDown() throws Exception {
+ if (host != null) {
+ node.stop();
+ host.destroy();
+ }
}
+ @Test
public void testOSGiComponent() throws Exception {
- SCADomain scaDomain = SCADomain.newInstance(compositeName);
- OSGiTestInterface testService =
scaDomain.getService(OSGiTestInterface.class, "OSGiTestServiceComponent");
+ OSGiTestInterface testService =
node.getService(OSGiTestInterface.class, "OSGiTestServiceComponent");
assert (testService != null);
assert (testService instanceof Proxy);
String str = testService.testService();
- assertEquals(className, str);
-
- scaDomain.close();
+ Assert.assertEquals(className, str);
}
Modified:
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java?rev=751031&r1=751030&r2=751031&view=diff
==============================================================================
---
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
(original)
+++
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
Fri Mar 6 18:44:52 2009
@@ -37,7 +37,7 @@
import
org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationImpl;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
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;
@@ -110,13 +110,10 @@
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
reader.next();
- OSGiImplementationImpl osgiImpl =
(OSGiImplementationImpl)staxProcessor.read(reader);
+ OSGiImplementation osgiImpl =
(OSGiImplementation)staxProcessor.read(reader);
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");
}
}