You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by do...@apache.org on 2009/10/29 19:45:41 UTC

svn commit: r831060 [1/2] - in /tuscany/sandbox/dougsleite: implementation-guardian/ implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/ implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guard...

Author: dougsleite
Date: Thu Oct 29 18:45:38 2009
New Revision: 831060

URL: http://svn.apache.org/viewvc?rev=831060&view=rev
Log:
- Changing the implementation-guardian to work with the policy-guardianException module
- Adding the policy-guardianException module: The guardian member is implemented as policies

Added:
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.project
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/test/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/test/java/
    tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/test/resources/
Removed:
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java
Modified:
    tuscany/sandbox/dougsleite/implementation-guardian/   (props changed)
    tuscany/sandbox/dougsleite/implementation-guardian/pom.xml
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite
    tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java
    tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java

Propchange: tuscany/sandbox/dougsleite/implementation-guardian/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct 29 18:45:38 2009
@@ -0,0 +1,2 @@
+target
+.settings

Modified: tuscany/sandbox/dougsleite/implementation-guardian/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/pom.xml?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/pom.xml (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/pom.xml Thu Oct 29 18:45:38 2009
@@ -39,6 +39,12 @@
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy-guardianExceptionHandling</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-host-embedded</artifactId>
             <version>1.6-SNAPSHOT</version>
         </dependency>

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java Thu Oct 29 18:45:38 2009
@@ -29,8 +29,6 @@
 
     public String getParticipantIdentifier();
 
-    public void setUniqueParticipantID(int id);
-
     public int getParticipantState();
 
     public void setParticipantState(int state);

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java Thu Oct 29 18:45:38 2009
@@ -29,7 +29,7 @@
     //Methods to manage contexts
     public void enableContext(Context context);
 
-    public void removeContext();
+    public Context removeContext();
 
     //Methods to control the signaling of exceptions
     public void gthrow(GlobalExceptionInterface ex, List<String> participantList);

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java Thu Oct 29 18:45:38 2009
@@ -26,7 +26,6 @@
     public static Context CURRENT_CONTEXT = new Context("CURRENT_CONTEXT");
     public static Context INIT_CONTEXT = new Context("INIT_CONTEXT");
     public static Context GUARDIAN_CONTEXT = new Context("GUARDIAN_CONTEXT");
-
     private String name;
     private List<Class<? extends GlobalException>> exceptionList;
 

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java Thu Oct 29 18:45:38 2009
@@ -102,18 +102,18 @@
 
     public void addGuardianMember(GuardianMember guardianMember) {
         guardianList.add(guardianMember);
-        guardianMember.setUniqueParticipantID(guardianList.size() - 1);
+        //guardianMember.setUniqueParticipantID(guardianList.size() - 1);
     }
 
     public boolean removeGuardianMember(GuardianMember guardianMember) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return guardianList.remove(guardianMember);
     }
 
     public void enableContext(Context context) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
-    public void removeContext() {
+    public Context removeContext() {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java Thu Oct 29 18:45:38 2009
@@ -48,7 +48,8 @@
         @Override
         public Message invoke(Message msg) {
 
-            GuardianMember guardianMember = (GuardianMember) ((Object[]) msg.getBody())[0];
+            //GuardianMember guardianMember = (GuardianMember) ((Object[]) msg.getBody())[0];
+            GuardianMember guardianMember = (GuardianMember) msg.getBody();
             this.guardian.addGuardianMember(guardianMember);
 
             return msg;
@@ -65,7 +66,8 @@
         @Override
         public Message invoke(Message msg) {
 
-            GuardianMember guardianMember = (GuardianMember) ((Object[]) msg.getBody())[0];
+            GuardianMember guardianMember = (GuardianMember) msg.getBody();
+
             boolean returnedValue = this.guardian.removeGuardianMember(guardianMember);
 
             msg.setBody(returnedValue);

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite Thu Oct 29 18:45:38 2009
@@ -25,48 +25,28 @@
 
 	<component name="Participant1">
 		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>	
-		<reference name="guardian_member" target="GuardianMember1"/>
+		<reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/>
 		<reference name="nodes" target="Participant2 Participant3 Participant4"/>
 	</component>  
 
 	<component name="Participant2">
 		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>	
-		<reference name="guardian_member" target="GuardianMember2"/>
+		<reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/>
 		<reference name="nodes" target="Participant1 Participant3 Participant4"/>
 	</component>  
 
 	<component name="Participant3">
 		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>	
-		<reference name="guardian_member" target="GuardianMember3"/>
+		<reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/>
 		<reference name="nodes" target="Participant1 Participant2 Participant4"/>
 	</component>  
 
 	<component name="Participant4">
 		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>	
-		<reference name="guardian_member" target="GuardianMember4"/>
+		<reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/>
 		<reference name="nodes" target="Participant1 Participant2 Participant3"/>
 	</component>  
 
-	<component name="GuardianMember1">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> 
-		<reference name="guardian_group" target="GuardianComponent"/> 
-	</component> 
-
-	<component name="GuardianMember2">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> 
-		<reference name="guardian_group" target="GuardianComponent"/> 
-	</component> 
-
-	<component name="GuardianMember3">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> 
-		<reference name="guardian_group" target="GuardianComponent"/> 
-	</component> 
-
-	<component name="GuardianMember4">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> 
-		<reference name="guardian_group" target="GuardianComponent"/> 
-	</component> 
-
 	<component name="GuardianComponent">
 		<tuscany:implementation.guardian>
 

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite Thu Oct 29 18:45:38 2009
@@ -23,27 +23,17 @@
 	name="guardianTest">
 
 	<component name="Participant1">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>	
-		<reference name="guardian_member" target="GuardianMember1"/>
+		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>
+		<reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/>
 		<reference name="nodes" target="Participant2"/>
 	</component>  
 
 	<component name="Participant2">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>	
-		<reference name="guardian_member" target="GuardianMember2"/>
+		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/>
+		<reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/>
 		<reference name="nodes" target="Participant1"/>
 	</component>  
 
-	<component name="GuardianMember1">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> 
-		<reference name="guardian_group" target="GuardianComponent"/> 
-	</component> 
-
-	<component name="GuardianMember2">
-		<implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> 
-		<reference name="guardian_group" target="GuardianComponent"/> 
-	</component> 
-
 	<component name="GuardianComponent">
 		<tuscany:implementation.guardian>
 

Added: tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml (added)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml Thu Oct 29 18:45:38 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+    * 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.    
+-->
+<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+    xmlns:calc="http://calculator">
+
+    <!-- PolicySets -->
+    <policySet name="GuardianExceptionHandlingPolicy" provides="tuscany:guardianExceptionHandling" appliesTo="sca:implementation.java/sca:reference"
+        xmlns="http://www.osoa.org/xmlns/sca/1.0"/>
+        
+</definitions>
\ No newline at end of file

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java Thu Oct 29 18:45:38 2009
@@ -34,4 +34,6 @@
     public void kill();
 
     public boolean isDead();
+
+    public void setID(String pID);
 }

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java Thu Oct 29 18:45:38 2009
@@ -23,6 +23,7 @@
 import java.util.Queue;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.apache.tuscany.sca.implementation.guardian.GuardianGroup;
 import org.apache.tuscany.sca.implementation.guardian.GuardianMember;
 import org.apache.tuscany.sca.implementation.guardian.common.Context;
 import org.osoa.sca.annotations.Init;
@@ -42,8 +43,8 @@
     private int role;
     private String pID;
     private Queue<String> updates;
-    @Reference(name = "guardian_member", required = true)
-    public GuardianMember gm;
+    @Reference(name = "guardian", required = true)
+    public GuardianGroup guardianGroup;
     @Reference(name = "nodes", required = true)
     public List<Node> nodeList;
     private boolean forcePSFException;
@@ -73,15 +74,14 @@
         forceAUFException = false;
     }
 
-    @Init
-    public void init() {
-        pID = gm.getParticipantIdentifier();
+    public void setID(String pID) {
+        this.pID = pID;
     }
 
     @OneWay
     public void execute() {
         isDead = false;
-        gm.enableContext(mainContext);
+        guardianGroup.enableContext(mainContext);
         role = PRIMARY;
 
         while (true) {
@@ -92,7 +92,7 @@
                 System.out.println(pID + "#Main context: ");
                 sleep(pID + "#Sleeping at main context...", 4000);
 
-                gm.checkExceptionStatus();
+                guardianGroup.checkExceptionStatus();
 
                 if (role == PRIMARY) {
                     //Config as primary then...
@@ -109,12 +109,13 @@
                 
             } catch (PrimaryFailedException ex) {
                 System.out.println(pID + "# Exception captured!: PrimaryFailedException");
-                System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex));
+                System.out.println(pID + "#Needs propagation?: " + guardianGroup.propagate(ex));
 
-                if (gm.propagate(ex)) {
+                if (guardianGroup.propagate(ex)) {
                     //throw ex;
                     this.kill();
                     ex.printStackTrace();
+                    guardianGroup.removeContext();
                     return;
                 }
 
@@ -122,12 +123,14 @@
 
             } catch (BackupFailedException ex) {
                 System.out.println(pID + "# Exception captured!: BackupFailedException");
-                System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex));
+                System.out.println(pID + "#Needs propagation?: " + guardianGroup.propagate(ex));
 
-                if (gm.propagate(ex)) {
+                if (guardianGroup.propagate(ex)) {
                     //throw ex;
                     this.kill();
                     ex.printStackTrace();
+
+                    guardianGroup.removeContext();
                     return;
                 }
             }
@@ -141,14 +144,14 @@
 
         while (true) {
 
-            gm.enableContext(primaryContext);
+            guardianGroup.enableContext(primaryContext);
 
             //blockingCheck();
 
             try {
                 System.out.println(pID + "#Primary context: ");
                 sleep(pID + "#Sleeping at primary context...", 4000);
-                gm.checkExceptionStatus();
+                guardianGroup.checkExceptionStatus();
 
                 //Process the request then...
                 System.out.println(pID + "#Processing the request...");
@@ -173,7 +176,7 @@
 
             } catch (PrimaryServiceFailureException ex) {
                 System.out.println(pID + "# Exception captured!: PrimaryServiceFailureException");
-                gm.gthrow(new PrimaryFailedException(), null);
+                guardianGroup.gthrow(new PrimaryFailedException(), null);
             } catch (BackupFailedException ex) {
                 System.out.println(pID + "# Exception captured!: BackupFailedException");
                 //backupAvailable = false;
@@ -182,7 +185,7 @@
                 System.out.println(pID + "# Exception captured!: BackupJoinedException");
                 backupAvailable = true;
             } finally {
-                gm.removeContext();
+                guardianGroup.removeContext();
             }
         }
     }
@@ -206,14 +209,14 @@
     private void backupService() {
         while (true) {
 
-            gm.enableContext(backupContext);
+            guardianGroup.enableContext(backupContext);
 
             //blockingCheck();
 
             try {
                 System.out.println(pID + "#Backup context: ");
                 sleep(pID + "#Sleeping at backup service", 4000);
-                gm.checkExceptionStatus();
+                guardianGroup.checkExceptionStatus();
 
                 applyUpdate();
 
@@ -223,15 +226,15 @@
 
             } catch (ApplyUpdateFailureException ex) {
                 System.out.println(pID + "# Exception captured!: ApplyUpdateFailureException");
-                gm.gthrow(new BackupFailedException(), null);
+                guardianGroup.gthrow(new BackupFailedException(), null);
             } finally {
-                gm.removeContext();
+                guardianGroup.removeContext();
             }
         }
     }
 
     public String getID() {
-        return gm.getParticipantIdentifier();
+        return this.pID;
     }
 
     private void sleep(String msg, int millis) {

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java Thu Oct 29 18:45:38 2009
@@ -32,24 +32,28 @@
 
         System.out.println("Starting participat1...");
         Node c = scaDomain.getService(Node.class, "Participant1");
+        c.setID("Participant1");
         c.execute();
 
         System.in.read();
 
         System.out.println("Starting participant2...");
         Node c2 = scaDomain.getService(Node.class, "Participant2");
+        c2.setID("Participant2");
         c2.execute();
 
         System.in.read();
 
         System.out.println("Starting participant3...");
         Node c3 = scaDomain.getService(Node.class, "Participant3");
+        c3.setID("Participant3");
         c3.execute();
 
         System.in.read();
 
         System.out.println("Starting participant4...");
         Node c4 = scaDomain.getService(Node.class, "Participant4");
+        c4.setID("Participant4");
         c4.execute();
 
         System.in.read();

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java Thu Oct 29 18:45:38 2009
@@ -32,12 +32,14 @@
 
         System.out.println("Starting participat1...");
         Node c = scaDomain.getService(Node.class, "Participant1");
+        c.setID("Participant1");
         c.execute();
 
         System.in.read();
 
         System.out.println("Starting participant2...");
         Node c2 = scaDomain.getService(Node.class, "Participant2");
+        c2.setID("Participant2");
         c2.execute();
 
         System.in.read();

Modified: tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java?rev=831060&r1=831059&r2=831060&view=diff
==============================================================================
--- tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java (original)
+++ tuscany/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java Thu Oct 29 18:45:38 2009
@@ -32,12 +32,14 @@
 
         System.out.println("Starting participat1...");
         Node c = scaDomain.getService(Node.class, "Participant1");
+        c.setID("Participant1");
         c.execute();
 
         System.in.read();
 
         System.out.println("Starting participant2...");
         Node c2 = scaDomain.getService(Node.class, "Participant2");
+        c2.setID("Participant2");
         c2.execute();
 
         System.in.read();

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath Thu Oct 29 18:45:38 2009
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.project
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.project?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.project (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.project Thu Oct 29 18:45:38 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>tuscany-policy-guardianExceptionHandling</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs Thu Oct 29 18:45:38 2009
@@ -0,0 +1,5 @@
+#Tue Oct 27 11:15:30 BRST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs Thu Oct 29 18:45:38 2009
@@ -0,0 +1,9 @@
+#Tue Oct 27 11:15:01 BRST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE Thu Oct 29 18:45:38 2009
@@ -0,0 +1,205 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+
+
+

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE Thu Oct 29 18:45:38 2009
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml Thu Oct 29 18:45:38 2009
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>1.6-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-policy-guardianExceptionHandling</artifactId>
+    <name>Apache Tuscany SCA Guardian Exception Handling Policy Model</name>
+    
+    <dependencies>
+    	        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-impl</artifactId>
+            <version>1.6-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.6-SNAPSHOT</version>
+            <scope>test</scope>
+            <type>jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-guardian</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <configuration>
+                    <instructions>
+                        <Bundle-Version>${tuscany.version}</Bundle-Version>
+                        <Bundle-SymbolicName>org.apache.tuscany.sca.policy.guardianExceptionHandling</Bundle-SymbolicName>
+                        <Bundle-Description>${pom.name}</Bundle-Description>
+                        <Export-Package>org.apache.tuscany.sca.policy.guardianExceptionHandling*</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+
+
+
+
+

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java Thu Oct 29 18:45:38 2009
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.policy.guardianExceptionHandling;
+
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+
+public class GuardianExceptionHandlingImplementationPolicyProvider implements PolicyProvider {
+
+    private MessageFactory messageFactory;
+    private RuntimeComponent component;
+    private RuntimeComponentService service;
+    private Binding binding;
+
+    public GuardianExceptionHandlingImplementationPolicyProvider(ExtensionPointRegistry extensionPoints,
+            RuntimeComponent component,
+            RuntimeComponentService service,
+            Binding binding) {
+        ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        messageFactory = modelFactories.getFactory(MessageFactory.class);
+
+        this.component = component;
+        this.service = service;
+        this.binding = binding;
+    }
+    
+    public Interceptor createInterceptor(Operation operation) {
+
+        return new GuardianExceptionHandlingPolicyInterceptor(service, service.getRuntimeWire(binding));
+    }
+
+    public String getPhase() {
+        return Phase.IMPLEMENTATION_POLICY;
+    }
+}

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java Thu Oct 29 18:45:38 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.policy.guardianExceptionHandling;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Policy;
+
+public class GuardianExceptionHandlingPolicy implements Policy {
+
+    public QName getSchemaName() {
+        return null;
+    }
+
+    public boolean isUnresolved() {
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+    }
+}

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java Thu Oct 29 18:45:38 2009
@@ -0,0 +1,61 @@
+/*
+ * 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.policy.guardianExceptionHandling;
+
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.SCADefinitions;
+import org.apache.tuscany.sca.provider.SCADefinitionsProvider;
+import org.apache.tuscany.sca.provider.SCADefinitionsProviderException;
+
+public class GuardianExceptionHandlingPolicyDefinitionsProvider implements SCADefinitionsProvider {
+    private String definitionsFile = "org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml";
+    URLArtifactProcessor urlArtifactProcessor = null;
+    
+    public GuardianExceptionHandlingPolicyDefinitionsProvider(ExtensionPointRegistry registry) {
+        URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+        urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class);
+    }
+
+    public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException {
+        // Allow privileged access to load resource. Requires RuntimePermssion in security policy.
+        URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+            public URL run() {
+                return getClass().getClassLoader().getResource(definitionsFile);
+            }
+        });
+        
+        try {
+            URI uri = new URI(definitionsFile);
+            return (SCADefinitions)urlArtifactProcessor.read(null, 
+                                                             uri, 
+                                                             definitionsFileUrl);
+        } catch ( Exception e ) {
+            throw new SCADefinitionsProviderException(e);
+        }
+    }
+
+}

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java Thu Oct 29 18:45:38 2009
@@ -0,0 +1,172 @@
+/*
+ * 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.policy.guardianExceptionHandling;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.tuscany.sca.implementation.guardian.common.Context;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.implementation.guardian.GuardianMember;
+import org.apache.tuscany.sca.implementation.guardian.common.GlobalException;
+import org.apache.tuscany.sca.implementation.guardian.common.GlobalExceptionInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class GuardianExceptionHandlingPolicyInterceptor implements Interceptor {
+
+    public static final String ENABLE_CONTEXT = "enableContext";
+    public static final String REMOVE_CONTEXT = "removeContext";
+    public static final String GTHROW = "gthrow";
+    public static final String PROPAGATE = "propagate";
+    public static final String CHECK_EXCEPTION_STATUS = "checkExceptionStatus";
+    private Invoker next;
+    private RuntimeWire runtimeWire;
+    private RuntimeComponentService service;
+
+    public GuardianExceptionHandlingPolicyInterceptor(RuntimeComponentService service, RuntimeWire runtimeWire) {
+        super();
+        this.runtimeWire = runtimeWire;
+        this.service = service;
+    }
+
+    //IMPLEMENTAR A LOGICA ENTRE {P <-> GM <-> GG}
+    public Message invoke(Message msg) {
+
+        Class targetComponentImplClass = msg.getTo().getComponent().getImplementation().getClass();
+
+        String implementationGuardian = "org.apache.tuscany.sca.implementation.guardian.impl.GuardianGroupImplementationImpl";
+        Message responseMsg = null;
+
+//        //Test the target component - must be a implemenation.guardian
+//        try {
+//            if (!targetComponentImplClass.equals(Class.forName(implementationJava))) {
+//                throw new InvalidPolicyAssociationException("The target component must be a implementation.guardian");
+//            }
+//        } catch (ClassNotFoundException ex) {
+//            Logger.getLogger(GuardianExceptionHandlingPolicyInterceptor.class.getName()).log(Level.SEVERE, null, ex);
+//        }
+
+        try {
+            if (targetComponentImplClass.equals(Class.forName(implementationGuardian))) {
+
+                String msgOperationName = msg.getOperation().getName();
+                String componentName = msg.getFrom().getComponent().getName();
+
+                GuardianMemberFactoryImpl factory = GuardianMemberFactoryImpl.getInstance();
+                GuardianMember gm = factory.createGuardianMember(componentName, msg, this);
+
+                Object msgBody = msg.getBody();
+
+                if (msgOperationName.equals(ENABLE_CONTEXT)) {
+                    Context context = (Context)((Object[]) msg.getBody())[0];
+                    gm.enableContext(context);
+                    msg.setBody(null);
+                    return msg;
+                } else if (msgOperationName.equals(REMOVE_CONTEXT)) {
+                    Context removedContext = gm.removeContext();
+                    msg.setBody(removedContext);
+
+                    //All the contexts were removed
+                    if(gm.getCurrentContext().equals(Context.INIT_CONTEXT)) {
+                        factory.removeGuardianMember(componentName, msg, this);
+                    }
+
+                    return msg;
+                } else if (msgOperationName.equals(GTHROW)) {
+                    GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msgBody)[0];
+                    List<String> participantList = (List<String>) ((Object[]) msgBody)[1];
+                    gm.gthrow(ex, participantList);
+                    msg.setBody(null);
+                    return msg;
+                } else if (msgOperationName.equals(PROPAGATE)) {
+                    GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msgBody)[0];
+                    boolean response = gm.propagate(ex);
+                    msg.setBody(response);
+                    return msg;
+                } else if (msgOperationName.equals(CHECK_EXCEPTION_STATUS)) {
+                    try {
+                        gm.checkExceptionStatus();
+                        msg.setBody(null);
+                    } catch (GlobalException ex) {
+                        msg.setFaultBody(ex);
+                    }
+                    return msg;
+                }
+            } else {
+                //throw new UnsupportedOperationException("Invocation of " + msgOperationName + " is not allowed");
+                responseMsg = getNext().invoke(msg);
+            }
+        } catch (ClassNotFoundException ex) {
+            Logger.getLogger(GuardianExceptionHandlingPolicyInterceptor.class.getName()).log(Level.SEVERE, null, ex);
+        }
+
+        return responseMsg;
+    }
+
+    public Message invokeGuardianGroupOperation(String operationName, Message msg) {
+
+        //Changing the operation
+        Operation desiredOperation = findOperation(operationName);
+
+        msg.setOperation(desiredOperation);
+
+        RuntimeComponent component = msg.getTo().getComponent();
+        ImplementationProvider implProvider = component.getImplementationProvider();
+
+        Message responseMsg = implProvider.createInvoker(this.service, desiredOperation).invoke(msg);
+
+        return responseMsg;
+    }
+
+    private Operation findOperation(String method) {
+        if (method.contains(".")) {
+            method = method.substring(method.lastIndexOf(".") + 1);
+        }
+
+        List<Operation> operations = runtimeWire.getTarget().getInterfaceContract().getInterface().getOperations();
+        
+        Operation result = null;
+        for (Operation o : operations) {
+            if (o.getName().equalsIgnoreCase(method)) {
+                result = o;
+                break;
+            }
+        }
+
+        return result;
+    }
+
+    
+
+    public Invoker getNext() {
+        return next;
+    }
+
+    public void setNext(Invoker next) {
+        this.next = next;
+    }
+}

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java Thu Oct 29 18:45:38 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.policy.guardianExceptionHandling;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class GuardianExceptionHandlingPolicyProviderFactory implements PolicyProviderFactory<GuardianExceptionHandlingPolicy> {
+
+    private ExtensionPointRegistry extensionPoints;
+
+    public GuardianExceptionHandlingPolicyProviderFactory(ExtensionPointRegistry registry) {
+        super();
+        this.extensionPoints = registry;
+    }
+
+    public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) {
+        return null;
+    }
+
+    public PolicyProvider createReferencePolicyProvider(RuntimeComponent component,
+            RuntimeComponentReference reference,
+            Binding binding) {
+        return null;
+    }
+
+    public PolicyProvider createServicePolicyProvider(RuntimeComponent component,
+            RuntimeComponentService service,
+            Binding binding) {
+        return new GuardianExceptionHandlingImplementationPolicyProvider(extensionPoints, component, service, binding);
+    }
+
+    public Class getModelType() {
+        return null;
+    }
+}

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java Thu Oct 29 18:45:38 2009
@@ -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.policy.guardianExceptionHandling;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.tuscany.sca.implementation.guardian.GuardianMember;
+import org.apache.tuscany.sca.invocation.Message;
+
+public class GuardianMemberFactoryImpl {
+
+    Map<String, GuardianMember> guardianMembers;
+    private static GuardianMemberFactoryImpl instance = null;
+
+    public static GuardianMemberFactoryImpl getInstance() {
+        if (instance == null) {
+            instance = new GuardianMemberFactoryImpl();
+        }
+        return instance;
+    }
+
+    protected GuardianMemberFactoryImpl() {
+        guardianMembers = new HashMap<String, GuardianMember>();
+    }
+
+    public GuardianMember createGuardianMember(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) {
+        GuardianMemberImpl gm = (GuardianMemberImpl) guardianMembers.get(componentName);
+
+        if (gm == null) {
+            gm = new GuardianMemberImpl(componentName, msg, interceptor);
+            guardianMembers.put(componentName, gm);
+
+            //Inform the Guardian Group of the new Guardian Member
+            Object msgBody = msg.getBody();
+
+            msg.setBody(gm);
+            interceptor.invokeGuardianGroupOperation("addGuardianMember", msg);
+
+            msg.setBody(msgBody);
+        }
+
+        gm.setMessage(msg);
+        gm.setGuardianExceptionHandlingPolicyInterceptor(interceptor);
+
+        return gm;
+    }
+
+    public GuardianMember removeGuardianMember(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) {
+
+        GuardianMember gm = guardianMembers.remove(componentName);
+
+        if (gm != null) {
+
+            Object msgBody = msg.getBody();
+
+            msg.setBody(gm);
+            interceptor.invokeGuardianGroupOperation("removeGuardianMember", msg);
+
+            msg.setBody(msgBody);
+        }
+
+        return gm;
+    }
+}

Added: tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java?rev=831060&view=auto
==============================================================================
--- tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java (added)
+++ tuscany/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java Thu Oct 29 18:45:38 2009
@@ -0,0 +1,186 @@
+/*
+ * 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.policy.guardianExceptionHandling;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Stack;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.tuscany.sca.implementation.guardian.common.GlobalExceptionInterface;
+import org.apache.tuscany.sca.implementation.guardian.GuardianGroup;
+import org.apache.tuscany.sca.implementation.guardian.GuardianMember;
+import org.apache.tuscany.sca.implementation.guardian.common.Context;
+import org.apache.tuscany.sca.implementation.guardian.common.GlobalException;
+import org.apache.tuscany.sca.implementation.guardian.common.JoinException;
+import org.apache.tuscany.sca.implementation.guardian.common.SuspendException;
+import org.apache.tuscany.sca.invocation.Message;
+
+public class GuardianMemberImpl implements GuardianMember {
+
+    private int participantState;
+    private Stack<Context> contextList;
+    private Queue<GlobalException> exceptionQueue;
+    private String id;
+    
+    //FIXME: Review the usage of this variable
+    private boolean exceptionThrown;
+    private Message msg;
+    private GuardianExceptionHandlingPolicyInterceptor interceptor;
+
+    protected GuardianMemberImpl(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) {
+        contextList = new Stack<Context>();
+        contextList.add(Context.INIT_CONTEXT);
+        exceptionQueue = new LinkedList<GlobalException>();
+        participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE;
+        exceptionThrown = false;
+
+        this.id = componentName;
+        this.msg = msg;
+        this.interceptor = interceptor;
+    }
+
+    public void setGuardianExceptionHandlingPolicyInterceptor(GuardianExceptionHandlingPolicyInterceptor interceptor) {
+        this.interceptor = interceptor;
+    }
+
+    public GuardianExceptionHandlingPolicyInterceptor getGuardianExceptionHandlingPolicyInterceptor() {
+        return this.interceptor;
+    }
+
+    public void setMessage(Message msg) {
+        this.msg = msg;
+    }
+
+    public Message getMessage() {
+        return this.msg;
+    }
+
+    public void addException(GlobalException ex) {
+        exceptionQueue.add(ex);
+    }
+
+    public Context getCurrentContext() {
+        return contextList.peek();
+    }
+
+    public void enableContext(Context context) {
+        //Update the context list with the related set of exceptions
+
+        if (contextList.size() == 1) {
+            contextList.push(context);
+
+            JoinException ex = new JoinException();
+            ex.setSignalingContext(context);
+            ex.putSignalingParticipant(getParticipantIdentifier());
+            gthrow(ex, null);
+        } else {
+            contextList.push(context);
+        }
+
+    }
+
+    public Context removeContext() {
+//        if (contextList.size() > 1) {
+//            return contextList.pop();
+//        }
+        return contextList.pop();
+    }
+
+    //If participantList is null then signal to ALL participants
+    public void gthrow(GlobalExceptionInterface ex, List<String> participantList) {
+        //1)Block the participant until raise an exception
+
+        if (!(ex instanceof SuspendException)) {
+            //Set the exception's parameters
+            ex.setSignalingContext(getCurrentContext());
+            ex.putSignalingParticipant(getParticipantIdentifier());
+
+            //Prepare the parameters
+            Object[] params = {ex, participantList};
+            msg.setBody(params);
+
+            interceptor.invokeGuardianGroupOperation("gthrow", msg);
+            //guardianGroup.gthrow(ex, participantList);
+
+            exceptionThrown = true;
+        } else {
+            setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE);
+        }
+    }
+
+    public boolean propagate(GlobalExceptionInterface ex) {
+        //1)Compares the current context with the exception's target context
+        return !getCurrentContext().equals(ex.getTargetContext());
+    }
+
+    public void checkExceptionStatus() throws GlobalException {
+
+        //Blocks until the state be diferent the SUSPENDED_STATE
+        while (participantState == GuardianGroup.SUSPENDED_PARTICIPANT_STATE && exceptionThrown) {
+            System.out.println(getParticipantIdentifier() + ": I am blocked!");
+            try {
+                Thread.sleep(5000);
+            } catch (InterruptedException ex) {
+                Logger.getLogger(GuardianMemberImpl.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+        exceptionThrown = false;
+        System.out.println(getParticipantIdentifier() + ": I am not blocked!");
+
+        GlobalException exc;
+
+        if ((exc = exceptionQueue.peek()) == null) {
+            System.out.println(getParticipantIdentifier() + "#No exception on exception queue");
+            return;
+        }
+
+        //Check if ex.targetContext() matches the participant id
+        //Eg. ex.targetContext(): Main and participant id: Init.Main.Backup -> should thrown the exception
+        //Test if the exception should be thrown in the target context
+        for (Context c : contextList) {
+            if (exc.getTargetContext().equals(c) && (c.equals(Context.INIT_CONTEXT) || c.getExceptionList().contains(exc.getClass()))) {
+                System.out.println(getParticipantIdentifier() + "#Returning an exception");
+                exceptionQueue.poll();
+                throw exc;
+            }
+        }
+
+        return;
+    }
+
+    public String getParticipantIdentifier() {
+        //1) Return the participant identifier -> context list dot separated
+        StringBuffer participantIdentifier = new StringBuffer();
+        participantIdentifier.append(this.id);
+        for (int i = 0; i < contextList.size(); i++) {
+            participantIdentifier.append("." + contextList.get(i).getName());
+        }
+        return participantIdentifier.toString();
+    }
+
+    public int getParticipantState() {
+        return participantState;
+    }
+
+    public void setParticipantState(int state) {
+        this.participantState = state;
+    }
+}