diff options
Diffstat (limited to 'branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src')
8 files changed, 319 insertions, 0 deletions
diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java new file mode 100644 index 0000000000..1aa3dce320 --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package greeter; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +public class GreeterClient { + + public final static void main(String[] args) throws Exception { + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + GreeterLocal greeterLocal = + compositeContext.locateService(GreeterLocal.class, "GreeterServiceComponent"); + greeterLocal.greet("John"); + System.out.println("Sleeping for 5 seconds ..."); + Thread.sleep(5000); + System.out.println("Done ..."); + } +} diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java new file mode 100644 index 0000000000..39ca24aadd --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java @@ -0,0 +1,37 @@ +/* + * 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 greeter; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +@Scope("MODULE") +public class GreeterImpl implements GreeterLocal { + + private GreeterService greeterService; + + @Reference + public void setGreeterService(GreeterService greeterService) { + this.greeterService = greeterService; + } + + public void greet(String name) { + this.greeterService.greet(name); + } +} diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java new file mode 100644 index 0000000000..7cf650f73b --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java @@ -0,0 +1,24 @@ +/* + * 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 greeter; + +public interface GreeterLocal { + public void greet(String name); +} diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java new file mode 100644 index 0000000000..57279b8a7c --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java @@ -0,0 +1,30 @@ +/* + * 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 greeter; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface GreeterService { + @OneWay + public void greet(String name); +} diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..c450e10408 --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" name="greeterws">
+
+ <component name="GreeterServiceComponent">
+ <implementation.java class="greeter.GreeterImpl" />
+ </component>
+
+ <component name="GreeterServiceComponent">
+ <implementation.java class="greeter.GreeterImpl" />
+ <reference name="greeterService">GreeterService</reference>
+ </component>
+
+ <reference name="GreeterService">
+ <!--
+ <interface.java interface="helloworld.HelloWorldService"
+ callbackInterface="helloworld.HelloWorldCallback"/>
+ -->
+
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" interface="http://greeter#wsdl.interface(Greeter)"
+ wsdli:wsdlLocation="http://greeter wsdl/greeter.wsdl" />
+
+ <binding.ws endpoint="http://greeter#wsdl.endpoint(GreeterService/GreeterSoapPort)" location="wsdl/greeter.wsdl" />
+ </reference>
+</composite>
diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl new file mode 100644 index 0000000000..f96b24bae6 --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://greeter" xmlns:tns="http://greeter" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="greeter">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://greeter" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="greet">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="greetRequest">
+ <wsdl:part element="tns:greet" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="greet">
+ <wsdl:input message="tns:greetRequest" name="greetRequest" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="GreeterSoapBinding" type="tns:Greeter">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="greet">
+ <wsdlsoap:operation soapAction="greet" />
+ <wsdl:input name="greetRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="GreeterService">
+ <wsdl:port binding="tns:GreeterSoapBinding" name="GreeterSoapPort">
+ <wsdlsoap:address
+ location="http://localhost:8080/sample-greeterws-oneway-1.0-incubator-M2/services/GreeterWebService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java new file mode 100644 index 0000000000..1f017744de --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java @@ -0,0 +1,58 @@ +/* + * 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 greeter; + +import org.apache.tuscany.test.SCATestCase; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +public class GreeterWSOneWayClient extends SCATestCase { + + private GreeterLocal greeterLocal; + + @Override + protected void setUp() throws Exception { + try { + setApplicationSCDL(GreeterService.class, "META-INF/sca/default.scdl"); + ClassLoader classLoader = getClass().getClassLoader(); + addExtension("test.extensions", classLoader.getResource("META-INF/tuscany/test-extensions.scdl")); + + super.setUp(); + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + greeterLocal = compositeContext.locateService(GreeterLocal.class, "GreeterServiceComponent"); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + public void testWSClient() { + try { + greeterLocal.greet("John"); + + System.out.println("Sleeping ..."); + Thread.sleep(5000); + + System.out.println("Done ..."); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } +} diff --git a/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl new file mode 100644 index 0000000000..ec3643cf00 --- /dev/null +++ b/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="test.extensions">
+
+ <include name="org.apache.tuscany.databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl"/>
+ <include name="org.apache.tuscany.databinding.sdo" scdlResource="META-INF/sca/databinding.sdo.scdl"/>
+ <include name="org.apache.tuscany.idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl"/>
+ <include name="org.apache.tuscany.binding.axis2" scdlResource="META-INF/sca/binding.axis2.scdl"/>
+
+</composite>
\ No newline at end of file |