Author: kwilliams
Date: Tue Apr 22 14:43:17 2008
New Revision: 650667

URL: http://svn.apache.org/viewvc?rev=650667&view=rev
Log:
Applying Gilbert's patch for TUSCANY-2257

Added:
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java
   (with props)
Modified:
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/resources/scope.composite
    
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
+public interface JService {
+
+    public String getName();
+
+    public String getFailedReason();
+    
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
+public interface KService {
+
+    public String getName();
+
+    public String callL1();
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
+public interface LService {
+
+    public String getName();
+    
+    public String getCurrentState();
+    
+    public String setCurrentState(String currentState);
+    
+       public int getDestroyCalledCounter();
+
+       public int getInitCalledCounter();
+
+       public int getInstanceCounter();
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
+public interface MService {
+
+    public String getName();
+
+    public String getFailedReason();
+    
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
+public interface NService {
+
+    public String getName();
+
+    public String callO1(int nthTime);
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
+public interface OService {
+
+    public String getName();
+    
+    public String getCurrentState();
+    
+    public String setCurrentState(String currentState);
+    
+       public int getDestroyCalledCounter();
+
+       public int getInitCalledCounter();
+
+       public int getInstanceCounter();
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Scope;
+
[EMAIL PROTECTED](JService.class)
[EMAIL PROTECTED]("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;
+               }
+               
+       }
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Scope;
+
[EMAIL PROTECTED](KService.class)
[EMAIL PROTECTED]("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";
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Scope;
+
[EMAIL PROTECTED](LService.class)
[EMAIL PROTECTED]("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;
+       }
+       
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Scope;
+
[EMAIL PROTECTED](MService.class)
[EMAIL PROTECTED]("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;
+               }
+               
+       }
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Scope;
+
[EMAIL PROTECTED](NService.class)
[EMAIL PROTECTED]("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";
+    }
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java?rev=650667&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java
 Tue Apr 22 14:43:17 2008
@@ -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.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Scope;
+
[EMAIL PROTECTED](OService.class)
[EMAIL PROTECTED]("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;
+       }
+       
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/resources/scope.composite
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/resources/scope.composite?rev=650667&r1=650666&r2=650667&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/resources/scope.composite
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/main/resources/scope.composite
 Tue Apr 22 14:43:17 2008
@@ -73,4 +73,38 @@
                <property name="p1">p1</property>       
        </component>
        
+       <component name="JComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl.JServiceImpl"
 />
+               <reference name="k1" target="KComponent"/>
+       </component>
+       
+       <component name="KComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl.KServiceImpl"
 />
+               <reference name="l1" target="LComponent"/>
+       </component>
+       
+       <component name="LComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl.LServiceImpl"
 />
+       </component>
+
+       <component name="MComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl.MServiceImpl"
 />
+               <reference name="n1" target="NComponent"/>
+       </component>
+
+       <component name="NComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl.NServiceImpl"
 />
+               <reference name="o1" target="OComponent"/>
+       </component>
+       
+       <component name="OComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl.OServiceImpl"
 />
+       </component>
+       
 </composite>

Modified: 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java?rev=650667&r1=650666&r2=650667&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java
 Tue Apr 22 14:43:17 2008
@@ -29,6 +29,11 @@
 import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.FService;
 import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.GService;
 import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.HService;
+import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.JService;
+import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.MService;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -51,6 +56,25 @@
     protected static int numFThread = 5;
     protected static int numHThread = 5;
        
+    @BeforeClass
+    public static void init() throws Exception {
+        try {
+            System.out.println("Setting up");
+            domain = SCADomain.newInstance(compositeName);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    @AfterClass
+    public static void destroy() throws Exception {
+
+        System.out.println("Cleaning up");
+        if (domain != null)
+            domain.close();
+
+    }
+    
     /**
      * Line 259:<br>
      * <li>STATELESS</li>
@@ -71,12 +95,12 @@
      */
     @Test
     public void atScope1() throws Exception {
-        System.out.println("atScope1 - Setting up");
-        domain = SCADomain.newInstance(compositeName);
+        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();
@@ -85,14 +109,13 @@
         b2.join();
         c1.join();
         c2.join();
-        System.out.println("atScope1 - Cleaning up");
-        if (domain != null)
-            domain.close();
+        
+        System.out.println("");
+
         Assert.assertEquals("None", b1.failedReason);
         Assert.assertEquals("None", b2.failedReason);
         Assert.assertEquals("None", c1.failedReason);
         Assert.assertEquals("None", c2.failedReason);
-        System.out.println("");
     }
     
     /**
@@ -106,21 +129,10 @@
      * During that time, all service requests will be delegated to the same
      * implementation instance of a request-scoped component.<br>
      * <p>
-     * Lines 290 to 293:<br>
-     * 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..<br>
-     * <p>
-     * @TODO - Need to find out how to test lines 290 to 293
-     *       - Need to find out when destroy method be called
      */
     @Test
     public void atScope2() throws Exception {
-        System.out.println("atScope2 - Setting up");
-        domain = SCADomain.newInstance(compositeName);
+        System.out.println("atScope2");
         ArrayList<DThread> d = new ArrayList<DThread>();
         for (int i = 0; i < numDThread; i++)
                d.add(new DThread("ThreadD"+i));
@@ -128,12 +140,9 @@
                d.get(i).start();
         for (int i = 0; i < numDThread; i++)
                d.get(i).join();
-        System.out.println("atScope2 - Cleaning up");
-        if (domain != null)
-            domain.close();
+        System.out.println("");
         for (int i = 0; i < numDThread; i++)
                Assert.assertEquals("None", d.get(i).failedReason);
-        System.out.println("");
     }
     
     /**
@@ -152,8 +161,7 @@
      */
     @Test
     public void atScope3() throws Exception {
-        System.out.println("atScope3 - Setting up");
-        domain = SCADomain.newInstance(compositeName);
+        System.out.println("atScope3");
         FService fService = domain.getService(FService.class, "FComponent");
         String serviceName = fService.getName();
         boolean isInitReady   = fService.isInitReady();
@@ -171,15 +179,13 @@
         
         int instanceCounter   = fService.getInstanceCounter();
         int initCalledCounter = fService.getInitCalledCounter();
+        int destroyCalledCounter = fService.getDestroyCalledCounter();
+        System.out.println("");
         
-        System.out.println("atScope3 - Cleaning up");
-        if (domain != null)
-            domain.close();
-               
         Assert.assertTrue(isInitReady);
         Assert.assertEquals(1, instanceCounter);
         Assert.assertEquals(1, initCalledCounter);
-        System.out.println("");
+        Assert.assertEquals(0, destroyCalledCounter);
     }
     
     /**
@@ -192,24 +198,23 @@
      * Section 1.8.9 "@EagerInit"<br>
      * <p>
      * GService is defined as eager initialization. It will be initialized
-     * when everytime calls SCADomain.newInstance(compositeName), so the 
-     * initCalledCounter is greater than 1.
+     * when calls SCADomain.newInstance(compositeName), so the 
+     * initCalledCounter is 1.
      */
     @Test
     public void atScope4() throws Exception {
-        System.out.println("atScope4 - Setting up");
-        domain = SCADomain.newInstance(compositeName);
+        System.out.println("atScope4");
+
         GService gService = domain.getService(GService.class, "GComponent");
         int initCalledCounter    = gService.getInitCalledCounter();
         int destroyCalledCounter = gService.getDestroyCalledCounter();
         
-        System.out.println("atScope4 - Cleaning up");
-        if (domain != null)
-            domain.close();
-        
-        Assert.assertTrue(initCalledCounter > 1);
-        Assert.assertTrue(destroyCalledCounter > 1);
+        System.out.println("initCalledCounter="+ initCalledCounter);
+        System.out.println("destroyCalledCounter="+ destroyCalledCounter);
         System.out.println("");
+
+        Assert.assertEquals(1, initCalledCounter);
+        Assert.assertEquals(0, destroyCalledCounter);
     }
     
     /**
@@ -229,8 +234,8 @@
      */
     @Test
     public void atScope5() throws Exception {
-        System.out.println("atScope5 - Setting up");
-        domain = SCADomain.newInstance(compositeName);
+        System.out.println("atScope5");
+
         ArrayList<HThread> g = new ArrayList<HThread>();
         for (int i = 0; i < numHThread; i++)
                g.add(new HThread("ThreadH"+i));
@@ -241,18 +246,61 @@
         
         HService hService = domain.getService(HService.class, "HComponent");
         String failedReason = hService.testCounters(numHThread);
+        System.out.println("");
 
-        System.out.println("atScope5 - Cleaning up");
-        if (domain != null)
-            domain.close();
-        
         for (int i = 0; i < numHThread; i++)
                Assert.assertEquals("None", g.get(i).failedReason);
         Assert.assertEquals("None", failedReason);
+    }
+
+    /** Lines 290 to 293:<br>
+    * 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..<br>
+    * <p>
+    * 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.<br>
+    * <p>
+    */
+    @Test
+    public void atScope6() throws Exception {
+        System.out.println("atScope6");
 
+        JService jService = domain.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.<br>
+     */
+    @Test
+    @Ignore
+    // JIRA T-2256
+    public void atScope7() throws Exception {
+        System.out.println("atScope7");
+
+        MService mService = domain.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";
@@ -435,4 +483,5 @@
     }
 
 }
+
 


Reply via email to