From 7d98f0821539f81d371d9be38a0bd1e4650d8cd0 Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 21 Mar 2009 09:19:18 +0000 Subject: [maven-release-plugin] copy for branch 2.0-M2 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756900 13f79535-47bb-0310-9956-ffa450edef68 --- .../vtest/java-api/annotations/scope/pom.xml | 46 ++ .../vtest/javaapi/annotations/scope/AService.java | 29 ++ .../vtest/javaapi/annotations/scope/BService.java | 40 ++ .../vtest/javaapi/annotations/scope/CService.java | 40 ++ .../vtest/javaapi/annotations/scope/DService.java | 43 ++ .../vtest/javaapi/annotations/scope/FService.java | 43 ++ .../vtest/javaapi/annotations/scope/GService.java | 35 ++ .../vtest/javaapi/annotations/scope/HService.java | 36 ++ .../vtest/javaapi/annotations/scope/IService.java | 48 +++ .../vtest/javaapi/annotations/scope/JService.java | 33 ++ .../vtest/javaapi/annotations/scope/KService.java | 33 ++ .../vtest/javaapi/annotations/scope/LService.java | 41 ++ .../vtest/javaapi/annotations/scope/MService.java | 33 ++ .../vtest/javaapi/annotations/scope/NService.java | 33 ++ .../vtest/javaapi/annotations/scope/OService.java | 41 ++ .../annotations/scope/impl/AServiceImpl.java | 32 ++ .../annotations/scope/impl/BServiceImpl.java | 112 +++++ .../annotations/scope/impl/CServiceImpl.java | 114 +++++ .../annotations/scope/impl/DServiceImpl.java | 116 +++++ .../annotations/scope/impl/FServiceImpl.java | 116 +++++ .../annotations/scope/impl/GServiceImpl.java | 75 ++++ .../annotations/scope/impl/HServiceImpl.java | 86 ++++ .../annotations/scope/impl/IServiceImpl.java | 131 ++++++ .../annotations/scope/impl/JServiceImpl.java | 78 ++++ .../annotations/scope/impl/KServiceImpl.java | 80 ++++ .../annotations/scope/impl/LServiceImpl.java | 83 ++++ .../annotations/scope/impl/MServiceImpl.java | 81 ++++ .../annotations/scope/impl/NServiceImpl.java | 85 ++++ .../annotations/scope/impl/OServiceImpl.java | 83 ++++ .../scope/src/main/resources/scope.composite | 110 +++++ .../annotations/scope/ScopeAnnotationTestCase.java | 476 +++++++++++++++++++++ 31 files changed, 2432 insertions(+) create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/pom.xml create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/resources/scope.composite create mode 100644 sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java (limited to 'sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope') diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/pom.xml b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/pom.xml new file mode 100644 index 0000000000..8a905a7ebc --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-scope + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Scope + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.java new file mode 100644 index 0000000000..b7cf3fba71 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.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.vtest.javaapi.annotations.scope; + + +/** + * Simple Service + */ +public interface AService { + + public String getName(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java new file mode 100644 index 0000000000..7da9d29424 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +/** + * Simple Service + */ +public interface BService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java new file mode 100644 index 0000000000..208c6a78b0 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +/** + * Simple Service + */ +public interface CService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.java new file mode 100644 index 0000000000..f9b87ad251 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface DService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.java new file mode 100644 index 0000000000..0e4ed9c18d --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface FService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java new file mode 100644 index 0000000000..566dc93e6d --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java @@ -0,0 +1,35 @@ +/* + * 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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface GService { + + public String getName(); + + public int getInitCalledCounter(); + + public int getDestroyCalledCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.java new file mode 100644 index 0000000000..714b3ce8f4 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + + +/** + * Simple Service + */ +@Remotable +public interface HService { + + public String getName(); + + public String test(); + + public String testCounters(int n); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.java new file mode 100644 index 0000000000..88cf95b593 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Conversational; +import org.oasisopen.sca.annotation.EndsConversation; + +/** + * Simple Service + */ +@Conversational +public interface IService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String getConversationId(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + + @EndsConversation + public void endConversation(); +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java new file mode 100644 index 0000000000..ea974100ab --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface JService { + + public String getName(); + + public String getFailedReason(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java new file mode 100644 index 0000000000..454009da12 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface KService { + + public String getName(); + + public String callL1(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java new file mode 100644 index 0000000000..2910b1c81c --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface LService { + + public String getName(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java new file mode 100644 index 0000000000..81d0692d7a --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface MService { + + public String getName(); + + public String getFailedReason(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java new file mode 100644 index 0000000000..3493a88206 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface NService { + + public String getName(); + + public String callO1(int nthTime); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java new file mode 100644 index 0000000000..982568b236 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface OService { + + public String getName(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java new file mode 100644 index 0000000000..f7a57941dc --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + public String getName() { + return "AService"; + } + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java new file mode 100644 index 0000000000..29d6284c43 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java @@ -0,0 +1,112 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.BService; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Destroy; + +@Service(BService.class) +public class BServiceImpl implements BService { + + private static int instanceCounter = 0; + + private static int initCalledCounter = 0; + + private static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + private int currentInstanceId = 0; + + public String currentState = null; + + private boolean isInitReady = false; + + public BServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initBService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + } + + @Destroy + public void destroyBService() { + destroyCalledCounter++; + } + + public String getName() { + return "BService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java new file mode 100644 index 0000000000..037d900176 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java @@ -0,0 +1,114 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.CService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(CService.class) +@Scope("STATELESS") +public class CServiceImpl implements CService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + public int currentInstanceId = 0; + + public String currentState = null; + + public boolean isInitReady = false; + + public CServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initCService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + } + + @Destroy + public void destroyCService() { + destroyCalledCounter++; + } + + public String getName() { + return "CService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java new file mode 100644 index 0000000000..d5f1326086 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java @@ -0,0 +1,116 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.DService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(DService.class) +@Scope("REQUEST") +public class DServiceImpl implements DService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + public int currentInstanceId = 0; + + public String currentState = null; + + public boolean isInitReady = false; + + public DServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initDService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + System.out.println("DService" + currentInstanceId + "->initDService"); + } + + @Destroy + public void destroyDService() { + destroyCalledCounter++; + System.out.println("DService" + currentInstanceId + "->destroyDService"); + } + + public String getName() { + return "DService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "DService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java new file mode 100644 index 0000000000..e2bfa3c45a --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java @@ -0,0 +1,116 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.FService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(FService.class) +@Scope("COMPOSITE") +public class FServiceImpl implements FService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + public int currentInstanceId = 0; + + public String currentState = null; + + public boolean isInitReady = false; + + public FServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initFService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + System.out.println("FService" + currentInstanceId + "->initFService"); + } + + @Destroy + public void destroyFService() { + destroyCalledCounter++; + System.out.println("FService" + currentInstanceId + "->destroyFService"); + } + + public String getName() { + return "FService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "FService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.java new file mode 100644 index 0000000000..28b8bd84b9 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.GService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.EagerInit; + +@Scope("COMPOSITE") +@EagerInit +public class GServiceImpl implements GService { + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + @Init + public void initGService() throws Exception { + initCalledCounter++; + System.out.println("GService->initGService"); + } + + @Destroy + public void destroyGService() { + destroyCalledCounter++; + System.out.println("GService->destroyGService"); + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + public String getName() { + return "GService"; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java new file mode 100644 index 0000000000..404f329201 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java @@ -0,0 +1,86 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.IService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.HService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(HService.class) +public class HServiceImpl implements HService { + + @Reference + public IService i1; + + public String getName() { + return "HService"; + } + + public String test() { + + String serviceName = i1.getName(); + String conversationIdBefore = i1.getConversationId(); + + for (int i = 0; i < 10; i++) { + String newState = "state-" + i; + i1.setCurrentState(newState); + String currentState = i1.getCurrentState(); + if (currentState == null || !currentState.equals(serviceName + "-" + newState)) { + i1.endConversation(); + return "CurrentStateLost - " + currentState; + } + } + + boolean isInitReady = i1.isInitReady(); + + String conversationIdAfter = i1.getConversationId(); + + i1.endConversation(); + + if (!isInitReady) + return "InitNotReady"; + + if (!conversationIdBefore.equals(conversationIdAfter)) + return "DifferentConversationId"; + + return "None"; + } + + public String testCounters(int n) { + int instanceCounter = i1.getInstanceCounter(); + int initCalledCounter = i1.getInitCalledCounter(); + int destroyCalledCounter = i1.getDestroyCalledCounter(); + + System.out.println("instanceCounter=" + instanceCounter); + System.out.println("initCalledCounter=" + initCalledCounter); + System.out.println("destroyCalledCounter=" + destroyCalledCounter); + + if (instanceCounter != n + 1) + return "IncorrectInstanceCounter"; + if (initCalledCounter != n + 1) + return "IncorrectInitCalledCounter"; + if (destroyCalledCounter != n) + return "IncorrectDestroyCalledCounter"; + + return "None"; + } + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java new file mode 100644 index 0000000000..66d14c2e96 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java @@ -0,0 +1,131 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.IService; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(IService.class) +@Scope("CONVERSATION") +public class IServiceImpl implements IService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + @ConversationID + protected String conversationId; + + public int currentInstanceId = 0; + + public AService a1; + + public String p1; + + public String currentState = null; + + public boolean isInitReady = false; + + public IServiceImpl() { + synchronized (IServiceImpl.class) { + currentInstanceId = ++instanceCounter; + } + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initIService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + System.out.println("IService" + currentInstanceId + "->initIService"); + } + + @Destroy + public void destroyIService() { + destroyCalledCounter++; + System.out.println("IService" + currentInstanceId + "->destroyIService"); + } + + public void endConversation() { + System.out.println("IService" + currentInstanceId + "->endConversation"); + } + + public String getName() { + return "IService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String getConversationId() { + return conversationId; + } + + public String setCurrentState(String currentState) { + this.currentState = "IService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java new file mode 100644 index 0000000000..80546f677c --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java @@ -0,0 +1,78 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import java.util.Timer; +import java.util.TimerTask; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.KService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.JService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(JService.class) +@Scope("COMPOSITE") +public class JServiceImpl implements JService { + + @Reference + public KService k1; + + public static String failedReason = ""; + + public static Timer aTimer = null; + + @Init + public void initJService() throws Exception { + aTimer = new Timer(); + aTimer.schedule(new JTimerTask(), 1000); + System.out.println("JService->initJService"); + } + + @Destroy + public void destroyJService() { + aTimer.cancel(); + System.out.println("JService->destroyJService"); + } + + public String getName() { + return "JService"; + } + + public String getFailedReason() { + return failedReason; + } + + private class JTimerTask extends TimerTask { + + public boolean cancel() { + return true; + } + + public void run() { + String result = k1.callL1(); + if (!result.equals("None")) + failedReason = failedReason + ";" + result; + } + + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java new file mode 100644 index 0000000000..022a9d11f6 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java @@ -0,0 +1,80 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.KService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.LService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(KService.class) +@Scope("STATELESS") +public class KServiceImpl implements KService { + + public static int instanceCounter = 0; + + public String previousL1Name = null; + + public int currentInstanceId = 0; + + @Reference + public LService l1; + + public KServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + + public String getName() { + return "KService"+currentInstanceId; + } + + public String callL1() { + + for (int i = 1; i < 11; i++) { + System.out.println(getName() + " calls LService " + i + (i == 1 ? "st time:" : (i == 2 ? "nd time:" : (i == 3 ? "rd time:" : "th time")))); + + String serviceName = l1.getName(); + for (int j = 0; j < 10; j++) { + String newState = "state-" + j; + l1.setCurrentState(newState); + String currentState = l1.getCurrentState(); + if (!currentState.equals(serviceName + "-" + newState)) { + return "CurrentStateLost - " + currentState; + } + } + + System.out.print(" Name=" + serviceName); + System.out.print(", #Instance=" + l1.getInstanceCounter()); + System.out.print(", #InitCalled=" + l1.getInitCalledCounter()); + System.out.println(", #DestroyCalled=" + l1.getDestroyCalledCounter()); + + if (previousL1Name == null) { + previousL1Name = serviceName; + } else { + if (!previousL1Name.equals(serviceName)) + return "DifferentLServiceInstance"; + } + } + return "None"; + } + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java new file mode 100644 index 0000000000..196cd6f39a --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java @@ -0,0 +1,83 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.LService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(LService.class) +@Scope("REQUEST") +public class LServiceImpl implements LService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public int currentInstanceId = 0; + + public String currentState = null; + + public LServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + @Init + public void initLService() throws Exception { + initCalledCounter++; + System.out.println("LService" + currentInstanceId + "->initLService"); + } + + @Destroy + public void destroyLService() { + destroyCalledCounter++; + System.out.println("LService" + currentInstanceId + "->destroyLService"); + } + + public String getName() { + return "LService" + currentInstanceId; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "LService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java new file mode 100644 index 0000000000..acc7d8ca9e --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java @@ -0,0 +1,81 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import java.util.Timer; +import java.util.TimerTask; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.MService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.NService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(MService.class) +@Scope("COMPOSITE") +public class MServiceImpl implements MService { + + @Reference + public NService n1; + + public static String failedReason = ""; + + public static Timer aTimer = null; + + public static int counter = 0; + + @Init + public void initMService() throws Exception { + aTimer = new Timer(); + aTimer.schedule(new MTimerTask(), 1000, 1000); + System.out.println("MService->initMService"); + } + + @Destroy + public void destroyMService() { + aTimer.cancel(); + System.out.println("MService->destroyMService"); + } + + public String getName() { + return "MService"; + } + + public String getFailedReason() { + return failedReason; + } + + private class MTimerTask extends TimerTask { + + public boolean cancel() { + return true; + } + + public void run() { + counter++; + String result = n1.callO1(counter); + if (!result.equals("None")) + failedReason = failedReason + ";" + result; + } + + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java new file mode 100644 index 0000000000..b9d799331f --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.NService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.OService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(NService.class) +@Scope("STATELESS") +public class NServiceImpl implements NService { + + public static int instanceCounter = 0; + + public String previousL1Name = null; + + public int currentInstanceId = 0; + + @Reference + public OService o1; + + public NServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + + public String getName() { + return "NService"+currentInstanceId; + } + + public String callO1(int nthTime) { + + for (int i = 1; i < 11; i++) { + System.out.println(getName() + " calls OService " + i + (i == 1 ? "st time:" : (i == 2 ? "nd time:" : (i == 3 ? "rd time:" : "th time")))); + + String serviceName = o1.getName(); + for (int j = 0; j < 10; j++) { + String newState = "state-" + j; + o1.setCurrentState(newState); + String currentState = o1.getCurrentState(); + if (!currentState.equals(serviceName + "-" + newState)) { + return "CurrentStateLost - " + currentState; + } + } + + System.out.print(" Name=" + serviceName); + System.out.print(", #Instance=" + o1.getInstanceCounter()); + System.out.print(", #InitCalled=" + o1.getInitCalledCounter()); + System.out.println(", #DestroyCalled=" + o1.getDestroyCalledCounter()); + + if (previousL1Name == null) { + previousL1Name = serviceName; + } else { + if (!previousL1Name.equals(serviceName)) + return "DifferentOServiceInstance"; + } + + } + + if (o1.getInstanceCounter() < nthTime) { + return "SharedSameInstance"; + } + + return "None"; + } +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java new file mode 100644 index 0000000000..60178ba2a3 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java @@ -0,0 +1,83 @@ +/* + * 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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.OService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(OService.class) +@Scope("REQUEST") +public class OServiceImpl implements OService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public int currentInstanceId = 0; + + public String currentState = null; + + public OServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + @Init + public void initOService() throws Exception { + initCalledCounter++; + System.out.println("OService" + currentInstanceId + "->initOService"); + } + + @Destroy + public void destroyOService() { + destroyCalledCounter++; + System.out.println("OService" + currentInstanceId + "->destroyOService"); + } + + public String getName() { + return "OService" + currentInstanceId; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "OService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } + +} diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/resources/scope.composite b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/resources/scope.composite new file mode 100644 index 0000000000..7c195b2b5d --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/main/resources/scope.composite @@ -0,0 +1,110 @@ + + + + + + + + + + + + p1 + + + + + + p1 + + + + + + p1 + + + + + + p1 + + + + + + p1 + + + + + + + + + + + p1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java new file mode 100644 index 0000000000..6d65416ce8 --- /dev/null +++ b/sandbox/ant/sca/branches/2.0-M2/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java @@ -0,0 +1,476 @@ +/* + * 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.vtest.javaapi.annotations.scope; + +import java.util.ArrayList; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This test class tests the Scope annotation described in section 1.2.4 + * including 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, and 1.8.16
+ *

+ * Check following:
+ *

  • Number of service instances be created
  • + *
  • Init method be called and where all property and reference injection is + * complete.
  • + *
  • Destroy method be called
  • + *
  • State be preserved in request and conversation scopes but not others
  • + */ +public class ScopeAnnotationTestCase { + + protected static String compositeName = "scope.composite"; + + protected static int numDThread = 5; + protected static int numFThread = 5; + protected static int numHThread = 5; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Line 259:
    + *
  • STATELESS
  • + *

    + * Line 284:
    + * For stateless components, there is no implied correlation between + * service requests.
    + *

    + * Line 1589 to 1591:
    + * The default value is 'STATELESS'. For 'STATELESS' implementations, + * a different implementation instance may be used to service each request. + * Implementation instances may be newly created or be drawn from a pool + * of instances.
    + *

    + * BComponent is not defined '@Scope'
    + * CComponent is defined '@Scope("STATELESS")'
    + *

    + */ + @Test + public void atScope1() throws Exception { + System.out.println("atScope1"); + BThread b1 = new BThread("ThreadB1"); + BThread b2 = new BThread("ThreadB2"); + CThread c1 = new CThread("ThreadC1"); + CThread c2 = new CThread("ThreadC2"); + + b1.start(); + b2.start(); + c1.start(); + c2.start(); + b1.join(); + b2.join(); + c1.join(); + c2.join(); + + System.out.println(""); + + Assert.assertEquals("None", b1.failedReason); + Assert.assertEquals("None", b2.failedReason); + Assert.assertEquals("None", c1.failedReason); + Assert.assertEquals("None", c2.failedReason); + } + + /** + * Line 260:
    + *

  • REQUEST
  • + *

    + * Lines 286 to 289:
    + * The lifecycle of request scope extends from the point a request on a + * remotable interface enters the SCA runtime and a thread processes that + * request until the thread completes synchronously processing the request. + * During that time, all service requests will be delegated to the same + * implementation instance of a request-scoped component.
    + *

    + */ + @Test + public void atScope2() throws Exception { + System.out.println("atScope2"); + ArrayList d = new ArrayList(); + for (int i = 0; i < numDThread; i++) + d.add(new DThread("ThreadD"+i)); + for (int i = 0; i < numDThread; i++) + d.get(i).start(); + for (int i = 0; i < numDThread; i++) + d.get(i).join(); + System.out.println(""); + for (int i = 0; i < numDThread; i++) + Assert.assertEquals("None", d.get(i).failedReason); + } + + /** + * Line 262:
    + *

  • COMPOSITE
  • + *

    + * Lines 296 to 298:
    + * All service requests are dispatched to the same implementation instance + * for the lifetime of the containing composite. The lifetime of the + * containing composite is defined as the time it becomes active in the + * runtime to the time it is deactivated, either normally or abnormally.
    + *

    + * Following lines should be found at System out
    + * atScope3 - Cleaning up
    + * FService1->destroyFService + */ + @Test + public void atScope3() throws Exception { + System.out.println("atScope3"); + FService fService = ServiceFinder.getService(FService.class, "FComponent"); + String serviceName = fService.getName(); + boolean isInitReady = fService.isInitReady(); + + ArrayList f = new ArrayList(); + for (int i = 0; i < numFThread; i++) + f.add(new FThread("ThreadF"+i)); + for (int i = 0; i < numFThread; i++) + f.get(i).start(); + for (int i = 0; i < numFThread; i++) + f.get(i).join(); + for (int i = 0; i < numFThread; i++) { + Assert.assertEquals(serviceName, f.get(i).serviceName); + } + + int instanceCounter = fService.getInstanceCounter(); + int initCalledCounter = fService.getInitCalledCounter(); + int destroyCalledCounter = fService.getDestroyCalledCounter(); + System.out.println(""); + + Assert.assertTrue(isInitReady); + Assert.assertEquals(1, instanceCounter); + Assert.assertEquals(1, initCalledCounter); + Assert.assertEquals(0, destroyCalledCounter); + } + + /** + * Lines 299 to 302:
    + * A composite scoped implementation may also specify eager initialization + * using the "@EagerInit" annotation. When marked for eager initialization, + * the composite scoped instance will be created when its containing + * component is started. If a method is marked with the "@Init" annotation, + * it will be called when the instance is created.

    + * Section 1.8.9 "@EagerInit"
    + *

    + * GService is defined as eager initialization. It will be initialized + * when calls SCADomain.newInstance(compositeName), so the + * initCalledCounter is 1. + */ + @Test + public void atScope4() throws Exception { + System.out.println("atScope4"); + + GService gService = ServiceFinder.getService(GService.class, "GComponent"); + int initCalledCounter = gService.getInitCalledCounter(); + int destroyCalledCounter = gService.getDestroyCalledCounter(); + + System.out.println("initCalledCounter="+ initCalledCounter); + System.out.println("destroyCalledCounter="+ destroyCalledCounter); + System.out.println(""); + + Assert.assertEquals(1, initCalledCounter); + Assert.assertEquals(0, destroyCalledCounter); + } + + /** + * Line 261:
    + *

  • CONVERSATION
  • + *

    + * Lines 305 to 310:
    + * A conversation is defined as a series of correlated interactions between + * a client and a target service. A conversational scope starts when the + * first service request is dispatched to an implementation instance + * offering a conversational service. A conversational scope completes + * after an end operation defined by the service contract is called and + * completes processing or the conversation expires. A conversation may be + * long-running and the SCA runtime may choose to passivate implementation + * instances. If this occurs, the runtime must guarantee implementation + * instance state is preserved. + */ + @Test + public void atScope5() throws Exception { + System.out.println("atScope5"); + + ArrayList g = new ArrayList(); + for (int i = 0; i < numHThread; i++) + g.add(new HThread("ThreadH"+i)); + for (int i = 0; i < numHThread; i++) + g.get(i).start(); + for (int i = 0; i < numHThread; i++) + g.get(i).join(); + + HService hService = ServiceFinder.getService(HService.class, "HComponent"); + String failedReason = hService.testCounters(numHThread); + System.out.println(""); + + for (int i = 0; i < numHThread; i++) + Assert.assertEquals("None", g.get(i).failedReason); + Assert.assertEquals("None", failedReason); + } + + /** Lines 290 to 293:
    + * There are times when a local request scoped service is called without + * there being a remotable service earlier in the call stack, such as when + * a local service is called from a non-SCA entity. In these cases, a + * remote request is always considered to be present, but the lifetime of + * the request is implementation dependent. For example, a timer event + * could be treated as a remote request..
    + *

    + * When the composite runs, composite scope service JService kicks off a + * timer by the @Init method. When the timer expires, JService invokes a + * method that calls an operation on the reference to a stateless scope + * sevice KService. KService calls a request scope service LService + * multiple times. The results of the calls to LService should be set up to + * differ depending on whether the same instance is called each time - + * without the interface being declared Conversational.
    + *

    + */ + @Test + public void atScope6() throws Exception { + System.out.println("atScope6"); + + JService jService = ServiceFinder.getService(JService.class, "JComponent"); + jService.getName(); + Thread.sleep(2000); + String failedReason = jService.getFailedReason(); + System.out.println(""); + + Assert.assertEquals("", failedReason); + } + + /** + * Same as atScope6 but the timer triggers KService multiple times.
    + */ + @Test + @Ignore("TUSCANY-2256") + public void atScope7() throws Exception { + System.out.println("atScope7"); + + MService mService = ServiceFinder.getService(MService.class, "MComponent"); + mService.getName(); + Thread.sleep(6000); + String failedReason = mService.getFailedReason(); + System.out.println(""); + + Assert.assertEquals("", failedReason); + } + + private class BThread extends Thread { + private String name = null; + public String failedReason = "Unknown"; + + public BThread(String name) { + super(); + this.name = name; + failedReason = "Unknown"; + } + + @Override + public void run() { + BService bService = ServiceFinder.getService(BService.class, "BComponent"); + bService.setCurrentState(name + "-state-1"); + System.out.println(name + "->" + bService.getName()); + if (!bService.isInitReady()) { + failedReason = "InitNotReady"; + return; + } + if (bService.getCurrentState() != null) { + failedReason = "CurrentStateNotNull"; + return; + } + int counter = bService.getInstanceCounter(); + if (counter < 2) { + failedReason = "OnlyOneInstance - " + counter; + return; + } + counter = bService.getInitCalledCounter(); + if (counter < 2) { + failedReason = "InitBeCalledOnce - " + counter; + return; + } + counter = bService.getDestroyCalledCounter(); + if (counter < 2) { + failedReason = "DestroyBeCalledOnce - " + counter; + return; + } + failedReason = "None"; + } + } + + private class CThread extends Thread { + private String name = null; + public String failedReason = "Unknown"; + + public CThread(String name) { + super(); + this.name = name; + failedReason = "Unknown"; + } + + @Override + public void run() { + CService cService = ServiceFinder.getService(CService.class, "CComponent"); + cService.setCurrentState(name + "-state-1"); + System.out.println(name + "->" + cService.getName()); + if (!cService.isInitReady()) { + failedReason = "InitNotReady"; + return; + } + if (cService.getCurrentState() != null) { + failedReason = "CurrentStateNotNull"; + return; + } + int counter = cService.getInstanceCounter(); + if (counter < 2) { + failedReason = "OnlyOneInstance - " + counter; + return; + } + counter = cService.getInitCalledCounter(); + if (counter < 2) { + failedReason = "InitBeCalledOnce - " + counter; + return; + } + counter = cService.getDestroyCalledCounter(); + if (counter < 2) { + failedReason = "DestroyBeCalledOnce - " + counter; + return; + } + failedReason = "None"; + } + } + + private class DThread extends Thread { + + private String name = null; + public String failedReason = "Unknown"; + + public DThread(String name) { + super(); + this.name = name; + failedReason = "Unknown"; + } + + @Override + public void run() { + DService dService = ServiceFinder.getService(DService.class, "DComponent"); + String serviceName = dService.getName(); + System.out.println(name + "->" + serviceName); + + for (int i = 0; i < 10; i++) { + String newState = name + "-state-" + i; + dService.setCurrentState(newState); + String currentState = dService.getCurrentState(); + if (!currentState.equals(serviceName + "-" + newState)) { + failedReason = "CurrentStateLost - " + currentState; + return; + } + } + + if (!dService.isInitReady()) { + failedReason = "InitNotReady"; + return; + } + + int counter = dService.getInstanceCounter(); + if (counter > numDThread) { + failedReason = "TooMuchInstance - " + counter; + return; + } + + counter = dService.getInitCalledCounter(); + if (counter > numDThread) { + failedReason = "InitBeCalledTooMuch - " + counter; + return; + } + + // JIRA T-2215 + /* Don't know when destroy method be called + counter = dService.getDestroyCalledCounter(); + if (counter > numDThreads) { + failedReason = "DestroyBeCalledTooMuch - " + counter; + return; + } + */ + failedReason = "None"; + } + } + + private class FThread extends Thread { + + private String name = null; + + public String serviceName = null; + + public FThread(String name) { + super(); + this.name = name; + } + + @Override + public void run() { + FService fService = ServiceFinder.getService(FService.class, "FComponent"); + serviceName = fService.getName(); + System.out.println(name + "->" + serviceName); + + for (int i = 0; i < 10; i++) { + String newState = name + "-state-" + i; + fService.setCurrentState(newState); + fService.getCurrentState(); + } + } + } + + private class HThread extends Thread { + + public String failedReason = "Unknown"; + + public HThread(String name) { + super(); + failedReason = "Unknown"; + } + + @Override + public void run() { + HService hService = ServiceFinder.getService(HService.class, "HComponent"); + failedReason = hService.test(); + } + } + +} + + -- cgit v1.2.3