diff options
author | dougsleite <dougsleite@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-29 18:45:38 +0000 |
---|---|---|
committer | dougsleite <dougsleite@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-29 18:45:38 +0000 |
commit | c4800a6c1b96b327f7f964ebf468348624363abf (patch) | |
tree | 1f96f5b9b87b6f25fab6602ea4a4dfc042e99aca /sandbox | |
parent | a1a3fca873e35c3f7dd4036aa1a734df3b7100e9 (diff) |
- 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
Diffstat (limited to 'sandbox')
33 files changed, 1057 insertions, 176 deletions
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 @@ -39,6 +39,12 @@ <dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-guardianExceptionHandling</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
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<String> 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<Class<? extends GlobalException>> 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/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 @@ <component name="Participant1"> <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember1"/> + <reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/> <reference name="nodes" target="Participant2 Participant3 Participant4"/> </component> <component name="Participant2"> <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember2"/> + <reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/> <reference name="nodes" target="Participant1 Participant3 Participant4"/> </component> <component name="Participant3"> <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember3"/> + <reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/> <reference name="nodes" target="Participant1 Participant2 Participant4"/> </component> <component name="Participant4"> <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember4"/> + <reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/> <reference name="nodes" target="Participant1 Participant2 Participant3"/> </component> - <component name="GuardianMember1"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianComponent"/> - </component> - - <component name="GuardianMember2"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianComponent"/> - </component> - - <component name="GuardianMember3"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianComponent"/> - </component> - - <component name="GuardianMember4"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianComponent"/> - </component> - <component name="GuardianComponent"> <tuscany:implementation.guardian> 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"> <component name="Participant1"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember1"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> + <reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/> <reference name="nodes" target="Participant2"/> </component> <component name="Participant2"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember2"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> + <reference name="guardian" target="GuardianComponent" requires="tuscany:guardianExceptionHandling"/> <reference name="nodes" target="Participant1"/> </component> - <component name="GuardianMember1"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianComponent"/> - </component> - - <component name="GuardianMember2"> - <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianComponent"/> - </component> - <component name="GuardianComponent"> <tuscany:implementation.guardian> 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 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:calc="http://calculator">
+
+ <!-- PolicySets -->
+ <policySet name="GuardianExceptionHandlingPolicy" provides="tuscany:guardianExceptionHandling" appliesTo="sca:implementation.java/sca:reference"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0"/>
+
+</definitions>
\ No newline at end of file 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<String> updates; - @Reference(name = "guardian_member", required = true) - public GuardianMember gm; + @Reference(name = "guardian", required = true) + public GuardianGroup guardianGroup; @Reference(name = "nodes", required = true) public List<Node> nodeList; private boolean forcePSFException; @@ -73,15 +74,14 @@ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" output="target/classes" path="src/main/java"/> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> + <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>tuscany-policy-guardianExceptionHandling</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.maven.ide.eclipse.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.maven.ide.eclipse.maven2Nature</nature> + </natures> +</projectDescription> 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 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-guardianExceptionHandling</artifactId>
+ <name>Apache Tuscany SCA Guardian Exception Handling Policy Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-guardian</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.policy.guardianExceptionHandling</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.policy.guardianExceptionHandling*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
+
+
+
+
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<URL>() { + public URL run() { + return getClass().getClassLoader().getResource(definitionsFile); + } + }); + + try { + URI uri = new URI(definitionsFile); + return (SCADefinitions)urlArtifactProcessor.read(null, + uri, + definitionsFileUrl); + } catch ( Exception e ) { + throw new SCADefinitionsProviderException(e); + } + } + +} 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<String> participantList = (List<String>) ((Object[]) msgBody)[1]; + gm.gthrow(ex, participantList); + msg.setBody(null); + return msg; + } else if (msgOperationName.equals(PROPAGATE)) { + GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msgBody)[0]; + boolean response = gm.propagate(ex); + msg.setBody(response); + return msg; + } else if (msgOperationName.equals(CHECK_EXCEPTION_STATUS)) { + try { + gm.checkExceptionStatus(); + msg.setBody(null); + } catch (GlobalException ex) { + msg.setFaultBody(ex); + } + return msg; + } + } else { + //throw new UnsupportedOperationException("Invocation of " + msgOperationName + " is not allowed"); + responseMsg = getNext().invoke(msg); + } + } catch (ClassNotFoundException ex) { + Logger.getLogger(GuardianExceptionHandlingPolicyInterceptor.class.getName()).log(Level.SEVERE, null, ex); + } + + return responseMsg; + } + + public Message invokeGuardianGroupOperation(String operationName, Message msg) { + + //Changing the operation + Operation desiredOperation = findOperation(operationName); + + msg.setOperation(desiredOperation); + + RuntimeComponent component = msg.getTo().getComponent(); + ImplementationProvider implProvider = component.getImplementationProvider(); + + Message responseMsg = implProvider.createInvoker(this.service, desiredOperation).invoke(msg); + + return responseMsg; + } + + private Operation findOperation(String method) { + if (method.contains(".")) { + method = method.substring(method.lastIndexOf(".") + 1); + } + + List<Operation> operations = runtimeWire.getTarget().getInterfaceContract().getInterface().getOperations(); + + Operation result = null; + for (Operation o : operations) { + if (o.getName().equalsIgnoreCase(method)) { + result = o; + break; + } + } + + return result; + } + + + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} 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<GuardianExceptionHandlingPolicy> { + + private ExtensionPointRegistry extensionPoints; + + public GuardianExceptionHandlingPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.extensionPoints = registry; + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + return null; + } + + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return null; + } + + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return new GuardianExceptionHandlingImplementationPolicyProvider(extensionPoints, component, service, binding); + } + + public Class getModelType() { + return null; + } +} 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<String, GuardianMember> guardianMembers; + private static GuardianMemberFactoryImpl instance = null; + + public static GuardianMemberFactoryImpl getInstance() { + if (instance == null) { + instance = new GuardianMemberFactoryImpl(); + } + return instance; + } + + protected GuardianMemberFactoryImpl() { + guardianMembers = new HashMap<String, GuardianMember>(); + } + + public GuardianMember createGuardianMember(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) { + GuardianMemberImpl gm = (GuardianMemberImpl) guardianMembers.get(componentName); + + if (gm == null) { + gm = new GuardianMemberImpl(componentName, msg, interceptor); + guardianMembers.put(componentName, gm); + + //Inform the Guardian Group of the new Guardian Member + Object msgBody = msg.getBody(); + + msg.setBody(gm); + interceptor.invokeGuardianGroupOperation("addGuardianMember", msg); + + msg.setBody(msgBody); + } + + gm.setMessage(msg); + gm.setGuardianExceptionHandlingPolicyInterceptor(interceptor); + + return gm; + } + + public GuardianMember removeGuardianMember(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) { + + GuardianMember gm = guardianMembers.remove(componentName); + + if (gm != null) { + + Object msgBody = msg.getBody(); + + msg.setBody(gm); + interceptor.invokeGuardianGroupOperation("removeGuardianMember", msg); + + msg.setBody(msgBody); + } + + return gm; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java index 80b9321e79..5e9ae7853c 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.implementation.guardian.impl; +package org.apache.tuscany.sca.policy.guardianExceptionHandling; import java.util.LinkedList; import java.util.List; @@ -31,42 +31,46 @@ 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") +import org.apache.tuscany.sca.invocation.Message; + public class GuardianMemberImpl implements GuardianMember { private int participantState; private Stack<Context> contextList; - private Queue<GlobalException> exceptionQueue; - @Reference(name = "guardian_group", required = true) - public GuardianGroup guardianGroup; - private int id; + private String id; + //FIXME: Review the usage of this variable private boolean exceptionThrown; + private Message msg; + private GuardianExceptionHandlingPolicyInterceptor interceptor; - public GuardianMemberImpl() { + protected GuardianMemberImpl(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) { contextList = new Stack<Context>(); contextList.add(Context.INIT_CONTEXT); exceptionQueue = new LinkedList<GlobalException>(); participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE; exceptionThrown = false; + + this.id = componentName; + this.msg = msg; + this.interceptor = interceptor; + } + + public void setGuardianExceptionHandlingPolicyInterceptor(GuardianExceptionHandlingPolicyInterceptor interceptor) { + this.interceptor = interceptor; + } + + public GuardianExceptionHandlingPolicyInterceptor getGuardianExceptionHandlingPolicyInterceptor() { + return this.interceptor; } - @Init - public void init() { - guardianGroup.addGuardianMember(this); + public void setMessage(Message msg) { + this.msg = msg; } - @Destroy - public void destroy() { - guardianGroup.removeGuardianMember(this); + public Message getMessage() { + return this.msg; } public void addException(GlobalException ex) { @@ -76,25 +80,28 @@ public class GuardianMemberImpl implements GuardianMember { 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) { + 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 void removeContext() { - if (!contextList.isEmpty()) { - contextList.pop(); - } + public Context removeContext() { +// if (contextList.size() > 1) { +// return contextList.pop(); +// } + return contextList.pop(); } //If participantList is null then signal to ALL participants @@ -106,7 +113,13 @@ public class GuardianMemberImpl implements GuardianMember { ex.setSignalingContext(getCurrentContext()); ex.putSignalingParticipant(getParticipantIdentifier()); - guardianGroup.gthrow(ex, participantList); + //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); @@ -163,10 +176,6 @@ public class GuardianMemberImpl implements GuardianMember { return participantIdentifier.toString(); } - public void setUniqueParticipantID(int id) { - this.id = id; - } - public int getParticipantState() { return participantState; } 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 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+
+ <!-- Policy Intents Defined by the SCA Runtime -->
+ <intent name="guardianExceptionHandling" constrains="sca:implementation.java/sca:reference">
+ <description>
+ All messages to the guardian group implementation will be intercepted by the guardian member
+ </description>
+ </intent>
+</definitions>
\ No newline at end of file |