From c4800a6c1b96b327f7f964ebf468348624363abf Mon Sep 17 00:00:00 2001 From: dougsleite Date: Thu, 29 Oct 2009 18:45:38 +0000 Subject: - Changing the implementation-guardian to work with the policy-guardianException module - Adding the policy-guardianException module: The guardian member is implemented as policies git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@831060 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/dougsleite/implementation-guardian/pom.xml | 6 + .../implementation/guardian/GuardianMember.java | 2 - .../guardian/GuardianPrimitives.java | 2 +- .../implementation/guardian/common/Context.java | 1 - .../guardian/impl/GuardianGroupImpl.java | 6 +- .../guardian/impl/GuardianMemberImpl.java | 177 ------------------ .../guardian/provider/GuardianGroupInvoker.java | 6 +- .../concurrentExceptions/primaryBackup.composite | 28 +-- .../primaryBackup/simple/primaryBackup.composite | 18 +- .../src/test/java/definitions.xml | 28 +++ .../guardian/GuardianImplementationTest.java | 77 -------- .../guardian/itests/primaryBackup/common/Node.java | 2 + .../itests/primaryBackup/common/NodeImpl.java | 43 +++-- .../primaryBackup/concurrentExceptions/Launch.java | 4 + .../itests/primaryBackup/simple/Launch.java | 2 + .../itests/primaryBackup/simple/Launch2.java | 2 + .../policy-guardianExceptionHandling/.classpath | 10 + .../policy-guardianExceptionHandling/.project | 23 +++ .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + .../policy-guardianExceptionHandling/LICENSE | 205 +++++++++++++++++++++ .../policy-guardianExceptionHandling/NOTICE | 6 + .../policy-guardianExceptionHandling/pom.xml | 100 ++++++++++ ...eptionHandlingImplementationPolicyProvider.java | 59 ++++++ .../GuardianExceptionHandlingPolicy.java | 38 ++++ ...ExceptionHandlingPolicyDefinitionsProvider.java | 61 ++++++ ...GuardianExceptionHandlingPolicyInterceptor.java | 172 +++++++++++++++++ ...dianExceptionHandlingPolicyProviderFactory.java | 58 ++++++ .../GuardianMemberFactoryImpl.java | 80 ++++++++ .../GuardianMemberImpl.java | 186 +++++++++++++++++++ .../InvalidPolicyAssociationException.java | 38 ++++ ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 ++ ...che.tuscany.sca.provider.SCADefinitionsProvider | 19 ++ .../guardianExceptionHandling/definitions.xml | 31 ++++ 34 files changed, 1202 insertions(+), 321 deletions(-) delete mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml delete mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/.classpath create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/.project create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider create mode 100644 sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml (limited to 'sandbox/dougsleite') diff --git a/sandbox/dougsleite/implementation-guardian/pom.xml b/sandbox/dougsleite/implementation-guardian/pom.xml index dcd91936e6..3752c6ded5 100644 --- a/sandbox/dougsleite/implementation-guardian/pom.xml +++ b/sandbox/dougsleite/implementation-guardian/pom.xml @@ -37,6 +37,12 @@ + + org.apache.tuscany.sca + tuscany-policy-guardianExceptionHandling + 1.6-SNAPSHOT + + org.apache.tuscany.sca tuscany-host-embedded diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java index b82bf082b1..ec562b082b 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java @@ -29,8 +29,6 @@ public interface GuardianMember extends GuardianPrimitives { public String getParticipantIdentifier(); - public void setUniqueParticipantID(int id); - public int getParticipantState(); public void setParticipantState(int state); diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java index c50e855d30..3aa014ee12 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java @@ -29,7 +29,7 @@ public interface GuardianPrimitives { //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 participantList); diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java index 95c6f3bed6..6eb777b587 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java @@ -26,7 +26,6 @@ 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> exceptionList; diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java index 5a243560e3..9094fc248d 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java @@ -102,18 +102,18 @@ public class GuardianGroupImpl implements GuardianGroup { 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."); } diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java deleted file mode 100644 index 80b9321e79..0000000000 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java +++ /dev/null @@ -1,177 +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.implementation.guardian.impl; - -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.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -@Service(GuardianMember.class) -@Scope("COMPOSITE") -public class GuardianMemberImpl implements GuardianMember { - - private int participantState; - private Stack contextList; - - private Queue 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(); - contextList.add(Context.INIT_CONTEXT); - exceptionQueue = new LinkedList(); - 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 Context getCurrentContext() { - return contextList.peek(); - } - - - 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 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 { - 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 int getParticipantState() { - return participantState; - } - - public void setParticipantState(int state) { - this.participantState = state; - } -} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java index 8f393ebcb9..987e211a48 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java @@ -48,7 +48,8 @@ public class GuardianGroupInvoker implements Invoker { @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 @@ public class GuardianGroupInvoker implements Invoker { @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); diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite index fcb78e3879..a337d40b70 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite @@ -25,48 +25,28 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite index 85af4efd48..a00847573f 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite @@ -23,27 +23,17 @@ name="guardianTest"> - - + + - - + + - - - - - - - - - - diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml b/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml new file mode 100644 index 0000000000..0793e69334 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/definitions.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java deleted file mode 100644 index ba4f6230d8..0000000000 --- a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java +++ /dev/null @@ -1,77 +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.implementation.guardian; - -import org.apache.tuscany.sca.implementation.guardian.*; -import org.apache.tuscany.sca.host.embedded.SCADomain; -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.impl.GuardianMemberImpl; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class GuardianImplementationTest { - -// private SCADomain scaDomain; -// private GuardianGroup guardian; -// -// @Before -// public void init() throws Exception { -// scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/implementation/guardian/guardianTest.composite"); -// guardian = scaDomain.getService(GuardianGroup.class, "GuardianComponent"); -// } -// -// @Test -// public void enabelContextTest() throws Exception { -// guardian.enableContext(Context.INIT_CONTEXT); -// } -// -// @After -// public void destroy() { -// scaDomain.close(); -// } - public static void main(String... args) { - - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/implementation/guardian/guardianTest.composite"); - GuardianGroup guardian = scaDomain.getService(GuardianGroup.class, "GuardianComponent"); - - System.out.println("\n#EnableContext invocation"); - guardian.enableContext(Context.INIT_CONTEXT); - - System.out.println("\n#RemoveContext invocation"); - guardian.removeContext(); - - System.out.println("\n#CheckExceptionStatus invocation"); - guardian.checkExceptionStatus(); - - System.out.println("\n#CheckExceptionStatus invocation"); - boolean value = guardian.propagate(new GlobalException()); - System.out.println("returned value: " + value); - - System.out.println("\n#AddGuardianMember invocation"); - guardian.addGuardianMember(new GuardianMemberImpl()); - - System.out.println("\n#RemoveGuardianMember invocation"); - value = guardian.removeGuardianMember(new GuardianMemberImpl()); - System.out.println("returned value: " + value); - - } - -} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java index 6aa9456816..8890f631d4 100644 --- a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java @@ -34,4 +34,6 @@ public interface Node { public void kill(); public boolean isDead(); + + public void setID(String pID); } diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java index 37f4f529f0..6004468f73 100644 --- a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java @@ -23,6 +23,7 @@ import java.util.List; 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 @@ public class NodeImpl implements Node, TestInterface { private int role; private String pID; private Queue 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 nodeList; private boolean forcePSFException; @@ -73,15 +74,14 @@ public class NodeImpl implements Node, TestInterface { 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 @@ public class NodeImpl implements Node, TestInterface { 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 @@ public class NodeImpl implements Node, TestInterface { } 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 @@ public class NodeImpl implements Node, TestInterface { } 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 @@ public class NodeImpl implements Node, TestInterface { 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 @@ public class NodeImpl implements Node, TestInterface { } 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 @@ public class NodeImpl implements Node, TestInterface { System.out.println(pID + "# Exception captured!: BackupJoinedException"); backupAvailable = true; } finally { - gm.removeContext(); + guardianGroup.removeContext(); } } } @@ -206,14 +209,14 @@ public class NodeImpl implements Node, TestInterface { 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 @@ public class NodeImpl implements Node, TestInterface { } 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) { diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java index ab0c21dba6..169f8e50d4 100644 --- a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java @@ -32,24 +32,28 @@ public class Launch { 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(); diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java index 86df9bc5f9..1206d45db2 100644 --- a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java @@ -32,12 +32,14 @@ public class Launch { 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(); diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java index 1c5fd26745..e08251e07a 100644 --- a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java @@ -32,12 +32,14 @@ public class Launch2 { 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(); diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath b/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath new file mode 100644 index 0000000000..f42fb64cfa --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/.project b/sandbox/dougsleite/policy-guardianExceptionHandling/.project new file mode 100644 index 0000000000..935115b5ef --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/.project @@ -0,0 +1,23 @@ + + + tuscany-policy-guardianExceptionHandling + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs b/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..91ffe469de --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs b/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000000..fdf8a00902 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs @@ -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 diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE b/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE @@ -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. + + + diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE b/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE @@ -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/). + diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml b/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml new file mode 100644 index 0000000000..3ccf37efb7 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml @@ -0,0 +1,100 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.6-SNAPSHOT + ../pom.xml + + tuscany-policy-guardianExceptionHandling + Apache Tuscany SCA Guardian Exception Handling Policy Model + + + + + org.apache.tuscany.sca + tuscany-contribution + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-policy + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution-impl + 1.6-SNAPSHOT + test + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + test + jar + + + org.apache.tuscany.sca + tuscany-implementation-guardian + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java + 1.6-SNAPSHOT + + + + + + + org.apache.felix + maven-bundle-plugin + + + + ${tuscany.version} + org.apache.tuscany.sca.policy.guardianExceptionHandling + ${pom.name} + org.apache.tuscany.sca.policy.guardianExceptionHandling* + + + + + + + + + + + + diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java new file mode 100644 index 0000000000..01ca3a0166 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java @@ -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; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java new file mode 100644 index 0000000000..a4179bd666 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java @@ -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) { + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java new file mode 100644 index 0000000000..b1ca3f2edc --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java @@ -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() { + 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); + } + } + +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java new file mode 100644 index 0000000000..a98b300aae --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java @@ -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 participantList = (List) ((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 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; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java new file mode 100644 index 0000000000..bd2d67ad6f --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java @@ -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 { + + 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; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java new file mode 100644 index 0000000000..2f5e9617ed --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.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 guardianMembers; + private static GuardianMemberFactoryImpl instance = null; + + public static GuardianMemberFactoryImpl getInstance() { + if (instance == null) { + instance = new GuardianMemberFactoryImpl(); + } + return instance; + } + + protected GuardianMemberFactoryImpl() { + guardianMembers = new HashMap(); + } + + 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; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java new file mode 100644 index 0000000000..5e9ae7853c --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java @@ -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 contextList; + private Queue 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(); + contextList.add(Context.INIT_CONTEXT); + exceptionQueue = new LinkedList(); + 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 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; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java new file mode 100644 index 0000000000..183e60c8be --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java @@ -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; + +public class InvalidPolicyAssociationException extends RuntimeException { + + public InvalidPolicyAssociationException() { + super(); + } + + public InvalidPolicyAssociationException(String message) { + super(message); + } + + public InvalidPolicyAssociationException(String message, Throwable cause) { + super(message, cause); + } + + public InvalidPolicyAssociationException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..7365a52151 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the policy extension +org.apache.tuscany.sca.policy.guardianExceptionHandling.GuardianExceptionHandlingPolicyProviderFactory;model=org.apache.tuscany.sca.policy.guardianExceptionHandling.GuardianExceptionHandlingPolicy diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..30c8b4f8fd --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for SCA Definitions Providers +org.apache.tuscany.sca.policy.guardianExceptionHandling.GuardianExceptionHandlingPolicyDefinitionsProvider \ No newline at end of file diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml new file mode 100644 index 0000000000..94bc0c023a --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml @@ -0,0 +1,31 @@ + + + + + + + + All messages to the guardian group implementation will be intercepted by the guardian member + + + \ No newline at end of file -- cgit v1.2.3