From 931daedb4ffd8c1e57f54ee324c5c7d284004607 Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 22 Nov 2010 12:38:34 +0000 Subject: TUSCANY-3783 - Start working up a test case to drive the async infrastructure improvements git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1037692 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/implementation-sample-async/pom.xml | 6 + .../src/main/java/sampleasync/impl/ImplUtil.java | 148 ++++++++++++++++++ .../impl/SampleAsyncImplementation.java | 41 +++++ .../impl/SampleAsyncImplementationProcessor.java | 174 +++++++++++++++++++++ .../java/sampleasync/impl/SampleAsyncProvider.java | 91 +++++++++++ .../impl/SampleAsyncProviderFactory.java | 48 ++++++ .../java/sampleasync/impl/SampleJavaInvoker.java | 52 ++++++ .../java/sampleasync/impl/SampleWSDLInvoker.java | 56 +++++++ .../java/sampleasync/impl/SampleWSDLProxy.java | 57 +++++++ ...ca.contribution.processor.StAXArtifactProcessor | 1 + ...any.sca.contribution.processor.ValidationSchema | 1 + ...cany.sca.provider.ImplementationProviderFactory | 1 + .../resources/sampleasync/impl/sampleasync.xsd | 38 +++++ .../src/test/java/sampleasync/Upper.java | 33 ++++ .../test/java/sampleasync/UpperAsyncReference.java | 47 ++++++ .../test/java/sampleasync/UpperAsyncService.java | 36 +++++ .../impl/SampleAsyncReferenceTestCase.java | 63 ++++++++ .../impl/UpperJavaAsyncReferenceImpl.java | 70 +++++++++ .../impl/UpperJavaAsyncServiceImpl.java | 39 +++++ .../impl/UpperSampleAsyncReferenceImpl.java | 41 +++++ .../impl/UpperSampleAsyncServiceImpl.java | 42 +++++ .../src/test/resources/test.composite | 3 +- .../src/test/resources/testasync.composite | 45 ++++++ 23 files changed, 1132 insertions(+), 1 deletion(-) create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/ImplUtil.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementation.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementationProcessor.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/sampleasync/impl/sampleasync.xsd create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/Upper.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncReference.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncService.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/SampleAsyncReferenceTestCase.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncReferenceImpl.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncServiceImpl.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncReferenceImpl.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncServiceImpl.java create mode 100644 sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/testasync.composite (limited to 'sca-java-2.x') diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/pom.xml b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/pom.xml index ca45d32152..56f690aac2 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/pom.xml +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/pom.xml @@ -36,6 +36,12 @@ 2.0-SNAPSHOT + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + + org.apache.tuscany.sca tuscany-binding-ws-runtime-axis2 diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/ImplUtil.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/ImplUtil.java new file mode 100644 index 0000000000..c30c784d64 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/ImplUtil.java @@ -0,0 +1,148 @@ +/* + * 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 sampleasync.impl; + +import java.lang.annotation.Annotation; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; + +import sample.api.Java; +import sample.api.WSDL; + +/** + * Utility functions to help develop a component implementation extension. + */ +class ImplUtil { + + /** + * Return a Sample implementation with the given name. + */ + static SampleAsyncImplementation implementation(String name) { + final SampleAsyncImplementation impl = new SampleAsyncImplementation(name); + impl.setUnresolved(true); + return impl; + } + + /** + * Return the Java class configured on an annotation. + */ + static Class clazz(final Annotation a) { + return ((Java)a).value(); + } + + /** + * Return the WSDL QName configured on an annotation. + */ + static QName qname(final Annotation a) { + final String uri = ((WSDL)a).value(); + final int h = uri.indexOf('#'); + return new QName(uri.substring(0, h), uri.substring(h + 1)); + } + + /** + * Convert a Java class to an interface contract. + */ + static JavaInterfaceContract contract(final Class c, final JavaInterfaceFactory jif) throws InvalidInterfaceException { + final JavaInterfaceContract ic = jif.createJavaInterfaceContract(); + ic.setInterface(jif.createJavaInterface(c)); + return ic; + } + + /** + * Convert a WSDL interface to an interface contract. + */ + static WSDLInterfaceContract contract(final WSDLInterface wi, final WSDLFactory wf) { + final WSDLInterfaceContract ic = wf.createWSDLInterfaceContract(); + ic.setInterface(wi); + return ic; + } + + /** + * Convert a Java class to a service. + */ + static Service service(final Class c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException { + Service s = af.createService(); + s.setName(c.getSimpleName()); + s.setInterfaceContract(contract(c, jif)); + return s; + } + + /** + * Convert a WSDL interface to a service. + */ + static Service service(final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) { + Service s = af.createService(); + s.setName(wi.getName().getLocalPart()); + s.setInterfaceContract(contract(wi, wf)); + return s; + } + + /** + * Convert a name and Java class to a reference. + */ + static Reference reference(final String name, final Class c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException { + final Reference r = af.createReference(); + r.setName(name); + r.setInterfaceContract(contract(c, jif)); + return r; + } + + /** + * Convert a name and WSDL interface to a reference. + */ + static Reference reference(final String name, final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) { + final Reference r = af.createReference(); + r.setName(name); + r.setInterfaceContract(contract(wi, wf)); + return r; + } + + /** + * Convert a WSDL qname to a WSDL interface. + */ + static WSDLInterface interfaze(final QName name, final WSDLFactory wif) { + final WSDLInterface wir = wif.createWSDLInterface(); + wir.setUnresolved(true); + wir.setName(name); + return wir; + } + + /** + * Convert a WSDL qname to a WSDL definition. + */ + static WSDLDefinition definition(final QName name, final WSDLFactory wif) { + final WSDLDefinition wdr = wif.createWSDLDefinition(); + wdr.setUnresolved(true); + wdr.setNamespace(name.getNamespaceURI()); + wdr.setNameOfPortTypeToResolve(name); + return wdr; + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementation.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementation.java new file mode 100644 index 0000000000..e0abd72b84 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementation.java @@ -0,0 +1,41 @@ +/* + * 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 sampleasync.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; + +/** + * Model representing a Sample implementation in an SCA assembly. + * + * @version $Rev$ $Date$ + */ +public class SampleAsyncImplementation extends ImplementationImpl { + static final QName QN = new QName(SCA11_TUSCANY_NS, "implementation.sampleasync"); + + final String name; + Class clazz; + + SampleAsyncImplementation(final String name) { + super(QN); + this.name = name; + } + +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementationProcessor.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementationProcessor.java new file mode 100644 index 0000000000..03fe3da178 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncImplementationProcessor.java @@ -0,0 +1,174 @@ +/* + * 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 sampleasync.impl; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static sampleasync.impl.SampleAsyncImplementation.QN; +import static sampleasync.impl.ImplUtil.clazz; +import static sampleasync.impl.ImplUtil.definition; +import static sampleasync.impl.ImplUtil.implementation; +import static sampleasync.impl.ImplUtil.interfaze; +import static sampleasync.impl.ImplUtil.qname; +import static sampleasync.impl.ImplUtil.reference; +import static sampleasync.impl.ImplUtil.service; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +import javax.wsdl.PortType; +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.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; +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.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject; + +import sample.api.Java; +import sample.api.WSDL; + +/** + * StAX artifact processor for Sample implementations. + * + * @version $Rev$ $Date$ + */ +public class SampleAsyncImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + final AssemblyFactory af; + final JavaInterfaceFactory jif; + final WSDLFactory wf; + + public SampleAsyncImplementationProcessor(final ExtensionPointRegistry ep) { + final FactoryExtensionPoint fep = ep.getExtensionPoint(FactoryExtensionPoint.class); + this.af = fep.getFactory(AssemblyFactory.class); + this.jif = fep.getFactory(JavaInterfaceFactory.class); + this.wf = fep.getFactory(WSDLFactory.class); + } + + public QName getArtifactType() { + return QN; + } + + public Class getModelType() { + return SampleAsyncImplementation.class; + } + + public SampleAsyncImplementation read(final XMLStreamReader r, final ProcessorContext ctx) throws ContributionReadException, XMLStreamException { + // Read the component implementation element + final SampleAsyncImplementation impl = implementation(r.getAttributeValue(null, "class")); + while(r.hasNext() && !(r.next() == END_ELEMENT && QN.equals(r.getName()))) + ; + return impl; + } + + public void resolve(final SampleAsyncImplementation impl, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException { + try { + // Resolve and introspect the implementation class + impl.clazz = resolve(impl.name, res, ctx); + + for(final Annotation a: impl.clazz.getAnnotations()) { + if(a instanceof Java) + impl.getServices().add(service(clazz(a), jif, af)); + else if(a instanceof WSDL) + impl.getServices().add(service(resolve(qname(a), res, ctx, wf), wf, af)); + } + + for(Field f: impl.clazz.getDeclaredFields()) { + for(final Annotation a: f.getAnnotations()) { + if(a instanceof Java) + impl.getReferences().add(reference(f.getName(), clazz(a), jif, af)); + else if(a instanceof WSDL) + impl.getReferences().add(reference(f.getName(), resolve(qname(a), res, ctx, wf), wf, af)); + } + } + + impl.setUnresolved(false); + } catch(InvalidInterfaceException e) { + throw new ContributionResolveException(e); + } + } + + public void write(final SampleAsyncImplementation impl, final XMLStreamWriter w, final ProcessorContext ctx) throws ContributionWriteException, XMLStreamException { + writeStart(w, QN.getNamespaceURI(), QN.getLocalPart(), new XAttr("class", impl.name)); + writeEnd(w); + } + + /** + * Resolve a Java class. + */ + static Class resolve(final String name, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException { + final ClassReference cr = res.resolveModel(ClassReference.class, new ClassReference(name), ctx); + if(cr.getJavaClass() != null) + return cr.getJavaClass(); + throw new ContributionResolveException(new ClassNotFoundException(name)); + } + + /** + * Resolve a WSDL interface. + */ + static WSDLInterface resolve(final QName name, final ModelResolver res, final ProcessorContext ctx, final WSDLFactory wif) throws ContributionResolveException { + final WSDLInterface wi = res.resolveModel(WSDLInterface.class, interfaze(name, wif), ctx); + if(!wi.isUnresolved()) + return domBound(wi); + + final WSDLDefinition wd = res.resolveModel(WSDLDefinition.class, definition(wi.getName(), wif), ctx); + if(wd.isUnresolved()) + throw new ContributionResolveException("Couldn't find " + name.getNamespaceURI()); + + WSDLObject pt = wd.getWSDLObject(PortType.class, name); + if(pt == null) + throw new ContributionResolveException("Couldn't find " + name); + try { + final WSDLInterface nwi = wif.createWSDLInterface(pt.getElement(), wd, res, ctx.getMonitor()); + nwi.setWsdlDefinition(wd); + res.addModel(nwi, ctx); + return domBound(nwi); + } catch(InvalidInterfaceException e) { + throw new ContributionResolveException(e); + } + } + + /** + * Return a WSDL interface configured to use a DOM databinding. + */ + static WSDLInterface domBound(WSDLInterface wi) throws ContributionResolveException { + try { + final WSDLInterface domwi = (WSDLInterface)wi.clone(); + domwi.resetDataBinding(DOMDataBinding.NAME); + return domwi; + } catch(CloneNotSupportedException e) { + throw new ContributionResolveException(e); + } + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java new file mode 100644 index 0000000000..f87e468320 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java @@ -0,0 +1,91 @@ +/* + * 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 sampleasync.impl; + +import java.lang.reflect.Field; + +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation; +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; + +/** + * Implementation provider for Sample component implementations. + * + * @version $Rev$ $Date$ + */ +class SampleAsyncProvider implements ImplementationProvider { + final RuntimeComponent comp; + final SampleAsyncImplementation impl; + final ProxyFactory pxf; + Object instance; + + SampleAsyncProvider(final RuntimeComponent comp, final SampleAsyncImplementation impl, ProxyFactory pf) { + this.comp = comp; + this.impl = impl; + this.pxf = pf; + } + + public void start() { + // Construct implementation instance and inject reference proxies + try { + instance = impl.clazz.newInstance(); + + for(ComponentReference r: comp.getReferences()) { + final Field f = impl.clazz.getDeclaredField(r.getName()); + f.setAccessible(true); + // Inject a Java or WSDLReference proxy + final Interface i = r.getInterfaceContract().getInterface(); + if(i instanceof JavaInterface) + f.set(instance, pxf.createProxy(comp.getComponentContext().getServiceReference(f.getType(), r.getName()))); + else + f.set(instance, new SampleWSDLProxy(r.getEndpointReferences().get(0), i)); + } + } catch(Exception e) { + throw new RuntimeException(e); + } + } + + public void stop() { + instance = null; + } + + public boolean supportsOneWayInvocation() { + return false; + } + + public Invoker createInvoker(final RuntimeComponentService s, final Operation op) { + try { + // Creating an invoker for a Java or WSDL-typed implementation + if(op instanceof JavaOperation) + return new SampleJavaInvoker((JavaOperation)op, impl.clazz, instance); + return new SampleWSDLInvoker((WSDLOperation)op, impl.clazz, instance); + } catch(Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java new file mode 100644 index 0000000000..1a7dad9eb4 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java @@ -0,0 +1,48 @@ +/* + * 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 sampleasync.impl; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; +import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Factory for Sample implementation providers. + * + * @version $Rev$ $Date$ + */ +public class SampleAsyncProviderFactory implements ImplementationProviderFactory { + final ProxyFactory pxf; + + public SampleAsyncProviderFactory(final ExtensionPointRegistry ep) { + pxf = ExtensibleProxyFactory.getInstance(ep); + } + + public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final SampleAsyncImplementation impl) { + return new SampleAsyncProvider(comp, impl, pxf); + } + + public Class getModelType() { + return SampleAsyncImplementation.class; + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java new file mode 100644 index 0000000000..437d141be0 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.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 sampleasync.impl; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +/** + * Invoker for Sample components that implement a Java interface. + * + * @version $Rev$ $Date$ + */ +class SampleJavaInvoker implements Invoker { + final Object instance; + final Method method; + + SampleJavaInvoker(final JavaOperation op, final Class clazz, final Object instance) throws SecurityException, NoSuchMethodException { + this.instance = instance; + this.method = clazz.getMethod(op.getJavaMethod().getName(), op.getJavaMethod().getParameterTypes()); + } + + public Message invoke(final Message msg) { + try { + // Call the method that implements the operation + msg.setBody(method.invoke(instance, (Object[])msg.getBody())); + } catch(Exception e) { + e.printStackTrace(); + msg.setFaultBody(e.getCause()); + } + return msg; + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java new file mode 100644 index 0000000000..5611928573 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java @@ -0,0 +1,56 @@ +/* + * 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 sampleasync.impl; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.w3c.dom.Element; + +/** + * Invoker for Sample components that implement a WSDL interface using a generic + * call method. + * + * @version $Rev$ $Date$ + */ +class SampleWSDLInvoker implements Invoker { + final String name; + final Object instance; + final Method method; + + SampleWSDLInvoker(final WSDLOperation op, final Class clazz, final Object instance) throws SecurityException, NoSuchMethodException { + this.name = op.getName(); + this.instance = instance; + this.method = clazz.getMethod("call", String.class, Element.class); + } + + public Message invoke(final Message msg) { + try { + // Invoke the generic call method + msg.setBody(method.invoke(instance, name, ((Object[])msg.getBody())[0])); + } catch(Exception e) { + e.printStackTrace(); + msg.setFaultBody(e.getCause()); + } + return msg; + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java new file mode 100644 index 0000000000..ff84db1d1a --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sampleasync.impl; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.w3c.dom.Element; + +import sample.api.WSDLReference; + +/** + * Proxy used to call operations on WSDL references. + */ +class SampleWSDLProxy implements WSDLReference { + final RuntimeEndpointReference repr; + final Map ops; + + SampleWSDLProxy(EndpointReference epr, Interface wi) { + repr = (RuntimeEndpointReference)epr; + ops = new HashMap(); + for(Operation o: wi.getOperations()) + ops.put(o.getName(), o); + } + + @Override + public Element call(String op, Element e) { + try { + // Invoke the named operation on the endpoint reference + return (Element)repr.invoke(ops.get(op), new Object[] {e}); + } catch(InvocationTargetException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index 908ac95a2e..00d0306d92 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -17,4 +17,5 @@ # Implementation class for the artifact processor extension sample.impl.SampleImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.sample,model=sample.impl.SampleImplementation +sampleasync.impl.SampleAsyncImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.sampleasync,model=sampleasync.impl.SampleAsyncImplementation diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema index 85aff44074..42e61c9d89 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -16,3 +16,4 @@ # under the License. # sample/impl/sample.xsd +sampleasync/impl/sampleasync.xsd diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory index 32a7efcaf9..4eeecb7ba2 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -17,4 +17,5 @@ # Implementation provider for Sample components sample.impl.SampleProviderFactory;model=sample.impl.SampleImplementation +sampleasync.impl.SampleAsyncProviderFactory;model=sampleasync.impl.SampleAsyncImplementation diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/sampleasync/impl/sampleasync.xsd b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/sampleasync/impl/sampleasync.xsd new file mode 100644 index 0000000000..ff70fd6020 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/resources/sampleasync/impl/sampleasync.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/Upper.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/Upper.java new file mode 100644 index 0000000000..0c29cea1dc --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/Upper.java @@ -0,0 +1,33 @@ +/* + * 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 sampleasync; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface Upper { + + String upper(String s); +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncReference.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncReference.java new file mode 100644 index 0000000000..ad2e62f85d --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncReference.java @@ -0,0 +1,47 @@ +/* + * 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 sampleasync; + +import java.util.concurrent.Future; + +import javax.xml.ws.AsyncHandler; +import javax.xml.ws.Response; + +import org.oasisopen.sca.annotation.AsyncInvocation; +import org.oasisopen.sca.annotation.Remotable; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +@Remotable +@AsyncInvocation +public interface UpperAsyncReference { + + // Sync + String upper(String s); + + // Aysnc Poll + public Response upperAsync(String s); + + // Async Callback + public Future upperAsync(String s, AsyncHandler handler); +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncService.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncService.java new file mode 100644 index 0000000000..019b0c2f12 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/UpperAsyncService.java @@ -0,0 +1,36 @@ +/* + * 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 sampleasync; + +import org.oasisopen.sca.ResponseDispatch; +import org.oasisopen.sca.annotation.AsyncInvocation; +import org.oasisopen.sca.annotation.Remotable; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +@Remotable +@AsyncInvocation +public interface UpperAsyncService { + + void upper(String s,ResponseDispatch response); +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/SampleAsyncReferenceTestCase.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/SampleAsyncReferenceTestCase.java new file mode 100644 index 0000000000..6511f3ddf3 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/SampleAsyncReferenceTestCase.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sampleasync.impl; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import sampleasync.Upper; + +/** + * Test how to run an SCA contribution containing a test composite on a + * Tuscany runtime node. + * + * @version $Rev$ $Date$ + */ +public class SampleAsyncReferenceTestCase { + static Node node; + + @BeforeClass + public static void setUp() throws Exception { + final NodeFactory nf = NodeFactory.newInstance(); + String here = SampleAsyncReferenceTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString(); + node = nf.createNode(new Contribution("test", here)); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } + + @Test + public void testReference() { + System.out.println("SampleAsyncReferenceTestCase.testReference"); + Upper upper = node.getService(Upper.class, "SampleAsyncReference"); + final String r = upper.upper("async"); + System.out.println(r); + assertEquals("ASYNC", r); + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncReferenceImpl.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncReferenceImpl.java new file mode 100644 index 0000000000..9cf7ff9883 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncReferenceImpl.java @@ -0,0 +1,70 @@ +/* + * 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 sampleasync.impl; + +import static java.lang.System.out; + +import java.util.concurrent.ExecutionException; + +import javax.xml.ws.Response; + +import org.oasisopen.sca.annotation.Reference; + +import sampleasync.Upper; +import sampleasync.UpperAsyncReference; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +public class UpperJavaAsyncReferenceImpl implements Upper { + + @Reference + UpperAsyncReference upper; + + public String upper(String s) { + out.println("UpperAsyncReferenceImpl.upper(" + s + ")"); + + // async poll + Response response = upper.upperAsync(s); + + while (!response.isDone()){ + System.out.println("Waiting for poll"); + try { + Thread.sleep(500); + } catch (Exception ex) { + // do nothing + } + } + + String result = null; + + try { + result = response.get(); + System.out.println("Async client poll patern: result = " + result); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + return result; + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncServiceImpl.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncServiceImpl.java new file mode 100644 index 0000000000..33eb668e59 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperJavaAsyncServiceImpl.java @@ -0,0 +1,39 @@ +/* + * 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 sampleasync.impl; + +import static java.lang.System.out; + +import org.oasisopen.sca.ResponseDispatch; + +import sampleasync.UpperAsyncService; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +public class UpperJavaAsyncServiceImpl implements UpperAsyncService { + + public void upper(String s,ResponseDispatch response) { + out.println("UpperServiceImple.upper(" + s + ")"); + response.sendResponse(s.toUpperCase()); + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncReferenceImpl.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncReferenceImpl.java new file mode 100644 index 0000000000..e4ac64c37c --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncReferenceImpl.java @@ -0,0 +1,41 @@ +/* + * 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 sampleasync.impl; + +import static java.lang.System.out; +import sample.api.Java; +import sampleasync.Upper; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Upper.class) +public class UpperSampleAsyncReferenceImpl { + + @Java(Upper.class) + Upper upper; + + public String upper(String s) { + out.println("UpperReferenceImpl.upper(" + s + ")"); + return upper.upper(s); + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncServiceImpl.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncServiceImpl.java new file mode 100644 index 0000000000..c71c3ca2b9 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sampleasync/impl/UpperSampleAsyncServiceImpl.java @@ -0,0 +1,42 @@ +/* + * 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 sampleasync.impl; + +import static java.lang.System.out; + +import org.oasisopen.sca.ResponseDispatch; + +import sample.api.Java; +import sampleasync.Upper; +import sampleasync.UpperAsyncService; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Upper.class) +public class UpperSampleAsyncServiceImpl { + + public String upper(String s) { + out.println("UpperServiceImple.upper(" + s + ")"); + return s.toUpperCase(); + } +} diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/test.composite b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/test.composite index 43a75f50a7..1f5b98c00b 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/test.composite +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/test.composite @@ -55,6 +55,7 @@ - + + diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/testasync.composite b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/testasync.composite new file mode 100644 index 0000000000..c289a1ab32 --- /dev/null +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/resources/testasync.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3