From 3c7c4a749baafcf375f4785a7668d3a25c9063e3 Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:42:27 +0000 Subject: Moving 1.x trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835700 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/com/example/ExampleClient.java | 26 ++++++ .../main/java/com/example/ExampleClientImpl.java | 59 +++++++++++++ .../src/main/java/com/example/ExampleService.java | 30 +++++++ .../main/java/com/example/ExampleServiceImpl.java | 33 ++++++++ .../sca/itest/callablerefwsreturn/Alpha.java | 26 ++++++ .../sca/itest/callablerefwsreturn/AlphaImpl.java | 96 ++++++++++++++++++++++ .../sca/itest/callablerefwsreturn/Beta.java | 27 ++++++ .../sca/itest/callablerefwsreturn/BetaImpl.java | 46 +++++++++++ .../sca/itest/callablerefwsreturn/Gamma.java | 34 ++++++++ .../sca/itest/callablerefwsreturn/GammaImpl.java | 49 +++++++++++ .../CallableReferenceWsReturnTest.composite | 54 ++++++++++++ .../src/main/resources/example.composite | 40 +++++++++ 12 files changed, 520 insertions(+) create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/CallableReferenceWsReturnTest.composite create mode 100644 sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/example.composite (limited to 'sca-java-1.x/trunk/itest/callablereferences-ws/src/main') diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java new file mode 100644 index 0000000000..ecf1ac27e1 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java @@ -0,0 +1,26 @@ +/* + * 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 com.example; + +public interface ExampleClient { + + void runTest(); + + void sayHello(String name); +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java new file mode 100644 index 0000000000..c46087d865 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.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 com.example; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ExampleClient.class) +@Scope("COMPOSITE") +public class ExampleClientImpl implements ExampleClient { + + private ExampleService myService; + + @Context + protected ComponentContext context; + + @Reference + public void setMyService(ExampleService myService) { + this.myService = myService; + } + + public void runTest() { + ServiceReference ref = context.createSelfReference(ExampleClient.class); + ref.getService().sayHello("Jack"); + CallableReference result = myService.hello("Jill", ref); + if (result != null) { + ((CallableReference)result).getService().sayHello("John"); + } + result = myService.hello("Jane", null); + if (result != null) { + ((CallableReference)result).getService().sayHello("Jim"); + } + } + + public void sayHello(String name) { + System.out.println("Hello, client " + name + "!"); + } +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java new file mode 100644 index 0000000000..670c145cc3 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleService.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 com.example; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ExampleService { + + CallableReference hello(String name, ServiceReference ref); + +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java new file mode 100644 index 0000000000..eb4d647a22 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.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 com.example; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ServiceReference; + +public class ExampleServiceImpl implements ExampleService { + + public CallableReference hello(String name, ServiceReference ref) { + if (ref != null) { + ((ServiceReference)ref).getService().sayHello(name); + } + return (CallableReference)ref; + } + +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java new file mode 100644 index 0000000000..bb5e57397d --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java @@ -0,0 +1,26 @@ +/* + * 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 org.apache.tuscany.sca.itest.callablerefwsreturn; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Alpha { + boolean run(); +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java new file mode 100644 index 0000000000..6e5f1cedf9 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java @@ -0,0 +1,96 @@ +/* + * 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 org.apache.tuscany.sca.itest.callablerefwsreturn; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.Conversation; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(Alpha.class) +@Scope("COMPOSITE") +public class AlphaImpl implements Alpha { + @Reference + public Beta beta; + + @Context + protected ComponentContext componentContext; + + Object conversationId0 = null; + + public boolean run() { + CallableReference gammaRef = null; + try { + Object conversationId1 = null; + Object conversationId2 = null; + + // it is expected that this call returns a reference to Gamma that + // reuses the established Conversation + gammaRef = beta.getRef(); + + // no Conversation exists + Conversation con = gammaRef.getConversation(); + if (con == null) { + System.out.println("Alpha1: Conversation to gamma is null"); + } else { + System.out + .println("Alpha1: Conversation to gamma exists. conversationId=" + + con.getConversationID()); + conversationId1 = con.getConversationID(); + } + + // this call should reuse a Conversation, but as none exists it + // creates a new conversation + gammaRef.getService().doSomething(); + gammaRef.getService().doSomething(); + gammaRef.getService().doSomething(); + + con = gammaRef.getConversation(); + if (con == null) { + System.out.println("Alpha2: Conversation to gamma is null"); + } else { + System.out + .println("Alpha2: Conversation to gamma exists. conversationId=" + + con.getConversationID()); + conversationId2 = con.getConversationID(); + } + + boolean testPassed = conversationId1.equals(conversationId2); + + if (conversationId0 == null){ + conversationId0 = conversationId1; + return testPassed; + } else { + return testPassed && (!conversationId0.equals(conversationId1)); + } + + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + if (gammaRef != null) { + gammaRef.getService().stop(); + } + } + } + +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java new file mode 100644 index 0000000000..995e4fcf39 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.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 org.apache.tuscany.sca.itest.callablerefwsreturn; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Beta { + CallableReference getRef(); +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java new file mode 100644 index 0000000000..be72fd779e --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java @@ -0,0 +1,46 @@ +/* + * 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 org.apache.tuscany.sca.itest.callablerefwsreturn; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(Beta.class) +@Scope("COMPOSITE") +public class BetaImpl implements Beta { + @Context + protected ComponentContext componentContext; + + @Reference + public Gamma gamma; + + public CallableReference getRef() { + ServiceReference gammaRef = componentContext + .getServiceReference(Gamma.class, "gamma"); + Gamma g = gammaRef.getService(); + g.start(); + return gammaRef; + } + +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java new file mode 100644 index 0000000000..b73f26b573 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java @@ -0,0 +1,34 @@ +/* + * 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 org.apache.tuscany.sca.itest.callablerefwsreturn; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Conversational +public interface Gamma { + int start(); + + void doSomething(); + + @EndsConversation + void stop(); +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java new file mode 100644 index 0000000000..c3abc4c65d --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java @@ -0,0 +1,49 @@ +/* + * 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 org.apache.tuscany.sca.itest.callablerefwsreturn; + +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(Gamma.class) +@Scope("CONVERSATION") +public class GammaImpl implements Gamma { + @ConversationID + protected String conversationId; + + public GammaImpl() { + System.out.println("GammaImpl:GammaImpl(), conversationId=" + + conversationId); + } + + public int start() { + System.out.println("Gamma:start(), conversationId=" + conversationId); + return 1; + } + + public void doSomething() { + System.out.println("Gamma:doSomething(), conversationId=" + + conversationId); + } + + public void stop() { + System.out.println("Gamma:stop(), conversationId=" + conversationId); + } +} diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/CallableReferenceWsReturnTest.composite b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/CallableReferenceWsReturnTest.composite new file mode 100644 index 0000000000..3d782a0b84 --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/CallableReferenceWsReturnTest.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/example.composite b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/example.composite new file mode 100644 index 0000000000..ea0819a32e --- /dev/null +++ b/sca-java-1.x/trunk/itest/callablereferences-ws/src/main/resources/example.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3