From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/itest/Record.java | 29 ++ .../org/apache/tuscany/sca/itest/TestResult.java | 36 +++ .../tuscany/sca/itest/conversational/AService.java | 56 ++++ .../tuscany/sca/itest/conversational/Alpha.java | 32 ++ .../tuscany/sca/itest/conversational/BService.java | 42 +++ .../tuscany/sca/itest/conversational/Beta.java | 31 ++ .../tuscany/sca/itest/conversational/CService.java | 42 +++ .../sca/itest/conversational/Constants.java | 25 ++ .../conversational/ConversationIdService.java | 29 ++ .../conversational/ConversationalCallback.java | 50 ++++ .../itest/conversational/ConversationalClient.java | 50 ++++ .../ConversationalReferenceClient.java | 36 +++ .../conversational/ConversationalService.java | 62 ++++ ...ersationalServiceNonConversationalCallback.java | 62 ++++ .../tuscany/sca/itest/conversational/DService.java | 46 +++ .../tuscany/sca/itest/conversational/Gamma.java | 41 +++ .../conversational/NonConversationalCallback.java | 46 +++ .../itest/conversational/impl/AServiceImpl.java | 111 +++++++ .../sca/itest/conversational/impl/AlphaImpl.java | 70 +++++ .../itest/conversational/impl/BServiceImpl.java | 73 +++++ .../sca/itest/conversational/impl/BetaImpl.java | 51 ++++ .../itest/conversational/impl/CServiceImpl.java | 85 ++++++ .../impl/ConversationAgeComponentImpl.java | 75 +++++ .../impl/ConversationIdComponentImpl.java | 48 +++ .../impl/ConversationMaxIdleComponentImpl.java | 75 +++++ .../impl/ConversationalClientStatefulImpl.java | 321 +++++++++++++++++++++ ...lientStatefulNonConversationalCallbackImpl.java | 310 ++++++++++++++++++++ .../impl/ConversationalClientStatelessImpl.java | 317 ++++++++++++++++++++ .../impl/ConversationalReferenceClientImpl.java | 43 +++ .../impl/ConversationalServiceRequestImpl.java | 123 ++++++++ .../impl/ConversationalServiceStatefulImpl.java | 117 ++++++++ ...rviceStatefulNonConversationalCallbackImpl.java | 117 ++++++++ .../impl/ConversationalServiceStatelessImpl.java | 123 ++++++++ .../ConversationalServiceStatelessScopeImpl.java | 93 ++++++ .../itest/conversational/impl/DServiceImpl.java | 71 +++++ .../sca/itest/conversational/impl/GammaImpl.java | 66 +++++ .../src/main/resources/ConversationAge.composite | 31 ++ .../main/resources/ConversationUniqueId.composite | 53 ++++ .../src/main/resources/conversationId.composite | 27 ++ .../main/resources/conversationLifetime.composite | 33 +++ .../src/main/resources/conversational.composite | 99 +++++++ 41 files changed, 3247 insertions(+) create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationAge.composite create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationUniqueId.composite create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationId.composite create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationLifetime.composite create mode 100644 sandbox/axis2-1.4/itest/conversations/src/main/resources/conversational.composite (limited to 'sandbox/axis2-1.4/itest/conversations/src/main') diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.java new file mode 100644 index 0000000000..a3b83dfc14 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.java @@ -0,0 +1,29 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * @version $Rev$ $Date$ + */ +public class Record implements Serializable { + public String id; + public String conversationId; +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.java new file mode 100644 index 0000000000..8e98b9cbd4 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.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 org.apache.tuscany.sca.itest; + +import java.util.Hashtable; + +/** + * @version $Rev$ $Date$ + */ +public class TestResult { + public static Hashtable results = new Hashtable(); + private static int completed = 0; + public static synchronized void updateCompleted() { + ++completed; + } + + public static synchronized int getCompleted() { + return completed; + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java new file mode 100644 index 0000000000..e7583c339a --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java @@ -0,0 +1,56 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Conversational; + +/** + * Simple conversational Service that uses another Conversational Service + */ +@Conversational +public interface AService { + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + String getState(); + + /** + * Returns the state for the other service that this service is using + * + * @return The state for the other service that this service is using + */ + String getStateOnB(); + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + void setState(String aState); + + /** + * Sets the state for the other service that this service is using + * + * @param aState The state for the other service that this service is using + */ + void setStateOnB(String aState); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.java new file mode 100644 index 0000000000..bc4a5fc571 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.java @@ -0,0 +1,32 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@Remotable +public interface Alpha { + @OneWay + void run(int param); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.java new file mode 100644 index 0000000000..77d7f4c007 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.java @@ -0,0 +1,42 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Conversational; + +/** + * Simple conversational Service + */ +@Conversational +public interface BService { + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + String getState(); + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + void setState(String aState); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java new file mode 100644 index 0000000000..e422938b27 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java @@ -0,0 +1,31 @@ +/* + * 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.conversational; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@Remotable +public interface Beta { + CallableReference getRef(int param); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java new file mode 100644 index 0000000000..a6dbf56797 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java @@ -0,0 +1,42 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Conversational; + +/** + * Simple conversational Service that uses another Conversational Service + */ +@Conversational +public interface CService { + + String getState(); + + void setState(String aState); + + Object getConversationID(); + + Object getConversationObjectConversationId(); + + void setConversationID(String theID); + + void endConversation(); + + void endConversationViaAnnotatedMethod(); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java new file mode 100644 index 0000000000..3f04e9f09e --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java @@ -0,0 +1,25 @@ +/* + * 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.conversational; + +public interface Constants { + + String A_INITIAL_VALUE = "Initial Value of A"; + String B_INITIAL_VALUE = "Initial Value of B"; +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java new file mode 100644 index 0000000000..53dadc3dc7 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java @@ -0,0 +1,29 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Conversational; + +@Conversational +public interface ConversationIdService { + + String getCIDField(); + String getCIDSetter(); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java new file mode 100644 index 0000000000..8cad88d2f4 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java @@ -0,0 +1,50 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The callback interface used when testing conversational callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +@Conversational +public interface ConversationalCallback { + + public void init(); + + public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws Exception; + + @EndsConversation + public String endConversation(); + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java new file mode 100644 index 0000000000..2532346349 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java @@ -0,0 +1,50 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Remotable; + +/** + * The client for the conversational itest. Is implemented by clients + * offering both stateless and stateful callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Remotable +public interface ConversationalClient { + + public int runConversationFromInjectedReference(); + public int runConversationFromInjectedReference2(); + public int runConversationFromServiceReference(); + public int runConversationWithUserDefinedConversationId(); + public String runConversationCheckUserDefinedConversationId(); + public int runConversationCheckingScope(); + public int runConversationWithCallback(); + public int runConversationHavingPassedReference(); + public String runConversationBusinessException(); + public String runConversationBusinessExceptionCallback(); + public int runConversationCallingEndedConversation(); + public int runConversationCallingEndedConversationCallback(); + public String runConversationCallingEndedConversationCheckConversationId(); + public String runConversationCallingEndedConversationCallbackCheckConversationId(); + public int runConversationAgeTimeout(); + public int runConversationIdleTimeout(); + public int runConversationPrincipleError(); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java new file mode 100644 index 0000000000..8f008fa711 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.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 org.apache.tuscany.sca.itest.conversational; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +/** + * The client that calls into an existing conversation by accepting + * a reference to that conversation + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Remotable +public interface ConversationalReferenceClient { + + public void incrementCount(CallableReference conversationalService); + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java new file mode 100644 index 0000000000..546382cfd1 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java @@ -0,0 +1,62 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The service interface used when testing conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +@Conversational +@Callback(ConversationalCallback.class) +public interface ConversationalService { + + public void init(); + + public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws Exception; + + public void initializeCountCallback(int count); + + public void incrementCountCallback(); + + public int retrieveCountCallback(); + + public void businessExceptionCallback() throws Exception; + + @EndsConversation + public String endConversation(); + + public String endConversationCallback(); + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java new file mode 100644 index 0000000000..f1a21cc18f --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java @@ -0,0 +1,62 @@ +/* + * 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.conversational; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The service interface used when testing conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +@Conversational +@Callback(NonConversationalCallback.class) +public interface ConversationalServiceNonConversationalCallback { + + public void init(); + + public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws Exception; + + public void initializeCountCallback(int count); + + public void incrementCountCallback(); + + public int retrieveCountCallback(); + + public void businessExceptionCallback() throws Exception; + + @EndsConversation + public String endConversation(); + + public String endConversationCallback(); + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java new file mode 100644 index 0000000000..74afbfb763 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.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.conversational; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; + +/** + * Simple conversational Service + */ +@Conversational +public interface DService { + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + String getState(); + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + void setState(String aState); + + @EndsConversation + void endConversationViaAnnotatedMethod(); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java new file mode 100644 index 0000000000..5f97b16088 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java @@ -0,0 +1,41 @@ +/* + * 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.conversational; + +import org.apache.tuscany.sca.itest.Record; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@Remotable +@Conversational +public interface Gamma { + void start(int param); + + boolean hasNext(); + + Record next(); + + @EndsConversation + void stop(); +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java new file mode 100644 index 0000000000..3ce3e3ada7 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.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.conversational; + +import org.osoa.sca.annotations.Remotable; + + +/** + * The callback interface used when testing conversational callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +public interface NonConversationalCallback { + + public void init(); + + public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws Exception; + + public String endConversation(); + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java new file mode 100644 index 0000000000..95c9c7ae6e --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java @@ -0,0 +1,111 @@ +/* + * 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.conversational.impl; + +import java.lang.reflect.Proxy; +import org.apache.tuscany.sca.core.invocation.JDKInvocationHandler; + +import org.apache.tuscany.sca.itest.conversational.AService; +import org.apache.tuscany.sca.itest.conversational.BService; +import org.apache.tuscany.sca.itest.conversational.Constants; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Simple conversational Service that uses another Conversational Service + */ +@Service(AService.class) +@Scope("CONVERSATION") +public class AServiceImpl implements AService { + + /** + * The state + */ + private String state = Constants.A_INITIAL_VALUE; + + /** + * The reference to the other service + */ + private BService b; + + /** + * Constructor + * + */ + public AServiceImpl() { + System.out.println("---> AServiceImpl constructor for " + this); + } + + /** + * Inject the reference to the other service + * @param aB The other service. + */ + @Reference(name="b") + public void setB(BService aB) { + System.out.println("---> Setting reference to B on " + this + " to " + aB); + this.b = aB; + } + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + public String getState() { + return state; + } + + /** + * Returns the state for the other service that this service is using + * + * @return The state for the other service that this service is using + */ + public String getStateOnB() { + return b.getState(); + } + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + public void setState(String aState) { + this.state = aState; + } + + /** + * Sets the state for the other service that this service is using + * + * @param aState The state for the other service that this service is using + */ + public void setStateOnB(String aState) { + b.setState(aState); + } + + /** + * Sets the conversation ID for this service + * @param id The Conversation ID + */ + @ConversationID + public void setConversationID(String id) { + System.out.println("Conversation ID for " + this + " is set to " + id); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java new file mode 100644 index 0000000000..a5f37f7a52 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java @@ -0,0 +1,70 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.Record; +import org.apache.tuscany.sca.itest.TestResult; +import org.apache.tuscany.sca.itest.conversational.Alpha; +import org.apache.tuscany.sca.itest.conversational.Beta; +import org.apache.tuscany.sca.itest.conversational.Gamma; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ + +@Service(Alpha.class) +@Scope("COMPOSITE") +public class AlphaImpl implements Alpha { + @Reference + public Beta beta; + + @Context + protected ComponentContext componentContext; + + public void run(int param) { + CallableReference gammaRef = null; + boolean testPassed = true; + try { + gammaRef = beta.getRef(param); + while (gammaRef.getService().hasNext()) { + Record record = gammaRef.getService().next(); + if (!record.conversationId.equals(gammaRef.getConversation().getConversationID())) { + // Record returned is not from this conversation. + testPassed = false; + } + } + } catch (Exception ex) { + testPassed = false; + ex.printStackTrace(); + } finally { + TestResult.updateCompleted(); + if (gammaRef != null) { + TestResult.results.put(gammaRef.getConversation() + .getConversationID(), testPassed); + gammaRef.getService().stop(); + } + } + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java new file mode 100644 index 0000000000..c1e27641ef --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java @@ -0,0 +1,73 @@ +/* + * 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.conversational.impl; + + +import org.apache.tuscany.sca.itest.conversational.BService; +import org.apache.tuscany.sca.itest.conversational.Constants; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Simple conversational Service + */ +@Service(BService.class) +@Scope("CONVERSATION") +public class BServiceImpl implements BService { + + /** + * The state for this service + */ + private String state = Constants.B_INITIAL_VALUE; + + /** + * Constructor + */ + public BServiceImpl() { + System.out.println("---> BServiceImpl constructor for " + this); + } + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + public String getState() { + return state; + } + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + public void setState(String aState) { + this.state = aState; + } + + /** + * Sets the conversation ID for this service + * @param id The Conversation ID + */ + @ConversationID + public void setConversationID(String id) { + System.out.println("Conversation ID for " + this + " is set to " + id); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.java new file mode 100644 index 0000000000..900b8f743f --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.java @@ -0,0 +1,51 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.Beta; +import org.apache.tuscany.sca.itest.conversational.Gamma; +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; + +/** + * @version $Rev$ $Date$ + */ + +@Service(Beta.class) +@Scope("COMPOSITE") +public class BetaImpl implements Beta { + @Context + protected ComponentContext componentContext; + + @Reference + public Gamma gamma; + + public CallableReference getRef(int param) { + ServiceReference gammaRef = componentContext + .getServiceReference(Gamma.class, "gamma"); + Gamma g = gammaRef.getService(); + g.start(param); + return gammaRef; + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java new file mode 100644 index 0000000000..b21f956bd9 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java @@ -0,0 +1,85 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.CService; +import org.apache.tuscany.sca.itest.conversational.DService; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Simple conversational Service that uses another Conversational Service + */ +@Service(CService.class) +@Scope("CONVERSATION") +public class CServiceImpl implements CService { + + private ServiceReference dServiceRef; + + @Reference(name = "d") + public void setD(ServiceReference servRef) { + this.dServiceRef = servRef; + } + + public String getState() { + return dServiceRef.getService().getState(); + } + + public void setState(String aState) { + dServiceRef.getService().setState(aState); + } + + + /* + * When the coversationId is set manually the client may access the + * conversation id that will be used by the reference using + * ServiceReference.getConversationId() + */ + public Object getConversationID() { + return dServiceRef.getConversationID(); + } + + /* + * Whether the conversation ID is chosen by the client or is generated by + * the system, the client may access the conversation ID by calling + * Conversation.getConversationID(). + */ + public Object getConversationObjectConversationId() { + // TODO Auto-generated method stub + if (dServiceRef.getConversation() != null){ + return dServiceRef.getConversation().getConversationID(); + } else { + return null; + } + } + + public void endConversation() { + dServiceRef.getConversation().end(); + } + + public void endConversationViaAnnotatedMethod() { + dServiceRef.getService().endConversationViaAnnotatedMethod(); + } + + public void setConversationID(String theID) { + dServiceRef.setConversationID(theID); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java new file mode 100644 index 0000000000..9deef312ac --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java @@ -0,0 +1,75 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="1 seconds") +public class ConversationAgeComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws Exception { + } + + public void businessExceptionCallback() throws Exception { + } + + public void destroy() { + } + + public String endConversation() { + return null; + } + + public String endConversationCallback() { + return null; + } + + public void incrementCount() { + } + + public void incrementCountCallback() { + } + + public void init() { + } + + public void initializeCount(int count) { + this.count = count; + } + + public void initializeCountCallback(int count) { + } + + public int retrieveCount() { + return count; + } + + public int retrieveCountCallback() { + return 0; + } + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java new file mode 100644 index 0000000000..cffa76186a --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java @@ -0,0 +1,48 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationIdService; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationIdService.class) +@Scope("CONVERSATION") +public class ConversationIdComponentImpl implements ConversationIdService { + + @ConversationID + public String cid; + + private String setterCid; + + public String getCIDField() { + return cid; + } + public String getCIDSetter() { + return setterCid; + } + + + @ConversationID + public void setCID(String cid) { + this.setterCid = cid; + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java new file mode 100644 index 0000000000..1272c7ab7f --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java @@ -0,0 +1,75 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="1 seconds") +public class ConversationMaxIdleComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws Exception { + } + + public void businessExceptionCallback() throws Exception { + } + + public void destroy() { + } + + public String endConversation() { + return null; + } + + public String endConversationCallback() { + return null; + } + + public void incrementCount() { + } + + public void incrementCountCallback() { + } + + public void init() { + } + + public void initializeCount(int count) { + this.count = count; + } + + public void initializeCountCallback(int count) { + } + + public int retrieveCount() { + return count; + } + + public int retrieveCountCallback() { + return 0; + } + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java new file mode 100644 index 0000000000..847b038881 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java @@ -0,0 +1,321 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * The client for the conversational itest which presents a stateful + * callback interface + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalClient.class}) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="10 minutes", + maxIdleTime="5 minutes", + singlePrincipal=false) +public class ConversationalClientStatefulImpl implements ConversationalClient, ConversationalCallback { + + @Context + protected ComponentContext componentContext; + + @Reference + protected ConversationalService conversationalService; + + @Reference + protected ConversationalService conversationalService2; + + @Reference + protected ConversationalReferenceClient conversationalReferenceClient; + + private int clientCount = 0; + private int callbackCount = 0; + + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + // From ConversationalClient + public int runConversationFromInjectedReference(){ + calls.append("runConversationFromInjectedReference,"); + conversationalService.initializeCount(1); + conversationalService.incrementCount(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromInjectedReference2(){ + calls.append("runConversationFromInjectedReference2,"); + + conversationalService2.initializeCount(1); + conversationalService2.incrementCount(); + + // stick in a call to the first reference to + // make sure the two references don't clash + conversationalService.initializeCount(1); + + clientCount = conversationalService2.retrieveCount(); + conversationalService2.endConversation(); + + // end the conversation through the first reference + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromServiceReference(){ + calls.append("runConversationFromServiceReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public int runConversationWithUserDefinedConversationId(){ + calls.append("runConversationWithUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation1"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationCheckUserDefinedConversationId(){ + calls.append("runConversationCheckUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation2"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + + String clientConversationId = serviceReference.getConversationID().toString(); + String serverConversationId = callableReference.endConversation(); + + if (clientConversationId.equals("MyConversation2") && + serverConversationId.equals("MyConversation2") ) { + return clientConversationId; + } else { + return "client = " + clientConversationId + + "server = " + serverConversationId; + } + + } + public int runConversationCheckingScope(){ + calls.append("runConversationCheckingScope,"); + // run a conversation + return runConversationFromInjectedReference(); + + // test will then use a static method to find out how many times + // init/destroy were called + } + public int runConversationWithCallback(){ + calls.append("runConversationWithCallback,"); + callbackCount = 2; + conversationalService.initializeCountCallback(1); + conversationalService.incrementCountCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + + return clientCount; + } + public int runConversationHavingPassedReference(){ + calls.append("runConversationHavingPassedReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + conversationalReferenceClient.incrementCount(serviceReference); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationBusinessException(){ + calls.append("runConversationbusinessException,"); + try { + conversationalService.initializeCount(1); + conversationalService.businessException(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public String runConversationBusinessExceptionCallback(){ + calls.append("runConversationbusinessExceptionCallback,"); + try { + conversationalService.initializeCountCallback(1); + conversationalService.businessExceptionCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public int runConversationCallingEndedConversation(){ + calls.append("runConversationCallingEndedConversation,"); + conversationalService.initializeCount(1); + conversationalService.endConversation(); + return conversationalService.retrieveCount(); + } + + public int runConversationCallingEndedConversationCallback(){ + calls.append("runConversationCallingEndedConversationCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.endConversationCallback(); + return conversationalService.retrieveCountCallback(); + } + + public String runConversationCallingEndedConversationCheckConversationId(){ + calls.append("runConversationCallingEndedConversationCheckConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation3"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + if (serviceReference.getConversation() ==null ) { + return null; + } else { + return serviceReference.getConversation().getConversationID().toString(); + } + } + + public String runConversationCallingEndedConversationCallbackCheckConversationId(){ + calls.append("runConversationCallingEndedConversationCallbackCheckConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation3"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversationCallback(); + + if (serviceReference.getConversation() ==null ) { + return null; + } else { + return serviceReference.getConversation().getConversationID().toString(); + } + } + + public int runConversationAgeTimeout(){ + calls.append("runConversationAgeTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationIdleTimeout(){ + calls.append("runConversationIdleTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationPrincipleError(){ + calls.append("runConversationPrincipleError,"); + // TODO - when policy framework is done + return clientCount; + } + + + // From ConversationalCallback + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + callbackCount += count; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + callbackCount++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return callbackCount; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + callbackCount = 0; + return null; + } + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java new file mode 100644 index 0000000000..b77e4c0194 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java @@ -0,0 +1,310 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.apache.tuscany.sca.itest.conversational.NonConversationalCallback; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * The client for the conversational itest which presents a stateful + * callback interface + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalClient.class}) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="10 minutes", + maxIdleTime="5 minutes", + singlePrincipal=false) +public class ConversationalClientStatefulNonConversationalCallbackImpl implements ConversationalClient, NonConversationalCallback { + + @Context + protected ComponentContext componentContext; + + @Reference + protected ConversationalService conversationalService; + + @Reference + protected ConversationalService conversationalService2; + + @Reference + protected ConversationalReferenceClient conversationalReferenceClient; + + private int clientCount = 0; + private int callbackCount = 0; + + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + // From ConversationalClient + public int runConversationFromInjectedReference(){ + calls.append("runConversationFromInjectedReference,"); + conversationalService.initializeCount(1); + conversationalService.incrementCount(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromInjectedReference2(){ + calls.append("runConversationFromInjectedReference2,"); + + conversationalService2.initializeCount(1); + conversationalService2.incrementCount(); + + // stick in a call to the first reference to + // make sure the two references don't clash + conversationalService.initializeCount(1); + + clientCount = conversationalService2.retrieveCount(); + conversationalService2.endConversation(); + + // end the conversation through the first reference + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromServiceReference(){ + calls.append("runConversationFromServiceReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public int runConversationWithUserDefinedConversationId(){ + calls.append("runConversationWithUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation1"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationCheckUserDefinedConversationId(){ + calls.append("runConversationCheckUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation2"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + return callableReference.endConversation(); + + } + public int runConversationCheckingScope(){ + calls.append("runConversationCheckingScope,"); + // run a conversation + return runConversationFromInjectedReference(); + + // test will then use a static method to find out how many times + // init/destroy were called + } + public int runConversationWithCallback(){ + calls.append("runConversationWithCallback,"); + callbackCount = 2; + conversationalService.initializeCountCallback(1); + conversationalService.incrementCountCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + + return clientCount; + } + public int runConversationHavingPassedReference(){ + calls.append("runConversationHavingPassedReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + conversationalReferenceClient.incrementCount(serviceReference); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationBusinessException(){ + calls.append("runConversationbusinessException,"); + try { + conversationalService.initializeCount(1); + conversationalService.businessException(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public String runConversationBusinessExceptionCallback(){ + calls.append("runConversationbusinessExceptionCallback,"); + try { + conversationalService.initializeCountCallback(1); + conversationalService.businessExceptionCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public String runConversationCallingEndedConversationCheckConversationId(){ + calls.append("runConversationCallingEndedConversationCheckConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation3"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + if (serviceReference.getConversation() ==null ) { + return null; + } else { + return serviceReference.getConversation().getConversationID().toString(); + } + } + + public String runConversationCallingEndedConversationCallbackCheckConversationId(){ + calls.append("runConversationCallingEndedConversationCallbackCheckConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation3"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversationCallback(); + + if (serviceReference.getConversation() ==null ) { + return null; + } else { + return serviceReference.getConversation().getConversationID().toString(); + } + } + + public int runConversationCallingEndedConversation(){ + calls.append("runConversationCallingEndedConversation,"); + conversationalService.initializeCount(1); + conversationalService.endConversation(); + return conversationalService.retrieveCount(); + } + + public int runConversationCallingEndedConversationCallback(){ + calls.append("runConversationCallingEndedConversationCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.endConversationCallback(); + return conversationalService.retrieveCountCallback(); + } + + public int runConversationAgeTimeout(){ + calls.append("runConversationAgeTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationIdleTimeout(){ + calls.append("runConversationIdleTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationPrincipleError(){ + calls.append("runConversationPrincipleError,"); + // TODO - when policy framework is done + return clientCount; + } + + + // From ConversationalCallback + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + callbackCount += count; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + callbackCount++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return callbackCount; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + return null; + } + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java new file mode 100644 index 0000000000..5b3906fc2c --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java @@ -0,0 +1,317 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * The client for the conversational itest which presents a stateful + * callback interface + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalClient.class}) +public class ConversationalClientStatelessImpl implements ConversationalClient, ConversationalCallback { + + @Context + protected ComponentContext componentContext; + + @Reference + protected ConversationalService conversationalService; + + @Reference + protected ConversationalService conversationalService2; + + @Reference + protected ConversationalReferenceClient conversationalReferenceClient; + + private int clientCount = 0; + private int callbackCount = 0; + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + // From ConversationalClient + public int runConversationFromInjectedReference(){ + calls.append("runConversationFromInjectedReference,"); + conversationalService.initializeCount(1); + conversationalService.incrementCount(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromInjectedReference2(){ + calls.append("runConversationFromInjectedReference2,"); + + // now test the second reference + conversationalService2.initializeCount(1); + conversationalService2.incrementCount(); + + // stick in a call to the first reference to + // make sure the two references don't clash + conversationalService.initializeCount(1); + + clientCount = conversationalService2.retrieveCount(); + conversationalService2.endConversation(); + + // end the conversation through the first reference + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromServiceReference(){ + calls.append("runConversationFromServiceReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public int runConversationWithUserDefinedConversationId(){ + calls.append("runConversationWithUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation1"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + // serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationCheckUserDefinedConversationId(){ + calls.append("runConversationCheckUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation2"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + + String clientConversationId = serviceReference.getConversationID().toString(); + String serverConfersationId = callableReference.endConversation(); + + if (clientConversationId.equals("MyConversation2") && + serverConfersationId.equals("MyConversation2") ) { + return clientConversationId; + } else { + return "client = " + clientConversationId + + "server = " + serverConfersationId; + } + } + public int runConversationCheckingScope(){ + calls.append("runConversationCheckingScope,"); + // run a conversation + return runConversationFromInjectedReference(); + + // test will then use a static method to find out how many times + // init/destroy were called + } + public int runConversationWithCallback(){ + calls.append("runConversationWithCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.incrementCountCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + + return clientCount; + } + + public int runConversationHavingPassedReference(){ + calls.append("runConversationHavingPassedReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + conversationalReferenceClient.incrementCount(serviceReference); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + + public String runConversationBusinessException(){ + calls.append("runConversationbusinessException,"); + try { + conversationalService.initializeCount(1); + conversationalService.businessException(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public String runConversationBusinessExceptionCallback(){ + calls.append("runConversationbusinessExceptionCallback,"); + try { + conversationalService.initializeCountCallback(1); + conversationalService.businessExceptionCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public int runConversationCallingEndedConversation(){ + calls.append("runConversationCallingEndedConversation,"); + conversationalService.initializeCount(1); + conversationalService.endConversation(); + return conversationalService.retrieveCount(); + } + + public int runConversationCallingEndedConversationCallback(){ + calls.append("runConversationCallingEndedConversationCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.endConversationCallback(); + return conversationalService.retrieveCountCallback(); + } + + public String runConversationCallingEndedConversationCheckConversationId(){ + calls.append("runConversationCallingEndedConversationCheckConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation3"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + if (serviceReference.getConversation() ==null ) { + return null; + } else { + return serviceReference.getConversation().getConversationID().toString(); + } + } + + public String runConversationCallingEndedConversationCallbackCheckConversationId(){ + calls.append("runConversationCallingEndedConversationCallbackCheckConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation3"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversationCallback(); + + if (serviceReference.getConversation() ==null ) { + return null; + } else { + return serviceReference.getConversation().getConversationID().toString(); + } + } + + public int runConversationAgeTimeout(){ + calls.append("runConversationAgeTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationIdleTimeout(){ + calls.append("runConversationIdleTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationPrincipleError(){ + calls.append("runConversationPrincipleError,"); + // TODO - when policy framework is done + return clientCount; + } + + + // From ConversationalCallback + @Init + public void init(){ + calls.append("init,"); + + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + callbackCount = 0; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + callbackCount++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return callbackCount; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + callbackCount = 0; + return null; + } + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java new file mode 100644 index 0000000000..8fe7c5b6ba --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java @@ -0,0 +1,43 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Service; + +/** + * A client component that accepts a reference to an ongoing conversation + * and takes part in that conversation + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalReferenceClient.class}) +public class ConversationalReferenceClientImpl implements ConversationalReferenceClient{ + + public void incrementCount(CallableReference conversationalService){ + ConversationalService callableReference = conversationalService.getService(); + + callableReference.incrementCount(); + } + + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java new file mode 100644 index 0000000000..9a25f0f59a --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java @@ -0,0 +1,123 @@ +/* + * 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.conversational.impl; + +import java.util.HashMap; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * The service used when testing stateful conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Service(ConversationalService.class) +@Scope("REQUEST") +public class ConversationalServiceRequestImpl implements ConversationalService { + + @ConversationID + protected String conversationId; + + @Callback + protected ConversationalCallback conversationalCallback; + + // static area in which to hold conversational data + private static HashMap conversationalState = new HashMap(); + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + Integer conversationalCount = new Integer(count); + conversationalState.put(conversationId, conversationalCount); + } + + public void incrementCount(){ + calls.append("incrementCount,"); + Integer conversationalCount = conversationalState.get(conversationId); + conversationalCount++; + conversationalState.put(conversationId, conversationalCount); + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + Integer count = conversationalState.get(conversationId); + if (count != null){ + return count.intValue(); + } else { + return -999; + } + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void initializeCountCallback(int count){ + calls.append("initializeCountCallback,"); + initializeCount(count); + conversationalCallback.initializeCount(count); + } + + public void incrementCountCallback(){ + calls.append("incrementCountCallback,"); + incrementCount(); + conversationalCallback.incrementCount(); + } + + public int retrieveCountCallback(){ + calls.append("retrieveCountCallback,"); + return conversationalCallback.retrieveCount(); + } + + public void businessExceptionCallback() throws Exception { + calls.append("businessExceptionCallback,"); + conversationalCallback.businessException(); + } + + public String endConversation(){ + calls.append("endConversation,"); + conversationalState.remove(conversationId); + return conversationId; + } + + public String endConversationCallback(){ + calls.append("endConversationCallback,"); + return conversationalCallback.endConversation(); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java new file mode 100644 index 0000000000..efcbdff06f --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java @@ -0,0 +1,117 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * The service used when testing stateful conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="10 minutes", + maxIdleTime="5 minutes", + singlePrincipal=false) +public class ConversationalServiceStatefulImpl implements ConversationalService { + + @ConversationID + protected String conversationId; + + @Callback + protected ConversationalCallback conversationalCallback; + + // local count - accumulates during the conversation + private int count = 0; + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + this.count = count; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + count++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return count; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void initializeCountCallback(int count){ + calls.append("initializeCountCallback,"); + this.count = count; + conversationalCallback.initializeCount(count); + } + + public void incrementCountCallback(){ + calls.append("incrementCountCallback,"); + count++; + conversationalCallback.incrementCount(); + } + + public int retrieveCountCallback(){ + calls.append("retrieveCountCallback,"); + return conversationalCallback.retrieveCount(); + } + + public void businessExceptionCallback() throws Exception { + calls.append("businessExceptionCallback,"); + conversationalCallback.businessException(); + } + + public String endConversation(){ + calls.append("endConversation,"); + count = 0; + return conversationId; + } + + public String endConversationCallback(){ + calls.append("endConversationCallback,"); + return conversationalCallback.endConversation(); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java new file mode 100644 index 0000000000..8454b3846b --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java @@ -0,0 +1,117 @@ +/* + * 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.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalServiceNonConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.NonConversationalCallback; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * The service used when testing stateful conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Service(ConversationalServiceNonConversationalCallback.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="10 minutes", + maxIdleTime="5 minutes", + singlePrincipal=false) +public class ConversationalServiceStatefulNonConversationalCallbackImpl implements ConversationalServiceNonConversationalCallback { + + @ConversationID + protected String conversationId; + + @Callback + protected NonConversationalCallback nonConversationalCallback; + + // local count - accumulates during the conversation + private int count = 0; + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + this.count = count; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + count++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return count; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void initializeCountCallback(int count){ + calls.append("initializeCountCallback,"); + this.count = count; + nonConversationalCallback.initializeCount(count); + } + + public void incrementCountCallback(){ + calls.append("incrementCountCallback,"); + count++; + nonConversationalCallback.incrementCount(); + } + + public int retrieveCountCallback(){ + calls.append("retrieveCountCallback,"); + return nonConversationalCallback.retrieveCount(); + } + + public void businessExceptionCallback() throws Exception { + calls.append("businessExceptionCallback,"); + nonConversationalCallback.businessException(); + } + + public String endConversation(){ + calls.append("endConversation,"); + count = 0; + return conversationId; + } + + public String endConversationCallback(){ + calls.append("endConversationCallback,"); + return nonConversationalCallback.endConversation(); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java new file mode 100644 index 0000000000..07186c91e1 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java @@ -0,0 +1,123 @@ +/* + * 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.conversational.impl; + +import java.util.HashMap; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * The service used when testing stateful conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Service(ConversationalService.class) +@Scope("STATELESS") +public class ConversationalServiceStatelessImpl implements ConversationalService { + + @ConversationID + protected String conversationId; + + @Callback + protected ConversationalCallback conversationalCallback; + + // static area in which to hold conversational data + private static HashMap conversationalState = new HashMap(); + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + Integer conversationalCount = new Integer(count); + conversationalState.put(conversationId, conversationalCount); + } + + public void incrementCount(){ + calls.append("incrementCount,"); + Integer conversationalCount = conversationalState.get(conversationId); + conversationalCount++; + conversationalState.put(conversationId, conversationalCount); + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + Integer count = conversationalState.get(conversationId); + if (count != null){ + return count.intValue(); + } else { + return -999; + } + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void initializeCountCallback(int count){ + calls.append("initializeCountCallback,"); + initializeCount(count); + conversationalCallback.initializeCount(count); + } + + public void incrementCountCallback(){ + calls.append("incrementCountCallback,"); + incrementCount(); + conversationalCallback.incrementCount(); + } + + public int retrieveCountCallback(){ + calls.append("retrieveCountCallback,"); + return conversationalCallback.retrieveCount(); + } + + public void businessExceptionCallback() throws Exception { + calls.append("businessExceptionCallback,"); + conversationalCallback.businessException(); + } + + public String endConversation(){ + calls.append("endConversation,"); + conversationalState.remove(conversationId); + return conversationId; + } + + public String endConversationCallback(){ + calls.append("endConversationCallback,"); + return conversationalCallback.endConversation(); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java new file mode 100644 index 0000000000..344aa99dff --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java @@ -0,0 +1,93 @@ +/* + * 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.conversational.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +public class ConversationalServiceStatelessScopeImpl implements ConversationalService { + + @ConversationID + protected String cid; + + static Map state = new HashMap(); + + public void destroy() { + // TODO Auto-generated method stub + + } + + public String endConversation() { + state.remove(cid); + return cid; + } + + public String endConversationCallback() { + // TODO Auto-generated method stub + return null; + + } + + public void incrementCount() { + state.put(cid, Integer.valueOf(state.get(cid)+1)); + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void incrementCountCallback() { + // TODO Auto-generated method stub + + } + + public void init() { + // TODO Auto-generated method stub + + } + + public void initializeCount(int count) { + state.put(cid, Integer.valueOf(count)); + } + + public void initializeCountCallback(int count) { + // TODO Auto-generated method stub + + } + + public void businessExceptionCallback() throws Exception { + throw new Exception("Business Exception"); + } + + public int retrieveCount() { + return state.get(cid); + } + + public int retrieveCountCallback() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java new file mode 100644 index 0000000000..8d79bb75e8 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java @@ -0,0 +1,71 @@ +/* + * 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.conversational.impl; + + +import org.apache.tuscany.sca.itest.conversational.Constants; +import org.apache.tuscany.sca.itest.conversational.DService; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Simple conversational Service + */ +@Service(DService.class) +@Scope("CONVERSATION") +public class DServiceImpl implements DService { + + /** + * The state for this service + */ + private String state = "Initial state value"; + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + public String getState() { + return state; + } + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + public void setState(String aState) { + this.state = aState; + } + + /** + * Sets the conversation ID for this service + * @param id The Conversation ID + */ + @ConversationID + public void setConversationID(String id) { + System.out.println ("Setting conversation ID at service = " + id ); + } + + public void endConversationViaAnnotatedMethod() { + System.out.println ("Annotated Ends Conversation"); + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java new file mode 100644 index 0000000000..d1b769216b --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java @@ -0,0 +1,66 @@ +/* + * 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.conversational.impl; + +import java.util.ArrayList; + +import org.apache.tuscany.sca.itest.Record; +import org.apache.tuscany.sca.itest.conversational.Gamma; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ + +@Service(Gamma.class) +@Scope("CONVERSATION") +public class GammaImpl implements Gamma { + @ConversationID + public String conversationId; + + private ArrayList list; + + public void start(int param) { + list = new ArrayList(); + fillList(param, conversationId); + } + + public boolean hasNext() { + return !list.isEmpty(); + } + + public Record next() { + return list.remove(0); + } + + public void stop() { + list = null; + } + + private void fillList(int param, String cid) { + for (int i = 0; i < param; i++) { + Record record = new Record(); + record.id = "id_" + i; + record.conversationId = cid; + list.add(record); + } + } +} diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationAge.composite b/sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationAge.composite new file mode 100644 index 0000000000..abd1c35ced --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationAge.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationUniqueId.composite b/sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationUniqueId.composite new file mode 100644 index 0000000000..831449a079 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/resources/ConversationUniqueId.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationId.composite b/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationId.composite new file mode 100644 index 0000000000..e61eb08194 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationId.composite @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationLifetime.composite b/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationLifetime.composite new file mode 100644 index 0000000000..3b79dc43d9 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversationLifetime.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversational.composite b/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversational.composite new file mode 100644 index 0000000000..4da3ce74d5 --- /dev/null +++ b/sandbox/axis2-1.4/itest/conversations/src/main/resources/conversational.composite @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3