diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java')
5 files changed, 197 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java new file mode 100644 index 0000000000..adc48e85a4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java @@ -0,0 +1,27 @@ +/* + * 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.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldCallback { + + public void getGreetingsCallback(String getGreetingsReturn); +} diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..f59c409f45 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java @@ -0,0 +1,40 @@ +/* + * 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.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This client program shows how to invoke a web service asynchronously with a callback + */ + +public class HelloWorldClient { + + public final static void main(String[] args) throws Exception { + + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + HelloWorldLocal helloWorldLocal = + compositeContext.locateService(HelloWorldLocal.class, "HelloWorldServiceComponent"); + helloWorldLocal.getGreetings("John"); + + // Sleep for 5 seconds to wait the callback to happen + Thread.sleep(5000); + } +} diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java new file mode 100644 index 0000000000..a5b9074af0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.apache.tuscany.api.annotation.DataType; +import org.osoa.sca.annotations.Service; + +import commonj.sdo.DataObject; + +@Service +public interface HelloWorldLocal { + + public String getGreetings(String name); + @DataType(name="commonj.sdo.DataObject") + public String getGreetings1(DataObject name); + +} diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..fc64f62a7b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,38 @@ +/* + * 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.apache.tuscany.api.annotation.DataType; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +import commonj.sdo.DataObject; + +@Remotable +@Service +@Callback(HelloWorldCallback.class) +public interface HelloWorldService { + + public String getGreetings(String name); + @DataType(name="commonj.sdo.DataObject") + public String getGreetings1(DataObject name); + + public void getGreetingsWithCallback(String name); +} diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..af5a21f5a1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java @@ -0,0 +1,59 @@ +/* + * 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.osoa.sca.annotations.Scope; + +import commonj.sdo.DataObject; + + +/** + * This client program shows how to create an SCA runtime, start it, + * locate the HelloWorld service and invoke it. + */ + + +@Scope("MODULE") +public class HelloWorldServiceComponent implements HelloWorldLocal { + + HelloWorldService helloWorldService; + + public String getGreetings(String name) { + + return helloWorldService.getGreetings(name); + } + + public HelloWorldService getHelloWorldService() { + return helloWorldService; + } + + public void setHelloWorldService(HelloWorldService helloWorldService) { + this.helloWorldService = helloWorldService; + } + + public String getGreetings1(DataObject name) { + return helloWorldService.getGreetings1(name); + } + + public void getGreetingsCallback(String getGreetingsReturn) { + System.out.println("Callback: " + getGreetingsReturn); + } + + +} |