From a29294f0f590b045a027325f77bcf14abc36a337 Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 4 Sep 2010 08:43:06 +0000 Subject: Start of a maven archetype for creating a Tuscany binding extension git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@992562 13f79535-47bb-0310-9956-ffa450edef68 --- sca-java-2.x/trunk/archetypes/binding/pom.xml | 53 +++++++++++ .../META-INF/maven/archetype-metadata.xml | 61 ++++++++++++ .../archetype-resources/META-INF/MANIFEST.MF | 17 ++++ .../src/main/resources/archetype-resources/pom.xml | 83 +++++++++++++++++ .../src/main/java/__bindingName__Binding.java | 102 +++++++++++++++++++++ .../main/java/__bindingName__BindingFactory.java | 35 +++++++ .../__bindingName__BindingProviderFactory.java | 50 ++++++++++ .../__bindingName__ReferenceBindingProvider.java | 58 ++++++++++++ .../runtime/__bindingName__ReferenceInvoker.java | 56 +++++++++++ .../__bindingName__ServiceBindingProvider.java | 60 ++++++++++++ .../runtime/__bindingName__ServiceInvoker.java | 43 +++++++++ .../main/java/runtime/__bindingName__Stash.java | 47 ++++++++++ .../__package__.__bindingName__BindingFactory | 20 ++++ ...ca.contribution.processor.StAXArtifactProcessor | 20 ++++ ...any.sca.contribution.processor.ValidationSchema | 19 ++++ ...che.tuscany.sca.provider.BindingProviderFactory | 20 ++++ .../src/main/resources/binding-__bindingName__.xsd | 42 +++++++++ .../src/test/java/helloworld/HelloWorldClient.java | 36 ++++++++ .../src/test/java/helloworld/HelloWorldImpl.java | 31 +++++++ .../test/java/helloworld/HelloWorldService.java | 31 +++++++ .../src/test/java/test/FooBindingTestCase.java | 57 ++++++++++++ .../src/test/resources/helloworld.composite | 39 ++++++++ .../resources/projects/basic/archetype.properties | 6 ++ .../src/test/resources/projects/basic/goal.txt | 0 24 files changed, 986 insertions(+) create mode 100644 sca-java-2.x/trunk/archetypes/binding/pom.xml create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/META-INF/MANIFEST.MF create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/pom.xml create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__Binding.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__BindingFactory.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__BindingProviderFactory.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceBindingProvider.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceInvoker.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceBindingProvider.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceInvoker.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__Stash.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/__package__.__bindingName__BindingFactory create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/binding-__bindingName__.xsd create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldService.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/test/FooBindingTestCase.java create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/resources/helloworld.composite create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/archetype.properties create mode 100644 sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/goal.txt (limited to 'sca-java-2.x/trunk/archetypes') diff --git a/sca-java-2.x/trunk/archetypes/binding/pom.xml b/sca-java-2.x/trunk/archetypes/binding/pom.xml new file mode 100644 index 0000000000..6a4c9b9466 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../../pom.xml + + + tuscany-binding-archetype + maven-archetype + Create a Tuscany binding extension project + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-5 + + + + + + + maven-archetype-plugin + 2.0-alpha-5 + true + + + + + + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/META-INF/maven/archetype-metadata.xml b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..94f44feb00 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/*.* + + + + src/test/java + + **/*.java + + + + src/test/resources + + **/*.* + + + + META-INF + + MANIFEST.MF + + + + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..f895a144e6 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +SCA-Version: 1.1 +Bundle-Name: Apache Tuscany SCA Foo Binding +Bundle-Vendor: The Apache Software Foundation +Bundle-Version: 2.0.0 +Bundle-ManifestVersion: 2 +Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt +Bundle-Description: Apache Tuscany SCA Foo Binding +Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0", + org.apache.tuscany.sca.core;version="2.0.0", + org.apache.tuscany.sca.interfacedef;version="2.0.0", + org.apache.tuscany.sca.invocation;version="2.0.0", + org.apache.tuscany.sca.provider;version="2.0.0", + org.apache.tuscany.sca.runtime;version="2.0.0" +Bundle-SymbolicName: org.apache.tuscany.sca.binding.foo +Bundle-DocURL: http://www.apache.org/ +Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/pom.xml b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..e2c8982762 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-SNAPSHOT + ../pom.xml + + ${artifactId} + ${groupId} + Apache Tuscany SCA Foo Binding Runtime + + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-SNAPSHOT + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-SNAPSHOT + test + + + + ${version} + + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__Binding.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__Binding.java new file mode 100644 index 0000000000..ea177ea446 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__Binding.java @@ -0,0 +1,102 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo; + +import javax.xml.namespace.QName; + +import ${package}.assembly.Binding; +import ${package}.assembly.OperationSelector; +import ${package}.assembly.WireFormat; + +/** + * Represents a binding to an Foo service. + */ +public class FooBinding implements Binding { + + QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.foo"); + + private String name; + private String uri; + private String bindingType; + + public String getBindingType() { + return bindingType; + } + + public void setBindingType(String bindingType) { + this.bindingType = bindingType; + } + + public String getName() { + return name; + } + + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean arg0) { + } + + public QName getType() { + return TYPE; + } + + public WireFormat getRequestWireFormat() { + return null; + } + + public void setRequestWireFormat(WireFormat wireFormat) { + } + + public WireFormat getResponseWireFormat() { + return null; + } + + public void setResponseWireFormat(WireFormat wireFormat) { + } + + public OperationSelector getOperationSelector() { + return null; + } + + public void setOperationSelector(OperationSelector operationSelector) { + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__BindingFactory.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__BindingFactory.java new file mode 100644 index 0000000000..933d208588 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/__bindingName__BindingFactory.java @@ -0,0 +1,35 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo; + + +/** + * Factory implementation to create Foo Models + */ +public class FooBindingFactory { + + public FooBinding createFooBinding() { + return new FooBinding(); + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__BindingProviderFactory.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__BindingProviderFactory.java new file mode 100644 index 0000000000..ec9e358b4d --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__BindingProviderFactory.java @@ -0,0 +1,50 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo.runtime; + +import ${package}.binding.foo.FooBinding; +import ${package}.core.ExtensionPointRegistry; +import ${package}.provider.BindingProviderFactory; +import ${package}.provider.ReferenceBindingProvider; +import ${package}.provider.ServiceBindingProvider; +import ${package}.runtime.RuntimeEndpoint; +import ${package}.runtime.RuntimeEndpointReference; + +public class FooBindingProviderFactory implements BindingProviderFactory { + + public FooBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public Class getModelType() { + return FooBinding.class; + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) { + return new FooReferenceBindingProvider(endpoint); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { + return new FooServiceBindingProvider(endpoint); + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceBindingProvider.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceBindingProvider.java new file mode 100644 index 0000000000..9615501203 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceBindingProvider.java @@ -0,0 +1,58 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo.runtime; + +import ${package}.assembly.EndpointReference; +import ${package}.interfacedef.InterfaceContract; +import ${package}.interfacedef.Operation; +import ${package}.invocation.Invoker; +import ${package}.provider.ReferenceBindingProvider; + +public class FooReferenceBindingProvider implements ReferenceBindingProvider { + + private EndpointReference endpoint; + private InterfaceContract contract; + + public FooReferenceBindingProvider(EndpointReference endpoint) { + this.endpoint = endpoint; + } + + public Invoker createInvoker(Operation operation) { + return new FooReferenceInvoker(operation, endpoint); + } + + public void start() { + } + + public void stop() { + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceInvoker.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceInvoker.java new file mode 100644 index 0000000000..8f8eabb5f6 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ReferenceInvoker.java @@ -0,0 +1,56 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo.runtime; + +import ${package}.assembly.EndpointReference; +import ${package}.interfacedef.Operation; +import ${package}.invocation.Invoker; +import ${package}.invocation.Message; + +public class FooReferenceInvoker implements Invoker { + + protected Operation operation; + protected EndpointReference endpoint; + + public FooReferenceInvoker(Operation operation, EndpointReference endpoint) { + this.operation = operation; + this.endpoint = endpoint; + } + + public Message invoke(Message msg) { + try { + + return doInvoke(msg); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public Message doInvoke(Message msg) { + // Add some code here to make an invocation over the foo binding protocol + // For this sample we'll just get it from the static stash + FooServiceInvoker fi = FooStash.getService(endpoint.getBinding().getURI()); + return fi.invokeService(msg); + } +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceBindingProvider.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceBindingProvider.java new file mode 100644 index 0000000000..b33591e44d --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceBindingProvider.java @@ -0,0 +1,60 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo.runtime; + +import ${package}.binding.foo.FooBinding; +import ${package}.interfacedef.InterfaceContract; +import ${package}.provider.ServiceBindingProvider; +import ${package}.runtime.RuntimeEndpoint; + +public class FooServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeEndpoint endpoint; + private InterfaceContract contract; + + public FooServiceBindingProvider(RuntimeEndpoint endpoint) { + this.endpoint = endpoint; + } + + public void start() { + // add some code here to start the service + + // For this sample we'll just share it in a static + FooStash.addService(endpoint.getBinding().getURI(), new FooServiceInvoker(endpoint)); + + System.out.println("bindingType=" + ((FooBinding)endpoint.getBinding()).getBindingType()); + } + + public void stop() { + FooStash.removeService(endpoint.getBinding().getURI()); + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceInvoker.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceInvoker.java new file mode 100644 index 0000000000..bbadb9b6b0 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__ServiceInvoker.java @@ -0,0 +1,43 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo.runtime; + +import ${package}.invocation.Message; +import ${package}.runtime.RuntimeEndpoint; + +public class FooServiceInvoker { + + private RuntimeEndpoint wire; + + public FooServiceInvoker(RuntimeEndpoint wire) { + this.wire = wire; + } + + /** + * Send the request down the wire to invoke the service + */ + public Message invokeService(Message msg) { + return wire.invoke(msg); + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__Stash.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__Stash.java new file mode 100644 index 0000000000..7271c08a83 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/java/runtime/__bindingName__Stash.java @@ -0,0 +1,47 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 ${package}.binding.foo.runtime; + +import java.util.HashMap; +import java.util.Map; + +/** + * Simplistic static Map to share service endpoints with references + */ +public class FooStash { + + private static Map services = new HashMap(); + + public static void addService(String uri, FooServiceInvoker fooServiceInvoker) { + services.put(uri, fooServiceInvoker); + } + + public static FooServiceInvoker getService(String uri) { + return services.get(uri); + } + + public static void removeService(String uri) { + services.remove(uri); + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/__package__.__bindingName__BindingFactory b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/__package__.__bindingName__BindingFactory new file mode 100644 index 0000000000..5de0163ece --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/__package__.__bindingName__BindingFactory @@ -0,0 +1,20 @@ +# 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 model factory +org.apache.tuscany.sca.binding.foo.FooBindingFactory + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..94b3a7e68a --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,20 @@ +# 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 +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.foo,model=${package}.${bindingName}Binding,factory={package}.${bindingName}BindingFactory + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..2e1b0e53d7 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# 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. +# +binding-${bindingName}.xsd + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..4e0ecf48e9 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,20 @@ +# 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 binding extension +{package}.runtime.${bindingName}BindingProviderFactory;model={package}.${bindingName}Binding + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/binding-__bindingName__.xsd b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/binding-__bindingName__.xsd new file mode 100644 index 0000000000..9322aabd6d --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/main/resources/binding-__bindingName__.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldClient.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..de982cefc1 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldClient.java @@ -0,0 +1,36 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +import org.oasisopen.sca.annotation.Reference; + +public class HelloWorldClient implements HelloWorldService { + + @Reference + public HelloWorldService ref; + + public String sayHello(String name) { + return ref.sayHello(name); + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..521f6828ce --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,31 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + + +public class HelloWorldImpl implements HelloWorldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldService.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..eca0df1543 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/helloworld/HelloWorldService.java @@ -0,0 +1,31 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface HelloWorldService { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/test/FooBindingTestCase.java b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/test/FooBindingTestCase.java new file mode 100644 index 0000000000..e9c92648e4 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/java/test/FooBindingTestCase.java @@ -0,0 +1,57 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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 test; + +import helloworld.HelloWorldService; +import junit.framework.Assert; + +import ${package}.http.jetty.JettyServer; +import ${package}.node.Node; +import ${package}.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class FooBindingTestCase { + + private static Node node; + + @Test + public void testSayHello() { + HelloWorldService service = node.getService(HelloWorldService.class, "HelloWorldClient/HelloWorldService"); + Assert.assertEquals("Hello boo", service.sayHello("boo")); + } + + @BeforeClass + public static void init() throws Exception { + JettyServer.portDefault = 8085; + node = NodeFactory.newInstance().createNode("helloworld.composite").start(); + } + + @AfterClass + public static void destroy() throws Exception { + if (node != null) { + node.stop(); + } + } + +} diff --git a/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/resources/helloworld.composite b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/resources/helloworld.composite new file mode 100644 index 0000000000..4dc3150697 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/main/resources/archetype-resources/src/test/resources/helloworld.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/archetype.properties b/sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..c5919ec925 --- /dev/null +++ b/sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,6 @@ +#Sat Sep 04 08:10:22 BST 2010 +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +bindingName=Bar + diff --git a/sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/goal.txt b/sca-java-2.x/trunk/archetypes/binding/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3