From 08adcf2e783e4733e0fd646d353db3592c62140d Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 16 Feb 2012 15:43:08 +0000 Subject: Delete old RC tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1245046 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/sample/api/Java.java | 34 --- .../src/main/java/sample/api/WSDL.java | 34 --- .../src/main/java/sample/api/WSDLReference.java | 30 -- .../src/main/java/sample/impl/EmbedUtil.java | 311 --------------------- .../src/main/java/sample/impl/ImplUtil.java | 148 ---------- .../sample/impl/SampleAsyncResponseInvoker.java | 70 ----- .../java/sample/impl/SampleImplementation.java | 41 --- .../sample/impl/SampleImplementationProcessor.java | 174 ------------ .../main/java/sample/impl/SampleJavaInvoker.java | 52 ---- .../src/main/java/sample/impl/SampleProvider.java | 114 -------- .../java/sample/impl/SampleProviderFactory.java | 50 ---- .../main/java/sample/impl/SampleWSDLInvoker.java | 134 --------- .../src/main/java/sample/impl/SampleWSDLProxy.java | 104 ------- ...ca.contribution.processor.StAXArtifactProcessor | 20 -- ...any.sca.contribution.processor.ValidationSchema | 18 -- ...cany.sca.provider.ImplementationProviderFactory | 20 -- .../src/main/resources/sample/impl/sample.xsd | 38 --- 17 files changed, 1392 deletions(-) delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/Java.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDL.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/EmbedUtil.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/ImplUtil.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleAsyncResponseInvoker.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementation.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementationProcessor.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleJavaInvoker.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProvider.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProviderFactory.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLInvoker.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory delete mode 100644 sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/sample/impl/sample.xsd (limited to 'sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main') diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/Java.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/Java.java deleted file mode 100644 index 6c9240005f..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/Java.java +++ /dev/null @@ -1,34 +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 sample.api; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Target( {TYPE, FIELD}) -@Retention(RUNTIME) -public @interface Java { - - Class value(); -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDL.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDL.java deleted file mode 100644 index 655770ec32..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDL.java +++ /dev/null @@ -1,34 +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 sample.api; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Target( {TYPE, FIELD}) -@Retention(RUNTIME) -public @interface WSDL { - - String value(); -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java deleted file mode 100644 index a25df3e895..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java +++ /dev/null @@ -1,30 +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 sample.api; - -import org.w3c.dom.Element; - -public interface WSDLReference { - - Element call(String op, Element e); - public Element callBare(String op, Element... e); - void callAsync(String op, Element e); - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/EmbedUtil.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/EmbedUtil.java deleted file mode 100644 index 0ccbcc9e36..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/EmbedUtil.java +++ /dev/null @@ -1,311 +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 sample.impl; - -import java.net.URI; -import java.net.URL; -import java.util.Arrays; - -import javax.wsdl.PortType; -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; -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 org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; - -/** - * A few utility functions to help embed a Tuscany runtime, and a simple DSL - * to help assemble and run SCDL. - */ -public class EmbedUtil { - - /** - * A runtime embedder context, which conveniently initializes a Node factory - * and gets the various registries, factories and extension points we need. - */ - static class Context { - final NodeFactory nf; - final ExtensionPointRegistry epr; - final FactoryExtensionPoint fep; - final ContributionFactory cf; - final AssemblyFactory af; - final JavaInterfaceFactory jif; - final WSDLFactory wif; - final URLArtifactProcessorExtensionPoint apep; - final ExtensibleURLArtifactProcessor aproc; - final ModelResolverExtensionPoint mrep; - final ProviderFactoryExtensionPoint pfep; - - Context(final NodeFactory nf) { - this.nf = nf; - epr = nf.getExtensionPointRegistry(); - fep = epr.getExtensionPoint(FactoryExtensionPoint.class); - cf = fep.getFactory(ContributionFactory.class); - af = fep.getFactory(AssemblyFactory.class); - jif = fep.getFactory(JavaInterfaceFactory.class); - wif = fep.getFactory(WSDLFactory.class); - apep = epr.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - aproc = new ExtensibleURLArtifactProcessor(apep); - mrep = epr.getExtensionPoint(ModelResolverExtensionPoint.class); - pfep = epr.getExtensionPoint(ProviderFactoryExtensionPoint.class); - } - } - - static Context embedContext(NodeFactory nf) { - return new Context(nf); - } - - /** - * A mini DSL to help build and assemble contributions and SCDL composites. - */ - interface Builder { - T build(Context ec); - } - - static T build(final Builder builder, final Context ec) { - return builder.build(ec); - } - - /** - * Return a contribution builder. - */ - static Builder contrib(final String uri, final String loc, final Builder... artifacts) { - return new Builder() { - public Contribution build(final Context ec) { - final Contribution c = ec.cf.createContribution(); - c.setURI(uri); - c.setLocation(loc); - c.setModelResolver(new ExtensibleModelResolver(c, ec.mrep, ec.fep)); - for(Builder a: artifacts) - c.getArtifacts().add(a.build(ec)); - return c; - } - }; - } - - /** - * Return an artifact builder. - */ - static Builder artifact(final String uri, final Object model) { - return new Builder() { - public Artifact build(final Context ec) { - final Artifact a = ec.cf.createArtifact(); - a.setURI(uri); - a.setModel(model); - return a; - } - }; - } - - /** - * Return a composite builder. - */ - static Builder composite(final String ns, final String name, final Builder... components) { - return new Builder() { - public Composite build(final Context ec) { - final Composite compos = ec.af.createComposite(); - compos.setName(new QName(ns, name)); - for(final Builder c: components) - compos.getComponents().add(c.build(ec)); - return compos; - } - }; - } - - /** - * Return a component builder. - */ - static Builder component(final String name, final Builder impl, final Builder... references) { - return new Builder() { - public Component build(final Context ec) { - final Component c = ec.af.createComponent(); - c.setName(name); - c.setImplementation(impl.build(ec)); - for(Builder r: references) - c.getReferences().add(r.build(ec)); - return c; - } - }; - } - - /** - * Return an implementation builder. - */ - static Builder implementation(final Class clazz, final Builder... contracts) { - return new Builder() { - public SampleImplementation build(final Context ec) { - final SampleImplementation impl = ImplUtil.implementation(clazz.getName()); - impl.clazz = clazz; - impl.setUnresolved(false); - for(final Builder b: contracts) { - Contract c = b.build(ec); - if(c instanceof Service) - impl.getServices().add((Service)c); - else - impl.getReferences().add((Reference)c); - } - return impl; - } - }; - } - - /** - * Return a reference builder. - */ - static Builder reference(final String name, final Class c) { - return new Builder() { - public Reference build(final Context ec) { - try { - return ImplUtil.reference(name, c, ec.jif, ec.af); - } catch(InvalidInterfaceException e) { - throw new RuntimeException(e); - } - } - }; - } - - static Builder reference(final String name, final WSDLInterface c) { - return new Builder() { - public Reference build(final Context ec) { - return ImplUtil.reference(name, c, ec.wif, ec.af); - } - }; - } - - static Builder reference(final String name, final String target) { - return new Builder() { - public ComponentReference build(final Context ec) { - final ComponentReference r = ec.af.createComponentReference(); - r.setName(name); - final ComponentService s = ec.af.createComponentService(); - s.setUnresolved(true); - s.setName(target); - r.getTargets().add(s); - return r; - } - }; - } - - /** - * Return a service builder. - */ - static Builder service(final Class c) { - return new Builder() { - public Service build(final Context ec) { - try { - return ImplUtil.service(c, ec.jif, ec.af); - } catch(InvalidInterfaceException e) { - throw new RuntimeException(e); - } - } - }; - } - - static Builder service(final WSDLInterface c) { - return new Builder() { - public Service build(final Context ec) { - return ImplUtil.service(c, ec.wif, ec.af); - } - }; - } - - /** - * Return a WSDLInterface builder which loads a WSDL into a contribution. - */ - static Builder wsdli(final String uri, final String ns, final String name, final Contribution c) { - return new Builder() { - public WSDLInterface build(final Context ec) { - try { - final ProcessorContext ctx = new ProcessorContext(); - final WSDLDefinition wd = ec.aproc.read(null, new URI(uri), new URL(new URL(c.getLocation()), uri), ctx, WSDLDefinition.class); - c.getModelResolver().addModel(wd, ctx); - c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx); - final WSDLObject pt = wd.getWSDLObject(PortType.class, new QName(ns, name)); - if(pt == null) - throw new ContributionResolveException("Couldn't find " + name); - final WSDLInterface nwi = ec.wif.createWSDLInterface(pt.getElement(), wd, c.getModelResolver(), null); - nwi.setWsdlDefinition(wd); - nwi.resetDataBinding(DOMDataBinding.NAME); - return nwi; - } catch(Exception e) { - throw new RuntimeException(e); - } - } - }; - } - - /** - * Return the extension point registry used by our nodes. - */ - static ExtensionPointRegistry extensionPoints(final Context ec) { - return ec.epr; - } - - /** - * Return the provider factory extension point used by our nodes. - */ - static ProviderFactoryExtensionPoint providerFactories(final Context ec) { - return ec.pfep; - } - - /** - * Add a deployable composite to a contribution. - */ - static Contribution deploy(final Contribution contrib, final Composite... comps) { - for(Composite c: comps) - contrib.getDeployables().add(c); - return contrib; - } - - /** - * Configure a node with a list of contributions. - */ - static Node node(final NodeFactory nf, final Contribution... contributions) { - return nf.createNode(Arrays.asList(contributions)); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/ImplUtil.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/ImplUtil.java deleted file mode 100644 index abd4cd7ab0..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/ImplUtil.java +++ /dev/null @@ -1,148 +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 sample.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 SampleImplementation implementation(String name) { - final SampleImplementation impl = new SampleImplementation(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/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleAsyncResponseInvoker.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleAsyncResponseInvoker.java deleted file mode 100644 index aed21ecc4e..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleAsyncResponseInvoker.java +++ /dev/null @@ -1,70 +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 sample.impl; - -import java.lang.reflect.Method; -import java.util.Map; - -import org.apache.tuscany.sca.core.invocation.Constants; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvokerAsyncResponse; -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 SampleAsyncResponseInvoker implements InvokerAsyncResponse { - final String name; - final Object instance; - final Operation op; - Map asyncMessageMap; - - SampleAsyncResponseInvoker(Map asyncMessageMap, final Operation op, final Class clazz, final Object instance) { - this.asyncMessageMap = asyncMessageMap; - this.name = op.getName(); - this.instance = instance; - this.op = op; - } - - public void invokeAsyncResponse(final Message msg) { - try { - String messageID = (String) msg.getHeaders().get("RELATES_TO"); - if (messageID == null ) { - messageID = (String) msg.getHeaders().get(Constants.MESSAGE_ID); - } // end if - - String forwardOpName = (String)asyncMessageMap.get(messageID); - - // process the async response - //Object response = ((Object[])msg.getBody())[0]; - Object response = msg.getBody(); - - Method method = instance.getClass().getMethod(forwardOpName + "Callback", Element.class); - method.invoke(instance, response); - } catch(Exception e) { - e.printStackTrace(); - // TODO - need to throw this to somewhere? - } - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementation.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementation.java deleted file mode 100644 index 41ce71a732..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementation.java +++ /dev/null @@ -1,41 +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 sample.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 SampleImplementation extends ImplementationImpl { - static final QName QN = new QName(SCA11_TUSCANY_NS, "implementation.sample"); - - final String name; - Class clazz; - - SampleImplementation(final String name) { - super(QN); - this.name = name; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementationProcessor.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementationProcessor.java deleted file mode 100644 index 6017030d35..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleImplementationProcessor.java +++ /dev/null @@ -1,174 +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 sample.impl; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static sample.impl.SampleImplementation.QN; -import static sample.impl.ImplUtil.clazz; -import static sample.impl.ImplUtil.definition; -import static sample.impl.ImplUtil.implementation; -import static sample.impl.ImplUtil.interfaze; -import static sample.impl.ImplUtil.qname; -import static sample.impl.ImplUtil.reference; -import static sample.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 SampleImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { - final AssemblyFactory af; - final JavaInterfaceFactory jif; - final WSDLFactory wf; - - public SampleImplementationProcessor(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 SampleImplementation.class; - } - - public SampleImplementation read(final XMLStreamReader r, final ProcessorContext ctx) throws ContributionReadException, XMLStreamException { - // Read the component implementation element - final SampleImplementation impl = implementation(r.getAttributeValue(null, "class")); - while(r.hasNext() && !(r.next() == END_ELEMENT && QN.equals(r.getName()))) - ; - return impl; - } - - public void resolve(final SampleImplementation 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 SampleImplementation 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/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleJavaInvoker.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleJavaInvoker.java deleted file mode 100644 index 244251c4c9..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleJavaInvoker.java +++ /dev/null @@ -1,52 +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 sample.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/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProvider.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProvider.java deleted file mode 100644 index 7186c0a0d2..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProvider.java +++ /dev/null @@ -1,114 +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 sample.impl; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -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.invocation.InvokerAsyncRequest; -import org.apache.tuscany.sca.invocation.InvokerAsyncResponse; -import org.apache.tuscany.sca.provider.ImplementationAsyncProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * Implementation provider for Sample component implementations. - * - * @version $Rev$ $Date$ - */ -class SampleProvider implements ImplementationAsyncProvider { - final RuntimeComponent comp; - final SampleImplementation impl; - final ProxyFactory pxf; - final ExtensionPointRegistry ep; - Object instance; - - // make this static rather than worrying about persistence on the reference side - static Map asyncMessageMap = new HashMap(); - - SampleProvider(final RuntimeComponent comp, final SampleImplementation impl, ProxyFactory pf, ExtensionPointRegistry ep) { - this.comp = comp; - this.impl = impl; - this.pxf = pf; - this.ep = ep; - } - - 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(asyncMessageMap, r.getEndpointReferences().get(0), i, ep)); - } - } 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); - } - } - - public InvokerAsyncRequest createAsyncInvoker(RuntimeComponentService service, Operation operation) { - // Only providing Async support through WSDL interfaces in this test - try { - return new SampleWSDLInvoker((WSDLOperation)operation, impl.clazz, instance); - } catch(Exception e) { - throw new RuntimeException(e); - } - } - - public InvokerAsyncResponse createAsyncResponseInvoker(Operation operation) { - return new SampleAsyncResponseInvoker(asyncMessageMap, operation, impl.clazz, instance); - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProviderFactory.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProviderFactory.java deleted file mode 100644 index 86ddd50ea6..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleProviderFactory.java +++ /dev/null @@ -1,50 +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 sample.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 SampleProviderFactory implements ImplementationProviderFactory { - final ProxyFactory pxf; - final ExtensionPointRegistry ep; - - public SampleProviderFactory(final ExtensionPointRegistry ep) { - this.ep = ep; - pxf = ExtensibleProxyFactory.getInstance(ep); - } - - public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final SampleImplementation impl) { - return new SampleProvider(comp, impl, pxf, ep); - } - - public Class getModelType() { - return SampleImplementation.class; - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLInvoker.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLInvoker.java deleted file mode 100644 index 5c76cfd90a..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLInvoker.java +++ /dev/null @@ -1,134 +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 sample.impl; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.core.invocation.AsyncResponseInvoker; -import org.apache.tuscany.sca.core.invocation.InterceptorAsyncImpl; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeEndpoint; -import org.oasisopen.sca.ServiceRuntimeException; -import org.w3c.dom.Element; - -/** - * Invoker for Sample components that implement a WSDL interface using a generic - * call method. - * - * @version $Rev$ $Date$ - */ -class SampleWSDLInvoker extends InterceptorAsyncImpl { - 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 Invoker getNext() { - // Can't get next for an implementation invoker - return null; - } - - public Message invoke(final Message msg) { - return processRequest(msg); - } - - public void invokeAsyncRequest(Message msg) { - if (msg.getOperation().getName().equals("upper")){ - // Retrieve the async callback information - AsyncResponseInvoker respInvoker = (AsyncResponseInvoker)msg.getHeaders().get("ASYNC_RESPONSE_INVOKER"); - if( respInvoker == null ) throw new ServiceRuntimeException("Async Implementation invoked with no response invoker"); - - Message responseMsg = processRequest(msg); - - // in this sample programming model we make the async - // response from the implementation provider. The - // component implementation itself doesn't get a chance to - // do async responses. - - // At this point we could serialize the AsyncResponseInvoker and pick it up again - // later to send the async response - - try { - FileOutputStream fos = new FileOutputStream("ari.dat"); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(respInvoker); - oos.close(); - respInvoker.invokeAsyncResponse(responseMsg); - } catch (Exception ex) { - ex.printStackTrace(); - } - - } else if (msg.getOperation().getName().equals("upper2")){ - Message responseMsg = processRequest(msg); - - // read the async response invoker back in and call it - FileInputStream fis = null; - ObjectInputStream ois = null; - try { - fis = new FileInputStream("ari.dat"); - ois = new ObjectInputStream(fis); - AsyncResponseInvoker respInvoker = (AsyncResponseInvoker) ois.readObject(); - ois.close(); - respInvoker.invokeAsyncResponse(responseMsg); - } catch (Exception ex) { - ex.printStackTrace(); - } - } else { - // Retrieve the async callback information - AsyncResponseInvoker respInvoker = (AsyncResponseInvoker)msg.getHeaders().get("ASYNC_RESPONSE_INVOKER"); - if( respInvoker == null ) throw new ServiceRuntimeException("Async Implementation invoked with no response invoker"); - - Message responseMsg = processRequest(msg); - - if (responseMsg.getBody() != null){ - respInvoker.invokeAsyncResponse(responseMsg); - } - } - - } // end method invokeAsyncRequest - - public Message processRequest(Message msg) { - try { - //AsyncHeader asyncHeader = (String) message.getHeaders().get("ASYNC-HEADER"); - // Invoke the generic call method - Object response = method.invoke(instance, name, ((Object[])msg.getBody())[0]); - msg.setBody(response); - } catch(Exception e) { - e.printStackTrace(); - msg.setFaultBody(e.getCause()); - } - return msg; - } - - public Message processResponse(Message msg) { - return msg; - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java deleted file mode 100644 index 5b42bce28f..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java +++ /dev/null @@ -1,104 +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 sample.impl; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.invocation.Constants; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.MessageFactory; -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; - final ExtensionPointRegistry ep; - final MessageFactory mf; - Map asyncMessageMap; - - SampleWSDLProxy(Map asyncMessageMap, EndpointReference epr, Interface wi, ExtensionPointRegistry ep) { - this.asyncMessageMap = asyncMessageMap; - this.ep = ep; - mf = ep.getExtensionPoint(MessageFactory.class); - repr = (RuntimeEndpointReference)epr; - ops = new ConcurrentHashMap(); - 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); - } - } - - @Override - public Element callBare(String op, Element... e) { - try { - // Invoke the named operation on the endpoint reference - return (Element)repr.invoke(ops.get(op), e); - } catch(InvocationTargetException ex) { - throw new RuntimeException(ex); - } - } - - @Override - public void callAsync(String op, Element e) { - // Asynchronously invoke the named operation on the endpoint reference - Message message = mf.createMessage(); - message.setBody(new Object[]{e}); - - // Generate MESSAGE_ID here. - // String messageID = "myuniqueid"; - String messageID = UUID.randomUUID().toString(); - message.getHeaders().put(Constants.MESSAGE_ID, messageID); - - // save the message id ready for when we process the response - asyncMessageMap.put(messageID, op); - - // We could add implementation specific headers here if required - //message.getHeaders().put(Constants.???, ???); - - try { - repr.invokeAsync(ops.get(op), message); - } catch (Throwable ex) { - ex.printStackTrace(); - } - - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index 908ac95a2e..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,20 +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 -sample.impl.SampleImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.sample,model=sample.impl.SampleImplementation - diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema deleted file mode 100644 index 85aff44074..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema +++ /dev/null @@ -1,18 +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. -# -sample/impl/sample.xsd diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory deleted file mode 100644 index 32a7efcaf9..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory +++ /dev/null @@ -1,20 +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 provider for Sample components -sample.impl.SampleProviderFactory;model=sample.impl.SampleImplementation - diff --git a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/sample/impl/sample.xsd b/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/sample/impl/sample.xsd deleted file mode 100644 index c057aef1c1..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC1/samples/extending-tuscany/implementation-sample/src/main/resources/sample/impl/sample.xsd +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - -- cgit v1.2.3