diff options
Diffstat (limited to 'branches/sca-equinox')
28 files changed, 531 insertions, 87 deletions
diff --git a/branches/sca-equinox/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java b/branches/sca-equinox/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java index cfe7a649d9..80368a0fb6 100644 --- a/branches/sca-equinox/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java +++ b/branches/sca-equinox/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java @@ -22,7 +22,7 @@ package org.apache.tuscany.sca.binding.jms; import javax.jms.Message; import javax.jms.Session; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; +import org.apache.tuscany.sca.binding.jms.impl.JMSBindingImpl; import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; public class TestMessageProcessor extends XMLTextMessageProcessor { @@ -31,7 +31,7 @@ public class TestMessageProcessor extends XMLTextMessageProcessor { public static boolean extractPayloadFromJMSMessageCalled; public static boolean setOperationNameCalled; - public TestMessageProcessor(JMSBinding jmsBinding) { + public TestMessageProcessor(JMSBindingImpl jmsBinding) { super(jmsBinding); } public Object extractPayloadFromJMSMessage(Message message) { diff --git a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java index f7ed5058c5..23ba985ebb 100644 --- a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java +++ b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java @@ -18,15 +18,9 @@ */ package org.apache.tuscany.sca.binding.ws.wsdlgen; -import java.util.List; -import java.util.Map; - -import javax.wsdl.Definition; -import javax.wsdl.Operation; -import javax.wsdl.PortType; - import junit.framework.TestCase; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor; import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint; @@ -50,7 +44,7 @@ import org.osoa.sca.annotations.Remotable; public class BindingWSDLGeneratorTestCase extends TestCase { public void testCreateWSDLInterfaceContract() throws InvalidInterfaceException { - DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(); + DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class); XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class); DefaultJavaInterfaceFactory factory = new DefaultJavaInterfaceFactory(); diff --git a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java index c51ab8af99..1b08255e46 100644 --- a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java +++ b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java @@ -24,6 +24,7 @@ import java.io.StringWriter; import javax.wsdl.Definition; import javax.wsdl.xml.WSDLWriter; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor; import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint; @@ -50,7 +51,7 @@ public class Interface2WSDLGeneratorTestCase { JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null); new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface); new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface); - DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(); + DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); WSDLDefinition wsdlDefinition = new DefaultWSDLFactory(modelFactories).createWSDLDefinition(); DefaultXSDFactory factory = new DefaultXSDFactory(); Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false, new XSDModelResolver(null, null), dataBindings, factory, null); diff --git a/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java index 5c6080d699..e4082b3b85 100644 --- a/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java +++ b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java @@ -24,6 +24,7 @@ import static junit.framework.Assert.assertTrue; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.ContributionFactory; import org.apache.tuscany.sca.contribution.DefaultContributionFactory; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.junit.Before; @@ -45,7 +46,7 @@ public class ExtensibleModelResolverTestCase { ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(); resolvers.addResolver(Model.class, TestModelResolver.class); - FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(); + FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); resolver = new ExtensibleModelResolver(null, resolvers, factories, null); diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java index 6b9eaeab8d..9258a837d8 100644 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java +++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java @@ -44,10 +44,13 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; 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.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -66,6 +69,15 @@ public class DefaultValidatingXMLInputFactory extends ValidatingXMLInputFactory private boolean hasSchemas; private Schema aggregatedSchema; + public DefaultValidatingXMLInputFactory(ExtensionPointRegistry registry) { + FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class); + XMLInputFactory factory = factoryExtensionPoint.getFactory(XMLInputFactory.class); + this.inputFactory = factory; + this.schemas = registry.getExtensionPoint(ValidationSchemaExtensionPoint.class); + this.monitor = + registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class).createMonitor(); + } + /** * Constructs a new XMLInputFactory. * diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java index da249a09e4..c0eef5a7a8 100644 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java +++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java @@ -27,16 +27,4 @@ import javax.xml.stream.XMLInputFactory; * @version $Rev$ $Date$ */ public abstract class ValidatingXMLInputFactory extends XMLInputFactory { - - /** - * Create a new default validating XML input factory. - * @return - */ - public static ValidatingXMLInputFactory newInstance() { - return new DefaultValidatingXMLInputFactory( - XMLInputFactory.newInstance(), - new DefaultValidationSchemaExtensionPoint(), - null); - } - } diff --git a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java index 5c6080d699..e4082b3b85 100644 --- a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java +++ b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java @@ -24,6 +24,7 @@ import static junit.framework.Assert.assertTrue; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.ContributionFactory; import org.apache.tuscany.sca.contribution.DefaultContributionFactory; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.junit.Before; @@ -45,7 +46,7 @@ public class ExtensibleModelResolverTestCase { ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(); resolvers.addResolver(Model.class, TestModelResolver.class); - FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(); + FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); resolver = new ExtensibleModelResolver(null, resolvers, factories, null); diff --git a/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java b/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java index 3b109f3137..26c0f3ecb6 100644 --- a/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java +++ b/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java @@ -28,6 +28,7 @@ import junit.framework.TestCase; import org.apache.tuscany.sca.contribution.resolver.ClassReference; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import com.example.ipo.sdo.SdoFactory; @@ -69,7 +70,7 @@ public class ImportSDOProcessorTestCase extends TestCase { @Override protected void setUp() throws Exception { - loader = new ImportSDOProcessor(new DefaultFactoryExtensionPoint(), null); + loader = new ImportSDOProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()), null); xmlFactory = XMLInputFactory.newInstance(); } diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java index 1d0da12f91..c1221aad7a 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java @@ -33,13 +33,14 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery; * @version $Rev$ $Date$ */ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint { - + private ExtensionPointRegistry extensionPointRegistry; private HashMap<Class<?>, Object> factories = new HashMap<Class<?>, Object>(); /** * Constructs a new DefaultModelFactoryExtensionPoint. */ - public DefaultFactoryExtensionPoint() { + public DefaultFactoryExtensionPoint(ExtensionPointRegistry extensionPointRegistry) { + this.extensionPointRegistry = extensionPointRegistry; } /** @@ -88,43 +89,35 @@ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint { public <T> T getFactory(Class<T> factoryInterface) { Object factory = factories.get(factoryInterface); if (factory == null) { - - if (factoryInterface.isInterface()) { - - // Dynamically load a factory class declared under META-INF/services - try { - ServiceDeclaration factoryDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(factoryInterface.getName()); - if (factoryDeclaration != null) { - Class<?> factoryClass = factoryDeclaration.loadClass(); - + + // Dynamically load a factory class declared under META-INF/services + try { + ServiceDeclaration factoryDeclaration = + ServiceDiscovery.getInstance().getFirstServiceDeclaration(factoryInterface.getName()); + if (factoryDeclaration != null) { + Class<?> factoryClass = factoryDeclaration.loadClass(); + + try { + // Default empty constructor + Constructor<?> constructor = factoryClass.getConstructor(); + factory = constructor.newInstance(); + } catch (NoSuchMethodException e) { try { - // Default empty constructor - Constructor<?> constructor = factoryClass.getConstructor(); - factory = constructor.newInstance(); - } catch (NoSuchMethodException e) { - // Constructor taking the model factory extension point Constructor<?> constructor = factoryClass.getConstructor(FactoryExtensionPoint.class); factory = constructor.newInstance(this); + } catch (NoSuchMethodException e1) { + // Constructor taking the extension point registry + Constructor<?> constructor = factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(extensionPointRegistry); } - - // Cache the loaded factory - addFactory(factory); } - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } else { - // Call the newInstance static method on the factory abstract class - try { - factory = ServiceDiscovery.getInstance().newFactoryClassInstance(factoryInterface.getName()); - } catch (Exception e) { - throw new IllegalArgumentException(e); + // Cache the loaded factory + addFactory(factory); } - - // Cache the factory - addFactory(factory); + } catch (Exception e) { + throw new IllegalArgumentException(e); } } return factoryInterface.cast(factory); diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java index 0f408600aa..7d9dc0e9ef 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java @@ -24,8 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; import java.security.AccessController; @@ -45,7 +43,7 @@ import java.util.logging.Logger; /** * A ServiceDiscoverer that find META-INF/services/... using the Context ClassLoader. * - * @version $Rev: $ $Date: $ + * @version $Rev$ $Date$ */ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer { private static final Logger logger = Logger.getLogger(ContextClassLoaderServiceDiscoverer.class.getName()); @@ -243,11 +241,4 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer { } - public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException { - Class<?> factoryClass = Class.forName(name, false, classLoaderReference.get()); - Method newInstanceMethod = factoryClass.getMethod("newInstance"); - Object factory = newInstanceMethod.invoke(null); - return factory; - } - } diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java index 679e3d1f57..f89a25d199 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java @@ -47,16 +47,4 @@ public interface ServiceDiscoverer { */ public ServiceDeclaration getFirstServiceDeclaration(String name) throws IOException; - /** - * Create a new instance of a factory service class. - * - * @param name - * @return service implementation class - * @throws SecurityException - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException; - } diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java index 552691ab6b..e78cb136d3 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.extensibility; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Set; @@ -84,9 +83,17 @@ public class ServiceDiscovery implements ServiceDiscoverer { return service; } - public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException { - Object factory = getServiceDiscoverer().newFactoryClassInstance(name); - return factory; + public Object newFactoryClassInstance(String name) { + try { + ServiceDeclaration declaration = getFirstServiceDeclaration(name); + if (declaration == null) { + return null; + } + Class<?> factoryClass = declaration.loadClass(); + return factoryClass.newInstance(); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } } } diff --git a/branches/sca-equinox/modules/thirdparty-library/pom.xml b/branches/sca-equinox/modules/thirdparty-library/pom.xml index 166850ddcb..09c3eb2822 100644 --- a/branches/sca-equinox/modules/thirdparty-library/pom.xml +++ b/branches/sca-equinox/modules/thirdparty-library/pom.xml @@ -87,8 +87,12 @@ <id>build-thirdparty-distro</id> <phase>generate-resources</phase> <goals> - <goal>build-thirdparty-distro</goal> + <goal>generate-modules</goal> </goals> + <configuration> + <generateTargetPlatform>true</generateTargetPlatform> + <generatePlugin>true</generatePlugin> + </configuration> </execution> <!-- diff --git a/branches/sca-equinox/pom.xml b/branches/sca-equinox/pom.xml index c3f5d14db7..d53095df8f 100644 --- a/branches/sca-equinox/pom.xml +++ b/branches/sca-equinox/pom.xml @@ -244,6 +244,9 @@ <module>demos</module> <module>distribution</module> </modules> + <build> + <defaultGoal>eclipse:eclipse</defaultGoal> + </build> </profile> <profile> diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddService.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..adbd18a9e4 --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +@EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + // Calculate + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ba897fa301 --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Reference; + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideService.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractService.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/resources/Calculator.composite b/branches/sca-equinox/samples/calculator-osgi/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..913081b9be --- /dev/null +++ b/branches/sca-equinox/samples/calculator-osgi/src/main/resources/Calculator.composite @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://sample" + xmlns:sample="http://sample" + name="Calculator"> + + <component name="CalculatorServiceComponent"> + <implementation.java class="calculator.CalculatorServiceImpl"/> + <reference name="addService" target="AddServiceComponent" /> + <reference name="subtractService" target="SubtractServiceComponent" /> + <reference name="multiplyService" target="MultiplyServiceComponent" /> + <reference name="divideService" target="DivideServiceComponent" /> + </component> + + <component name="AddServiceComponent"> + <implementation.java class="calculator.AddServiceImpl"/> + </component> + + <component name="SubtractServiceComponent"> + <implementation.java class="calculator.SubtractServiceImpl"/> + </component> + + <component name="MultiplyServiceComponent"> + <implementation.java class="calculator.MultiplyServiceImpl"/> + </component> + + <component name="DivideServiceComponent"> + <implementation.java class="calculator.DivideServiceImpl"/> + </component> + + <component name="CalculatorClient"> + <implementation.java class="calculator.CalculatorClient"/> + <reference name="calculatorService" target="CalculatorServiceComponent" /> + </component> + +</composite> diff --git a/branches/sca-equinox/samples/calculator-rcp/pom.xml b/branches/sca-equinox/samples/calculator-rcp/pom.xml index 91f820f03c..6191b0803d 100644 --- a/branches/sca-equinox/samples/calculator-rcp/pom.xml +++ b/branches/sca-equinox/samples/calculator-rcp/pom.xml @@ -198,7 +198,7 @@ <Bundle-Description>${pom.name}</Bundle-Description> <Bundle-Activator>calculator.rcp.Activator</Bundle-Activator> <Eclipse-LazyStart>true</Eclipse-LazyStart> - <Export-Package>calculator.rcp*</Export-Package> + <Export-Package></Export-Package> </instructions> <manifestLocation>${basedir}/META-INF</manifestLocation> </configuration> diff --git a/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java index f8bd7b91ab..851699611f 100644 --- a/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java +++ b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java @@ -215,7 +215,6 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { // Copy a WAR as is log.info("Adding WAR artifact: " + artifact); copyFile(artifactFile, root); - bundleSymbolicNames.add(bundleName); } else { |