From a40e527938d76ba71f211da7e327adb50384ba69 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:26:33 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/implementation-pojo-extension/README | 70 --------- .../implementation-pojo-extension/build.xml | 51 ------ .../samples/implementation-pojo-extension/pom.xml | 77 --------- .../src/main/java/pojo/POJOImplementation.java | 65 -------- .../main/java/pojo/POJOImplementationFactory.java | 36 ----- .../pojo/impl/POJOImplementationFactoryImpl.java | 36 ----- .../java/pojo/impl/POJOImplementationImpl.java | 155 ------------------ .../pojo/impl/POJOImplementationProcessor.java | 173 --------------------- .../pojo/provider/POJOImplementationInvoker.java | 68 -------- .../pojo/provider/POJOImplementationProvider.java | 106 ------------- .../POJOImplementationProviderFactory.java | 45 ------ ...ca.contribution.processor.StAXArtifactProcessor | 19 --- ...any.sca.contribution.processor.ValidationSchema | 19 --- ...cany.sca.provider.ImplementationProviderFactory | 19 --- .../services/pojo.POJOImplementationFactory | 19 --- .../main/resources/sample-implementation-pojo.xsd | 38 ----- .../src/test/java/helloworld/HelloWorld.java | 26 ---- .../src/test/java/helloworld/HelloWorldImpl.java | 37 ----- .../src/test/java/helloworld/HelloWorldImpl2.java | 37 ----- .../test/java/helloworld/HelloWorldTestCase.java | 51 ------ .../helloworld/HelloWorldImpl2.componentType | 26 ---- .../test/resources/helloworld/helloworld.composite | 33 ---- 22 files changed, 1206 deletions(-) delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/README delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/build.xml delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/pom.xml delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType delete mode 100644 tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite (limited to 'tags/java/sca/1.2.1/samples/implementation-pojo-extension') diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/README b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/README deleted file mode 100644 index 3b201779e1..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/README +++ /dev/null @@ -1,70 +0,0 @@ -Implementation POJO Sample -========================== -This sample demonstrates how new implementation types are constructed for -Apache Tuscany SCA. - -The README in the samples directory (the directory above this) provides -general instructions about building and running samples. Take a look there -first. - -Sample Overview ---------------- -This sample contains a POJO implementation type as an example of how to create -new implementation types. - -implementation-pojo-extension/ - src/ - main/ - java/ - pojo/ - implementation model interfaces - impl/ - implementations of the model interfaces - provider/ - runtime implementation - resources/ - META-INF/ - services/ - declares the extension - test/ - java/ - helloworld/ - HelloWorldTestCase.java - JUnit test case - resources/ - helloworld.composite - the SCA assembly used during unit testing - - build.xml - the Ant build file - pom.xml - the Maven build file - -Building The Sample Extension Using Ant ------------------------------------------ -With the binary distribution the sample extension can be built using Ant as -follows - -cd implementation-pojo-extension -ant compile - -Building The Sample Using Maven -------------------------------------------- -With either the binary or source distributions the sample can be built -using Maven as follows. - -cd implementation-pojo-extension -mvn - -Maven will also test that the sample extension built properly. You should see -the following output from the test phase. - -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running helloworld.HelloWorldTestCase -Initializing POJO -Initializing POJO -Executing POJO sayHello -Initializing POJO -Initializing POJO -Executing POJO sayHello -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.616 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 - -This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/build.xml b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/build.xml deleted file mode 100644 index 78bae79859..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/build.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/pom.xml b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/pom.xml deleted file mode 100644 index 1c0c05137f..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-sca - 1.2.1-incubating - ../../pom.xml - - sample-implementation-pojo-extension - Apache Tuscany SCA POJO Implementation Extension Sample - - - - apache.incubator - http://people.apache.org/repo/m2-incubating-repository - - - - - - org.apache.tuscany.sca - tuscany-assembly-xml - 1.2.1-incubating - - - - org.apache.tuscany.sca - tuscany-interface-java-xml - 1.2.1-incubating - - - - org.apache.tuscany.sca - tuscany-core-spi - 1.2.1-incubating - - - - org.apache.tuscany.sca - tuscany-host-embedded - 1.2.1-incubating - test - - - - junit - junit - 4.2 - test - - - - - - ${artifactId} - - - diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java deleted file mode 100644 index 7c2f5d236f..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package pojo; - -import java.lang.reflect.Method; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.Implementation; - - -/** - * Represents a POJO implementation in an SCA assembly. - * - * @version $Rev$ $Date$ - */ -public interface POJOImplementation extends Implementation { - - /** - * Returns the POJO class name - * @return - */ - public String getPOJOName(); - - /** - * Sets the POJO class name - * @param pojoName - */ - public void setPOJOName(String pojoName); - - /** - * Returns the POJO class. - * @return - */ - public Class getPOJOClass(); - - /** - * Sets the POJO class. - * @param pojoClass - */ - public void setPOJOClass(Class pojoClass); - - /** - * Returns the POJO's methods. - * @return - */ - public Map getMethods(); - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java deleted file mode 100644 index bbcfb3d0dc..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package pojo; - - -/** - * Factory for the POJO implementation model. - * - * @version $Rev$ $Date$ - */ -public interface POJOImplementationFactory { - - /** - * Creates a new POJO implementation model object. - * @return a new POJO implementation model object - */ - POJOImplementation createPOJOImplementation(); - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java deleted file mode 100644 index 0dad270a6c..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package pojo.impl; - -import pojo.POJOImplementation; -import pojo.POJOImplementationFactory; - -/** - * A factory for the POJO implementation model. - * - * @version $Rev$ $Date$ - */ -public class POJOImplementationFactoryImpl implements POJOImplementationFactory { - - public POJOImplementation createPOJOImplementation() { - return new POJOImplementationImpl(); - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java deleted file mode 100644 index f2d6871039..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java +++ /dev/null @@ -1,155 +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 pojo.impl; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; - -import pojo.POJOImplementation; - - -/** - * Represents a POJO implementation in an SCA assembly. - * - * @version $Rev$ $Date$ - */ -class POJOImplementationImpl implements POJOImplementation { - - private String pojoName; - private Class pojoClass; - private String uri; - private Map methods; - private List services = new ArrayList(); - private List references = new ArrayList(); - private List properties = new ArrayList(); - private boolean unresolved; - - POJOImplementationImpl() { - } - - /** - * Returns the POJO class name - * @return - */ - public String getPOJOName() { - return pojoName; - } - - /** - * Sets the POJO class name - * @param pojoName - */ - public void setPOJOName(String pojoName) { - this.pojoName = pojoName; - setURI(pojoName.replace('.', '/')); - } - - /** - * Returns the POJO class. - * @return - */ - public Class getPOJOClass() { - return pojoClass; - } - - /** - * Sets the POJO class. - * @param pojoClass - */ - public void setPOJOClass(Class pojoClass) { - this.pojoClass = pojoClass; - setPOJOName(pojoClass.getName()); - - // Index the POJO's methods - methods = new HashMap(); - Method[] m = pojoClass.getMethods(); - for (int i = 0; i < m.length; i++) { - methods.put(m[i].getName(), m[i]); - } - } - - /** - * Returns the POJO's methods. - * @return - */ - public Map getMethods() { - return methods; - } - - public ConstrainingType getConstrainingType() { - // The sample POJO implementation does not support constrainingTypes - return null; - } - - public List getProperties() { - return properties; - } - - public List getServices() { - return services; - } - - public List getReferences() { - return references; - } - - public String getURI() { - return uri; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - // The sample POJO implementation does not support constrainingTypes - } - - public void setURI(String uri) { - this.uri = uri; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - @Override - public int hashCode() { - return uri.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof POJOImplementationImpl) { - return ((POJOImplementationImpl)obj).getURI().equals(uri); - } else { - return false; - } - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java deleted file mode 100644 index fbdbd9de79..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java +++ /dev/null @@ -1,173 +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 pojo.impl; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -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; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -import pojo.POJOImplementation; -import pojo.POJOImplementationFactory; - -/** - * Implements a STAX based artifact processor for POJO implementations. - * - * The artifact processor is responsible for processing - * elements in SCA assembly XML composite files and populating the POJO - * implementation model, resolving its references to other artifacts in the SCA - * contribution, and optionally write the model back to SCA assembly XML. - */ -public class POJOImplementationProcessor implements StAXArtifactProcessor { - private static final QName IMPLEMENTATION_POJO = new QName("http://pojo", "implementation.pojo"); - - private AssemblyFactory assemblyFactory; - private JavaInterfaceFactory javaFactory; - private POJOImplementationFactory pojoImplementationFactory; - private PolicyFactory policyFactory; - private PolicyAttachPointProcessor policyProcessor; - - public POJOImplementationProcessor(ModelFactoryExtensionPoint modelFactories) { - - // Get the assembly and Java interface factories as we'll need them to - // create model objects - assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - policyFactory = modelFactories.getFactory(PolicyFactory.class); - pojoImplementationFactory = modelFactories.getFactory(POJOImplementationFactory.class); - policyProcessor = new PolicyAttachPointProcessor(policyFactory); - } - - public QName getArtifactType() { - // Returns the qname of the XML element processed by this processor - return IMPLEMENTATION_POJO; - } - - public Class getModelType() { - // Returns the type of model processed by this processor - return POJOImplementation.class; - } - - public POJOImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - // Read an element - POJOImplementation implementation = pojoImplementationFactory.createPOJOImplementation(); - - // Read policies - policyProcessor.readPolicies(implementation, reader); - - // Read the POJO class attribute. - String className = reader.getAttributeValue(null, "class"); - implementation.setPOJOName(className); - - // Mark the POJO model unresolved to track the fact that it's not - // completely initialized, its class is not loaded yet and services - // and references not initialized either - implementation.setUnresolved(true); - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && IMPLEMENTATION_POJO.equals(reader.getName())) { - break; - } - } - - return implementation; - } - - public void resolve(POJOImplementation implementation, ModelResolver resolver) throws ContributionResolveException { - - // Resolve the POJO implementation - - // First resolve its class - ClassReference classReference = new ClassReference(implementation.getPOJOName()); - classReference = resolver.resolveModel(ClassReference.class, classReference); - Class pojoClass = classReference.getJavaClass(); - if (pojoClass == null) { - throw new ContributionResolveException("Class could not be resolved: " + implementation.getPOJOName()); - } - implementation.setPOJOClass(pojoClass); - - // Check to see if we have a .componentType file describing the POJO class - ComponentType componentType = assemblyFactory.createComponentType(); - componentType.setUnresolved(true); - componentType.setURI(implementation.getURI() + ".componentType"); - componentType = resolver.resolveModel(ComponentType.class, componentType); - if (!componentType.isUnresolved()) { - - // We have a component type description, merge it into the POJO model - implementation.getServices().addAll(componentType.getServices()); - implementation.getReferences().addAll(componentType.getReferences()); - implementation.getProperties().addAll(componentType.getProperties()); - - } else { - - // We have no component type description, simply introspect the POJO and - // create a single Service for it - Service service = assemblyFactory.createService(); - service.setName(pojoClass.getSimpleName()); - JavaInterface javaInterface; - try { - javaInterface = javaFactory.createJavaInterface(pojoClass); - } catch (InvalidInterfaceException e) { - throw new ContributionResolveException(e); - } - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); - interfaceContract.setInterface(javaInterface); - service.setInterfaceContract(interfaceContract); - implementation.getServices().add(service); - } - - // Mark the implementation resolved now - implementation.setUnresolved(false); - } - - public void write(POJOImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write element - policyProcessor.writePolicyPrefixes(implementation, writer); - writer.writeStartElement(IMPLEMENTATION_POJO.getNamespaceURI(), IMPLEMENTATION_POJO.getLocalPart()); - policyProcessor.writePolicyAttributes(implementation, writer); - - if (implementation.getPOJOName() != null) { - writer.writeAttribute("class", implementation.getPOJOName()); - } - - writer.writeEndElement(); - } -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java deleted file mode 100644 index 87333c61f6..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java +++ /dev/null @@ -1,68 +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 pojo.provider; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.osoa.sca.ServiceRuntimeException; - -/** - * Implements an invoker for POJO component implementations. - * - * The invoker is responsible for handling invocations of a business operation. - * Input business data is passed to the invoke method in a Message object. - * The invoke method is responsible for handling the invocation and returning a Message with - * the output business data. - * - * In this example we are simply delegating the operation invocations to the - * corresponding methods on the POJO implementation class using Java reflection. - * - * Depending on the type of implementation being handled, more sophisticated invokers can - * use other techniques to delegate the invocation to the implementation artifact directly, call a - * runtime engine like a BPEL engine or an XQuery engine (this is what the Tuscany - * implementation-bpel and implementation-xquery extensions do) or just completely handle the - * invocation in the invoker itself if the implementation has a fixed behavior for example. - */ -class POJOImplementationInvoker implements Invoker { - - private Object pojoInstance; - private Method method; - - POJOImplementationInvoker(Object pojoInstance, Operation operation, Method method) { - this.pojoInstance = pojoInstance; - this.method = method; - } - - public Message invoke(Message msg) { - try { - msg.setBody(method.invoke(pojoInstance, (Object[])msg.getBody())); - } catch (InvocationTargetException e) { - msg.setFaultBody(e); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - return msg; - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java deleted file mode 100644 index 73a0d22493..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java +++ /dev/null @@ -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 pojo.provider; - -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.osoa.sca.ServiceRuntimeException; - -import pojo.POJOImplementation; - -/** - * An implementation provider for sample CRUD implementations. - * - * The implementation provider is responsible for handling the lifecycle of a component - * implementation and creating operation invokers for the service operations provided - * by the implementation. - * - * The start() and stop() methods are called when a component is started - * and stopped. In this example we are using that opportunity to call init and destroy methods - * on the POJO instance if these methods exist. - * - * The createInvoker method is called for each operation provided by the component - * implementation. The implementation provider can create an invoker and initialize it - * at that time to minimize the amount of work to be performed on each invocation. - * - * For example here we are looking up the Java method corresponding to the service operation - * at passing it to the invoker constructor. This way the invoker won't have to lookup the Java - * method on each invocation. - */ -class POJOImplementationProvider implements ImplementationProvider { - - private POJOImplementation implementation; - private Object pojoInstance; - - /** - * Constructs a new CRUD implementation. - */ - POJOImplementationProvider(RuntimeComponent component, POJOImplementation implementation) { - this.implementation = implementation; - - // Create a new instance of the POJO - try { - pojoInstance = implementation.getPOJOClass().newInstance(); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - public void start() { - try { - // Invoke the POJO's init method - Method initMethod = implementation.getMethods().get("init"); - if (initMethod != null) { - initMethod.invoke(pojoInstance); - } - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - public void stop() { - try { - // Invoke the POJO's destroy method - Method destroyMethod = implementation.getMethods().get("destroy"); - if (destroyMethod != null) { - destroyMethod.invoke(pojoInstance); - } - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } finally { - pojoInstance = null; - } - } - - public Invoker createInvoker(RuntimeComponentService service, Operation operation) { - Method method = implementation.getMethods().get(operation.getName()); - POJOImplementationInvoker invoker = new POJOImplementationInvoker(pojoInstance, operation, method); - return invoker; - } - - public boolean supportsOneWayInvocation() { - return false; - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java deleted file mode 100644 index 22f2be09e9..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java +++ /dev/null @@ -1,45 +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 pojo.provider; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -import pojo.POJOImplementation; - -/** - * A factory for POJO implementation providers. - */ -public class POJOImplementationProviderFactory implements ImplementationProviderFactory { - - public POJOImplementationProviderFactory(ExtensionPointRegistry registry) { - } - - public Class getModelType() { - // Returns the type of model processed by this processor - return POJOImplementation.class; - } - - public ImplementationProvider createImplementationProvider(RuntimeComponent component, POJOImplementation implementation) { - return new POJOImplementationProvider(component, implementation); - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index 8337e81c5f..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Implementation class for the artifact processor extension -pojo.impl.POJOImplementationProcessor;qname=http://pojo#implementation.pojo,model=pojo.POJOImplementation,factory=pojo.POJOImplementationFactory diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema deleted file mode 100644 index 64dd230a15..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# URI of the XML schema to be used for validation -sample-implementation-pojo.xsd diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory deleted file mode 100644 index b30ea3b9cf..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Implementation class for the implementation extension -pojo.provider.POJOImplementationProviderFactory;model=pojo.POJOImplementation diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory deleted file mode 100644 index 075af98240..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Implementation class for implementation model factory -pojo.impl.POJOImplementationFactoryImpl diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd deleted file mode 100644 index c9d170770b..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java deleted file mode 100644 index cc32929f09..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package helloworld; - -public interface HelloWorld { - - String sayHello(String name); - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java deleted file mode 100644 index 0580e30aba..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package helloworld; - -public class HelloWorldImpl { - - public void init() { - System.out.println("Initializing POJO"); - } - - public void destroy() { - System.out.println("Destroying POJO"); - } - - public String sayHello(String name) { - System.out.println("Executing POJO sayHello"); - return "Hello " + name; - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java deleted file mode 100644 index 69ab1f567e..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package helloworld; - -public class HelloWorldImpl2 { - - public void init() { - System.out.println("Initializing POJO"); - } - - public void destroy() { - System.out.println("Destroying POJO"); - } - - public String sayHello(String name) { - System.out.println("Executing POJO sayHello"); - return "Hello " + name; - } - -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java deleted file mode 100644 index d8b5f41adc..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package helloworld; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -/** - * Tests the POJO implementation extension. - */ -public class HelloWorldTestCase extends TestCase { - - private SCADomain scaDomain; - - @Override - protected void setUp() throws Exception { - scaDomain = SCADomain.newInstance("helloworld/helloworld.composite"); - } - - @Override - protected void tearDown() throws Exception { - scaDomain.close(); - } - - public void testHello() throws Exception { - HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent"); - assertEquals("Hello petra", helloworld.sayHello("petra")); - } - - public void testHello2() throws Exception { - HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent2/HelloWorld2"); - assertEquals("Hello petra", helloworld.sayHello("petra")); - } -} diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType deleted file mode 100644 index a92c5ab8db..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite b/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite deleted file mode 100644 index c38094dfc9..0000000000 --- a/tags/java/sca/1.2.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - -- cgit v1.2.3