summaryrefslogtreecommitdiffstats
path: root/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany
diff options
context:
space:
mode:
authordougsleite <dougsleite@13f79535-47bb-0310-9956-ffa450edef68>2009-09-28 14:37:58 +0000
committerdougsleite <dougsleite@13f79535-47bb-0310-9956-ffa450edef68>2009-09-28 14:37:58 +0000
commitf4f96f8c8ec04e4c1709d3037e57589145be12fa (patch)
treea8bf81061fdc2af53fae50eebf063bd1ecfdc854 /sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany
parent215c005bde88752999978adce56b09d2a90a13b7 (diff)
- Changing the guardian-model, policy-recoveryrules, policy-resolutiontrees to a new module: implementation-guardian;
- The new module creates a new kind of implementation (implementation.guardian) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@819561 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany')
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java30
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java38
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java81
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java79
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java85
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java54
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java32
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java637
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java40
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java184
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java38
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java30
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java30
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java39
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java38
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java153
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java38
-rw-r--r--sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java38
18 files changed, 0 insertions, 1664 deletions
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java
deleted file mode 100644
index 848c4a874d..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.guardian;
-
-public interface BlockingInterface {
-
- //@OneWay
- public void block();
-
- //@OneWay
- public void unblock();
-
- public boolean isBlocked();
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java
deleted file mode 100644
index 30584f2d78..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.guardian;
-
-class ConcurrentExceptionOcurrenceException extends Exception {
-
- public ConcurrentExceptionOcurrenceException() {
- super();
- }
-
- public ConcurrentExceptionOcurrenceException(String message) {
- super(message);
- }
-
- public ConcurrentExceptionOcurrenceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConcurrentExceptionOcurrenceException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java
deleted file mode 100644
index 9fa4db4f78..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.guardian;
-
-import javax.xml.namespace.QName;
-
-public interface Constants {
-
- String RECOVERY_RULES = "recovery_rules";
- QName RECOVERY_RULES_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RECOVERY_RULES);
-
- String RULE = "rule";
- QName RULE_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RULE);
-
- String NAME = "name";
- QName NAME_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, NAME);
-
- String SIGNALED_EXCEPTION = "signaled_exception";
- QName SIGNALED_EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, SIGNALED_EXCEPTION);
-
- String PARTICIPANT = "participant";
- QName PARTICIPANT_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, PARTICIPANT);
-
- String MATCH = "match";
- QName MATCH_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MATCH);
-
- String THROW_EXCEPTION = "throw_exception";
- QName THROW_EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, THROW_EXCEPTION);
-
- String CLASS = "class";
- QName CLASS_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, CLASS);
-
- String TARGET_CONTEXT = "target_context";
- QName TARGET_CONTEXT_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, TARGET_CONTEXT);
-
- String MIN_PARTICIPANT_JOINED = "min_participant_joined";
- QName MIN_PARTICIPANT_JOINED_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MIN_PARTICIPANT_JOINED);
-
- String MAX_PARTICIPANT_JOINED = "max_participant_joined";
- QName MAX_PARTICIPANT_JOINED_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MAX_PARTICIPANT_JOINED);
-
- String AFFECTED_PARTICIPANTS = "affected_participants";
- QName AFFECTED_PARTICIPANTS_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, AFFECTED_PARTICIPANTS);
-
- String FIRST = "FIRST";
- QName FIRST_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, FIRST);
-
- String LAST = "LAST";
- QName LAST_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, LAST);
-
- String ALL = "ALL";
- QName ALL_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, ALL);
-
- String RESOLUTION_TREE = "resolution_tree";
- QName RESOLUTION_TREE_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RESOLUTION_TREE);
-
- String RESOLUTION_TREES = "resolution_trees";
- QName RESOLUTION_TREES_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RESOLUTION_TREES);
-
- String EXCEPTION_LEVEL = "exception_level";
- QName EXCEPTION_LEVEL_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, EXCEPTION_LEVEL);
-
- String EXCEPTION = "exception";
- QName EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, EXCEPTION);
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java
deleted file mode 100644
index 3ac5d63a42..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.guardian;
-
-import java.util.LinkedList;
-import java.util.List;
-
-public class Context {
-
- 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;
-
- public Context() {
- this(null);
- }
-
- public Context(String name) {
- this(name, new LinkedList<Class<? extends GlobalException>>());
- }
-
- public Context(String name, List<Class<? extends GlobalException>> exceptionList) {
- this.name = name;
- this.exceptionList = exceptionList;
- }
-
- public void addException(Class<? extends GlobalException> ex) {
- this.exceptionList.add(ex);
- }
-
- public void setExceptionList(List<Class<? extends GlobalException>> exceptionList) {
- this.exceptionList = exceptionList;
- }
-
- public List<Class<? extends GlobalException>> getExceptionList() {
- return this.exceptionList;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj instanceof Context &&
- (((Context) obj).getName().equals(this.getName()) ||
- this == Context.CURRENT_CONTEXT ||
- ((Context) obj) == Context.CURRENT_CONTEXT));
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java
deleted file mode 100644
index b880db6aa1..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.guardian;
-
-import java.util.LinkedList;
-import java.util.List;
-
-public class GlobalException extends RuntimeException implements GlobalExceptionInterface {
-
- private List<String> signalingParticipants;
- private Context signalingContext;
- private Context targetContext;
-
- public GlobalException() {
- super();
- signalingParticipants = new LinkedList<String>();
- }
-
- public GlobalException(String message) {
- super(message);
- signalingParticipants = new LinkedList<String>();
- }
-
- public GlobalException(String message, Throwable cause) {
- super(message, cause);
- signalingParticipants = new LinkedList<String>();
- }
-
- public GlobalException(Throwable cause) {
- super(cause);
- signalingParticipants = new LinkedList<String>();
- }
-
- /**
- * @return the signalingContext
- */
- public Context getSignalingContext() {
- return signalingContext;
- }
-
- /**
- * @param signalingContext the signalingContext to set
- */
- public void setSignalingContext(Context signalingContext) {
- this.signalingContext = signalingContext;
- }
-
- /**
- * @return the targetContext
- */
- public Context getTargetContext() {
- return targetContext;
- }
-
- /**
- * @param targetContext the targetContext to set
- */
- public void setTargetContext(Context targetContext) {
- this.targetContext = targetContext;
- }
-
- public void putSignalingParticipant(String participant) {
- signalingParticipants.add(participant);
- }
-
- public List<String> getSignalingParticipants() {
- return signalingParticipants;
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java
deleted file mode 100644
index 68a09a9bc8..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.guardian;
-
-import java.util.List;
-
-public interface GlobalExceptionInterface {
-
- /**
- * @return the signalingContext
- */
- public Context getSignalingContext();
-
- /**
- * @param signalingContext the signalingContext to set
- */
- public void setSignalingContext(Context signalingContext);
-
- /**
- * @return the targetContext
- */
- public Context getTargetContext();
-
- /**
- * @param targetContext the targetContext to set
- */
- public void setTargetContext(Context targetContext);
-
- /**
- * @return the signalingProcess
- */
- public List<String> getSignalingParticipants();
-
- /**
- * @param signalingProcess the signalingProcess to set
- */
- public void putSignalingParticipant(String participant);
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java
deleted file mode 100644
index 5119390a14..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.guardian;
-
-import org.osoa.sca.annotations.Remotable;
-
-//@Remotable
-public interface GuardianGroup extends GuardianPrimitives {
-
- public static int NORMAL_PARTICIPANT_STATE = 0;
- public static int SUSPENDED_PARTICIPANT_STATE = 1;
-
- public void addGuardianMember(GuardianMember guardianMember);
-
- public boolean removeGuardianMember(GuardianMember guardianMember);
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java
deleted file mode 100644
index f9fe5c2c59..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- * 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.guardian;
-
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicyProcessor;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Scope;
-import org.osoa.sca.annotations.Service;
-import org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicyProcessor;
-
-@Service(GuardianGroup.class)
-@Scope("COMPOSITE")
-public class GuardianGroupImpl implements GuardianGroup {
-
- private List<GuardianMember> guardianList;
- private InnerGuardianGroupThread innerThread;
- private List<GlobalExceptionInterface> concurrentExList;
- private Map<String, OMElement> resolutionTreeElements;
- private ResolutionTreeUtils resolutionTreeUtils;
- private Map<String, OMElement> ruleElements;
-
- public GuardianGroupImpl() {
- guardianList = new LinkedList<GuardianMember>();
- concurrentExList = new LinkedList<GlobalExceptionInterface>();
- innerThread = new InnerGuardianGroupThread();
- resolutionTreeUtils = new ResolutionTreeUtils();
- }
-
- @Property(name = "recovery_rules", required = false)
- public void setRecoveryRules(String recoveryRules) {
- try {
- FileInputStream fileInputStream = new FileInputStream(recoveryRules);
- XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
-
- RecoveryRulesPolicyProcessor processor = new RecoveryRulesPolicyProcessor(null, null);
- ruleElements = processor.read(xmlReader).getRuleElements();
-
- } catch (ContributionReadException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- } catch (XMLStreamException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- } catch (FileNotFoundException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- @Property(name = "resolution_tree", required = false)
- public void setResolutionTree(String resolutionTree) {
-
- try {
- FileInputStream fileInputStream = new FileInputStream(resolutionTree);
- XMLStreamReader resolutionTreeReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
-
- ResolutionTreesPolicyProcessor processor = new ResolutionTreesPolicyProcessor(null, null);
- resolutionTreeElements = processor.read(resolutionTreeReader).getResolutionTreeElements();
-
- } catch (ContributionReadException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- } catch (XMLStreamException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- } catch (FileNotFoundException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public void addGuardianMember(GuardianMember guardianMember) {
- guardianList.add(guardianMember);
- guardianMember.setUniqueParticipantID(guardianList.size() - 1);
- }
-
- public void enableContext(Context context) {
- System.out.println("Enable Context.. nothing to do!");
- //throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void removeContext() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public synchronized void gthrow(GlobalExceptionInterface ex, List<String> participantList) {
-
- concurrentExList.add(ex);
-
- //Sends a message representing the exception to the other guardian members
- SuspendException suspendEx = new SuspendException();
- suspendEx.putSignalingParticipant(ex.getSignalingParticipants().get(0));
-
- if (participantList == null) {
- for (GuardianMember g : guardianList) {
- g.gthrow(suspendEx, null);
- }
- } else {
- for (GuardianMember g : guardianList) {
- if (participantList.contains(g.getParticipantIdentifier()) ||
- g.getParticipantIdentifier().equals(ex.getSignalingParticipants().get(0))) {
- g.gthrow(suspendEx, null);
- }
- }
- }
-
- if (!innerThread.isRunning()) {
- innerThread.setGlobalException(ex);
- new Thread(innerThread).start();
- }
- }
-
- public boolean propagate(GlobalExceptionInterface ex) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void checkExceptionStatus() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public boolean removeGuardianMember(GuardianMember guardianMember) {
- return this.guardianList.remove(guardianMember);
- }
-
- private class InnerGuardianGroupThread implements Runnable {
-
- private boolean isRunning;
- private GlobalExceptionInterface ex = null;
-
- public InnerGuardianGroupThread() {
- isRunning = false;
- }
-
- public void setGlobalException(GlobalExceptionInterface ex) {
- this.ex = ex;
- }
-
- public GlobalExceptionInterface getGlobalException() {
- return ex;
- }
-
- public void run() {
- isRunning = true;
-
- if (ex != null) {
-
- //Time window of 10 seconds just for tests
- try {
- Thread.sleep(10000);
- } catch (InterruptedException ex1) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1);
- }
-
- try {
- applyRecoveryRules(ex);
- } catch (ConcurrentExceptionOcurrenceException ce) {
- applyConcurrentRecoveryRules();
- }
-
- //Clear the concurrent exception list
- concurrentExList.clear();
-
- //Set up the participant state to NORMAL
- for (GuardianMember gm : guardianList) {
- if (gm.getParticipantState() == SUSPENDED_PARTICIPANT_STATE) {
- gm.setParticipantState(NORMAL_PARTICIPANT_STATE);
- }
- }
- }
- isRunning = false;
- }
-
- public boolean isRunning() {
- return isRunning;
- }
-
- private void applyRecoveryRules(GlobalExceptionInterface ex) throws ConcurrentExceptionOcurrenceException {
- ruleTag(ex, ruleElements.values().iterator());
- }
-
- private void ruleTag(GlobalExceptionInterface ex, Iterator<OMElement> ruleElements) throws ConcurrentExceptionOcurrenceException {
- String signaledException;
- String exceptionName;
-
- OMElement rule;
- while (ruleElements.hasNext()) {
-
- rule = ruleElements.next();
- signaledException = getAttributeValue(rule, Constants.SIGNALED_EXCEPTION);
- exceptionName = ex.getClass().getName();
-
- if (signaledException.equals(exceptionName)) {
- participantExceptionTag(ex, rule.getChildElements());
- break;
- }
- }
- }
-
- private void participantExceptionTag(GlobalExceptionInterface ex, Iterator<OMElement> participantElements) throws ConcurrentExceptionOcurrenceException {
- String matchParticipant;
- List<GuardianMember> gmList;
-
- OMElement participant;
- while (participantElements.hasNext()) {
- participant = participantElements.next();
-
- matchParticipant = getAttributeValue(participant, Constants.MATCH);
- gmList = getMatchingParticipants(matchParticipant, ex);
-
- if (!gmList.isEmpty()) {
- throwExceptionTag(gmList, ex, participant.getChildElements());
- }
- }
- }
-
- private void throwExceptionTag(List<GuardianMember> gmList, GlobalExceptionInterface ex, Iterator<OMElement> throwExceptionElements) throws ConcurrentExceptionOcurrenceException {
- String className;
- String targetContextName;
- Integer minParticipantJoined;
- Integer maxParticipantJoined;
-
- OMElement throwException;
- while (throwExceptionElements.hasNext()) {
-
- throwException = throwExceptionElements.next();
-
- className = getAttributeValue(throwException, Constants.CLASS);
- targetContextName = getAttributeValue(throwException, Constants.TARGET_CONTEXT);
-
- try {
- minParticipantJoined = Integer.parseInt(getAttributeValue(throwException, Constants.MIN_PARTICIPANT_JOINED));
- } catch (NumberFormatException nex) {
- minParticipantJoined = null;
- }
-
- try {
- maxParticipantJoined = Integer.parseInt(getAttributeValue(throwException, Constants.MAX_PARTICIPANT_JOINED));
- } catch (NumberFormatException nexc) {
- maxParticipantJoined = null;
- }
-
- //Test the min and max joined participants condition
- if (minParticipantJoined != null && maxParticipantJoined != null) {
- if (!(guardianList.size() >= minParticipantJoined && guardianList.size() < maxParticipantJoined)) {
- break;
- }
- } else if (minParticipantJoined != null) {
- if (!(guardianList.size() >= minParticipantJoined)) {
- break;
- }
- } else if (minParticipantJoined != null) {
- if (!(guardianList.size() >= minParticipantJoined)) {
- break;
- }
- }
-
- //<affected_participants>
- String affectedParticipants = affectedParticipantsTag(throwException.getChildElements());
- int index = -1;
-
- //Verify if the parameter is an index
- try {
- index = Integer.parseInt(affectedParticipants);
- } catch (NumberFormatException nexc) {
- index = -1;
- }
-
- //Create the new exception instance
- Class exceptionClass;
- try {
- exceptionClass = Class.forName(className);
-
- Context targetContext;
- if (targetContextName.toUpperCase().equals(Context.CURRENT_CONTEXT.getName().toUpperCase())) {
- targetContext = Context.CURRENT_CONTEXT;
- } else if (targetContextName.toUpperCase().equals(Context.INIT_CONTEXT.getName().toUpperCase())) {
- targetContext = Context.INIT_CONTEXT;
- } else {
- targetContext = new Context(targetContextName);
- }
- GlobalException newException = (GlobalException) exceptionClass.newInstance();
-
- newException.setTargetContext(targetContext);
- newException.setSignalingContext(ex.getSignalingContext());
- newException.putSignalingParticipant(ex.getSignalingParticipants().toString());
-
- //Check concurrent exception existence
- if (concurrentExList.size() > 1) {
- throw new ConcurrentExceptionOcurrenceException(concurrentExList.toString());
- }
-
- //Add the exception to the participants matched
- if (index != -1) {
- gmList.get(index).addException(newException);
- } else if (affectedParticipants != null && affectedParticipants.length() != 0) {
- if (affectedParticipants.toUpperCase().equals(Constants.FIRST)) {
- gmList.get(0).addException(newException);
- } else if (affectedParticipants.toUpperCase().equals(Constants.LAST)) {
- gmList.get(gmList.size() - 1).addException(newException);
- } else if (affectedParticipants.toUpperCase().equals(Constants.ALL)) {
- for (GuardianMember gm : gmList) {
- gm.addException(newException);
- }
- }
- } else {
- for (GuardianMember gm : gmList) {
- gm.addException(newException);
- }
- }
-
- } catch (InstantiationException ex1) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1);
- } catch (IllegalAccessException ex1) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1);
- } catch (ClassNotFoundException ex1) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1);
- }
- }
- }
-
- private String affectedParticipantsTag(Iterator<OMElement> affectedParticipantElements) {
-
- String affectedParticipantValue = null;
-
- OMElement affectedParticipant;
- while (affectedParticipantElements.hasNext()) {
-
- affectedParticipant = affectedParticipantElements.next();
- affectedParticipantValue = affectedParticipant.getText();
- }
-
- if (affectedParticipantValue != null && affectedParticipantValue.length() == 0) {
- affectedParticipantValue = null;
- }
-
- return affectedParticipantValue;
- }
-
- private String getAttributeValue(OMElement element, String attributeName) {
- OMAttribute at;
- Iterator it = element.getAllAttributes();
-
- while (it.hasNext()) {
- at = (OMAttribute) it.next();
- if (at.getLocalName().equals(attributeName)) {
- return at.getAttributeValue();
- }
- }
-
- return null;
- }
-
- private void applyConcurrentRecoveryRules() {
-
- boolean concurrentExOcurrence = false;
- List<GlobalExceptionInterface> copyConcurrentExList;
- GlobalExceptionInterface resolvedEx;
-
- do {
- System.out.println("Concurrent exceptions: " + concurrentExList);
-
- copyConcurrentExList = new LinkedList(concurrentExList);
-
- resolvedEx = checkExceptionResolutionTrees(copyConcurrentExList, resolutionTreeElements.values().iterator());
-
- concurrentExList.clear();
-
- System.out.println("Resolved Exception: " + resolvedEx);
- if (resolvedEx != null) {
- System.out.println("List of participants: " + resolvedEx.getSignalingParticipants());
- }
-
- try {
- //Process the exception list sequentially
- if (resolvedEx == null) {
- for (GlobalExceptionInterface ex : copyConcurrentExList) {
- applyRecoveryRules(ex);
- }
- } else {
- applyRecoveryRules(resolvedEx);
- }
-
- } catch (ConcurrentExceptionOcurrenceException exc) {
- concurrentExOcurrence = true;
- break;
- }
- } while (concurrentExOcurrence);
- }
-
- //FIXME: Need to check the exception level
- private GlobalExceptionInterface checkExceptionResolutionTrees(List<GlobalExceptionInterface> exceptionList, Iterator resolutionTreesElements) {
-
- OMElement tree;
- OMElement root;
- String exceptionLevel = null;
- GlobalExceptionInterface resolvedEx = null;
-
- while (resolutionTreesElements.hasNext()) {
- tree = (OMElement) resolutionTreesElements.next();
- exceptionLevel = tree.getAttributeValue(Constants.EXCEPTION_LEVEL_QNAME);
-
- root = (OMElement) tree.getChildElements().next();
- resolvedEx = checkExceptionResolutionTree(exceptionList, root);
-
- if (resolvedEx != null) {
- break;
- }
- }
-
- return resolvedEx;
- }
-
- //Search for the root of the smallest subtree that contains all the concurrently signaled exceptions. If not found, return null.
- private GlobalExceptionInterface checkExceptionResolutionTree(List<GlobalExceptionInterface> exceptionList, OMElement rootTree) {
-
- resolutionTreeUtils.setRoot(rootTree);
- String ex1, ex2;
- GlobalExceptionInterface resolvedEx = null;
-
- ex1 = exceptionList.get(0).getClass().getName();
- for (int i = 1; i < exceptionList.size(); i++) {
- ex2 = exceptionList.get(i).getClass().getName();
-
- try {
- ex1 = resolutionTreeUtils.getLowestCommonAncestor(ex1, ex2);
- } catch (InvalidNodeException invalidNodeException) {
- ex1 = null;
- break;
- }
- }
-
- if (ex1 != null) {
- Class exceptionClass;
-
- try {
- exceptionClass = Class.forName(ex1);
- resolvedEx = (GlobalException) exceptionClass.newInstance();
-
- for (GlobalExceptionInterface ex : exceptionList) {
- resolvedEx.putSignalingParticipant(ex.getSignalingParticipants().get(0));
- }
-
- } catch (InstantiationException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex);
- }
-
- return resolvedEx;
-
- } else {
- return null;
- }
- }
-
- private List<GuardianMember> getMatchingParticipants(String regularExpression, GlobalExceptionInterface signaledException) {
- List<GuardianMember> matchingParticipants = new LinkedList();
- String[] splitByComma = regularExpression.split(",");
-
- //Invalid regular expression
- if (splitByComma.length > 2) {
- throw new InvalidRegularExpression("The comma ',' operator can only be applied for two expressions");
- }
-
- //There is no comma on the regular expression
- if (splitByComma.length == 1) {
-
- if (regularExpression.toUpperCase().equals("SIGNALER")) {
- for (GuardianMember gm : guardianList) {
- if (signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) {
- matchingParticipants.add(gm);
- }
- }
- } else if (regularExpression.toUpperCase().equals("!SIGNALER")) {
- for (GuardianMember gm : guardianList) {
- if (!signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) {
- matchingParticipants.add(gm);
- }
- }
-
- } else {
- //Create an java regular expression
- String re = createJavaRegularExpression(regularExpression);
-
- for (GuardianMember gm : guardianList) {
- if (gm.getParticipantIdentifier().matches(re)) {
- matchingParticipants.add(gm);
- }
- }
- }
-
- } //There is comma on the regular expression
- else {
-
- String element;
- int index = -1;
- for (int i = 0; i < splitByComma.length; i++) {
- element = splitByComma[i].toUpperCase();
- if (element.equals("SIGNALER") || element.equals("!SIGNALER")) {
- if (index == -1) {
- index = i;
- } else {
- index = -1;
- }
- }
- }
-
- //Invalid expression
- if (index == -1) {
- throw new InvalidRegularExpression("The comma ',' requires a SIGNALER or !SIGNALER element in one side of the expression");
- }
-
- String re = createJavaRegularExpression(splitByComma[1 - index]);
-
- for (GuardianMember gm : guardianList) {
-
- //Test if the participant matches with the regular expression
- if (gm.getParticipantIdentifier().matches(re)) {
-
- //Test if the participant is Signaler
- if (splitByComma[index].toUpperCase().equals("SIGNALER")) {
-
- if (signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) {
- matchingParticipants.add(gm);
- }
- } //Test if the participant is not Signaler
- else {
- if (!signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) {
- matchingParticipants.add(gm);
- }
- }
- }
- }
-
- }
-
- return matchingParticipants;
- }
-
- /* Valid expressions: *, <Context>.*, <Context>, *.<Context>, *.<Context>.*,
- * *.<Context>.*.<Context>.*, <REG_EXP> || <REG_EXP>
- *
- * Invalid expressions: *.*, **,
- *
- * Not supported yet: !<Context>, !<Context> || <Context>, !(<Context> || <Context>)
- */
- private String createJavaRegularExpression(String regularExpression) throws InvalidRegularExpression {
- StringBuffer re = new StringBuffer();
-
- String[] splitByBar = regularExpression.split("\\|\\|");
- String[] splitByPeriod;
-
- for (int i = 0; i < splitByBar.length; i++) {
-
- splitByPeriod = splitByBar[i].split("\\.");
-
- if (i > 0) {
- re.append("|");
- }
-
- re.append("^");
- for (int j = 0; j < splitByPeriod.length; j++) {
-
- //*
- if (splitByPeriod[j].equals("*")) {
-
- //Validate the regular expression
- if (j + 1 != splitByPeriod.length && splitByPeriod[j + 1].equals("*")) {
- throw new InvalidRegularExpression();
- }
-
- //*
- if (splitByPeriod.length == 1) {
- re.append("(\\w+)");
- } //*.<CONTEXT>
-
- if (j == 0 && splitByPeriod.length != 1) {
- re.append("(\\w+\\");
- re.append(".)*");
- } //<CONTEXT>.*
- else {
- re.append("(\\");
- re.append(".\\w+)*");
- }
- } //<CONTEXT>
- else {
-
-// //Validate the regular expression
-// if (splitedByPeriod[j].matches("^(\\*)*$")) {
-// throw new RuntimeException("Invalid name for a context");
-// }
-
- //<CONTEXT> || <CONTEXT>.<CONTEXT>.<CONTEXT> || *.<CONTEXT>
- if (splitByPeriod.length == 1) {
- re.append("(\\w+\\");
- re.append(".)*");
- }
-
- if (j == 0 || j - 1 == 0) {
- re.append("(" + splitByPeriod[j] + ")");
- } else {
- re.append("(\\." + splitByPeriod[j] + ")");
- }
- }
- }
- re.append("$");
- }
- return re.toString();
- }
- }
-} \ No newline at end of file
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java
deleted file mode 100644
index 48dad22bff..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.guardian;
-
-public interface GuardianMember extends GuardianPrimitives {
-
- public void addException(GlobalException ex);
-
- public void setService(BlockingInterface service);
-
- public void removeService();
-
- public Context getCurrentContext();
-
- public BlockingInterface getService();
-
- public String getParticipantIdentifier();
-
- public void setUniqueParticipantID(int id);
-
- public int getParticipantState();
-
- public void setParticipantState(int state);
-}
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
deleted file mode 100644
index 893d5fcb1b..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.guardian;
-
-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.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Scope;
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Service;
-
-@Service(GuardianMember.class)
-@Scope("COMPOSITE")
-public class GuardianMemberImpl implements GuardianMember {
-
- private int participantState;
- private Stack<Context> contextList;
- private BlockingInterface service;
- private Queue<GlobalException> exceptionQueue;
- @Reference(name = "guardian_group", required = true)
- public GuardianGroup guardianGroup;
- private int id;
- //FIXME: Review the usage of this variable
- private boolean exceptionThrown;
-
- public GuardianMemberImpl() {
- contextList = new Stack<Context>();
- contextList.add(Context.INIT_CONTEXT);
- exceptionQueue = new LinkedList<GlobalException>();
- participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE;
- exceptionThrown = false;
- }
-
- @Init
- public void init() {
- guardianGroup.addGuardianMember(this);
- }
-
- @Destroy
- public void destroy() {
- guardianGroup.removeGuardianMember(this);
- }
-
- public void addException(GlobalException ex) {
- exceptionQueue.add(ex);
- }
-
- public void setService(BlockingInterface service) {
- this.service = service;
- }
-
- public Context getCurrentContext() {
- return contextList.peek();
- }
-
- public BlockingInterface getService() {
- return service;
- }
-
- public void enableContext(Context context) {
- //Update the context list with the related set of exceptions
- contextList.push(context);
-
- if (contextList.size() == 2) {
- JoinException ex = new JoinException();
- ex.setSignalingContext(context);
- ex.putSignalingParticipant(getParticipantIdentifier());
- gthrow(ex, null);
- }
-
- }
-
- public void removeContext() {
- if (!contextList.isEmpty()) {
- 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());
-
- guardianGroup.gthrow(ex, participantList);
- exceptionThrown = true;
- } else {
- /*if (service instanceof BlockingInterface && !service.isBlocked()) {
- service.block();
- }*/
- 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 void setUniqueParticipantID(int id) {
- this.id = id;
- }
-
- public void removeService() {
- this.service = null;
- }
-
- public int getParticipantState() {
- return participantState;
- }
-
- public void setParticipantState(int state) {
- this.participantState = state;
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java
deleted file mode 100644
index 9ddd22a2fd..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.guardian;
-
-import java.util.List;
-
-//@Remotable
-public interface GuardianPrimitives {
-
- //Methods to manage contexts
- public void enableContext(Context context);
-
- public void removeContext();
-
- //Methods to control the signaling of exceptions
- public void gthrow(GlobalExceptionInterface ex, List<String> participantList);
-
- public boolean propagate(GlobalExceptionInterface ex);
-
- //Method to check pending global exceptions
- public void checkExceptionStatus() throws GlobalException;
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java
deleted file mode 100644
index 3df76b0596..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.guardian;
-
-public class InvalidNodeException extends RuntimeException {
-
- public InvalidNodeException() {
- super();
- }
-
- public InvalidNodeException(String message) {
- super(message);
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java
deleted file mode 100644
index 30e750941e..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.guardian;
-
-public class InvalidRegularExpression extends RuntimeException {
-
- public InvalidRegularExpression() {
- super();
- }
-
- public InvalidRegularExpression(String message) {
- super(message);
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java
deleted file mode 100644
index b14ebeac2b..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.guardian;
-
-class JoinException extends GlobalException {
-
- public JoinException() {
- super();
- }
-
- public JoinException(String message) {
- super(message);
- }
-
- public JoinException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public JoinException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java
deleted file mode 100644
index 04e892f4bd..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.guardian;
-
-class LeaveException extends GlobalException {
-
- public LeaveException() {
- super();
- }
-
- public LeaveException(String message) {
- super(message);
- }
-
- public LeaveException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public LeaveException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java
deleted file mode 100644
index 09dd0673eb..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.guardian;
-
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-
-public class ResolutionTreeUtils {
-
- //E: Euler tour of the tree obtained by listing the nodes visited in a depth first search of the tree starting from the root. Contains 2n-1 elements
- private List<String> eulerTour;
- //L: Array of level numbers such that L[i] contains the tree-depth of the node E[i]. Contains 2n-1 elements
- private List<Integer> levels;
- //R: Map of size n such that R<K> contains the index of the first ocurrence of node 'K' in E
- private Map<String, Integer> rMap;
- private OMElement root;
- private int treeSize;
-
- public ResolutionTreeUtils() {
- init(null);
- }
-
- public ResolutionTreeUtils(OMElement root) {
- init(root);
- }
-
- public void setRoot(OMElement root) {
- init(root);
- }
-
- public List<String> getEulerTourDepthFirstSearch() {
-
- if (root == null) {
- throw new NullPointerException("The root musn't be null");
- }
-
- if (eulerTour == null) {
- eulerTour = new LinkedList<String>();
- levels = new LinkedList<Integer>();
-
- eulerTourDFSRecursive(root, 0);
- }
-
- return eulerTour;
- }
-
- public String getLowestCommonAncestor(String node1, String node2) {
- String lca = null;
- Integer indexNode1, indexNode2;
-
- Map<String, Integer> r = getRMap();
-
- indexNode1 = r.get(node1);
- indexNode2 = r.get(node2);
-
- //Check nodes existence
- if (indexNode1 == null && indexNode2 == null) {
- throw new InvalidNodeException("Could not find the specified nodes: " + node1 + " and " + node2);
- } else if (indexNode1 == null) {
- throw new InvalidNodeException("Could not find the specified nodes: " + node1);
- } else if (indexNode2 == null) {
- throw new InvalidNodeException("Could not find the specified nodes: " + node2);
- }
-
- int indexLCA;
- if (indexNode1 < indexNode2) {
- indexLCA = getRangeMinimumQuery(levels, indexNode1, indexNode2);
- } else {
- indexLCA = getRangeMinimumQuery(levels, indexNode2, indexNode1);
- }
-
- lca = eulerTour.get(indexLCA);
-
- return lca;
- }
-
- //Get the index of the smallest element between beginIndex and endIndex (both inclusive) in the list
- private int getRangeMinimumQuery(List list, int beginIndex, int endIndex) {
-
- List sublist = list.subList(beginIndex, endIndex + 1);
-
- Object elem = Collections.min(sublist);
-
- return sublist.indexOf(elem) + beginIndex;
- }
-
- private void init(OMElement root) {
- this.root = root;
- eulerTour = null;
- levels = null;
- rMap = null;
- treeSize = 0;
- }
-
- private void eulerTourDFSRecursive(OMElement node, int level) {
- String classAttribute = ((OMAttribute) node.getAllAttributes().next()).getAttributeValue();
- eulerTour.add(classAttribute);
-
- levels.add(level);
- treeSize++;
-
- Iterator children = node.getChildElements();
-
- OMElement child;
- while (children.hasNext()) {
- child = (OMElement) children.next();
- eulerTourDFSRecursive(child, level + 1);
- eulerTour.add(classAttribute);
- levels.add(level);
- }
- }
-
- private Map<String, Integer> getRMap() {
- if (rMap == null) {
- rMap = new Hashtable<String, Integer>();
-
- List<String> tour = getEulerTourDepthFirstSearch();
- for (int i = 0; i < tour.size(); i++) {
- String key = tour.get(i);
- if (!rMap.containsKey(key)) {
- rMap.put(key, i);
- }
-
- if (rMap.size() == treeSize) {
- break;
- }
- }
- }
- return rMap;
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java
deleted file mode 100644
index b7ede6d530..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.guardian;
-
-class SuspendException extends GlobalException {
-
- public SuspendException() {
- super();
- }
-
- public SuspendException(String message) {
- super(message);
- }
-
- public SuspendException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public SuspendException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java
deleted file mode 100644
index 81e3844280..0000000000
--- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.guardian;
-
-public class UnhandledException extends GlobalException {
-
- public UnhandledException() {
- super();
- }
-
- public UnhandledException(String message) {
- super(message);
- }
-
- public UnhandledException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public UnhandledException(Throwable cause) {
- super(cause);
- }
-}