summaryrefslogtreecommitdiffstats
path: root/sandbox/dougsleite/policy-guardianExceptionHandling
diff options
context:
space:
mode:
authordougsleite <dougsleite@13f79535-47bb-0310-9956-ffa450edef68>2009-10-29 18:45:38 +0000
committerdougsleite <dougsleite@13f79535-47bb-0310-9956-ffa450edef68>2009-10-29 18:45:38 +0000
commitc4800a6c1b96b327f7f964ebf468348624363abf (patch)
tree1f96f5b9b87b6f25fab6602ea4a4dfc042e99aca /sandbox/dougsleite/policy-guardianExceptionHandling
parenta1a3fca873e35c3f7dd4036aa1a734df3b7100e9 (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/dougsleite/policy-guardianExceptionHandling')
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/.classpath10
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/.project23
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.eclipse.jdt.core.prefs5
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/.settings/org.maven.ide.eclipse.prefs9
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/LICENSE205
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/NOTICE6
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/pom.xml100
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java59
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java38
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java61
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java172
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java58
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java80
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java186
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java38
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory19
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider19
-rw-r--r--sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml31
18 files changed, 1119 insertions, 0 deletions
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/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<Context> contextList;
+ private Queue<GlobalException> exceptionQueue;
+ private String id;
+
+ //FIXME: Review the usage of this variable
+ private boolean exceptionThrown;
+ private Message msg;
+ private GuardianExceptionHandlingPolicyInterceptor interceptor;
+
+ protected GuardianMemberImpl(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) {
+ contextList = new Stack<Context>();
+ contextList.add(Context.INIT_CONTEXT);
+ exceptionQueue = new LinkedList<GlobalException>();
+ participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE;
+ exceptionThrown = false;
+
+ this.id = componentName;
+ this.msg = msg;
+ this.interceptor = interceptor;
+ }
+
+ public void setGuardianExceptionHandlingPolicyInterceptor(GuardianExceptionHandlingPolicyInterceptor interceptor) {
+ this.interceptor = interceptor;
+ }
+
+ public GuardianExceptionHandlingPolicyInterceptor getGuardianExceptionHandlingPolicyInterceptor() {
+ return this.interceptor;
+ }
+
+ public void setMessage(Message msg) {
+ this.msg = msg;
+ }
+
+ public Message getMessage() {
+ return this.msg;
+ }
+
+ public void addException(GlobalException ex) {
+ exceptionQueue.add(ex);
+ }
+
+ public Context getCurrentContext() {
+ return contextList.peek();
+ }
+
+ public void enableContext(Context context) {
+ //Update the context list with the related set of exceptions
+
+ if (contextList.size() == 1) {
+ contextList.push(context);
+
+ JoinException ex = new JoinException();
+ ex.setSignalingContext(context);
+ ex.putSignalingParticipant(getParticipantIdentifier());
+ gthrow(ex, null);
+ } else {
+ contextList.push(context);
+ }
+
+ }
+
+ public Context removeContext() {
+// if (contextList.size() > 1) {
+// return contextList.pop();
+// }
+ return contextList.pop();
+ }
+
+ //If participantList is null then signal to ALL participants
+ public void gthrow(GlobalExceptionInterface ex, List<String> participantList) {
+ //1)Block the participant until raise an exception
+
+ if (!(ex instanceof SuspendException)) {
+ //Set the exception's parameters
+ ex.setSignalingContext(getCurrentContext());
+ ex.putSignalingParticipant(getParticipantIdentifier());
+
+ //Prepare the parameters
+ Object[] params = {ex, participantList};
+ msg.setBody(params);
+
+ interceptor.invokeGuardianGroupOperation("gthrow", msg);
+ //guardianGroup.gthrow(ex, participantList);
+
+ exceptionThrown = true;
+ } else {
+ setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE);
+ }
+ }
+
+ public boolean propagate(GlobalExceptionInterface ex) {
+ //1)Compares the current context with the exception's target context
+ return !getCurrentContext().equals(ex.getTargetContext());
+ }
+
+ public void checkExceptionStatus() throws GlobalException {
+
+ //Blocks until the state be diferent the SUSPENDED_STATE
+ while (participantState == GuardianGroup.SUSPENDED_PARTICIPANT_STATE && exceptionThrown) {
+ System.out.println(getParticipantIdentifier() + ": I am blocked!");
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException ex) {
+ Logger.getLogger(GuardianMemberImpl.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ exceptionThrown = false;
+ System.out.println(getParticipantIdentifier() + ": I am not blocked!");
+
+ GlobalException exc;
+
+ if ((exc = exceptionQueue.peek()) == null) {
+ System.out.println(getParticipantIdentifier() + "#No exception on exception queue");
+ return;
+ }
+
+ //Check if ex.targetContext() matches the participant id
+ //Eg. ex.targetContext(): Main and participant id: Init.Main.Backup -> should thrown the exception
+ //Test if the exception should be thrown in the target context
+ for (Context c : contextList) {
+ if (exc.getTargetContext().equals(c) && (c.equals(Context.INIT_CONTEXT) || c.getExceptionList().contains(exc.getClass()))) {
+ System.out.println(getParticipantIdentifier() + "#Returning an exception");
+ exceptionQueue.poll();
+ throw exc;
+ }
+ }
+
+ return;
+ }
+
+ public String getParticipantIdentifier() {
+ //1) Return the participant identifier -> context list dot separated
+ StringBuffer participantIdentifier = new StringBuffer();
+ participantIdentifier.append(this.id);
+ for (int i = 0; i < contextList.size(); i++) {
+ participantIdentifier.append("." + contextList.get(i).getName());
+ }
+ return participantIdentifier.toString();
+ }
+
+ public int getParticipantState() {
+ return participantState;
+ }
+
+ public void setParticipantState(int state) {
+ this.participantState = state;
+ }
+}
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