summaryrefslogtreecommitdiffstats
path: root/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java')
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java37
1 files changed, 22 insertions, 15 deletions
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java
index 5edecf4bcd..220325b1f0 100644
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java
+++ b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java
@@ -41,6 +41,7 @@ public class GuardianMemberImpl implements GuardianMember {
public GuardianMemberImpl() {
contextList = new Stack<Context>();
+ contextList.add(Context.INIT_CONTEXT);
exceptionQueue = new LinkedList<GlobalException>();
}
@@ -74,7 +75,7 @@ public class GuardianMemberImpl implements GuardianMember {
//Update the context list with the related set of exceptions
contextList.push(context);
- if (contextList.size() == 1) {
+ if (contextList.size() == 2) {
gthrow(new JoinException(), null);
}
@@ -162,23 +163,31 @@ public class GuardianMemberImpl implements GuardianMember {
// System.out.println("Equals: " + exc.getTargetContext().equals(getCurrentContext()) + "\n");
// }
- //FIX-ME: ex.targetContext() matches the participant id -> could use regular expressions
- //Eg. ex.targetContext(): Main and participant id: Init/Main/Backup -> should throw the exception
- String[] contexts = getParticipantIdentifier().split("\\.");
+ //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
if (exc != null) {
- for (int i = contexts.length - 1; i > 0; i--) {
- if (exc.getTargetContext().equals(new Context(contexts[i]))) {
+ 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;
}
}
}
-
-// if (exc != null && exc.getTargetContext().equals(getCurrentContext())) {
-// System.out.println(getParticipantIdentifier() + "#Returning an exception");
-// exceptionQueue.poll();
-// throw exc;
+// String[] contexts = getParticipantIdentifier().split("\\.");
+// if (exc != null) {
+// for (int i = contexts.length - 1; i > 0; i--) {
+// if (exc.getTargetContext().equals(new Context(contexts[i]))) {
+//
+// //Test if the exception should be thrown in the target context
+//
+//
+// System.out.println(getParticipantIdentifier() + "#Returning an exception");
+// exceptionQueue.poll();
+// throw exc;
+// }
+// }
// }
return;
@@ -189,12 +198,10 @@ public class GuardianMemberImpl implements GuardianMember {
public String getParticipantIdentifier() {
//1) Return the participant identifier -> context list dot separated
StringBuffer id = new StringBuffer();
- id.append(this.id + "." + Context.INIT_CONTEXT.getName());
+ //id.append(this.id + "." + Context.INIT_CONTEXT.getName());
+ id.append(this.id);
for (int i = 0; i < contextList.size(); i++) {
id.append("." + contextList.get(i).getName());
-// if (i + 1 != contextList.size()) {
-// id.append(".");
-// }
}
return id.toString();
}