From f4f96f8c8ec04e4c1709d3037e57589145be12fa Mon Sep 17 00:00:00 2001 From: dougsleite Date: Mon, 28 Sep 2009 14:37:58 +0000 Subject: - Changing the guardian-model, policy-recoveryrules, policy-resolutiontrees to a new module: implementation-guardian; - The new module creates a new kind of implementation (implementation.guardian) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@819561 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/dougsleite/guardian-model/.classpath | 10 - sandbox/dougsleite/guardian-model/.project | 29 - .../.settings/org.eclipse.jdt.core.prefs | 5 - .../.settings/org.maven.ide.eclipse.prefs | 9 - sandbox/dougsleite/guardian-model/pom.xml | 106 ---- .../sequenceDiagram-externalException.jpg | Bin 135077 -> 0 bytes .../tuscany/sca/guardian/BlockingInterface.java | 30 - .../ConcurrentExceptionOcurrenceException.java | 38 -- .../org/apache/tuscany/sca/guardian/Constants.java | 81 --- .../org/apache/tuscany/sca/guardian/Context.java | 79 --- .../tuscany/sca/guardian/GlobalException.java | 85 --- .../sca/guardian/GlobalExceptionInterface.java | 54 -- .../apache/tuscany/sca/guardian/GuardianGroup.java | 32 - .../tuscany/sca/guardian/GuardianGroupImpl.java | 637 -------------------- .../tuscany/sca/guardian/GuardianMember.java | 40 -- .../tuscany/sca/guardian/GuardianMemberImpl.java | 184 ------ .../tuscany/sca/guardian/GuardianPrimitives.java | 38 -- .../tuscany/sca/guardian/InvalidNodeException.java | 30 - .../sca/guardian/InvalidRegularExpression.java | 30 - .../apache/tuscany/sca/guardian/JoinException.java | 39 -- .../tuscany/sca/guardian/LeaveException.java | 38 -- .../tuscany/sca/guardian/ResolutionTreeUtils.java | 153 ----- .../tuscany/sca/guardian/SuspendException.java | 38 -- .../tuscany/sca/guardian/UnhandledException.java | 38 -- .../guardian-model/src/main/resources/lcaTest.xml | 21 - .../resources/primaryNbackups-concurrent.composite | 75 --- .../src/main/resources/primaryNbackups.composite | 74 --- .../src/main/resources/primarybackup-ws.composite | 63 -- .../src/main/resources/primarybackup.composite | 52 -- .../src/main/resources/recoveryrules.xml | 56 -- .../src/main/resources/recoveryrules_nbackpus.xml | 58 -- .../recoveryrules_nbackpus_concurrent.xml | 82 --- .../src/main/resources/resolutionTree.xml | 8 - .../tuscany/sca/guardian/itests/LCATestCase.java | 114 ---- .../itests/concurrentexceptions/Launch.java | 67 --- .../common/ApplyUpdateFailureException.java | 22 - .../common/BackupFailedException.java | 24 - .../common/BackupJoinedException.java | 24 - .../guardian/itests/primaryBackup/common/Node.java | 34 -- .../itests/primaryBackup/common/NodeImpl.java | 312 ---------- .../PrimaryBackupFailedTogetherException.java | 26 - .../common/PrimaryExistsException.java | 24 - .../common/PrimaryFailedException.java | 24 - .../common/PrimaryServiceFailureException.java | 24 - .../itests/primaryBackup/common/TestInterface.java | 26 - .../itests/primaryBackup/nbackups/Launch.java | 64 -- .../itests/primaryBackup/nbackups/Launch2.java | 70 --- .../itests/primaryBackup/nbackups/Launch3.java | 71 --- .../itests/primaryBackup/simple/Launch.java | 52 -- .../itests/primaryBackup/simple/Launch2.java | 52 -- .../dougsleite/implementation-guardian/.classpath | 10 + .../dougsleite/implementation-guardian/.project | 29 + sandbox/dougsleite/implementation-guardian/pom.xml | 94 +++ .../sequenceDiagram-externalException.jpg | Bin 0 -> 135077 bytes .../implementation/guardian/BlockingInterface.java | 31 + .../sca/implementation/guardian/GuardianGroup.java | 29 + .../guardian/GuardianGroupImplementation.java | 29 + .../GuardianGroupImplementationFactory.java | 24 + .../implementation/guardian/GuardianMember.java | 37 ++ .../guardian/GuardianPrimitives.java | 41 ++ .../sca/implementation/guardian/RecoveryRules.java | 32 + .../implementation/guardian/ResolutionTrees.java | 32 + .../ConcurrentExceptionOcurrenceException.java | 38 ++ .../implementation/guardian/common/Constants.java | 82 +++ .../implementation/guardian/common/Context.java | 79 +++ .../guardian/common/GlobalException.java | 85 +++ .../guardian/common/GlobalExceptionInterface.java | 54 ++ .../guardian/common/InvalidNodeException.java | 30 + .../common/InvalidRegularExpressionException.java | 30 + .../guardian/common/JoinException.java | 39 ++ .../guardian/common/LeaveException.java | 38 ++ .../guardian/common/ResolutionTreeUtils.java | 153 +++++ .../guardian/common/SuspendException.java | 38 ++ .../guardian/common/UnhandledException.java | 38 ++ .../guardian/impl/GuardianGroupImpl.java | 644 +++++++++++++++++++++ .../GuardianGroupImplementationFactoryImpl.java | 43 ++ .../impl/GuardianGroupImplementationImpl.java | 134 +++++ .../guardian/impl/GuardianMemberImpl.java | 177 ++++++ .../guardian/impl/RecoveryRulesImpl.java | 33 ++ .../guardian/impl/ResolutionTreesImpl.java | 33 ++ .../GuardianGroupImplementationProvider.java | 115 ++++ ...GuardianGroupImplementationProviderFactory.java | 38 ++ .../guardian/provider/GuardianGroupInvoker.java | 163 ++++++ .../xml/GuardianGroupImplementationProcessor.java | 144 +++++ .../guardian/xml/RecoveryRulesProcessor.java | 158 +++++ .../guardian/xml/ResolutionTreesProcessor.java | 157 +++++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...ion.guardian.GuardianGroupImplementationFactory | 19 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../implementation/guardian/guardianTest.composite | 36 ++ .../concurrentExceptions/primaryBackup.composite | 81 +++ .../concurrentExceptions/recoveryRules.xml | 82 +++ .../itests/primaryBackup/resolutionTrees.xml | 8 + .../primaryBackup/simple/primaryBackup.composite | 58 ++ .../itests/primaryBackup/simple/recoveryRules.xml | 56 ++ .../sca/implementation/guardian/lcaTest.xml | 21 + .../src/main/resources/resources.tar.gz | Bin 0 -> 2441 bytes .../guardian/GuardianImplementationTest.java | 77 +++ .../sca/implementation/guardian/LCATestCase.java | 115 ++++ .../common/ApplyUpdateFailureException.java | 22 + .../common/BackupFailedException.java | 24 + .../common/BackupJoinedException.java | 24 + .../guardian/itests/primaryBackup/common/Node.java | 37 ++ .../itests/primaryBackup/common/NodeImpl.java | 282 +++++++++ .../PrimaryBackupFailedTogetherException.java | 26 + .../common/PrimaryExistsException.java | 24 + .../common/PrimaryFailedException.java | 24 + .../common/PrimaryServiceFailureException.java | 24 + .../itests/primaryBackup/common/TestInterface.java | 26 + .../primaryBackup/concurrentExceptions/Launch.java | 69 +++ .../itests/primaryBackup/simple/Launch.java | 55 ++ .../itests/primaryBackup/simple/Launch2.java | 54 ++ sandbox/dougsleite/policy-recoveryrules/pom.xml | 84 --- .../policy/recoveryrules/RecoveryRulesPolicy.java | 49 -- .../RecoveryRulesPolicyDefinitionsProvider.java | 59 -- .../RecoveryRulesPolicyProcessor.java | 157 ----- .../RecoveryRulesPolicyProviderFactory.java | 55 -- ...ca.contribution.processor.StAXArtifactProcessor | 19 - ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 - ...che.tuscany.sca.provider.SCADefinitionsProvider | 19 - .../sca/policy/recoveryrules/definitions.xml | 31 - .../policy/recoveryrules/PolicyReadTestCase.java | 96 --- .../sca/policy/recoveryrules/test_policies.xml | 33 -- .../dougsleite/policy-resolutiontrees/.classpath | 10 - sandbox/dougsleite/policy-resolutiontrees/.project | 23 - .../.settings/org.eclipse.jdt.core.prefs | 5 - .../.settings/org.maven.ide.eclipse.prefs | 9 - sandbox/dougsleite/policy-resolutiontrees/pom.xml | 93 --- .../resolutiontrees/ResolutionTreesPolicy.java | 49 -- .../ResolutionTreesPolicyDefinitionsProvider.java | 59 -- .../ResolutionTreesPolicyProcessor.java | 157 ----- .../ResolutionTreesPolicyProviderFactory.java | 55 -- ...ca.contribution.processor.StAXArtifactProcessor | 19 - ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 - ...che.tuscany.sca.provider.SCADefinitionsProvider | 19 - .../sca/policy/resolutiontrees/definitions.xml | 31 - .../policy/resolutiontrees/PolicyReadTestCase.java | 96 --- .../sca/policy/resolutiontrees/test_policies.xml | 36 -- 138 files changed, 4213 insertions(+), 4643 deletions(-) delete mode 100644 sandbox/dougsleite/guardian-model/.classpath delete mode 100644 sandbox/dougsleite/guardian-model/.project delete mode 100644 sandbox/dougsleite/guardian-model/.settings/org.eclipse.jdt.core.prefs delete mode 100644 sandbox/dougsleite/guardian-model/.settings/org.maven.ide.eclipse.prefs delete mode 100644 sandbox/dougsleite/guardian-model/pom.xml delete mode 100644 sandbox/dougsleite/guardian-model/sequenceDiagram-externalException.jpg delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/lcaTest.xml delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups-concurrent.composite delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups.composite delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/primarybackup-ws.composite delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/primarybackup.composite delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules.xml delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus.xml delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus_concurrent.xml delete mode 100644 sandbox/dougsleite/guardian-model/src/main/resources/resolutionTree.xml delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/LCATestCase.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/concurrentexceptions/Launch.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupFailedException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupJoinedException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/Node.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/NodeImpl.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryExistsException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryFailedException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/TestInterface.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch2.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch3.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch.java delete mode 100644 sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch2.java create mode 100644 sandbox/dougsleite/implementation-guardian/.classpath create mode 100644 sandbox/dougsleite/implementation-guardian/.project create mode 100644 sandbox/dougsleite/implementation-guardian/pom.xml create mode 100644 sandbox/dougsleite/implementation-guardian/sequenceDiagram-externalException.jpg create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/BlockingInterface.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroup.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementation.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementationFactory.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/RecoveryRules.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/ResolutionTrees.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ConcurrentExceptionOcurrenceException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Constants.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalExceptionInterface.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidNodeException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidRegularExpressionException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/JoinException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/LeaveException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ResolutionTreeUtils.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/SuspendException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/UnhandledException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationFactoryImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/RecoveryRulesImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/ResolutionTreesImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProvider.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProviderFactory.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/GuardianGroupImplementationProcessor.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/RecoveryRulesProcessor.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/ResolutionTreesProcessor.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/guardianTest.composite create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/recoveryRules.xml create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/resolutionTrees.xml create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/recoveryRules.xml create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/lcaTest.xml create mode 100644 sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/LCATestCase.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupFailedException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupJoinedException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryExistsException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryFailedException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/TestInterface.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java create mode 100644 sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java delete mode 100644 sandbox/dougsleite/policy-recoveryrules/pom.xml delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicy.java delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyDefinitionsProvider.java delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProcessor.java delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProviderFactory.java delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/main/resources/org/apache/tuscany/sca/policy/recoveryrules/definitions.xml delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/test/java/org/apache/tuscany/sca/policy/recoveryrules/PolicyReadTestCase.java delete mode 100644 sandbox/dougsleite/policy-recoveryrules/src/test/resources/org/apache/tuscany/sca/policy/recoveryrules/test_policies.xml delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/.classpath delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/.project delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/.settings/org.eclipse.jdt.core.prefs delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/.settings/org.maven.ide.eclipse.prefs delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/pom.xml delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicy.java delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyDefinitionsProvider.java delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProcessor.java delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProviderFactory.java delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/main/resources/org/apache/tuscany/sca/policy/resolutiontrees/definitions.xml delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/test/java/org/apache/tuscany/sca/policy/resolutiontrees/PolicyReadTestCase.java delete mode 100644 sandbox/dougsleite/policy-resolutiontrees/src/test/resources/org/apache/tuscany/sca/policy/resolutiontrees/test_policies.xml diff --git a/sandbox/dougsleite/guardian-model/.classpath b/sandbox/dougsleite/guardian-model/.classpath deleted file mode 100644 index 554ad2954f..0000000000 --- a/sandbox/dougsleite/guardian-model/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/.project b/sandbox/dougsleite/guardian-model/.project deleted file mode 100644 index a5f54ef1d3..0000000000 --- a/sandbox/dougsleite/guardian-model/.project +++ /dev/null @@ -1,29 +0,0 @@ - - - tuscany-guardian-model - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - org.devzuz.q.maven.jdt.core.mavenNature - - diff --git a/sandbox/dougsleite/guardian-model/.settings/org.eclipse.jdt.core.prefs b/sandbox/dougsleite/guardian-model/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 2f04a7646c..0000000000 --- a/sandbox/dougsleite/guardian-model/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Tue Jun 23 15:59:15 BRT 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/guardian-model/.settings/org.maven.ide.eclipse.prefs b/sandbox/dougsleite/guardian-model/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index c8dabf2f86..0000000000 --- a/sandbox/dougsleite/guardian-model/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Jun 23 15:58:52 BRT 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/guardian-model/pom.xml b/sandbox/dougsleite/guardian-model/pom.xml deleted file mode 100644 index a204957231..0000000000 --- a/sandbox/dougsleite/guardian-model/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 1.6-SNAPSHOT - ../pom.xml - - tuscany-guardian - Apache Tuscany SCA Guardian Model - - - - apache.incubator - http://people.apache.org/repo/m2-snapshot-repository - - - - - - - org.apache.tuscany.sca - tuscany-host-embedded - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-data-api - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-implementation-java-runtime - 1.6-SNAPSHOT - runtime - - - - org.apache.axis2 - axis2-jaxws - 1.5 - - - - org.apache.axis2 - axis2 - 1.5 - - - - org.apache.tuscany.sca - tuscany-policy-resolutiontrees - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy-recoveryrules - 1.6-SNAPSHOT - - - - - - - - org.apache.felix - maven-bundle-plugin - - - - ${tuscany.version} - org.apache.tuscany.sca.guardian - ${pom.name} - org.apache.tuscany.sca.guardian* - - - - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/sequenceDiagram-externalException.jpg b/sandbox/dougsleite/guardian-model/sequenceDiagram-externalException.jpg deleted file mode 100644 index 60060ca0e2..0000000000 Binary files a/sandbox/dougsleite/guardian-model/sequenceDiagram-externalException.jpg and /dev/null differ diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java deleted file mode 100644 index 848c4a874d..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -public interface BlockingInterface { - - //@OneWay - public void block(); - - //@OneWay - public void unblock(); - - public boolean isBlocked(); -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java deleted file mode 100644 index 30584f2d78..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -class ConcurrentExceptionOcurrenceException extends Exception { - - public ConcurrentExceptionOcurrenceException() { - super(); - } - - public ConcurrentExceptionOcurrenceException(String message) { - super(message); - } - - public ConcurrentExceptionOcurrenceException(String message, Throwable cause) { - super(message, cause); - } - - public ConcurrentExceptionOcurrenceException(Throwable cause) { - super(cause); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java deleted file mode 100644 index 9fa4db4f78..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import javax.xml.namespace.QName; - -public interface Constants { - - String RECOVERY_RULES = "recovery_rules"; - QName RECOVERY_RULES_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RECOVERY_RULES); - - String RULE = "rule"; - QName RULE_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RULE); - - String NAME = "name"; - QName NAME_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, NAME); - - String SIGNALED_EXCEPTION = "signaled_exception"; - QName SIGNALED_EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, SIGNALED_EXCEPTION); - - String PARTICIPANT = "participant"; - QName PARTICIPANT_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, PARTICIPANT); - - String MATCH = "match"; - QName MATCH_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MATCH); - - String THROW_EXCEPTION = "throw_exception"; - QName THROW_EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, THROW_EXCEPTION); - - String CLASS = "class"; - QName CLASS_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, CLASS); - - String TARGET_CONTEXT = "target_context"; - QName TARGET_CONTEXT_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, TARGET_CONTEXT); - - String MIN_PARTICIPANT_JOINED = "min_participant_joined"; - QName MIN_PARTICIPANT_JOINED_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MIN_PARTICIPANT_JOINED); - - String MAX_PARTICIPANT_JOINED = "max_participant_joined"; - QName MAX_PARTICIPANT_JOINED_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MAX_PARTICIPANT_JOINED); - - String AFFECTED_PARTICIPANTS = "affected_participants"; - QName AFFECTED_PARTICIPANTS_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, AFFECTED_PARTICIPANTS); - - String FIRST = "FIRST"; - QName FIRST_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, FIRST); - - String LAST = "LAST"; - QName LAST_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, LAST); - - String ALL = "ALL"; - QName ALL_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, ALL); - - String RESOLUTION_TREE = "resolution_tree"; - QName RESOLUTION_TREE_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RESOLUTION_TREE); - - String RESOLUTION_TREES = "resolution_trees"; - QName RESOLUTION_TREES_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RESOLUTION_TREES); - - String EXCEPTION_LEVEL = "exception_level"; - QName EXCEPTION_LEVEL_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, EXCEPTION_LEVEL); - - String EXCEPTION = "exception"; - QName EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, EXCEPTION); -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java deleted file mode 100644 index 3ac5d63a42..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import java.util.LinkedList; -import java.util.List; - -public class Context { - - public static Context CURRENT_CONTEXT = new Context("CURRENT_CONTEXT"); - public static Context INIT_CONTEXT = new Context("INIT_CONTEXT"); - public static Context GUARDIAN_CONTEXT = new Context("GUARDIAN_CONTEXT"); - - private String name; - private List> exceptionList; - - public Context() { - this(null); - } - - public Context(String name) { - this(name, new LinkedList>()); - } - - public Context(String name, List> exceptionList) { - this.name = name; - this.exceptionList = exceptionList; - } - - public void addException(Class ex) { - this.exceptionList.add(ex); - } - - public void setExceptionList(List> exceptionList) { - this.exceptionList = exceptionList; - } - - public List> getExceptionList() { - return this.exceptionList; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof Context && - (((Context) obj).getName().equals(this.getName()) || - this == Context.CURRENT_CONTEXT || - ((Context) obj) == Context.CURRENT_CONTEXT)); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java deleted file mode 100644 index b880db6aa1..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import java.util.LinkedList; -import java.util.List; - -public class GlobalException extends RuntimeException implements GlobalExceptionInterface { - - private List signalingParticipants; - private Context signalingContext; - private Context targetContext; - - public GlobalException() { - super(); - signalingParticipants = new LinkedList(); - } - - public GlobalException(String message) { - super(message); - signalingParticipants = new LinkedList(); - } - - public GlobalException(String message, Throwable cause) { - super(message, cause); - signalingParticipants = new LinkedList(); - } - - public GlobalException(Throwable cause) { - super(cause); - signalingParticipants = new LinkedList(); - } - - /** - * @return the signalingContext - */ - public Context getSignalingContext() { - return signalingContext; - } - - /** - * @param signalingContext the signalingContext to set - */ - public void setSignalingContext(Context signalingContext) { - this.signalingContext = signalingContext; - } - - /** - * @return the targetContext - */ - public Context getTargetContext() { - return targetContext; - } - - /** - * @param targetContext the targetContext to set - */ - public void setTargetContext(Context targetContext) { - this.targetContext = targetContext; - } - - public void putSignalingParticipant(String participant) { - signalingParticipants.add(participant); - } - - public List getSignalingParticipants() { - return signalingParticipants; - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java deleted file mode 100644 index 68a09a9bc8..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import java.util.List; - -public interface GlobalExceptionInterface { - - /** - * @return the signalingContext - */ - public Context getSignalingContext(); - - /** - * @param signalingContext the signalingContext to set - */ - public void setSignalingContext(Context signalingContext); - - /** - * @return the targetContext - */ - public Context getTargetContext(); - - /** - * @param targetContext the targetContext to set - */ - public void setTargetContext(Context targetContext); - - /** - * @return the signalingProcess - */ - public List getSignalingParticipants(); - - /** - * @param signalingProcess the signalingProcess to set - */ - public void putSignalingParticipant(String participant); -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java deleted file mode 100644 index 5119390a14..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import org.osoa.sca.annotations.Remotable; - -//@Remotable -public interface GuardianGroup extends GuardianPrimitives { - - public static int NORMAL_PARTICIPANT_STATE = 0; - public static int SUSPENDED_PARTICIPANT_STATE = 1; - - public void addGuardianMember(GuardianMember guardianMember); - - public boolean removeGuardianMember(GuardianMember guardianMember); -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java deleted file mode 100644 index f9fe5c2c59..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java +++ /dev/null @@ -1,637 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicyProcessor; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; -import org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicyProcessor; - -@Service(GuardianGroup.class) -@Scope("COMPOSITE") -public class GuardianGroupImpl implements GuardianGroup { - - private List guardianList; - private InnerGuardianGroupThread innerThread; - private List concurrentExList; - private Map resolutionTreeElements; - private ResolutionTreeUtils resolutionTreeUtils; - private Map ruleElements; - - public GuardianGroupImpl() { - guardianList = new LinkedList(); - concurrentExList = new LinkedList(); - innerThread = new InnerGuardianGroupThread(); - resolutionTreeUtils = new ResolutionTreeUtils(); - } - - @Property(name = "recovery_rules", required = false) - public void setRecoveryRules(String recoveryRules) { - try { - FileInputStream fileInputStream = new FileInputStream(recoveryRules); - XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); - - RecoveryRulesPolicyProcessor processor = new RecoveryRulesPolicyProcessor(null, null); - ruleElements = processor.read(xmlReader).getRuleElements(); - - } catch (ContributionReadException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } catch (XMLStreamException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } catch (FileNotFoundException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } - } - - @Property(name = "resolution_tree", required = false) - public void setResolutionTree(String resolutionTree) { - - try { - FileInputStream fileInputStream = new FileInputStream(resolutionTree); - XMLStreamReader resolutionTreeReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); - - ResolutionTreesPolicyProcessor processor = new ResolutionTreesPolicyProcessor(null, null); - resolutionTreeElements = processor.read(resolutionTreeReader).getResolutionTreeElements(); - - } catch (ContributionReadException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } catch (XMLStreamException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } catch (FileNotFoundException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } - } - - public void addGuardianMember(GuardianMember guardianMember) { - guardianList.add(guardianMember); - guardianMember.setUniqueParticipantID(guardianList.size() - 1); - } - - public void enableContext(Context context) { - System.out.println("Enable Context.. nothing to do!"); - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void removeContext() { - throw new UnsupportedOperationException("Not supported yet."); - } - - public synchronized void gthrow(GlobalExceptionInterface ex, List participantList) { - - concurrentExList.add(ex); - - //Sends a message representing the exception to the other guardian members - SuspendException suspendEx = new SuspendException(); - suspendEx.putSignalingParticipant(ex.getSignalingParticipants().get(0)); - - if (participantList == null) { - for (GuardianMember g : guardianList) { - g.gthrow(suspendEx, null); - } - } else { - for (GuardianMember g : guardianList) { - if (participantList.contains(g.getParticipantIdentifier()) || - g.getParticipantIdentifier().equals(ex.getSignalingParticipants().get(0))) { - g.gthrow(suspendEx, null); - } - } - } - - if (!innerThread.isRunning()) { - innerThread.setGlobalException(ex); - new Thread(innerThread).start(); - } - } - - public boolean propagate(GlobalExceptionInterface ex) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public void checkExceptionStatus() { - throw new UnsupportedOperationException("Not supported yet."); - } - - public boolean removeGuardianMember(GuardianMember guardianMember) { - return this.guardianList.remove(guardianMember); - } - - private class InnerGuardianGroupThread implements Runnable { - - private boolean isRunning; - private GlobalExceptionInterface ex = null; - - public InnerGuardianGroupThread() { - isRunning = false; - } - - public void setGlobalException(GlobalExceptionInterface ex) { - this.ex = ex; - } - - public GlobalExceptionInterface getGlobalException() { - return ex; - } - - public void run() { - isRunning = true; - - if (ex != null) { - - //Time window of 10 seconds just for tests - try { - Thread.sleep(10000); - } catch (InterruptedException ex1) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); - } - - try { - applyRecoveryRules(ex); - } catch (ConcurrentExceptionOcurrenceException ce) { - applyConcurrentRecoveryRules(); - } - - //Clear the concurrent exception list - concurrentExList.clear(); - - //Set up the participant state to NORMAL - for (GuardianMember gm : guardianList) { - if (gm.getParticipantState() == SUSPENDED_PARTICIPANT_STATE) { - gm.setParticipantState(NORMAL_PARTICIPANT_STATE); - } - } - } - isRunning = false; - } - - public boolean isRunning() { - return isRunning; - } - - private void applyRecoveryRules(GlobalExceptionInterface ex) throws ConcurrentExceptionOcurrenceException { - ruleTag(ex, ruleElements.values().iterator()); - } - - private void ruleTag(GlobalExceptionInterface ex, Iterator ruleElements) throws ConcurrentExceptionOcurrenceException { - String signaledException; - String exceptionName; - - OMElement rule; - while (ruleElements.hasNext()) { - - rule = ruleElements.next(); - signaledException = getAttributeValue(rule, Constants.SIGNALED_EXCEPTION); - exceptionName = ex.getClass().getName(); - - if (signaledException.equals(exceptionName)) { - participantExceptionTag(ex, rule.getChildElements()); - break; - } - } - } - - private void participantExceptionTag(GlobalExceptionInterface ex, Iterator participantElements) throws ConcurrentExceptionOcurrenceException { - String matchParticipant; - List gmList; - - OMElement participant; - while (participantElements.hasNext()) { - participant = participantElements.next(); - - matchParticipant = getAttributeValue(participant, Constants.MATCH); - gmList = getMatchingParticipants(matchParticipant, ex); - - if (!gmList.isEmpty()) { - throwExceptionTag(gmList, ex, participant.getChildElements()); - } - } - } - - private void throwExceptionTag(List gmList, GlobalExceptionInterface ex, Iterator throwExceptionElements) throws ConcurrentExceptionOcurrenceException { - String className; - String targetContextName; - Integer minParticipantJoined; - Integer maxParticipantJoined; - - OMElement throwException; - while (throwExceptionElements.hasNext()) { - - throwException = throwExceptionElements.next(); - - className = getAttributeValue(throwException, Constants.CLASS); - targetContextName = getAttributeValue(throwException, Constants.TARGET_CONTEXT); - - try { - minParticipantJoined = Integer.parseInt(getAttributeValue(throwException, Constants.MIN_PARTICIPANT_JOINED)); - } catch (NumberFormatException nex) { - minParticipantJoined = null; - } - - try { - maxParticipantJoined = Integer.parseInt(getAttributeValue(throwException, Constants.MAX_PARTICIPANT_JOINED)); - } catch (NumberFormatException nexc) { - maxParticipantJoined = null; - } - - //Test the min and max joined participants condition - if (minParticipantJoined != null && maxParticipantJoined != null) { - if (!(guardianList.size() >= minParticipantJoined && guardianList.size() < maxParticipantJoined)) { - break; - } - } else if (minParticipantJoined != null) { - if (!(guardianList.size() >= minParticipantJoined)) { - break; - } - } else if (minParticipantJoined != null) { - if (!(guardianList.size() >= minParticipantJoined)) { - break; - } - } - - // - String affectedParticipants = affectedParticipantsTag(throwException.getChildElements()); - int index = -1; - - //Verify if the parameter is an index - try { - index = Integer.parseInt(affectedParticipants); - } catch (NumberFormatException nexc) { - index = -1; - } - - //Create the new exception instance - Class exceptionClass; - try { - exceptionClass = Class.forName(className); - - Context targetContext; - if (targetContextName.toUpperCase().equals(Context.CURRENT_CONTEXT.getName().toUpperCase())) { - targetContext = Context.CURRENT_CONTEXT; - } else if (targetContextName.toUpperCase().equals(Context.INIT_CONTEXT.getName().toUpperCase())) { - targetContext = Context.INIT_CONTEXT; - } else { - targetContext = new Context(targetContextName); - } - GlobalException newException = (GlobalException) exceptionClass.newInstance(); - - newException.setTargetContext(targetContext); - newException.setSignalingContext(ex.getSignalingContext()); - newException.putSignalingParticipant(ex.getSignalingParticipants().toString()); - - //Check concurrent exception existence - if (concurrentExList.size() > 1) { - throw new ConcurrentExceptionOcurrenceException(concurrentExList.toString()); - } - - //Add the exception to the participants matched - if (index != -1) { - gmList.get(index).addException(newException); - } else if (affectedParticipants != null && affectedParticipants.length() != 0) { - if (affectedParticipants.toUpperCase().equals(Constants.FIRST)) { - gmList.get(0).addException(newException); - } else if (affectedParticipants.toUpperCase().equals(Constants.LAST)) { - gmList.get(gmList.size() - 1).addException(newException); - } else if (affectedParticipants.toUpperCase().equals(Constants.ALL)) { - for (GuardianMember gm : gmList) { - gm.addException(newException); - } - } - } else { - for (GuardianMember gm : gmList) { - gm.addException(newException); - } - } - - } catch (InstantiationException ex1) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); - } catch (IllegalAccessException ex1) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); - } catch (ClassNotFoundException ex1) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); - } - } - } - - private String affectedParticipantsTag(Iterator affectedParticipantElements) { - - String affectedParticipantValue = null; - - OMElement affectedParticipant; - while (affectedParticipantElements.hasNext()) { - - affectedParticipant = affectedParticipantElements.next(); - affectedParticipantValue = affectedParticipant.getText(); - } - - if (affectedParticipantValue != null && affectedParticipantValue.length() == 0) { - affectedParticipantValue = null; - } - - return affectedParticipantValue; - } - - private String getAttributeValue(OMElement element, String attributeName) { - OMAttribute at; - Iterator it = element.getAllAttributes(); - - while (it.hasNext()) { - at = (OMAttribute) it.next(); - if (at.getLocalName().equals(attributeName)) { - return at.getAttributeValue(); - } - } - - return null; - } - - private void applyConcurrentRecoveryRules() { - - boolean concurrentExOcurrence = false; - List copyConcurrentExList; - GlobalExceptionInterface resolvedEx; - - do { - System.out.println("Concurrent exceptions: " + concurrentExList); - - copyConcurrentExList = new LinkedList(concurrentExList); - - resolvedEx = checkExceptionResolutionTrees(copyConcurrentExList, resolutionTreeElements.values().iterator()); - - concurrentExList.clear(); - - System.out.println("Resolved Exception: " + resolvedEx); - if (resolvedEx != null) { - System.out.println("List of participants: " + resolvedEx.getSignalingParticipants()); - } - - try { - //Process the exception list sequentially - if (resolvedEx == null) { - for (GlobalExceptionInterface ex : copyConcurrentExList) { - applyRecoveryRules(ex); - } - } else { - applyRecoveryRules(resolvedEx); - } - - } catch (ConcurrentExceptionOcurrenceException exc) { - concurrentExOcurrence = true; - break; - } - } while (concurrentExOcurrence); - } - - //FIXME: Need to check the exception level - private GlobalExceptionInterface checkExceptionResolutionTrees(List exceptionList, Iterator resolutionTreesElements) { - - OMElement tree; - OMElement root; - String exceptionLevel = null; - GlobalExceptionInterface resolvedEx = null; - - while (resolutionTreesElements.hasNext()) { - tree = (OMElement) resolutionTreesElements.next(); - exceptionLevel = tree.getAttributeValue(Constants.EXCEPTION_LEVEL_QNAME); - - root = (OMElement) tree.getChildElements().next(); - resolvedEx = checkExceptionResolutionTree(exceptionList, root); - - if (resolvedEx != null) { - break; - } - } - - return resolvedEx; - } - - //Search for the root of the smallest subtree that contains all the concurrently signaled exceptions. If not found, return null. - private GlobalExceptionInterface checkExceptionResolutionTree(List exceptionList, OMElement rootTree) { - - resolutionTreeUtils.setRoot(rootTree); - String ex1, ex2; - GlobalExceptionInterface resolvedEx = null; - - ex1 = exceptionList.get(0).getClass().getName(); - for (int i = 1; i < exceptionList.size(); i++) { - ex2 = exceptionList.get(i).getClass().getName(); - - try { - ex1 = resolutionTreeUtils.getLowestCommonAncestor(ex1, ex2); - } catch (InvalidNodeException invalidNodeException) { - ex1 = null; - break; - } - } - - if (ex1 != null) { - Class exceptionClass; - - try { - exceptionClass = Class.forName(ex1); - resolvedEx = (GlobalException) exceptionClass.newInstance(); - - for (GlobalExceptionInterface ex : exceptionList) { - resolvedEx.putSignalingParticipant(ex.getSignalingParticipants().get(0)); - } - - } catch (InstantiationException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } catch (ClassNotFoundException ex) { - Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); - } - - return resolvedEx; - - } else { - return null; - } - } - - private List getMatchingParticipants(String regularExpression, GlobalExceptionInterface signaledException) { - List matchingParticipants = new LinkedList(); - String[] splitByComma = regularExpression.split(","); - - //Invalid regular expression - if (splitByComma.length > 2) { - throw new InvalidRegularExpression("The comma ',' operator can only be applied for two expressions"); - } - - //There is no comma on the regular expression - if (splitByComma.length == 1) { - - if (regularExpression.toUpperCase().equals("SIGNALER")) { - for (GuardianMember gm : guardianList) { - if (signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { - matchingParticipants.add(gm); - } - } - } else if (regularExpression.toUpperCase().equals("!SIGNALER")) { - for (GuardianMember gm : guardianList) { - if (!signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { - matchingParticipants.add(gm); - } - } - - } else { - //Create an java regular expression - String re = createJavaRegularExpression(regularExpression); - - for (GuardianMember gm : guardianList) { - if (gm.getParticipantIdentifier().matches(re)) { - matchingParticipants.add(gm); - } - } - } - - } //There is comma on the regular expression - else { - - String element; - int index = -1; - for (int i = 0; i < splitByComma.length; i++) { - element = splitByComma[i].toUpperCase(); - if (element.equals("SIGNALER") || element.equals("!SIGNALER")) { - if (index == -1) { - index = i; - } else { - index = -1; - } - } - } - - //Invalid expression - if (index == -1) { - throw new InvalidRegularExpression("The comma ',' requires a SIGNALER or !SIGNALER element in one side of the expression"); - } - - String re = createJavaRegularExpression(splitByComma[1 - index]); - - for (GuardianMember gm : guardianList) { - - //Test if the participant matches with the regular expression - if (gm.getParticipantIdentifier().matches(re)) { - - //Test if the participant is Signaler - if (splitByComma[index].toUpperCase().equals("SIGNALER")) { - - if (signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { - matchingParticipants.add(gm); - } - } //Test if the participant is not Signaler - else { - if (!signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { - matchingParticipants.add(gm); - } - } - } - } - - } - - return matchingParticipants; - } - - /* Valid expressions: *, .*, , *., *..*, - * *..*..*, || - * - * Invalid expressions: *.*, **, - * - * Not supported yet: !, ! || , !( || ) - */ - private String createJavaRegularExpression(String regularExpression) throws InvalidRegularExpression { - StringBuffer re = new StringBuffer(); - - String[] splitByBar = regularExpression.split("\\|\\|"); - String[] splitByPeriod; - - for (int i = 0; i < splitByBar.length; i++) { - - splitByPeriod = splitByBar[i].split("\\."); - - if (i > 0) { - re.append("|"); - } - - re.append("^"); - for (int j = 0; j < splitByPeriod.length; j++) { - - //* - if (splitByPeriod[j].equals("*")) { - - //Validate the regular expression - if (j + 1 != splitByPeriod.length && splitByPeriod[j + 1].equals("*")) { - throw new InvalidRegularExpression(); - } - - //* - if (splitByPeriod.length == 1) { - re.append("(\\w+)"); - } //*. - - if (j == 0 && splitByPeriod.length != 1) { - re.append("(\\w+\\"); - re.append(".)*"); - } //.* - else { - re.append("(\\"); - re.append(".\\w+)*"); - } - } // - else { - -// //Validate the regular expression -// if (splitedByPeriod[j].matches("^(\\*)*$")) { -// throw new RuntimeException("Invalid name for a context"); -// } - - // || .. || *. - if (splitByPeriod.length == 1) { - re.append("(\\w+\\"); - re.append(".)*"); - } - - if (j == 0 || j - 1 == 0) { - re.append("(" + splitByPeriod[j] + ")"); - } else { - re.append("(\\." + splitByPeriod[j] + ")"); - } - } - } - re.append("$"); - } - return re.toString(); - } - } -} \ No newline at end of file diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java deleted file mode 100644 index 48dad22bff..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -public interface GuardianMember extends GuardianPrimitives { - - public void addException(GlobalException ex); - - public void setService(BlockingInterface service); - - public void removeService(); - - public Context getCurrentContext(); - - public BlockingInterface getService(); - - public String getParticipantIdentifier(); - - public void setUniqueParticipantID(int id); - - public int getParticipantState(); - - public void setParticipantState(int state); -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java deleted file mode 100644 index 893d5fcb1b..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Service; - -@Service(GuardianMember.class) -@Scope("COMPOSITE") -public class GuardianMemberImpl implements GuardianMember { - - private int participantState; - private Stack contextList; - private BlockingInterface service; - private Queue exceptionQueue; - @Reference(name = "guardian_group", required = true) - public GuardianGroup guardianGroup; - private int id; - //FIXME: Review the usage of this variable - private boolean exceptionThrown; - - public GuardianMemberImpl() { - contextList = new Stack(); - contextList.add(Context.INIT_CONTEXT); - exceptionQueue = new LinkedList(); - participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE; - exceptionThrown = false; - } - - @Init - public void init() { - guardianGroup.addGuardianMember(this); - } - - @Destroy - public void destroy() { - guardianGroup.removeGuardianMember(this); - } - - public void addException(GlobalException ex) { - exceptionQueue.add(ex); - } - - public void setService(BlockingInterface service) { - this.service = service; - } - - public Context getCurrentContext() { - return contextList.peek(); - } - - public BlockingInterface getService() { - return service; - } - - public void enableContext(Context context) { - //Update the context list with the related set of exceptions - contextList.push(context); - - if (contextList.size() == 2) { - JoinException ex = new JoinException(); - ex.setSignalingContext(context); - ex.putSignalingParticipant(getParticipantIdentifier()); - gthrow(ex, null); - } - - } - - public void removeContext() { - if (!contextList.isEmpty()) { - contextList.pop(); - } - } - - //If participantList is null then signal to ALL participants - public void gthrow(GlobalExceptionInterface ex, List participantList) { - //1)Block the participant until raise an exception - - if (!(ex instanceof SuspendException)) { - //Set the exception's parameters - ex.setSignalingContext(getCurrentContext()); - ex.putSignalingParticipant(getParticipantIdentifier()); - - guardianGroup.gthrow(ex, participantList); - exceptionThrown = true; - } else { - /*if (service instanceof BlockingInterface && !service.isBlocked()) { - service.block(); - }*/ - setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE); - } - } - - public boolean propagate(GlobalExceptionInterface ex) { - //1)Compares the current context with the exception's target context - return !getCurrentContext().equals(ex.getTargetContext()); - } - - public void checkExceptionStatus() throws GlobalException { - - //Blocks until the state be diferent the SUSPENDED_STATE - while (participantState == GuardianGroup.SUSPENDED_PARTICIPANT_STATE && exceptionThrown) { - System.out.println(getParticipantIdentifier() + ": I am blocked!"); - try { - Thread.sleep(5000); - } catch (InterruptedException ex) { - Logger.getLogger(GuardianMemberImpl.class.getName()).log(Level.SEVERE, null, ex); - } - } - exceptionThrown = false; - System.out.println(getParticipantIdentifier() + ": I am not blocked!"); - - GlobalException exc; - - if ((exc = exceptionQueue.peek()) == null) { - System.out.println(getParticipantIdentifier() + "#No exception on exception queue"); - return; - } - - //Check if ex.targetContext() matches the participant id - //Eg. ex.targetContext(): Main and participant id: Init.Main.Backup -> should thrown the exception - //Test if the exception should be thrown in the target context - for (Context c : contextList) { - if (exc.getTargetContext().equals(c) && (c.equals(Context.INIT_CONTEXT) || c.getExceptionList().contains(exc.getClass()))) { - System.out.println(getParticipantIdentifier() + "#Returning an exception"); - exceptionQueue.poll(); - throw exc; - } - } - - return; - } - - public String getParticipantIdentifier() { - //1) Return the participant identifier -> context list dot separated - StringBuffer participantIdentifier = new StringBuffer(); - participantIdentifier.append(this.id); - for (int i = 0; i < contextList.size(); i++) { - participantIdentifier.append("." + contextList.get(i).getName()); - } - return participantIdentifier.toString(); - } - - public void setUniqueParticipantID(int id) { - this.id = id; - } - - public void removeService() { - this.service = null; - } - - public int getParticipantState() { - return participantState; - } - - public void setParticipantState(int state) { - this.participantState = state; - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java deleted file mode 100644 index 9ddd22a2fd..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import java.util.List; - -//@Remotable -public interface GuardianPrimitives { - - //Methods to manage contexts - public void enableContext(Context context); - - public void removeContext(); - - //Methods to control the signaling of exceptions - public void gthrow(GlobalExceptionInterface ex, List participantList); - - public boolean propagate(GlobalExceptionInterface ex); - - //Method to check pending global exceptions - public void checkExceptionStatus() throws GlobalException; -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java deleted file mode 100644 index 3df76b0596..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -public class InvalidNodeException extends RuntimeException { - - public InvalidNodeException() { - super(); - } - - public InvalidNodeException(String message) { - super(message); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java deleted file mode 100644 index 30e750941e..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -public class InvalidRegularExpression extends RuntimeException { - - public InvalidRegularExpression() { - super(); - } - - public InvalidRegularExpression(String message) { - super(message); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java deleted file mode 100644 index b14ebeac2b..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.guardian; - -class JoinException extends GlobalException { - - public JoinException() { - super(); - } - - public JoinException(String message) { - super(message); - } - - public JoinException(String message, Throwable cause) { - super(message, cause); - } - - public JoinException(Throwable cause) { - super(cause); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java deleted file mode 100644 index 04e892f4bd..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -class LeaveException extends GlobalException { - - public LeaveException() { - super(); - } - - public LeaveException(String message) { - super(message); - } - - public LeaveException(String message, Throwable cause) { - super(message, cause); - } - - public LeaveException(Throwable cause) { - super(cause); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java deleted file mode 100644 index 09dd0673eb..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -import java.util.Collections; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; - -public class ResolutionTreeUtils { - - //E: Euler tour of the tree obtained by listing the nodes visited in a depth first search of the tree starting from the root. Contains 2n-1 elements - private List eulerTour; - //L: Array of level numbers such that L[i] contains the tree-depth of the node E[i]. Contains 2n-1 elements - private List levels; - //R: Map of size n such that R contains the index of the first ocurrence of node 'K' in E - private Map rMap; - private OMElement root; - private int treeSize; - - public ResolutionTreeUtils() { - init(null); - } - - public ResolutionTreeUtils(OMElement root) { - init(root); - } - - public void setRoot(OMElement root) { - init(root); - } - - public List getEulerTourDepthFirstSearch() { - - if (root == null) { - throw new NullPointerException("The root musn't be null"); - } - - if (eulerTour == null) { - eulerTour = new LinkedList(); - levels = new LinkedList(); - - eulerTourDFSRecursive(root, 0); - } - - return eulerTour; - } - - public String getLowestCommonAncestor(String node1, String node2) { - String lca = null; - Integer indexNode1, indexNode2; - - Map r = getRMap(); - - indexNode1 = r.get(node1); - indexNode2 = r.get(node2); - - //Check nodes existence - if (indexNode1 == null && indexNode2 == null) { - throw new InvalidNodeException("Could not find the specified nodes: " + node1 + " and " + node2); - } else if (indexNode1 == null) { - throw new InvalidNodeException("Could not find the specified nodes: " + node1); - } else if (indexNode2 == null) { - throw new InvalidNodeException("Could not find the specified nodes: " + node2); - } - - int indexLCA; - if (indexNode1 < indexNode2) { - indexLCA = getRangeMinimumQuery(levels, indexNode1, indexNode2); - } else { - indexLCA = getRangeMinimumQuery(levels, indexNode2, indexNode1); - } - - lca = eulerTour.get(indexLCA); - - return lca; - } - - //Get the index of the smallest element between beginIndex and endIndex (both inclusive) in the list - private int getRangeMinimumQuery(List list, int beginIndex, int endIndex) { - - List sublist = list.subList(beginIndex, endIndex + 1); - - Object elem = Collections.min(sublist); - - return sublist.indexOf(elem) + beginIndex; - } - - private void init(OMElement root) { - this.root = root; - eulerTour = null; - levels = null; - rMap = null; - treeSize = 0; - } - - private void eulerTourDFSRecursive(OMElement node, int level) { - String classAttribute = ((OMAttribute) node.getAllAttributes().next()).getAttributeValue(); - eulerTour.add(classAttribute); - - levels.add(level); - treeSize++; - - Iterator children = node.getChildElements(); - - OMElement child; - while (children.hasNext()) { - child = (OMElement) children.next(); - eulerTourDFSRecursive(child, level + 1); - eulerTour.add(classAttribute); - levels.add(level); - } - } - - private Map getRMap() { - if (rMap == null) { - rMap = new Hashtable(); - - List tour = getEulerTourDepthFirstSearch(); - for (int i = 0; i < tour.size(); i++) { - String key = tour.get(i); - if (!rMap.containsKey(key)) { - rMap.put(key, i); - } - - if (rMap.size() == treeSize) { - break; - } - } - } - return rMap; - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java deleted file mode 100644 index b7ede6d530..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -class SuspendException extends GlobalException { - - public SuspendException() { - super(); - } - - public SuspendException(String message) { - super(message); - } - - public SuspendException(String message, Throwable cause) { - super(message, cause); - } - - public SuspendException(Throwable cause) { - super(cause); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java deleted file mode 100644 index 81e3844280..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian; - -public class UnhandledException extends GlobalException { - - public UnhandledException() { - super(); - } - - public UnhandledException(String message) { - super(message); - } - - public UnhandledException(String message, Throwable cause) { - super(message, cause); - } - - public UnhandledException(Throwable cause) { - super(cause); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/lcaTest.xml b/sandbox/dougsleite/guardian-model/src/main/resources/lcaTest.xml deleted file mode 100644 index e528760ad8..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/lcaTest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups-concurrent.composite b/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups-concurrent.composite deleted file mode 100644 index 7cd28ff085..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups-concurrent.composite +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src/main/resources/recoveryrules_nbackpus_concurrent.xml - src/main/resources/resolutionTree.xml - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups.composite b/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups.composite deleted file mode 100644 index ecb12079f5..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups.composite +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src/main/resources/recoveryrules_nbackpus.xml - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup-ws.composite b/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup-ws.composite deleted file mode 100644 index 3de5d87fa2..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup-ws.composite +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - src/main/resources/recoveryrules.xml - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup.composite b/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup.composite deleted file mode 100644 index 9160a070c8..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup.composite +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src/main/resources/recoveryrules.xml - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules.xml b/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules.xml deleted file mode 100644 index 5df6a321e6..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus.xml b/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus.xml deleted file mode 100644 index 468fe5fc3a..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - FIRST - - - - - - - - - - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus_concurrent.xml b/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus_concurrent.xml deleted file mode 100644 index 65c509751c..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/recoveryrules_nbackpus_concurrent.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - FIRST - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FIRST - - - - - - diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/resolutionTree.xml b/sandbox/dougsleite/guardian-model/src/main/resources/resolutionTree.xml deleted file mode 100644 index 34c2fec0bf..0000000000 --- a/sandbox/dougsleite/guardian-model/src/main/resources/resolutionTree.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/LCATestCase.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/LCATestCase.java deleted file mode 100644 index bdcb7ac97d..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/LCATestCase.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests; - -import java.io.FileInputStream; -import org.apache.tuscany.sca.policy.resolutiontrees.*; -import org.apache.tuscany.sca.guardian.ResolutionTreeUtils; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Map; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import org.apache.axiom.om.OMElement; -import java.util.List; -import junit.framework.Assert; -import org.junit.Before; - -public class LCATestCase { - - private ResolutionTreeUtils treeUtils; - - @Before - public void init() throws Exception { - ResolutionTreesPolicyProcessor processor = new ResolutionTreesPolicyProcessor(null, null); - - FileInputStream fileInputStream = new FileInputStream("src/main/resources/lcaTest.xml"); - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); - - - ResolutionTreesPolicy policy = processor.read(reader); - Map resolutionTrees = policy.getResolutionTreeElements(); - - List rootElements = getRootElements(resolutionTrees.values()); - - treeUtils = new ResolutionTreeUtils(); - treeUtils.setRoot(rootElements.get(0)); - } - - @Test - public void testLCAEx2Ex2() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception2"); - System.out.println("lca: " + lca); - Assert.assertEquals("Exception2", lca); - } - - @Test - public void testLCAEx2Ex3() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception3"); - Assert.assertEquals("Exception1", lca); - } - - @Test - public void testLCAEx2Ex8() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception8"); - Assert.assertEquals("Exception1", lca); - } - - @Test - public void testLCAEx4Ex3() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception4", "Exception3"); - Assert.assertEquals("Exception1", lca); - } - - @Test - public void testLCAEx4Ex5() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception4", "Exception5"); - Assert.assertEquals("Exception2", lca); - } - - @Test - public void testLCAEx6Ex7() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception6", "Exception7"); - Assert.assertEquals("Exception3", lca); - } - - @Test - public void testLCAEx1Ex8() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception1", "Exception8"); - Assert.assertEquals("Exception1", lca); - } - - @Test - public void testLCAEx2Ex5() throws Exception { - String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception5"); - Assert.assertEquals("Exception2", lca); - } - - private List getRootElements(Collection resolutionTrees) { - List rootElements = new LinkedList(); - - for (OMElement resolutionTree : resolutionTrees) { - rootElements.add(resolutionTree.getFirstElement()); - } - - return rootElements; - } -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/concurrentexceptions/Launch.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/concurrentexceptions/Launch.java deleted file mode 100644 index 9ac2e9113b..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/concurrentexceptions/Launch.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.concurrentexceptions; - -import java.io.IOException; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; -import org.apache.tuscany.sca.host.embedded.SCADomain; - -public class Launch { - - public static void main(String... args) throws IOException { - SCADomain scaDomain = SCADomain.newInstance("primaryNbackups-concurrent.composite"); - - System.out.println("Starting participat1..."); - Node c = scaDomain.getService(Node.class, "Participant1"); - c.execute(); - - System.in.read(); - - System.out.println("Starting participant2..."); - Node c2 = scaDomain.getService(Node.class, "Participant2"); - c2.execute(); - - System.in.read(); - - System.out.println("Starting participant3..."); - Node c3 = scaDomain.getService(Node.class, "Participant3"); - c3.execute(); - - System.in.read(); - - System.out.println("Starting participant4..."); - Node c4 = scaDomain.getService(Node.class, "Participant4"); - c4.execute(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant1..."); - TestInterface t = scaDomain.getService(TestInterface.class, "Participant1"); - t.forcePrimaryServiceFailureException(); - - System.out.println("Forcing exception ocurrence at participant2..."); - TestInterface t2 = scaDomain.getService(TestInterface.class, "Participant2"); - t2.forceApplyUpdateFailureException(); - - System.in.read(); - - scaDomain.close(); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java deleted file mode 100644 index d7f0f763e2..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -public class ApplyUpdateFailureException extends RuntimeException { -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupFailedException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupFailedException.java deleted file mode 100644 index 6660d6b42f..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupFailedException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.*; - -public class BackupFailedException extends GlobalException { -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupJoinedException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupJoinedException.java deleted file mode 100644 index 6d81d1933e..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/BackupJoinedException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.GlobalException; - -public class BackupJoinedException extends GlobalException { -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/Node.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/Node.java deleted file mode 100644 index 9fb6a27a45..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/Node.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.BlockingInterface; -import org.osoa.sca.annotations.OneWay; - -public interface Node extends BlockingInterface { - - @OneWay - public void execute(); - - public void sendUpdate(String s); - - public void applyUpdate(); - - public String getID(); -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/NodeImpl.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/NodeImpl.java deleted file mode 100644 index 00880352b8..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/NodeImpl.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.apache.tuscany.sca.guardian.Context; -import org.apache.tuscany.sca.guardian.GuardianMember; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.OneWay; - -@Scope("COMPOSITE") -//public class NodeImpl implements Node, TestInterface { -public class NodeImpl implements Node { - - private static int PRIMARY = 0; - private static int BACKUP = 1; - private boolean isBlocked; - private Context mainContext; - private Context primaryContext; - private Context backupContext; - private int role; - private String pID; - private Queue updates; - @Reference(name = "guardian_member", required = true) - public GuardianMember gm; - @Reference(name = "nodes", required = true) - public List nodeList; - private boolean forcePSFException; - private boolean forceAUFException; - private int upcount; - - public NodeImpl() { - - mainContext = new Context("MAIN"); - mainContext.addException(PrimaryFailedException.class); - mainContext.addException(PrimaryExistsException.class); - - primaryContext = new Context("PRIMARY"); - primaryContext.addException(BackupFailedException.class); - primaryContext.addException(BackupJoinedException.class); - primaryContext.addException(PrimaryServiceFailureException.class); - - backupContext = new Context("BACKUP", null); - - updates = new LinkedList(); - - isBlocked = true; - - nodeList = new LinkedList(); - - forcePSFException = false; - forceAUFException = false; - } - - @Init - public void init() { - gm.setService(this); - pID = gm.getParticipantIdentifier(); - } - - @Destroy - public void destroy() { - gm.removeService(); - } - - @OneWay - public void execute() { - isBlocked = false; - gm.enableContext(mainContext); - role = PRIMARY; - - while (true) { - - //blockingCheck(); - - try { - System.out.println(pID + "#Main context: "); - sleep(pID + "#Sleeping at main context...", 4000); - - gm.checkExceptionStatus(); - - if (role == PRIMARY) { - //Config as primary then... - primaryService(); - } else { - //Config as backup then... - backupService(); - } - - - } catch (PrimaryExistsException ex) { - System.out.println(pID + "# Exception captured!: PrimaryExistsException"); - System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex)); - - if (gm.propagate(ex)) { - throw ex; - } - - role = BACKUP; - } catch (PrimaryFailedException ex) { - System.out.println(pID + "# Exception captured!: PrimaryFailedException"); - System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex)); - - if (gm.propagate(ex)) { - //throw ex; - this.block(); - ex.printStackTrace(); - return; - } - - role = PRIMARY; - - } catch (BackupFailedException ex) { - System.out.println(pID + "# Exception captured!: BackupFailedException"); - System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex)); - - if (gm.propagate(ex)) { - //throw ex; - this.block(); - ex.printStackTrace(); - return; - } - } - } - } - - private void primaryService() { - boolean backupAvailable = isThereBackupAvailable(); - - upcount = 1; - - while (true) { - - gm.enableContext(primaryContext); - - //blockingCheck(); - - try { - System.out.println(pID + "#Primary context: "); - sleep(pID + "#Sleeping at primary context...", 4000); - gm.checkExceptionStatus(); - - //Process the request then... - System.out.println(pID + "#Processing the request..."); - - //Check for an internal error - if (forcePSFException) { - throw new PrimaryServiceFailureException(); - } - - if (backupAvailable) { - - if (!updateBackups()) { - backupAvailable = isThereBackupAvailable(); - } - - } else { - System.out.println(pID + "#No backup available to send updates!"); - //backupAvailable = isThereBackupAvailable(); - } - //send the reply to the client - System.out.println(pID + "#Sending the reply to the client..."); - - } catch (PrimaryServiceFailureException ex) { - System.out.println(pID + "# Exception captured!: PrimaryServiceFailureException"); - gm.gthrow(new PrimaryFailedException(), null); - } catch (BackupFailedException ex) { - System.out.println(pID + "# Exception captured!: BackupFailedException"); - //backupAvailable = false; - backupAvailable = isThereBackupAvailable(); - } catch (BackupJoinedException ex) { - System.out.println(pID + "# Exception captured!: BackupJoinedException"); - backupAvailable = true; - } finally { - gm.removeContext(); - } - } - } - - private boolean updateBackups() { - boolean flag = false; - - for (Node n : nodeList) { - if (!n.isBlocked()) { - n.sendUpdate("Update " + upcount); - flag = true; - } - } - if (flag) { - upcount++; - } - - return flag; - } - - private void backupService() { - while (true) { - - gm.enableContext(backupContext); - - //blockingCheck(); - - try { - System.out.println(pID + "#Backup context: "); - sleep(pID + "#Sleeping at backup service", 4000); - gm.checkExceptionStatus(); - - applyUpdate(); - - if (forceAUFException) { - throw new ApplyUpdateFailureException(); - } - - } catch (ApplyUpdateFailureException ex) { - System.out.println(pID + "# Exception captured!: ApplyUpdateFailureException"); - gm.gthrow(new BackupFailedException(), null); - } finally { - gm.removeContext(); - } - } - } - - public String getID() { - return gm.getParticipantIdentifier(); - } - - private void sleep(String msg, int millis) { - try { - System.out.println(msg); - Thread.sleep(millis); - } catch (InterruptedException ex) { - Logger.getLogger(NodeImpl.class.getName()).log(Level.SEVERE, null, ex); - } - } - - private boolean isThereBackupAvailable() { - for (Node n : nodeList) { - if (!n.isBlocked()) { - return true; - } - } - return false; - } - - public void block() { - isBlocked = true; - } - - public boolean isBlocked() { - return isBlocked; - } - - public void unblock() { - isBlocked = false; - } - - private void blockingCheck() { - System.out.println(pID + "#Participant blocked!"); - while (isBlocked) { - System.out.println("isBlocked: " + isBlocked); - try { - Thread.sleep(5000); - } catch (InterruptedException ex) { - Logger.getLogger(NodeImpl.class.getName()).log(Level.SEVERE, null, ex); - } - } - System.out.println(pID + "#Participant unblocked!"); - } - - public void sendUpdate(String update) { - System.out.println(pID + "#Receiving updates from primary: " + update); - updates.offer(update); - } - - public void applyUpdate() { - if (!updates.isEmpty()) { - System.out.println(pID + "#Applying the updates received from the primary: " + updates.poll()); - } - } - - public void forcePrimaryServiceFailureException() { - forcePSFException = true; - } - - public void forceApplyUpdateFailureException() { - forceAUFException = true; - } -} - diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java deleted file mode 100644 index d2ce160bd7..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.GlobalException; - -public class PrimaryBackupFailedTogetherException extends GlobalException { - -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryExistsException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryExistsException.java deleted file mode 100644 index 935c97966e..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryExistsException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.GlobalException; - -public class PrimaryExistsException extends GlobalException { -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryFailedException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryFailedException.java deleted file mode 100644 index 00f2f84c00..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryFailedException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.GlobalException; - -public class PrimaryFailedException extends GlobalException { -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java deleted file mode 100644 index 46f52ea198..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -import org.apache.tuscany.sca.guardian.GlobalException; - -public class PrimaryServiceFailureException extends GlobalException { -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/TestInterface.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/TestInterface.java deleted file mode 100644 index f659a15530..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/TestInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; - -public interface TestInterface { - - public void forcePrimaryServiceFailureException(); - - public void forceApplyUpdateFailureException(); -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch.java deleted file mode 100644 index 333f231e59..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.nbackups; - -import java.io.IOException; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; -import org.apache.tuscany.sca.host.embedded.SCADomain; - -public class Launch { - - public static void main(String... args) throws IOException { - SCADomain scaDomain = SCADomain.newInstance("primaryNbackups.composite"); - - System.out.println("Starting participat1..."); - Node c = scaDomain.getService(Node.class, "Participant1"); - c.execute(); - - System.in.read(); - - System.out.println("Starting participant2..."); - Node c2 = scaDomain.getService(Node.class, "Participant2"); - c2.execute(); - - System.in.read(); - - System.out.println("Starting participant3..."); - Node c3 = scaDomain.getService(Node.class, "Participant3"); - c3.execute(); - - System.in.read(); - - System.out.println("Starting participant4..."); - Node c4 = scaDomain.getService(Node.class, "Participant4"); - c4.execute(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant1..."); - TestInterface t = scaDomain.getService(TestInterface.class, "Participant1"); - t.forcePrimaryServiceFailureException(); - - System.in.read(); - - scaDomain.close(); - } -} - diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch2.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch2.java deleted file mode 100644 index 94767c85dd..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch2.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.nbackups; - -import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; - -public class Launch2 { - - public static void main(String... args) throws IOException { - SCADomain scaDomain = SCADomain.newInstance("primaryNbackups.composite"); - - System.out.println("Starting participat1..."); - Node c = scaDomain.getService(Node.class, "Participant1"); - c.execute(); - - System.in.read(); - - System.out.println("Starting participant2..."); - Node c2 = scaDomain.getService(Node.class, "Participant2"); - c2.execute(); - - System.in.read(); - - System.out.println("Starting participant3..."); - Node c3 = scaDomain.getService(Node.class, "Participant3"); - c3.execute(); - - System.in.read(); - - System.out.println("Starting participant4..."); - Node c4 = scaDomain.getService(Node.class, "Participant4"); - c4.execute(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant2..."); - TestInterface t = scaDomain.getService(TestInterface.class, "Participant2"); - t.forceApplyUpdateFailureException(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant3..."); - TestInterface t2 = scaDomain.getService(TestInterface.class, "Participant3"); - t2.forceApplyUpdateFailureException(); - - System.in.read(); - - scaDomain.close(); - } -} - diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch3.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch3.java deleted file mode 100644 index 83d8c90d79..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/nbackups/Launch3.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2009 douglas. - * - * 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. - * under the License. - */ - -package org.apache.tuscany.sca.guardian.itests.primaryBackup.nbackups; - -import java.io.IOException; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; -import org.apache.tuscany.sca.host.embedded.SCADomain; - -/** - * - * @author douglas - */ -public class Launch3 { - public static void main(String... args) throws IOException { - SCADomain scaDomain = SCADomain.newInstance("primaryNbackups.composite"); - - System.out.println("Starting participat1..."); - Node c = scaDomain.getService(Node.class, "Participant1"); - c.execute(); - - System.in.read(); - - System.out.println("Starting participant2..."); - Node c2 = scaDomain.getService(Node.class, "Participant2"); - c2.execute(); - - System.in.read(); - - System.out.println("Starting participant3..."); - Node c3 = scaDomain.getService(Node.class, "Participant3"); - c3.execute(); - - System.in.read(); - - System.out.println("Starting participant4..."); - Node c4 = scaDomain.getService(Node.class, "Participant4"); - c4.execute(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant2..."); - TestInterface t = scaDomain.getService(TestInterface.class, "Participant2"); - t.forceApplyUpdateFailureException(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant1..."); - TestInterface t2 = scaDomain.getService(TestInterface.class, "Participant1"); - t2.forcePrimaryServiceFailureException(); - - System.in.read(); - - scaDomain.close(); - } -} diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch.java deleted file mode 100644 index 66b7d0a18d..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.simple; - -import java.io.IOException; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; -import org.apache.tuscany.sca.host.embedded.SCADomain; - -public class Launch { - - public static void main(String... args) throws IOException { - SCADomain scaDomain = SCADomain.newInstance("primarybackup.composite"); - - System.out.println("Starting participat1..."); - Node c = scaDomain.getService(Node.class, "Participant1"); - c.execute(); - - System.in.read(); - - System.out.println("Starting participant2..."); - Node c2 = scaDomain.getService(Node.class, "Participant2"); - c2.execute(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant1..."); - TestInterface t = scaDomain.getService(TestInterface.class, "Participant1"); - t.forcePrimaryServiceFailureException(); - - System.in.read(); - - scaDomain.close(); - } -} - diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch2.java b/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch2.java deleted file mode 100644 index 34eedcaa13..0000000000 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch2.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.simple; - -import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; - -public class Launch2 { - - public static void main(String... args) throws IOException { - SCADomain scaDomain = SCADomain.newInstance("primarybackup.composite"); - - System.out.println("Starting participat1..."); - Node c = scaDomain.getService(Node.class, "Participant1"); - c.execute(); - - System.in.read(); - - System.out.println("Starting participant2..."); - Node c2 = scaDomain.getService(Node.class, "Participant2"); - c2.execute(); - - System.in.read(); - - System.out.println("Forcing exception ocurrence at participant2..."); - TestInterface t = scaDomain.getService(TestInterface.class, "Participant2"); - t.forceApplyUpdateFailureException(); - - System.in.read(); - - scaDomain.close(); - } -} - diff --git a/sandbox/dougsleite/implementation-guardian/.classpath b/sandbox/dougsleite/implementation-guardian/.classpath new file mode 100644 index 0000000000..554ad2954f --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/.project b/sandbox/dougsleite/implementation-guardian/.project new file mode 100644 index 0000000000..a5f54ef1d3 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/.project @@ -0,0 +1,29 @@ + + + tuscany-guardian-model + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + org.devzuz.q.maven.jdt.core.mavenNature + + diff --git a/sandbox/dougsleite/implementation-guardian/pom.xml b/sandbox/dougsleite/implementation-guardian/pom.xml new file mode 100644 index 0000000000..dcd91936e6 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/pom.xml @@ -0,0 +1,94 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.6-SNAPSHOT + ../pom.xml + + tuscany-implementation-guardian + Apache Tuscany SCA Implementation Guardian Model + + + + apache.incubator + http://people.apache.org/repo/m2-snapshot-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.axis2 + axis2-jaxws + 1.5 + + + + org.apache.axis2 + axis2 + 1.5 + + + + + + + + org.apache.felix + maven-bundle-plugin + + + + ${tuscany.version} + org.apache.tuscany.sca.implementation.guardian + ${pom.name} + org.apache.tuscany.sca.implementation.guardian* + + + + + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/sequenceDiagram-externalException.jpg b/sandbox/dougsleite/implementation-guardian/sequenceDiagram-externalException.jpg new file mode 100644 index 0000000000..60060ca0e2 Binary files /dev/null and b/sandbox/dougsleite/implementation-guardian/sequenceDiagram-externalException.jpg differ diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/BlockingInterface.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/BlockingInterface.java new file mode 100644 index 0000000000..1bb1066435 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/BlockingInterface.java @@ -0,0 +1,31 @@ +/* + * 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; + +@Deprecated +public interface BlockingInterface { + + //@OneWay + public void block(); + + //@OneWay + public void unblock(); + + public boolean isBlocked(); +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroup.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroup.java new file mode 100644 index 0000000000..2775699843 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroup.java @@ -0,0 +1,29 @@ +/* + * 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; + +public interface GuardianGroup extends GuardianPrimitives { + + public static int NORMAL_PARTICIPANT_STATE = 0; + public static int SUSPENDED_PARTICIPANT_STATE = 1; + + public void addGuardianMember(GuardianMember guardianMember); + + public boolean removeGuardianMember(GuardianMember guardianMember); +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementation.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementation.java new file mode 100644 index 0000000000..cb7495f9e4 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementation.java @@ -0,0 +1,29 @@ +/* + * 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.axiom.om.OMElement; +import org.apache.tuscany.sca.assembly.Implementation; + +public interface GuardianGroupImplementation extends Implementation { + + public void setGuardianProperties(OMElement guardianProperties); + + public OMElement getGuardianProperties(); +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementationFactory.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementationFactory.java new file mode 100644 index 0000000000..d0758753b3 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroupImplementationFactory.java @@ -0,0 +1,24 @@ +/* + * 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; + +public interface GuardianGroupImplementationFactory { + + public GuardianGroupImplementation createGuardianGroupImplementation(); +} 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 new file mode 100644 index 0000000000..b82bf082b1 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java @@ -0,0 +1,37 @@ +/* + * 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.common.Context; +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public interface GuardianMember extends GuardianPrimitives { + + public void addException(GlobalException ex); + + public Context getCurrentContext(); + + 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 new file mode 100644 index 0000000000..c50e855d30 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java @@ -0,0 +1,41 @@ +/* + * 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 java.util.List; +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.GlobalExceptionInterface; + +//@Remotable +public interface GuardianPrimitives { + + //Methods to manage contexts + public void enableContext(Context context); + + public void removeContext(); + + //Methods to control the signaling of exceptions + public void gthrow(GlobalExceptionInterface ex, List participantList); + + public boolean propagate(GlobalExceptionInterface ex); + + //Method to check pending global exceptions + public void checkExceptionStatus() throws GlobalException; +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/RecoveryRules.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/RecoveryRules.java new file mode 100644 index 0000000000..4757615c21 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/RecoveryRules.java @@ -0,0 +1,32 @@ +/* + * 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 java.util.Map; +import javax.xml.namespace.QName; +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.assembly.xml.Constants; + +public interface RecoveryRules { + + public static final QName RECOVERY_RULES_POLICY_QNAME = + new QName(Constants.SCA10_TUSCANY_NS, org.apache.tuscany.sca.implementation.guardian.common.Constants.RECOVERY_RULES); + + public Map getRuleElements(); +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/ResolutionTrees.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/ResolutionTrees.java new file mode 100644 index 0000000000..d35deff75a --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/ResolutionTrees.java @@ -0,0 +1,32 @@ +/* + * 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 java.util.Map; +import javax.xml.namespace.QName; +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.assembly.xml.Constants; + +public interface ResolutionTrees { + + public static final QName RESOLUTION_TREES_POLICY_QNAME = + new QName(Constants.SCA10_TUSCANY_NS, org.apache.tuscany.sca.implementation.guardian.common.Constants.RESOLUTION_TREES); + + public Map getResolutionTreeElements(); +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ConcurrentExceptionOcurrenceException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ConcurrentExceptionOcurrenceException.java new file mode 100644 index 0000000000..4bfe1320b4 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ConcurrentExceptionOcurrenceException.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.implementation.guardian.common; + +public class ConcurrentExceptionOcurrenceException extends Exception { + + public ConcurrentExceptionOcurrenceException() { + super(); + } + + public ConcurrentExceptionOcurrenceException(String message) { + super(message); + } + + public ConcurrentExceptionOcurrenceException(String message, Throwable cause) { + super(message, cause); + } + + public ConcurrentExceptionOcurrenceException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Constants.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Constants.java new file mode 100644 index 0000000000..cf5d56179d --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Constants.java @@ -0,0 +1,82 @@ +/* + * 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.common; + +import javax.xml.namespace.QName; + +public interface Constants { + + String RECOVERY_RULES = "recovery_rules"; + QName RECOVERY_RULES_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RECOVERY_RULES); + + String RULE = "rule"; + QName RULE_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RULE); + + String NAME = "name"; + QName NAME_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, NAME); + + String SIGNALED_EXCEPTION = "signaled_exception"; + QName SIGNALED_EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, SIGNALED_EXCEPTION); + + String PARTICIPANT = "participant"; + QName PARTICIPANT_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, PARTICIPANT); + + String MATCH = "match"; + QName MATCH_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MATCH); + + String THROW_EXCEPTION = "throw_exception"; + QName THROW_EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, THROW_EXCEPTION); + + String CLASS = "class"; + QName CLASS_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, CLASS); + + String TARGET_CONTEXT = "target_context"; + QName TARGET_CONTEXT_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, TARGET_CONTEXT); + + String MIN_PARTICIPANT_JOINED = "min_participant_joined"; + QName MIN_PARTICIPANT_JOINED_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MIN_PARTICIPANT_JOINED); + + String MAX_PARTICIPANT_JOINED = "max_participant_joined"; + QName MAX_PARTICIPANT_JOINED_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, MAX_PARTICIPANT_JOINED); + + String AFFECTED_PARTICIPANTS = "affected_participants"; + QName AFFECTED_PARTICIPANTS_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, AFFECTED_PARTICIPANTS); + + String FIRST = "FIRST"; + QName FIRST_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, FIRST); + + String LAST = "LAST"; + QName LAST_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, LAST); + + String ALL = "ALL"; + QName ALL_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, ALL); + + String RESOLUTION_TREE = "resolution_tree"; + QName RESOLUTION_TREE_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RESOLUTION_TREE); + + String RESOLUTION_TREES = "resolution_trees"; + QName RESOLUTION_TREES_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, RESOLUTION_TREES); + + String EXCEPTION_LEVEL = "exception_level"; + QName EXCEPTION_LEVEL_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, EXCEPTION_LEVEL); + + String EXCEPTION = "exception"; + QName EXCEPTION_QNAME = new QName(org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS, EXCEPTION); + +} diff --git a/sandbox/dougsleite/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 new file mode 100644 index 0000000000..95c6f3bed6 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java @@ -0,0 +1,79 @@ +/* + * 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.common; + +import java.util.LinkedList; +import java.util.List; + +public class Context { + + public static Context CURRENT_CONTEXT = new Context("CURRENT_CONTEXT"); + public static Context INIT_CONTEXT = new Context("INIT_CONTEXT"); + public static Context GUARDIAN_CONTEXT = new Context("GUARDIAN_CONTEXT"); + + private String name; + private List> exceptionList; + + public Context() { + this(null); + } + + public Context(String name) { + this(name, new LinkedList>()); + } + + public Context(String name, List> exceptionList) { + this.name = name; + this.exceptionList = exceptionList; + } + + public void addException(Class ex) { + this.exceptionList.add(ex); + } + + public void setExceptionList(List> exceptionList) { + this.exceptionList = exceptionList; + } + + public List> getExceptionList() { + return this.exceptionList; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + return (obj instanceof Context && + (((Context) obj).getName().equals(this.getName()) || + this == Context.CURRENT_CONTEXT || + ((Context) obj) == Context.CURRENT_CONTEXT)); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalException.java new file mode 100644 index 0000000000..022fe1a5f8 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalException.java @@ -0,0 +1,85 @@ +/* + * 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.common; + +import java.util.LinkedList; +import java.util.List; + +public class GlobalException extends RuntimeException implements GlobalExceptionInterface { + + private List signalingParticipants; + private Context signalingContext; + private Context targetContext; + + public GlobalException() { + super(); + signalingParticipants = new LinkedList(); + } + + public GlobalException(String message) { + super(message); + signalingParticipants = new LinkedList(); + } + + public GlobalException(String message, Throwable cause) { + super(message, cause); + signalingParticipants = new LinkedList(); + } + + public GlobalException(Throwable cause) { + super(cause); + signalingParticipants = new LinkedList(); + } + + /** + * @return the signalingContext + */ + public Context getSignalingContext() { + return signalingContext; + } + + /** + * @param signalingContext the signalingContext to set + */ + public void setSignalingContext(Context signalingContext) { + this.signalingContext = signalingContext; + } + + /** + * @return the targetContext + */ + public Context getTargetContext() { + return targetContext; + } + + /** + * @param targetContext the targetContext to set + */ + public void setTargetContext(Context targetContext) { + this.targetContext = targetContext; + } + + public void putSignalingParticipant(String participant) { + signalingParticipants.add(participant); + } + + public List getSignalingParticipants() { + return signalingParticipants; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalExceptionInterface.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalExceptionInterface.java new file mode 100644 index 0000000000..450d4ae18b --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalExceptionInterface.java @@ -0,0 +1,54 @@ +/* + * 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.common; + +import java.util.List; + +public interface GlobalExceptionInterface { + + /** + * @return the signalingContext + */ + public Context getSignalingContext(); + + /** + * @param signalingContext the signalingContext to set + */ + public void setSignalingContext(Context signalingContext); + + /** + * @return the targetContext + */ + public Context getTargetContext(); + + /** + * @param targetContext the targetContext to set + */ + public void setTargetContext(Context targetContext); + + /** + * @return the signalingProcess + */ + public List getSignalingParticipants(); + + /** + * @param signalingProcess the signalingProcess to set + */ + public void putSignalingParticipant(String participant); +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidNodeException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidNodeException.java new file mode 100644 index 0000000000..ed85661dbf --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidNodeException.java @@ -0,0 +1,30 @@ +/* + * 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.common; + +public class InvalidNodeException extends RuntimeException { + + public InvalidNodeException() { + super(); + } + + public InvalidNodeException(String message) { + super(message); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidRegularExpressionException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidRegularExpressionException.java new file mode 100644 index 0000000000..99aa027fb8 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidRegularExpressionException.java @@ -0,0 +1,30 @@ +/* + * 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.common; + +public class InvalidRegularExpressionException extends RuntimeException { + + public InvalidRegularExpressionException() { + super(); + } + + public InvalidRegularExpressionException(String message) { + super(message); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/JoinException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/JoinException.java new file mode 100644 index 0000000000..890b8704ee --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/JoinException.java @@ -0,0 +1,39 @@ +/* + * 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.common; + +public class JoinException extends GlobalException { + + public JoinException() { + super(); + } + + public JoinException(String message) { + super(message); + } + + public JoinException(String message, Throwable cause) { + super(message, cause); + } + + public JoinException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/LeaveException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/LeaveException.java new file mode 100644 index 0000000000..9684de22ad --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/LeaveException.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.implementation.guardian.common; + +public class LeaveException extends GlobalException { + + public LeaveException() { + super(); + } + + public LeaveException(String message) { + super(message); + } + + public LeaveException(String message, Throwable cause) { + super(message, cause); + } + + public LeaveException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ResolutionTreeUtils.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ResolutionTreeUtils.java new file mode 100644 index 0000000000..fbf147285e --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ResolutionTreeUtils.java @@ -0,0 +1,153 @@ +/* + * 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.common; + +import java.util.Collections; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.apache.axiom.om.OMAttribute; +import org.apache.axiom.om.OMElement; + +public class ResolutionTreeUtils { + + //E: Euler tour of the tree obtained by listing the nodes visited in a depth first search of the tree starting from the root. Contains 2n-1 elements + private List eulerTour; + //L: Array of level numbers such that L[i] contains the tree-depth of the node E[i]. Contains 2n-1 elements + private List levels; + //R: Map of size n such that R contains the index of the first ocurrence of node 'K' in E + private Map rMap; + private OMElement root; + private int treeSize; + + public ResolutionTreeUtils() { + init(null); + } + + public ResolutionTreeUtils(OMElement root) { + init(root); + } + + public void setRoot(OMElement root) { + init(root); + } + + public List getEulerTourDepthFirstSearch() { + + if (root == null) { + throw new NullPointerException("The root musn't be null"); + } + + if (eulerTour == null) { + eulerTour = new LinkedList(); + levels = new LinkedList(); + + eulerTourDFSRecursive(root, 0); + } + + return eulerTour; + } + + public String getLowestCommonAncestor(String node1, String node2) { + String lca = null; + Integer indexNode1, indexNode2; + + Map r = getRMap(); + + indexNode1 = r.get(node1); + indexNode2 = r.get(node2); + + //Check nodes existence + if (indexNode1 == null && indexNode2 == null) { + throw new InvalidNodeException("Could not find the specified nodes: " + node1 + " and " + node2); + } else if (indexNode1 == null) { + throw new InvalidNodeException("Could not find the specified nodes: " + node1); + } else if (indexNode2 == null) { + throw new InvalidNodeException("Could not find the specified nodes: " + node2); + } + + int indexLCA; + if (indexNode1 < indexNode2) { + indexLCA = getRangeMinimumQuery(levels, indexNode1, indexNode2); + } else { + indexLCA = getRangeMinimumQuery(levels, indexNode2, indexNode1); + } + + lca = eulerTour.get(indexLCA); + + return lca; + } + + //Get the index of the smallest element between beginIndex and endIndex (both inclusive) in the list + private int getRangeMinimumQuery(List list, int beginIndex, int endIndex) { + + List sublist = list.subList(beginIndex, endIndex + 1); + + Object elem = Collections.min(sublist); + + return sublist.indexOf(elem) + beginIndex; + } + + private void init(OMElement root) { + this.root = root; + eulerTour = null; + levels = null; + rMap = null; + treeSize = 0; + } + + private void eulerTourDFSRecursive(OMElement node, int level) { + String classAttribute = ((OMAttribute) node.getAllAttributes().next()).getAttributeValue(); + eulerTour.add(classAttribute); + + levels.add(level); + treeSize++; + + Iterator children = node.getChildElements(); + + OMElement child; + while (children.hasNext()) { + child = (OMElement) children.next(); + eulerTourDFSRecursive(child, level + 1); + eulerTour.add(classAttribute); + levels.add(level); + } + } + + private Map getRMap() { + if (rMap == null) { + rMap = new Hashtable(); + + List tour = getEulerTourDepthFirstSearch(); + for (int i = 0; i < tour.size(); i++) { + String key = tour.get(i); + if (!rMap.containsKey(key)) { + rMap.put(key, i); + } + + if (rMap.size() == treeSize) { + break; + } + } + } + return rMap; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/SuspendException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/SuspendException.java new file mode 100644 index 0000000000..5ce2f5afd9 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/SuspendException.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.implementation.guardian.common; + +public class SuspendException extends GlobalException { + + public SuspendException() { + super(); + } + + public SuspendException(String message) { + super(message); + } + + public SuspendException(String message, Throwable cause) { + super(message, cause); + } + + public SuspendException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/UnhandledException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/UnhandledException.java new file mode 100644 index 0000000000..a8f9cdfad6 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/UnhandledException.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.implementation.guardian.common; + +public class UnhandledException extends GlobalException { + + public UnhandledException() { + super(); + } + + public UnhandledException(String message) { + super(message); + } + + public UnhandledException(String message, Throwable cause) { + super(message, cause); + } + + public UnhandledException(Throwable cause) { + super(cause); + } +} 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 new file mode 100644 index 0000000000..5a243560e3 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java @@ -0,0 +1,644 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.guardian.impl; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import org.apache.axiom.om.OMAttribute; +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.implementation.guardian.common.InvalidRegularExpressionException; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroup; +import org.apache.tuscany.sca.implementation.guardian.GuardianMember; +import org.apache.tuscany.sca.implementation.guardian.common.ConcurrentExceptionOcurrenceException; +import org.apache.tuscany.sca.implementation.guardian.common.Constants; +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.GlobalExceptionInterface; +import org.apache.tuscany.sca.implementation.guardian.common.InvalidNodeException; +import org.apache.tuscany.sca.implementation.guardian.common.ResolutionTreeUtils; +import org.apache.tuscany.sca.implementation.guardian.common.SuspendException; +import org.apache.tuscany.sca.implementation.guardian.xml.RecoveryRulesProcessor; +import org.apache.tuscany.sca.implementation.guardian.xml.ResolutionTreesProcessor; + +public class GuardianGroupImpl implements GuardianGroup { + + private List guardianList; + private InnerGuardianGroupThread innerThread; + private List concurrentExList; + private Map resolutionTreeElements; + private ResolutionTreeUtils resolutionTreeUtils; + private Map ruleElements; + + public GuardianGroupImpl(String recoveryRules, String resolutionTrees) { + guardianList = new LinkedList(); + concurrentExList = new LinkedList(); + innerThread = new InnerGuardianGroupThread(); + resolutionTreeUtils = new ResolutionTreeUtils(); + + setRecoveryRules(recoveryRules); + setResolutionTree(resolutionTrees); + } + + private void setRecoveryRules(String recoveryRules) { + try { + FileInputStream fileInputStream = new FileInputStream(recoveryRules); + XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + RecoveryRulesProcessor processor = new RecoveryRulesProcessor(); + ruleElements = processor.read(xmlReader).getRuleElements(); + + } catch (ContributionReadException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } catch (XMLStreamException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } catch (FileNotFoundException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private void setResolutionTree(String resolutionTree) { + + try { + FileInputStream fileInputStream = new FileInputStream(resolutionTree); + XMLStreamReader resolutionTreeReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + ResolutionTreesProcessor processor = new ResolutionTreesProcessor(); + resolutionTreeElements = processor.read(resolutionTreeReader).getResolutionTreeElements(); + + } catch (ContributionReadException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } catch (XMLStreamException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } catch (FileNotFoundException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void addGuardianMember(GuardianMember guardianMember) { + guardianList.add(guardianMember); + guardianMember.setUniqueParticipantID(guardianList.size() - 1); + } + + public boolean removeGuardianMember(GuardianMember guardianMember) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void enableContext(Context context) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void removeContext() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public synchronized void gthrow(GlobalExceptionInterface ex, List participantList) { + + concurrentExList.add(ex); + + //Sends a message representing the exception to the other guardian members + SuspendException suspendEx = new SuspendException(); + suspendEx.putSignalingParticipant(ex.getSignalingParticipants().get(0)); + + if (participantList == null) { + for (GuardianMember g : guardianList) { + g.gthrow(suspendEx, null); + } + } else { + for (GuardianMember g : guardianList) { + if (participantList.contains(g.getParticipantIdentifier()) || + g.getParticipantIdentifier().equals(ex.getSignalingParticipants().get(0))) { + g.gthrow(suspendEx, null); + } + } + } + + if (!innerThread.isRunning()) { + innerThread.setGlobalException(ex); + new Thread(innerThread).start(); + } + + } + + public boolean propagate(GlobalExceptionInterface ex) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void checkExceptionStatus() { + throw new UnsupportedOperationException("Not supported yet."); + } + + private class InnerGuardianGroupThread implements Runnable { + + private boolean isRunning; + private GlobalExceptionInterface ex = null; + + public InnerGuardianGroupThread() { + isRunning = false; + } + + public void setGlobalException(GlobalExceptionInterface ex) { + this.ex = ex; + } + + public GlobalExceptionInterface getGlobalException() { + return ex; + } + + public void run() { + isRunning = true; + + if (ex != null) { + + //Time window of 10 seconds just for tests + try { + Thread.sleep(10000); + } catch (InterruptedException ex1) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); + } + + try { + applyRecoveryRules(ex); + } catch (ConcurrentExceptionOcurrenceException ce) { + applyConcurrentRecoveryRules(); + } + + //Clear the concurrent exception list + concurrentExList.clear(); + + //Set up the participant state to NORMAL + for (GuardianMember gm : guardianList) { + if (gm.getParticipantState() == SUSPENDED_PARTICIPANT_STATE) { + gm.setParticipantState(NORMAL_PARTICIPANT_STATE); + } + } + } + isRunning = false; + } + + public boolean isRunning() { + return isRunning; + } + + private void applyRecoveryRules(GlobalExceptionInterface ex) throws ConcurrentExceptionOcurrenceException { + ruleTag(ex, ruleElements.values().iterator()); + } + + private void ruleTag(GlobalExceptionInterface ex, Iterator ruleElements) throws ConcurrentExceptionOcurrenceException { + String signaledException; + String exceptionName; + + OMElement rule; + while (ruleElements.hasNext()) { + + rule = ruleElements.next(); + signaledException = getAttributeValue(rule, Constants.SIGNALED_EXCEPTION); + exceptionName = ex.getClass().getName(); + + if (signaledException.equals(exceptionName)) { + participantExceptionTag(ex, rule.getChildElements()); + break; + } + } + } + + private void participantExceptionTag(GlobalExceptionInterface ex, Iterator participantElements) throws ConcurrentExceptionOcurrenceException { + String matchParticipant; + List gmList; + + OMElement participant; + while (participantElements.hasNext()) { + participant = participantElements.next(); + + matchParticipant = getAttributeValue(participant, Constants.MATCH); + gmList = getMatchingParticipants(matchParticipant, ex); + + if (!gmList.isEmpty()) { + throwExceptionTag(gmList, ex, participant.getChildElements()); + } + } + } + + private void throwExceptionTag(List gmList, GlobalExceptionInterface ex, Iterator throwExceptionElements) throws ConcurrentExceptionOcurrenceException { + String className; + String targetContextName; + Integer minParticipantJoined; + Integer maxParticipantJoined; + + OMElement throwException; + while (throwExceptionElements.hasNext()) { + + throwException = throwExceptionElements.next(); + + className = getAttributeValue(throwException, Constants.CLASS); + targetContextName = getAttributeValue(throwException, Constants.TARGET_CONTEXT); + + try { + minParticipantJoined = Integer.parseInt(getAttributeValue(throwException, Constants.MIN_PARTICIPANT_JOINED)); + } catch (NumberFormatException nex) { + minParticipantJoined = null; + } + + try { + maxParticipantJoined = Integer.parseInt(getAttributeValue(throwException, Constants.MAX_PARTICIPANT_JOINED)); + } catch (NumberFormatException nexc) { + maxParticipantJoined = null; + } + + //Test the min and max joined participants condition + if (minParticipantJoined != null && maxParticipantJoined != null) { + if (!(guardianList.size() >= minParticipantJoined && guardianList.size() < maxParticipantJoined)) { + break; + } + } else if (minParticipantJoined != null) { + if (!(guardianList.size() >= minParticipantJoined)) { + break; + } + } else if (minParticipantJoined != null) { + if (!(guardianList.size() >= minParticipantJoined)) { + break; + } + } + + // + String affectedParticipants = affectedParticipantsTag(throwException.getChildElements()); + int index = -1; + + //Verify if the parameter is an index + try { + index = Integer.parseInt(affectedParticipants); + } catch (NumberFormatException nexc) { + index = -1; + } + + //Create the new exception instance + Class exceptionClass; + try { + exceptionClass = Class.forName(className); + + Context targetContext; + if (targetContextName.toUpperCase().equals(Context.CURRENT_CONTEXT.getName().toUpperCase())) { + targetContext = Context.CURRENT_CONTEXT; + } else if (targetContextName.toUpperCase().equals(Context.INIT_CONTEXT.getName().toUpperCase())) { + targetContext = Context.INIT_CONTEXT; + } else { + targetContext = new Context(targetContextName); + } + GlobalException newException = (GlobalException) exceptionClass.newInstance(); + + newException.setTargetContext(targetContext); + newException.setSignalingContext(ex.getSignalingContext()); + newException.putSignalingParticipant(ex.getSignalingParticipants().toString()); + + //Check concurrent exception existence + if (concurrentExList.size() > 1) { + throw new ConcurrentExceptionOcurrenceException(concurrentExList.toString()); + } + + //Add the exception to the participants matched + if (index != -1) { + gmList.get(index).addException(newException); + } else if (affectedParticipants != null && affectedParticipants.length() != 0) { + if (affectedParticipants.toUpperCase().equals(Constants.FIRST)) { + gmList.get(0).addException(newException); + } else if (affectedParticipants.toUpperCase().equals(Constants.LAST)) { + gmList.get(gmList.size() - 1).addException(newException); + } else if (affectedParticipants.toUpperCase().equals(Constants.ALL)) { + for (GuardianMember gm : gmList) { + gm.addException(newException); + } + } + } else { + for (GuardianMember gm : gmList) { + gm.addException(newException); + } + } + + } catch (InstantiationException ex1) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); + } catch (IllegalAccessException ex1) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); + } catch (ClassNotFoundException ex1) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex1); + } + } + } + + private String affectedParticipantsTag(Iterator affectedParticipantElements) { + + String affectedParticipantValue = null; + + OMElement affectedParticipant; + while (affectedParticipantElements.hasNext()) { + + affectedParticipant = affectedParticipantElements.next(); + affectedParticipantValue = affectedParticipant.getText(); + } + + if (affectedParticipantValue != null && affectedParticipantValue.length() == 0) { + affectedParticipantValue = null; + } + + return affectedParticipantValue; + } + + private String getAttributeValue(OMElement element, String attributeName) { + OMAttribute at; + Iterator it = element.getAllAttributes(); + + while (it.hasNext()) { + at = (OMAttribute) it.next(); + if (at.getLocalName().equals(attributeName)) { + return at.getAttributeValue(); + } + } + + return null; + } + + private void applyConcurrentRecoveryRules() { + + boolean concurrentExOcurrence = false; + List copyConcurrentExList; + GlobalExceptionInterface resolvedEx; + + do { + System.out.println("Concurrent exceptions: " + concurrentExList); + + copyConcurrentExList = new LinkedList(concurrentExList); + + resolvedEx = checkExceptionResolutionTrees(copyConcurrentExList, resolutionTreeElements.values().iterator()); + + concurrentExList.clear(); + + System.out.println("Resolved Exception: " + resolvedEx); + if (resolvedEx != null) { + System.out.println("List of participants: " + resolvedEx.getSignalingParticipants()); + } + + try { + //Process the exception list sequentially + if (resolvedEx == null) { + for (GlobalExceptionInterface ex : copyConcurrentExList) { + applyRecoveryRules(ex); + } + } else { + applyRecoveryRules(resolvedEx); + } + + } catch (ConcurrentExceptionOcurrenceException exc) { + concurrentExOcurrence = true; + break; + } + } while (concurrentExOcurrence); + } + + //FIXME: Need to check the exception level + private GlobalExceptionInterface checkExceptionResolutionTrees(List exceptionList, Iterator resolutionTreesElements) { + + OMElement tree; + OMElement root; + String exceptionLevel = null; + GlobalExceptionInterface resolvedEx = null; + + while (resolutionTreesElements.hasNext()) { + tree = (OMElement) resolutionTreesElements.next(); + exceptionLevel = tree.getAttributeValue(Constants.EXCEPTION_LEVEL_QNAME); + + root = (OMElement) tree.getChildElements().next(); + resolvedEx = checkExceptionResolutionTree(exceptionList, root); + + if (resolvedEx != null) { + break; + } + } + + return resolvedEx; + } + + //Search for the root of the smallest subtree that contains all the concurrently signaled exceptions. If not found, return null. + private GlobalExceptionInterface checkExceptionResolutionTree(List exceptionList, OMElement rootTree) { + + resolutionTreeUtils.setRoot(rootTree); + String ex1, ex2; + GlobalExceptionInterface resolvedEx = null; + + ex1 = exceptionList.get(0).getClass().getName(); + for (int i = 1; i < exceptionList.size(); i++) { + ex2 = exceptionList.get(i).getClass().getName(); + + try { + ex1 = resolutionTreeUtils.getLowestCommonAncestor(ex1, ex2); + } catch (InvalidNodeException invalidNodeException) { + ex1 = null; + break; + } + } + + if (ex1 != null) { + Class exceptionClass; + + try { + exceptionClass = Class.forName(ex1); + resolvedEx = (GlobalException) exceptionClass.newInstance(); + + for (GlobalExceptionInterface ex : exceptionList) { + resolvedEx.putSignalingParticipant(ex.getSignalingParticipants().get(0)); + } + + } catch (InstantiationException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } catch (ClassNotFoundException ex) { + Logger.getLogger(GuardianGroupImpl.class.getName()).log(Level.SEVERE, null, ex); + } + + return resolvedEx; + + } else { + return null; + } + } + + private List getMatchingParticipants(String regularExpression, GlobalExceptionInterface signaledException) { + List matchingParticipants = new LinkedList(); + String[] splitByComma = regularExpression.split(","); + + //Invalid regular expression + if (splitByComma.length > 2) { + throw new InvalidRegularExpressionException("The comma ',' operator can only be applied for two expressions"); + } + + //There is no comma on the regular expression + if (splitByComma.length == 1) { + + if (regularExpression.toUpperCase().equals("SIGNALER")) { + for (GuardianMember gm : guardianList) { + if (signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { + matchingParticipants.add(gm); + } + } + } else if (regularExpression.toUpperCase().equals("!SIGNALER")) { + for (GuardianMember gm : guardianList) { + if (!signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { + matchingParticipants.add(gm); + } + } + + } else { + //Create an java regular expression + String re = createJavaRegularExpression(regularExpression); + + for (GuardianMember gm : guardianList) { + if (gm.getParticipantIdentifier().matches(re)) { + matchingParticipants.add(gm); + } + } + } + + } //There is comma on the regular expression + else { + + String element; + int index = -1; + for (int i = 0; i < splitByComma.length; i++) { + element = splitByComma[i].toUpperCase(); + if (element.equals("SIGNALER") || element.equals("!SIGNALER")) { + if (index == -1) { + index = i; + } else { + index = -1; + } + } + } + + //Invalid expression + if (index == -1) { + throw new InvalidRegularExpressionException("The comma ',' requires a SIGNALER or !SIGNALER element in one side of the expression"); + } + + String re = createJavaRegularExpression(splitByComma[1 - index]); + + for (GuardianMember gm : guardianList) { + + //Test if the participant matches with the regular expression + if (gm.getParticipantIdentifier().matches(re)) { + + //Test if the participant is Signaler + if (splitByComma[index].toUpperCase().equals("SIGNALER")) { + + if (signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { + matchingParticipants.add(gm); + } + } //Test if the participant is not Signaler + else { + if (!signaledException.getSignalingParticipants().contains(gm.getParticipantIdentifier())) { + matchingParticipants.add(gm); + } + } + } + } + + } + + return matchingParticipants; + } + + /* Valid expressions: *, .*, , *., *..*, + * *..*..*, || + * + * Invalid expressions: *.*, **, + * + * Not supported yet: !, ! || , !( || ) + */ + private String createJavaRegularExpression(String regularExpression) throws InvalidRegularExpressionException { + StringBuffer re = new StringBuffer(); + + String[] splitByBar = regularExpression.split("\\|\\|"); + String[] splitByPeriod; + + for (int i = 0; i < splitByBar.length; i++) { + + splitByPeriod = splitByBar[i].split("\\."); + + if (i > 0) { + re.append("|"); + } + + re.append("^"); + for (int j = 0; j < splitByPeriod.length; j++) { + + //* + if (splitByPeriod[j].equals("*")) { + + //Validate the regular expression + if (j + 1 != splitByPeriod.length && splitByPeriod[j + 1].equals("*")) { + throw new InvalidRegularExpressionException(); + } + + //* + if (splitByPeriod.length == 1) { + re.append("(\\w+)"); + } //*. + + if (j == 0 && splitByPeriod.length != 1) { + re.append("(\\w+\\"); + re.append(".)*"); + } //.* + else { + re.append("(\\"); + re.append(".\\w+)*"); + } + } // + else { + +// //Validate the regular expression +// if (splitedByPeriod[j].matches("^(\\*)*$")) { +// throw new RuntimeException("Invalid name for a context"); +// } + + // || .. || *. + if (splitByPeriod.length == 1) { + re.append("(\\w+\\"); + re.append(".)*"); + } + + if (j == 0 || j - 1 == 0) { + re.append("(" + splitByPeriod[j] + ")"); + } else { + re.append("(\\." + splitByPeriod[j] + ")"); + } + } + } + re.append("$"); + } + return re.toString(); + } + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationFactoryImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationFactoryImpl.java new file mode 100644 index 0000000000..cf6b3245ce --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationFactoryImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.guardian.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementation; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + +public class GuardianGroupImplementationFactoryImpl implements GuardianGroupImplementationFactory { + + private AssemblyFactory assemblyFactory; + private JavaInterfaceFactory javaFactory; + + public GuardianGroupImplementationFactoryImpl(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) { + this.assemblyFactory = assemblyFactory; + this.javaFactory = javaFactory; + } + + public GuardianGroupImplementation createGuardianGroupImplementation() { + return new GuardianGroupImplementationImpl(assemblyFactory, javaFactory); + } + +// public GuardianGroupImplementation createGuardianGroupImplementation() { +// return new GuardianGroupImplementationImpl(); +// } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationImpl.java new file mode 100644 index 0000000000..7520846d55 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImplementationImpl.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.guardian.impl; + +import org.apache.tuscany.sca.implementation.guardian.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + +public class GuardianGroupImplementationImpl implements GuardianGroupImplementation { + + private AssemblyFactory assemblyFactory; + private JavaInterfaceFactory javaFactory; + private List services = new ArrayList(); + private OMElement guardianProperties; + + public GuardianGroupImplementationImpl(AssemblyFactory assemblyFactory, + JavaInterfaceFactory javaFactory) { + + this.assemblyFactory = assemblyFactory; + this.javaFactory = javaFactory; + this.guardianProperties = null; + } + + private void introspectServices(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) { + + Service guardianService = assemblyFactory.createService(); + + guardianService.setName("GuardianGroup"); + + JavaInterface guardianInterface; + + try { + guardianInterface = javaFactory.createJavaInterface(GuardianGroup.class); + } catch (InvalidInterfaceException ex) { + throw new IllegalArgumentException(ex); + } + + JavaInterfaceContract guardianInterfaceContract = javaFactory.createJavaInterfaceContract(); + + guardianInterfaceContract.setInterface(guardianInterface); + + guardianService.setInterfaceContract(guardianInterfaceContract); + + services.add(guardianService); + } + + public void setGuardianProperties(OMElement guardianProperties) { + this.guardianProperties = guardianProperties; + } + + public OMElement getGuardianProperties() { + return this.guardianProperties; + } + + @Override + public String getURI() { + // The Guardian Model implementation does not have a URI + return null; + } + + @Override + public void setURI(String arg0) { + // The Guardian Model implementation does not have a URI + } + + @Override + public List getServices() { + if (services == null || services.size() == 0) { + introspectServices(assemblyFactory, javaFactory); + } + return services; + } + + @Override + public List getReferences() { + // The Guardian Model implementation does not support references + return Collections.emptyList(); + } + + @Override + public List getProperties() { + // The sample DATA implementation does not support properties + return Collections.emptyList(); + } + + @Override + public ConstrainingType getConstrainingType() { + // The Guardian Model implementation does not support constrainingTypes + return null; + } + + @Override + public void setConstrainingType(ConstrainingType arg0) { + // The Guardian Model implementation does not support constrainingTypes + } + + @Override + public boolean isUnresolved() { + // The Guardian Model implementation is always resolved + return false; + } + + @Override + public void setUnresolved(boolean arg0) { + // The Guardian Model implementation is always resolved + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java new file mode 100644 index 0000000000..80b9321e79 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.guardian.impl; + +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.Stack; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.tuscany.sca.implementation.guardian.common.GlobalExceptionInterface; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroup; +import org.apache.tuscany.sca.implementation.guardian.GuardianMember; +import org.apache.tuscany.sca.implementation.guardian.common.Context; +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.JoinException; +import org.apache.tuscany.sca.implementation.guardian.common.SuspendException; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(GuardianMember.class) +@Scope("COMPOSITE") +public class GuardianMemberImpl implements GuardianMember { + + private int participantState; + private Stack contextList; + + private Queue exceptionQueue; + @Reference(name = "guardian_group", required = true) + public GuardianGroup guardianGroup; + private int id; + //FIXME: Review the usage of this variable + private boolean exceptionThrown; + + public GuardianMemberImpl() { + contextList = new Stack(); + contextList.add(Context.INIT_CONTEXT); + exceptionQueue = new LinkedList(); + participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE; + exceptionThrown = false; + } + + @Init + public void init() { + guardianGroup.addGuardianMember(this); + } + + @Destroy + public void destroy() { + guardianGroup.removeGuardianMember(this); + } + + public void addException(GlobalException ex) { + exceptionQueue.add(ex); + } + + public Context getCurrentContext() { + return contextList.peek(); + } + + + public void enableContext(Context context) { + //Update the context list with the related set of exceptions + contextList.push(context); + + if (contextList.size() == 2) { + JoinException ex = new JoinException(); + ex.setSignalingContext(context); + ex.putSignalingParticipant(getParticipantIdentifier()); + gthrow(ex, null); + } + + } + + public void removeContext() { + if (!contextList.isEmpty()) { + contextList.pop(); + } + } + + //If participantList is null then signal to ALL participants + public void gthrow(GlobalExceptionInterface ex, List participantList) { + //1)Block the participant until raise an exception + + if (!(ex instanceof SuspendException)) { + //Set the exception's parameters + ex.setSignalingContext(getCurrentContext()); + ex.putSignalingParticipant(getParticipantIdentifier()); + + guardianGroup.gthrow(ex, participantList); + exceptionThrown = true; + } else { + setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE); + } + } + + public boolean propagate(GlobalExceptionInterface ex) { + //1)Compares the current context with the exception's target context + return !getCurrentContext().equals(ex.getTargetContext()); + } + + public void checkExceptionStatus() throws GlobalException { + + //Blocks until the state be diferent the SUSPENDED_STATE + while (participantState == GuardianGroup.SUSPENDED_PARTICIPANT_STATE && exceptionThrown) { + System.out.println(getParticipantIdentifier() + ": I am blocked!"); + try { + Thread.sleep(5000); + } catch (InterruptedException ex) { + Logger.getLogger(GuardianMemberImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + exceptionThrown = false; + System.out.println(getParticipantIdentifier() + ": I am not blocked!"); + + GlobalException exc; + + if ((exc = exceptionQueue.peek()) == null) { + System.out.println(getParticipantIdentifier() + "#No exception on exception queue"); + return; + } + + //Check if ex.targetContext() matches the participant id + //Eg. ex.targetContext(): Main and participant id: Init.Main.Backup -> should thrown the exception + //Test if the exception should be thrown in the target context + for (Context c : contextList) { + if (exc.getTargetContext().equals(c) && (c.equals(Context.INIT_CONTEXT) || c.getExceptionList().contains(exc.getClass()))) { + System.out.println(getParticipantIdentifier() + "#Returning an exception"); + exceptionQueue.poll(); + throw exc; + } + } + + return; + } + + public String getParticipantIdentifier() { + //1) Return the participant identifier -> context list dot separated + StringBuffer participantIdentifier = new StringBuffer(); + participantIdentifier.append(this.id); + for (int i = 0; i < contextList.size(); i++) { + participantIdentifier.append("." + contextList.get(i).getName()); + } + return participantIdentifier.toString(); + } + + public void setUniqueParticipantID(int id) { + this.id = id; + } + + public int getParticipantState() { + return participantState; + } + + public void setParticipantState(int state) { + this.participantState = state; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/RecoveryRulesImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/RecoveryRulesImpl.java new file mode 100644 index 0000000000..e2fc2f8048 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/RecoveryRulesImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.guardian.impl; + +import org.apache.tuscany.sca.implementation.guardian.RecoveryRules; +import java.util.Hashtable; +import java.util.Map; +import org.apache.axiom.om.OMElement; + +public class RecoveryRulesImpl implements RecoveryRules { + + private Map ruleElements = new Hashtable(); + + public Map getRuleElements() { + return ruleElements; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/ResolutionTreesImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/ResolutionTreesImpl.java new file mode 100644 index 0000000000..669f06b1ef --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/ResolutionTreesImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.guardian.impl; + +import java.util.Hashtable; +import java.util.Map; +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.implementation.guardian.ResolutionTrees; + +public class ResolutionTreesImpl implements ResolutionTrees { + + private Map resolutionTreeElements = new Hashtable(); + + public Map getResolutionTreeElements() { + return resolutionTreeElements; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProvider.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProvider.java new file mode 100644 index 0000000000..2eb3dbdf58 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProvider.java @@ -0,0 +1,115 @@ +/* + * 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.provider; + +import org.apache.tuscany.sca.implementation.guardian.impl.*; +import java.util.Iterator; +import org.apache.axiom.om.OMAttribute; +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroup; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementation; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.implementation.guardian.common.Constants; + +public class GuardianGroupImplementationProvider implements ImplementationProvider { + + private GuardianGroupImplementation implementation; + private GuardianGroupImpl guardian; + + public GuardianGroupImplementationProvider(RuntimeComponent component, GuardianGroupImplementation implementation) { + this.implementation = implementation; + this.guardian = createGuardian(implementation.getGuardianProperties()); + } + + private GuardianGroupImpl createGuardian(OMElement guardianProperties) { + GuardianGroupImpl guardian = null; + + String recoveryRules = null; + String resolutionTrees = null; + + OMAttribute at; + Iterator it = guardianProperties.getAllAttributes(); + while (it.hasNext()) { + at = (OMAttribute) it.next(); + + if (at.getLocalName().equals(Constants.RECOVERY_RULES)) { + recoveryRules = at.getAttributeValue(); + } else if (at.getLocalName().equals(Constants.RESOLUTION_TREES)) { + resolutionTrees = at.getAttributeValue(); + } + } + + if (recoveryRules != null && resolutionTrees != null) { + guardian = new GuardianGroupImpl(recoveryRules, resolutionTrees); + } + + return guardian; + } + + public void start() { + } + + public void stop() { + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + String operationName = operation.getName(); + String interfaceFullName = operation.getInterface().toString(); + + //GuardianGroup interface + if (interfaceFullName.equals(GuardianGroup.class.getName())) { + + //Why is the createInvoker ivoked 'n' static inner class times? + //System.out.println("NAME: " + operationName); + + //public void addGuardianMember(GuardianMember guardianMember) + if (operationName.equals("addGuardianMember")) { + return new GuardianGroupInvoker.AddGuardianMemberInvoker(guardian); + } //public boolean removeGuardianMember(GuardianMember guardianMember) + else if (operationName.equals("removeGuardianMember")) { + return new GuardianGroupInvoker.RemoveGuardianMemberInvoker(guardian); + } //public void enableContext(Context context); + else if (operationName.equals("enableContext")) { + return new GuardianGroupInvoker.EnableContextInvoker(guardian); + } //public void removeContext(); + else if (operationName.equals("removeContext")) { + return new GuardianGroupInvoker.RemoveContextInvoker(guardian); + } //public void gthrow(GlobalExceptionInterface ex, List participantList); + else if (operationName.equals("gthrow")) { + return new GuardianGroupInvoker.GthrowInvoker(guardian); + } //public boolean propagate(GlobalExceptionInterface ex); + else if (operationName.equals("propagate")) { + return new GuardianGroupInvoker.PropagateInvoker(guardian); + } //public void checkExceptionStatus() throws GlobalException; + else if (operationName.equals("checkExceptionStatus")) { + return new GuardianGroupInvoker.CheckExceptionStatusInvoker(guardian); + } + } + + return new GuardianGroupInvoker(null); + } + + public boolean supportsOneWayInvocation() { + return false; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProviderFactory.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProviderFactory.java new file mode 100644 index 0000000000..a42c35506d --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupImplementationProviderFactory.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.implementation.guardian.provider; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementation; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +public class GuardianGroupImplementationProviderFactory implements ImplementationProviderFactory { + public GuardianGroupImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, GuardianGroupImplementation implementation) { + return new GuardianGroupImplementationProvider(component, implementation); + } + + public Class getModelType() { + return GuardianGroupImplementation.class; + } +} 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 new file mode 100644 index 0000000000..8f393ebcb9 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/provider/GuardianGroupInvoker.java @@ -0,0 +1,163 @@ +/* + * 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.provider; + +import org.apache.tuscany.sca.implementation.guardian.impl.*; +import java.util.List; +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.GlobalExceptionInterface; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +public class GuardianGroupInvoker implements Invoker { + + protected final GuardianGroupImpl guardian; + + public GuardianGroupInvoker(GuardianGroupImpl guardian) { + this.guardian = guardian; + } + + public Message invoke(Message arg0) { + throw new UnsupportedOperationException("Not supported yet. 1"); + } + + //AddGuardianMember operation invoker + public static class AddGuardianMemberInvoker extends GuardianGroupInvoker { + + public AddGuardianMemberInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + GuardianMember guardianMember = (GuardianMember) ((Object[]) msg.getBody())[0]; + this.guardian.addGuardianMember(guardianMember); + + return msg; + } + } + + //RemoveGuardianMember operation invoker + public static class RemoveGuardianMemberInvoker extends GuardianGroupInvoker { + + public RemoveGuardianMemberInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + GuardianMember guardianMember = (GuardianMember) ((Object[]) msg.getBody())[0]; + boolean returnedValue = this.guardian.removeGuardianMember(guardianMember); + + msg.setBody(returnedValue); + return msg; + } + } + + //EnableContext operation invoker + public static class EnableContextInvoker extends GuardianGroupInvoker { + + public EnableContextInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + Context context = (Context) ((Object[]) msg.getBody())[0]; + + this.guardian.enableContext(context); + + return msg; + } + } + + //RemoveContext operation invoker + public static class RemoveContextInvoker extends GuardianGroupInvoker { + + public RemoveContextInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + this.guardian.removeContext(); + + return msg; + } + } + + //Gthrow operation invoker + public static class GthrowInvoker extends GuardianGroupInvoker { + + public GthrowInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msg.getBody())[0]; + List participantList = (List) ((Object[]) msg.getBody())[1]; + + this.guardian.gthrow(ex, participantList); + + return msg; + } + } + + //Propagate operation invoker + public static class PropagateInvoker extends GuardianGroupInvoker { + + public PropagateInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msg.getBody())[0]; + + boolean needPropagation = this.guardian.propagate(ex); + msg.setBody(needPropagation); + + return msg; + } + } + + //CheckExceptionStatus operation invoker + public static class CheckExceptionStatusInvoker extends GuardianGroupInvoker { + + public CheckExceptionStatusInvoker(GuardianGroupImpl guardian) { + super(guardian); + } + + @Override + public Message invoke(Message msg) { + + this.guardian.checkExceptionStatus(); + + return msg; + } + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/GuardianGroupImplementationProcessor.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/GuardianGroupImplementationProcessor.java new file mode 100644 index 0000000000..048ef7b9c8 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/GuardianGroupImplementationProcessor.java @@ -0,0 +1,144 @@ +/* + * 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.xml; + +import org.apache.tuscany.sca.implementation.guardian.*; +import java.util.Iterator; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMAttribute; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.implementation.guardian.impl.GuardianGroupImplementationFactoryImpl; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.monitor.Monitor; + +public class GuardianGroupImplementationProcessor implements StAXArtifactProcessor { + + protected static final QName IMPLEMENTATION_GUARDIAN = new QName(Constants.SCA10_TUSCANY_NS, "implementation.guardian"); + protected static final QName GUARDIAN_PROPERTIES = new QName(Constants.SCA10_TUSCANY_NS, "guardianProperties"); + private GuardianGroupImplementationFactory guardianGroupImplementationFactory; + + private AssemblyFactory assemblyFactor; + private JavaInterfaceFactory javaFactory; + + //public GuardianGroupImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + //public GuardianGroupImplementationProcessor(ModelFactoryExtensionPoint modelFactories) { + public GuardianGroupImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + + assemblyFactor = modelFactories.getFactory(AssemblyFactory.class); + javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); + + guardianGroupImplementationFactory = new GuardianGroupImplementationFactoryImpl(assemblyFactor, javaFactory); + //guardianGroupImplementationFactory = modelFactories.getFactory(GuardianGroupImplementationFactory.class); + } + + public GuardianGroupImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + assert IMPLEMENTATION_GUARDIAN.equals(reader.getName()); + + GuardianGroupImplementation implementation = guardianGroupImplementationFactory.createGuardianGroupImplementation(); + + while (reader.hasNext()) { + reader.next(); + + if (reader.isStartElement() && reader.getName().equals(GUARDIAN_PROPERTIES)) { + OMElement guardianPropertiesElement = readGuardianProperties(reader); + + //REVIEW + implementation.setGuardianProperties(guardianPropertiesElement); + + break; + } + } + + return implementation; + } + + private OMElement readGuardianProperties(XMLStreamReader reader) { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement element = fac.createOMElement(reader.getName()); + + for (int i = 0; i < reader.getAttributeCount(); i++) { + + String ns = reader.getAttributeNamespace(i); + String prefix = reader.getAttributePrefix(i); + String qname = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + + if (ns != null) { + element.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); + element.declareNamespace(ns, prefix); + } else { + element.addAttribute(qname, value, null); + } + } + + return element; + } + + public void write(GuardianGroupImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + writer.writeStartElement(IMPLEMENTATION_GUARDIAN.getNamespaceURI(), IMPLEMENTATION_GUARDIAN.getLocalPart()); + + OMElement guardianProperties = implementation.getGuardianProperties(); + if (guardianProperties != null) { + writeGuardianProperties(guardianProperties, writer); + } + + writer.writeEndElement(); + } + + private void writeGuardianProperties(OMElement guardianProperties, XMLStreamWriter writer) throws XMLStreamException { + + OMAttribute at; + + //write the element's name + writer.writeStartElement(guardianProperties.getLocalName()); + + //write the attributes + Iterator attributes = guardianProperties.getAllAttributes(); + while (attributes.hasNext()) { + at = (OMAttribute) attributes.next(); + writer.writeAttribute(at.getLocalName(), at.getAttributeValue()); + } + + writer.writeEndElement(); + } + + public QName getArtifactType() { + return IMPLEMENTATION_GUARDIAN; + } + + public void resolve(GuardianGroupImplementation arg0, ModelResolver arg1) throws ContributionResolveException { + } + + public Class getModelType() { + return GuardianGroupImplementation.class; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/RecoveryRulesProcessor.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/RecoveryRulesProcessor.java new file mode 100644 index 0000000000..7d82f356de --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/RecoveryRulesProcessor.java @@ -0,0 +1,158 @@ +/* + * 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.xml; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.implementation.guardian.common.Constants; +import org.apache.tuscany.sca.implementation.guardian.impl.RecoveryRulesImpl; +import org.apache.tuscany.sca.implementation.guardian.RecoveryRules; + +public class RecoveryRulesProcessor implements StAXArtifactProcessor, Constants { + + private static final QName RECOVERY_RULES_POLICY_QNAME = RecoveryRules.RECOVERY_RULES_POLICY_QNAME; + + public RecoveryRulesProcessor() { + } + + public RecoveryRules read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + + RecoveryRules policy = new RecoveryRulesImpl(); + QName name = null; + String ruleName = null; + OMElement ruleElement = null; + while (reader.hasNext()) { + + if (reader.isStartElement()) { + + name = reader.getName(); + if (RULE.equals(name.getLocalPart())) { + + ruleName = reader.getAttributeValue(null, Constants.NAME); + ruleElement = loadElement(reader); + + policy.getRuleElements().put(ruleName, ruleElement); + } + } else if (reader.isEndElement()) { + if (RECOVERY_RULES_POLICY_QNAME.equals(reader.getName())) { + break; + } + } + + reader.next(); + } + + return policy; + } + + public void write(RecoveryRules policy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public QName getArtifactType() { + return RECOVERY_RULES_POLICY_QNAME; + } + + public void resolve(RecoveryRules arg0, ModelResolver arg1) throws ContributionResolveException { + + } + + public Class getModelType() { + return RecoveryRules.class; + } + + private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement head = fac.createOMElement(reader.getName()); + + //Load the attributes for the rule tag + loadAttributes(reader, head, fac); + + OMElement current = head; + while (true) { + + switch (reader.next()) { + case XMLStreamConstants.START_ELEMENT: + + QName name = new QName(reader.getName().getLocalPart()); + OMElement child = fac.createOMElement(name, current); + + int count = reader.getNamespaceCount(); + for (int i = 0; i < count; i++) { + String prefix = reader.getNamespacePrefix(i); + String ns = reader.getNamespaceURI(i); + child.declareNamespace(ns, prefix); + } + + if (!"".equals(name.getNamespaceURI())) { + child.declareNamespace(name.getNamespaceURI(), name.getPrefix()); + } + + // add the attributes for this element + loadAttributes(reader, child, fac); + current = child; + break; + case XMLStreamConstants.CDATA: + fac.createOMText(current, reader.getText()); + break; + case XMLStreamConstants.CHARACTERS: + String text = reader.getText().trim(); + if (text.length() != 0) { + fac.createOMText(current, reader.getText()); + } + break; + case XMLStreamConstants.END_ELEMENT: + if (current == head) { + return head; + } else { + current = (OMElement) current.getParent(); + } + } + } + } + + private void loadAttributes(XMLStreamReader reader, OMElement elem, OMFactory fac) { + int count = reader.getAttributeCount(); + for (int i = 0; i < count; i++) { + String ns = reader.getAttributeNamespace(i); + String prefix = reader.getAttributePrefix(i); + String qname = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + + if (ns != null) { + elem.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); + elem.declareNamespace(ns, prefix); + } else { + elem.addAttribute(qname, value, null); + } + } + } + +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/ResolutionTreesProcessor.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/ResolutionTreesProcessor.java new file mode 100644 index 0000000000..b9cfe647b4 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/ResolutionTreesProcessor.java @@ -0,0 +1,157 @@ +/* + * 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.xml; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.implementation.guardian.common.Constants; +import org.apache.tuscany.sca.implementation.guardian.impl.ResolutionTreesImpl; +import org.apache.tuscany.sca.implementation.guardian.ResolutionTrees; + +public class ResolutionTreesProcessor implements StAXArtifactProcessor, Constants { + + private static final QName RESOLUTION_TREES_POLICY_QNAME = ResolutionTrees.RESOLUTION_TREES_POLICY_QNAME; + + public ResolutionTreesProcessor() { + } + + public ResolutionTrees read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + + ResolutionTrees policy = new ResolutionTreesImpl(); + QName name = null; + String ruleName = null; + OMElement ruleElement = null; + while (reader.hasNext()) { + + if (reader.isStartElement()) { + + name = reader.getName(); + if (RESOLUTION_TREE.equals(name.getLocalPart())) { + + ruleName = reader.getAttributeValue(null, Constants.EXCEPTION_LEVEL); + ruleElement = loadElement(reader); + + policy.getResolutionTreeElements().put(ruleName, ruleElement); + } + } else if (reader.isEndElement()) { + if (RESOLUTION_TREES_POLICY_QNAME.equals(reader.getName())) { + break; + } + } + + reader.next(); + } + + return policy; + } + + public void write(ResolutionTrees policy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public QName getArtifactType() { + return RESOLUTION_TREES_POLICY_QNAME; + } + + public void resolve(ResolutionTrees arg0, ModelResolver arg1) throws ContributionResolveException { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public Class getModelType() { + return ResolutionTrees.class; + } + + private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement head = fac.createOMElement(reader.getName()); + + //Load the attributes for the rule tag + loadAttributes(reader, head, fac); + + OMElement current = head; + while (true) { + + switch (reader.next()) { + case XMLStreamConstants.START_ELEMENT: + + QName name = new QName(reader.getName().getLocalPart()); + OMElement child = fac.createOMElement(name, current); + + int count = reader.getNamespaceCount(); + for (int i = 0; i < count; i++) { + String prefix = reader.getNamespacePrefix(i); + String ns = reader.getNamespaceURI(i); + child.declareNamespace(ns, prefix); + } + + if (!"".equals(name.getNamespaceURI())) { + child.declareNamespace(name.getNamespaceURI(), name.getPrefix()); + } + + // add the attributes for this element + loadAttributes(reader, child, fac); + current = child; + break; + case XMLStreamConstants.CDATA: + fac.createOMText(current, reader.getText()); + break; + case XMLStreamConstants.CHARACTERS: + String text = reader.getText().trim(); + if (text.length() != 0) { + fac.createOMText(current, reader.getText()); + } + break; + case XMLStreamConstants.END_ELEMENT: + if (current == head) { + return head; + } else { + current = (OMElement) current.getParent(); + } + } + } + } + + private void loadAttributes(XMLStreamReader reader, OMElement elem, OMFactory fac) { + int count = reader.getAttributeCount(); + for (int i = 0; i < count; i++) { + String ns = reader.getAttributeNamespace(i); + String prefix = reader.getAttributePrefix(i); + String qname = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + + if (ns != null) { + elem.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); + elem.declareNamespace(ns, prefix); + } else { + elem.addAttribute(qname, value, null); + } + } + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..b489bb90fc --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -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 artifact processor extension +org.apache.tuscany.sca.implementation.guardian.xml.GuardianGroupImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.guardian,model=org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementation,factory=org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory new file mode 100644 index 0000000000..744815a572 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory @@ -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 implementation model factory +org.apache.tuscany.sca.implementation.guardian.impl.GuardianGroupImplementationFactoryImpl diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..4ab8d2e6a3 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -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 implementation extension +org.apache.tuscany.sca.implementation.guardian.provider.GuardianGroupImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementation diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/guardianTest.composite b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/guardianTest.composite new file mode 100644 index 0000000000..d31485d67c --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/guardianTest.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + 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 new file mode 100644 index 0000000000..fcb78e3879 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/recoveryRules.xml b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/recoveryRules.xml new file mode 100644 index 0000000000..b2eacf8b8a --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/recoveryRules.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + FIRST + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FIRST + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/resolutionTrees.xml b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/resolutionTrees.xml new file mode 100644 index 0000000000..ca3fa1534c --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/resolutionTrees.xml @@ -0,0 +1,8 @@ + + + + + + + + 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 new file mode 100644 index 0000000000..85af4efd48 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/recoveryRules.xml b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/recoveryRules.xml new file mode 100644 index 0000000000..0016fa4d9f --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/recoveryRules.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/lcaTest.xml b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/lcaTest.xml new file mode 100644 index 0000000000..e528760ad8 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/lcaTest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz b/sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz new file mode 100644 index 0000000000..8845a544fe Binary files /dev/null and b/sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz differ 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 new file mode 100644 index 0000000000..ba4f6230d8 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/GuardianImplementationTest.java @@ -0,0 +1,77 @@ +/* + * 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/LCATestCase.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/LCATestCase.java new file mode 100644 index 0000000000..3c5e6b1b19 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/LCATestCase.java @@ -0,0 +1,115 @@ +/* + * 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 java.io.FileInputStream; +import org.apache.tuscany.sca.implementation.guardian.common.ResolutionTreeUtils; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Map; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; +import org.junit.Test; +import org.apache.axiom.om.OMElement; +import java.util.List; +import junit.framework.Assert; +import org.apache.tuscany.sca.implementation.guardian.xml.ResolutionTreesProcessor; +import org.junit.Before; + +public class LCATestCase { + + private ResolutionTreeUtils treeUtils; + + @Before + public void init() throws Exception { + ResolutionTreesProcessor processor = new ResolutionTreesProcessor(); + + FileInputStream fileInputStream = new FileInputStream("src/main/resources/org/apache/" + + "tuscany/sca/implementation/guardian/lcaTest.xml"); + XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + + ResolutionTrees policy = processor.read(reader); + Map resolutionTrees = policy.getResolutionTreeElements(); + + List rootElements = getRootElements(resolutionTrees.values()); + + treeUtils = new ResolutionTreeUtils(); + treeUtils.setRoot(rootElements.get(0)); + } + + @Test + public void testLCAEx2Ex2() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception2"); + System.out.println("lca: " + lca); + Assert.assertEquals("Exception2", lca); + } + + @Test + public void testLCAEx2Ex3() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception3"); + Assert.assertEquals("Exception1", lca); + } + + @Test + public void testLCAEx2Ex8() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception8"); + Assert.assertEquals("Exception1", lca); + } + + @Test + public void testLCAEx4Ex3() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception4", "Exception3"); + Assert.assertEquals("Exception1", lca); + } + + @Test + public void testLCAEx4Ex5() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception4", "Exception5"); + Assert.assertEquals("Exception2", lca); + } + + @Test + public void testLCAEx6Ex7() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception6", "Exception7"); + Assert.assertEquals("Exception3", lca); + } + + @Test + public void testLCAEx1Ex8() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception1", "Exception8"); + Assert.assertEquals("Exception1", lca); + } + + @Test + public void testLCAEx2Ex5() throws Exception { + String lca = treeUtils.getLowestCommonAncestor("Exception2", "Exception5"); + Assert.assertEquals("Exception2", lca); + } + + private List getRootElements(Collection resolutionTrees) { + List rootElements = new LinkedList(); + + for (OMElement resolutionTree : resolutionTrees) { + rootElements.add(resolutionTree.getFirstElement()); + } + + return rootElements; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java new file mode 100644 index 0000000000..b08b26942d --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/ApplyUpdateFailureException.java @@ -0,0 +1,22 @@ +/* + * 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.itests.primaryBackup.common; + +public class ApplyUpdateFailureException extends RuntimeException { +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupFailedException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupFailedException.java new file mode 100644 index 0000000000..25adf1d739 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupFailedException.java @@ -0,0 +1,24 @@ +/* + * 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.itests.primaryBackup.common; + +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public class BackupFailedException extends GlobalException { +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupJoinedException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupJoinedException.java new file mode 100644 index 0000000000..f0d29f461f --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupJoinedException.java @@ -0,0 +1,24 @@ +/* + * 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.itests.primaryBackup.common; + +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public class BackupJoinedException extends GlobalException { +} 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 new file mode 100644 index 0000000000..6aa9456816 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java @@ -0,0 +1,37 @@ +/* + * 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.itests.primaryBackup.common; + +import org.osoa.sca.annotations.OneWay; + +public interface Node { + + @OneWay + public void execute(); + + public void sendUpdate(String s); + + public void applyUpdate(); + + public String getID(); + + public void kill(); + + public boolean isDead(); +} 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 new file mode 100644 index 0000000000..37f4f529f0 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java @@ -0,0 +1,282 @@ +/* + * 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.itests.primaryBackup.common; + +import java.util.LinkedList; +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.GuardianMember; +import org.apache.tuscany.sca.implementation.guardian.common.Context; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.OneWay; + +@Scope("COMPOSITE") +public class NodeImpl implements Node, TestInterface { + + private static int PRIMARY = 0; + private static int BACKUP = 1; + private boolean isDead; + private Context mainContext; + private Context primaryContext; + private Context backupContext; + private int role; + private String pID; + private Queue updates; + @Reference(name = "guardian_member", required = true) + public GuardianMember gm; + @Reference(name = "nodes", required = true) + public List nodeList; + private boolean forcePSFException; + private boolean forceAUFException; + private int upcount; + + public NodeImpl() { + + mainContext = new Context("MAIN"); + mainContext.addException(PrimaryFailedException.class); + mainContext.addException(PrimaryExistsException.class); + + primaryContext = new Context("PRIMARY"); + primaryContext.addException(BackupFailedException.class); + primaryContext.addException(BackupJoinedException.class); + primaryContext.addException(PrimaryServiceFailureException.class); + + backupContext = new Context("BACKUP", null); + + updates = new LinkedList(); + + isDead = true; + + nodeList = new LinkedList(); + + forcePSFException = false; + forceAUFException = false; + } + + @Init + public void init() { + pID = gm.getParticipantIdentifier(); + } + + @OneWay + public void execute() { + isDead = false; + gm.enableContext(mainContext); + role = PRIMARY; + + while (true) { + + //blockingCheck(); + + try { + System.out.println(pID + "#Main context: "); + sleep(pID + "#Sleeping at main context...", 4000); + + gm.checkExceptionStatus(); + + if (role == PRIMARY) { + //Config as primary then... + primaryService(); + } else { + //Config as backup then... + backupService(); + } + + + } catch (PrimaryExistsException ex) { + System.out.println(pID + "# Exception captured!: PrimaryExistsException"); + role = BACKUP; + + } catch (PrimaryFailedException ex) { + System.out.println(pID + "# Exception captured!: PrimaryFailedException"); + System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex)); + + if (gm.propagate(ex)) { + //throw ex; + this.kill(); + ex.printStackTrace(); + return; + } + + role = PRIMARY; + + } catch (BackupFailedException ex) { + System.out.println(pID + "# Exception captured!: BackupFailedException"); + System.out.println(pID + "#Needs propagation?: " + gm.propagate(ex)); + + if (gm.propagate(ex)) { + //throw ex; + this.kill(); + ex.printStackTrace(); + return; + } + } + } + } + + private void primaryService() { + boolean backupAvailable = isThereBackupAvailable(); + + upcount = 1; + + while (true) { + + gm.enableContext(primaryContext); + + //blockingCheck(); + + try { + System.out.println(pID + "#Primary context: "); + sleep(pID + "#Sleeping at primary context...", 4000); + gm.checkExceptionStatus(); + + //Process the request then... + System.out.println(pID + "#Processing the request..."); + + //Check for an internal error + if (forcePSFException) { + throw new PrimaryServiceFailureException(); + } + + if (backupAvailable) { + + if (!updateBackups()) { + backupAvailable = isThereBackupAvailable(); + } + + } else { + System.out.println(pID + "#No backup available to send updates!"); + //backupAvailable = isThereBackupAvailable(); + } + //send the reply to the client + System.out.println(pID + "#Sending the reply to the client..."); + + } catch (PrimaryServiceFailureException ex) { + System.out.println(pID + "# Exception captured!: PrimaryServiceFailureException"); + gm.gthrow(new PrimaryFailedException(), null); + } catch (BackupFailedException ex) { + System.out.println(pID + "# Exception captured!: BackupFailedException"); + //backupAvailable = false; + backupAvailable = isThereBackupAvailable(); + } catch (BackupJoinedException ex) { + System.out.println(pID + "# Exception captured!: BackupJoinedException"); + backupAvailable = true; + } finally { + gm.removeContext(); + } + } + } + + private boolean updateBackups() { + boolean flag = false; + + for (Node n : nodeList) { + if (!n.isDead()) { + n.sendUpdate("Update " + upcount); + flag = true; + } + } + if (flag) { + upcount++; + } + + return flag; + } + + private void backupService() { + while (true) { + + gm.enableContext(backupContext); + + //blockingCheck(); + + try { + System.out.println(pID + "#Backup context: "); + sleep(pID + "#Sleeping at backup service", 4000); + gm.checkExceptionStatus(); + + applyUpdate(); + + if (forceAUFException) { + throw new ApplyUpdateFailureException(); + } + + } catch (ApplyUpdateFailureException ex) { + System.out.println(pID + "# Exception captured!: ApplyUpdateFailureException"); + gm.gthrow(new BackupFailedException(), null); + } finally { + gm.removeContext(); + } + } + } + + public String getID() { + return gm.getParticipantIdentifier(); + } + + private void sleep(String msg, int millis) { + try { + System.out.println(msg); + Thread.sleep(millis); + } catch (InterruptedException ex) { + Logger.getLogger(NodeImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private boolean isThereBackupAvailable() { + for (Node n : nodeList) { + if (!n.isDead()) { + return true; + } + } + return false; + } + + public void kill() { + isDead = true; + } + + public boolean isDead() { + return isDead; + } + + public void sendUpdate(String update) { + System.out.println(pID + "#Receiving updates from primary: " + update); + updates.offer(update); + } + + public void applyUpdate() { + if (!updates.isEmpty()) { + System.out.println(pID + "#Applying the updates received from the primary: " + updates.poll()); + } + } + + public void forcePrimaryServiceFailureException() { + forcePSFException = true; + } + + public void forceApplyUpdateFailureException() { + forceAUFException = true; + } +} + diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java new file mode 100644 index 0000000000..5521caa550 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryBackupFailedTogetherException.java @@ -0,0 +1,26 @@ +/* + * 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.itests.primaryBackup.common; + +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public class PrimaryBackupFailedTogetherException extends GlobalException { + +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryExistsException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryExistsException.java new file mode 100644 index 0000000000..d6297a1012 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryExistsException.java @@ -0,0 +1,24 @@ +/* + * 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.itests.primaryBackup.common; + +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public class PrimaryExistsException extends GlobalException { +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryFailedException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryFailedException.java new file mode 100644 index 0000000000..cc1715d077 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryFailedException.java @@ -0,0 +1,24 @@ +/* + * 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.itests.primaryBackup.common; + +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public class PrimaryFailedException extends GlobalException { +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java new file mode 100644 index 0000000000..0bcfb72bc8 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java @@ -0,0 +1,24 @@ +/* + * 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.itests.primaryBackup.common; + +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; + +public class PrimaryServiceFailureException extends GlobalException { +} diff --git a/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/TestInterface.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/TestInterface.java new file mode 100644 index 0000000000..7e7bd35cd2 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/TestInterface.java @@ -0,0 +1,26 @@ +/* + * 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.itests.primaryBackup.common; + +public interface TestInterface { + + public void forcePrimaryServiceFailureException(); + + public void forceApplyUpdateFailureException(); +} 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 new file mode 100644 index 0000000000..ab0c21dba6 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java @@ -0,0 +1,69 @@ +/* + * 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.itests.primaryBackup.concurrentExceptions; + +import java.io.IOException; +import org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.Node; +import org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.TestInterface; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class Launch { + + public static void main(String... args) throws IOException { + SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/" + + "implementation/guardian/itests/primaryBackup/" + + "concurrentExceptions/primaryBackup.composite"); + + System.out.println("Starting participat1..."); + Node c = scaDomain.getService(Node.class, "Participant1"); + c.execute(); + + System.in.read(); + + System.out.println("Starting participant2..."); + Node c2 = scaDomain.getService(Node.class, "Participant2"); + c2.execute(); + + System.in.read(); + + System.out.println("Starting participant3..."); + Node c3 = scaDomain.getService(Node.class, "Participant3"); + c3.execute(); + + System.in.read(); + + System.out.println("Starting participant4..."); + Node c4 = scaDomain.getService(Node.class, "Participant4"); + c4.execute(); + + System.in.read(); + + System.out.println("Forcing exception ocurrence at participant1..."); + TestInterface t = scaDomain.getService(TestInterface.class, "Participant1"); + t.forcePrimaryServiceFailureException(); + + System.out.println("Forcing exception ocurrence at participant2..."); + TestInterface t2 = scaDomain.getService(TestInterface.class, "Participant2"); + t2.forceApplyUpdateFailureException(); + + System.in.read(); + + scaDomain.close(); + } +} 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 new file mode 100644 index 0000000000..86df9bc5f9 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java @@ -0,0 +1,55 @@ +/* + * 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.itests.primaryBackup.simple; + +import java.io.IOException; +import org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.Node; +import org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.TestInterface; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class Launch { + + public static void main(String... args) throws IOException { + SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/" + + "implementation/guardian/itests/primaryBackup/" + + "simple/primaryBackup.composite"); + + System.out.println("Starting participat1..."); + Node c = scaDomain.getService(Node.class, "Participant1"); + c.execute(); + + System.in.read(); + + System.out.println("Starting participant2..."); + Node c2 = scaDomain.getService(Node.class, "Participant2"); + c2.execute(); + + System.in.read(); + + System.out.println("Forcing exception ocurrence at participant1..."); + TestInterface t = scaDomain.getService(TestInterface.class, "Participant1"); + t.forcePrimaryServiceFailureException(); + + + System.in.read(); + + scaDomain.close(); + } +} + 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 new file mode 100644 index 0000000000..1c5fd26745 --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java @@ -0,0 +1,54 @@ +/* + * 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.itests.primaryBackup.simple; + +import java.io.IOException; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.Node; +import org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.TestInterface; + +public class Launch2 { + + public static void main(String... args) throws IOException { + SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/" + + "implementation/guardian/itests/primaryBackup/" + + "simple/primaryBackup.composite"); + + System.out.println("Starting participat1..."); + Node c = scaDomain.getService(Node.class, "Participant1"); + c.execute(); + + System.in.read(); + + System.out.println("Starting participant2..."); + Node c2 = scaDomain.getService(Node.class, "Participant2"); + c2.execute(); + + System.in.read(); + + System.out.println("Forcing exception ocurrence at participant2..."); + TestInterface t = scaDomain.getService(TestInterface.class, "Participant2"); + t.forceApplyUpdateFailureException(); + + System.in.read(); + + scaDomain.close(); + } +} + diff --git a/sandbox/dougsleite/policy-recoveryrules/pom.xml b/sandbox/dougsleite/policy-recoveryrules/pom.xml deleted file mode 100644 index cadebf4985..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 1.6-SNAPSHOT - ../pom.xml - - tuscany-policy-recoveryrules - Apache Tuscany SCA Recovery Rules Policy Model - - - - - org.apache.tuscany.sca - tuscany-contribution - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-assembly-xml - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution-impl - 1.6-SNAPSHOT - test - - - org.apache.tuscany.sca - tuscany-guardian - 1.6-SNAPSHOT - - - - - - - org.apache.felix - maven-bundle-plugin - - - - ${tuscany.version} - org.apache.tuscany.sca.policy.recoveryrules - ${pom.name} - org.apache.tuscany.sca.policy.recoveryrules* - - - - - - - - - diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicy.java b/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicy.java deleted file mode 100644 index a2497935e2..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicy.java +++ /dev/null @@ -1,49 +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.policy.recoveryrules; - -import java.util.Hashtable; -import java.util.Map; -import javax.xml.namespace.QName; -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.policy.Policy; -import org.apache.tuscany.sca.assembly.xml.Constants; - -public class RecoveryRulesPolicy implements Policy { - - public static final QName RECOVERY_RULES_POLICY_QNAME = - new QName(Constants.SCA10_TUSCANY_NS, org.apache.tuscany.sca.guardian.Constants.RECOVERY_RULES); - - private Map ruleElements = new Hashtable(); - - public QName getSchemaName() { - return RECOVERY_RULES_POLICY_QNAME; - } - - public void setUnresolved(boolean unresolved) { - } - - public boolean isUnresolved() { - return false; - } - - public Map getRuleElements() { - return ruleElements; - } -} diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyDefinitionsProvider.java b/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyDefinitionsProvider.java deleted file mode 100644 index 37499cbad7..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyDefinitionsProvider.java +++ /dev/null @@ -1,59 +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.policy.recoveryrules; - -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 RecoveryRulesPolicyDefinitionsProvider implements SCADefinitionsProvider { - - private String definitionsFile = "org/apache/tuscany/sca/policy/recoveryrules/definitions.xml"; - URLArtifactProcessor urlArtifactProcessor = null; - - public RecoveryRulesPolicyDefinitionsProvider(ExtensionPointRegistry registry) { - URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - urlArtifactProcessor = (URLArtifactProcessor) documentProcessors.getProcessor(SCADefinitions.class); - } - - public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { - URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction() { - - public URL run() { - return getClass().getClassLoader().getResource(definitionsFile); - } - }); - - try { - URI uri = new URI(definitionsFile); - return (SCADefinitions) urlArtifactProcessor.read(null, - uri, - definitionsFileUrl); - } catch (Exception e) { - throw new SCADefinitionsProviderException(e); - } - } -} diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProcessor.java b/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProcessor.java deleted file mode 100644 index 44e6e04594..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProcessor.java +++ /dev/null @@ -1,157 +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.policy.recoveryrules; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.guardian.Constants; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.monitor.Monitor; - -public class RecoveryRulesPolicyProcessor implements StAXArtifactProcessor, Constants { - - private static final QName RECOVERY_RULES_POLICY_QNAME = RecoveryRulesPolicy.RECOVERY_RULES_POLICY_QNAME; - - public RecoveryRulesPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - } - - public RecoveryRulesPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - RecoveryRulesPolicy policy = new RecoveryRulesPolicy(); - QName name = null; - String ruleName = null; - OMElement ruleElement = null; - while (reader.hasNext()) { - - if (reader.isStartElement()) { - - name = reader.getName(); - if (RULE.equals(name.getLocalPart())) { - - ruleName = reader.getAttributeValue(null, Constants.NAME); - ruleElement = loadElement(reader); - - policy.getRuleElements().put(ruleName, ruleElement); - } - } else if (reader.isEndElement()) { - if (RECOVERY_RULES_POLICY_QNAME.equals(reader.getName())) { - break; - } - } - - reader.next(); - } - - return policy; - } - - public void write(RecoveryRulesPolicy policy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - throw new UnsupportedOperationException("Not supported yet."); - } - - public QName getArtifactType() { - return RECOVERY_RULES_POLICY_QNAME; - } - - public void resolve(RecoveryRulesPolicy arg0, ModelResolver arg1) throws ContributionResolveException { - throw new UnsupportedOperationException("Not supported yet."); - } - - public Class getModelType() { - return RecoveryRulesPolicy.class; - } - - private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { - OMFactory fac = OMAbstractFactory.getOMFactory(); - OMElement head = fac.createOMElement(reader.getName()); - - //Load the attributes for the rule tag - loadAttributes(reader, head, fac); - - OMElement current = head; - while (true) { - - switch (reader.next()) { - case XMLStreamConstants.START_ELEMENT: - - QName name = new QName(reader.getName().getLocalPart()); - OMElement child = fac.createOMElement(name, current); - - int count = reader.getNamespaceCount(); - for (int i = 0; i < count; i++) { - String prefix = reader.getNamespacePrefix(i); - String ns = reader.getNamespaceURI(i); - child.declareNamespace(ns, prefix); - } - - if (!"".equals(name.getNamespaceURI())) { - child.declareNamespace(name.getNamespaceURI(), name.getPrefix()); - } - - // add the attributes for this element - loadAttributes(reader, child, fac); - current = child; - break; - case XMLStreamConstants.CDATA: - fac.createOMText(current, reader.getText()); - break; - case XMLStreamConstants.CHARACTERS: - String text = reader.getText().trim(); - if (text.length() != 0) { - fac.createOMText(current, reader.getText()); - } - break; - case XMLStreamConstants.END_ELEMENT: - if (current == head) { - return head; - } else { - current = (OMElement) current.getParent(); - } - } - } - } - - private void loadAttributes(XMLStreamReader reader, OMElement elem, OMFactory fac) { - int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - String ns = reader.getAttributeNamespace(i); - String prefix = reader.getAttributePrefix(i); - String qname = reader.getAttributeLocalName(i); - String value = reader.getAttributeValue(i); - - if (ns != null) { - elem.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); - elem.declareNamespace(ns, prefix); - } else { - elem.addAttribute(qname, value, null); - } - } - } -} diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProviderFactory.java b/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProviderFactory.java deleted file mode 100644 index 9830f4f717..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProviderFactory.java +++ /dev/null @@ -1,55 +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.policy.recoveryrules; - -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 RecoveryRulesPolicyProviderFactory implements PolicyProviderFactory { - - public RecoveryRulesPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - } - - public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return null; - } - - public PolicyProvider createServicePolicyProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return null; - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { - return null; - } - - public Class getModelType() { - return RecoveryRulesPolicy.class; - } -} diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index 9fc1126935..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,19 +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. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#recovery_rules,model=org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicy diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory deleted file mode 100644 index e67f25b9c0..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory +++ /dev/null @@ -1,19 +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. - -# Implementation class for the policy extension -org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicyProviderFactory;model=org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicy diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider deleted file mode 100644 index d12ac9397a..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider +++ /dev/null @@ -1,19 +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. - -# Implementation class for SCA Definitions Providers -org.apache.tuscany.sca.policy.recoveryrules.RecoveryRulesPolicyDefinitionsProvider \ No newline at end of file diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/org/apache/tuscany/sca/policy/recoveryrules/definitions.xml b/sandbox/dougsleite/policy-recoveryrules/src/main/resources/org/apache/tuscany/sca/policy/recoveryrules/definitions.xml deleted file mode 100644 index c898f8faeb..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/org/apache/tuscany/sca/policy/recoveryrules/definitions.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - Describe the recovery rules for the guardian group - - - \ No newline at end of file diff --git a/sandbox/dougsleite/policy-recoveryrules/src/test/java/org/apache/tuscany/sca/policy/recoveryrules/PolicyReadTestCase.java b/sandbox/dougsleite/policy-recoveryrules/src/test/java/org/apache/tuscany/sca/policy/recoveryrules/PolicyReadTestCase.java deleted file mode 100644 index 93c3dcfaa1..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/test/java/org/apache/tuscany/sca/policy/recoveryrules/PolicyReadTestCase.java +++ /dev/null @@ -1,96 +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.policy.recoveryrules; - -import java.io.InputStream; -import java.io.StringWriter; -import java.net.URL; -import java.util.Iterator; -import java.util.Map; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import org.junit.Test; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.guardian.Constants; - -public class PolicyReadTestCase { - - @Test - public void testPolicyReading() throws Exception { - RecoveryRulesPolicyProcessor processor = new RecoveryRulesPolicyProcessor(null, null); - - URL url = getClass().getResource("test_policies.xml"); - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - - InputStream urlStream = url.openStream(); - XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream); - - - RecoveryRulesPolicy policy = processor.read(reader); - Map map = policy.getRuleElements(); - - StringWriter sw = new StringWriter(); - - XMLStreamWriter writter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw); - writter.writeStartDocument(); - writter.writeStartElement(Constants.RECOVERY_RULES); - - writeElements(map.values().iterator(), writter); - - writter.writeEndElement(); - writter.writeEndDocument(); - writter.close(); - - System.out.println(sw.toString()); - } - - private void writeElements(Iterator elements, XMLStreamWriter writer) throws Exception { - - OMElement el; - OMAttribute at; - - while (elements.hasNext()) { - el = (OMElement) elements.next(); - - //write the element's name - writer.writeStartElement(el.getLocalName()); - - //write the attributes - Iterator attributes = el.getAllAttributes(); - while (attributes.hasNext()) { - at = (OMAttribute) attributes.next(); - writer.writeAttribute(at.getLocalName(), at.getAttributeValue()); - } - - //write texts - if (el.getText().length() != 0) { - writer.writeCharacters(el.getText()); - } - - Iterator children = el.getChildElements(); - writeElements(children, writer); - - writer.writeEndElement(); - } - - } -} diff --git a/sandbox/dougsleite/policy-recoveryrules/src/test/resources/org/apache/tuscany/sca/policy/recoveryrules/test_policies.xml b/sandbox/dougsleite/policy-recoveryrules/src/test/resources/org/apache/tuscany/sca/policy/recoveryrules/test_policies.xml deleted file mode 100644 index bc87784407..0000000000 --- a/sandbox/dougsleite/policy-recoveryrules/src/test/resources/org/apache/tuscany/sca/policy/recoveryrules/test_policies.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - FIRST - - - - \ No newline at end of file diff --git a/sandbox/dougsleite/policy-resolutiontrees/.classpath b/sandbox/dougsleite/policy-resolutiontrees/.classpath deleted file mode 100644 index f42fb64cfa..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/sandbox/dougsleite/policy-resolutiontrees/.project b/sandbox/dougsleite/policy-resolutiontrees/.project deleted file mode 100644 index 8e94f3a1bd..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - tuscany-policy-recoveryrules - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/sandbox/dougsleite/policy-resolutiontrees/.settings/org.eclipse.jdt.core.prefs b/sandbox/dougsleite/policy-resolutiontrees/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b8efdb7c81..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Tue Jul 28 10:57:12 BRT 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-resolutiontrees/.settings/org.maven.ide.eclipse.prefs b/sandbox/dougsleite/policy-resolutiontrees/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index 8e178853bd..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Jul 28 10:57:03 BRT 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-resolutiontrees/pom.xml b/sandbox/dougsleite/policy-resolutiontrees/pom.xml deleted file mode 100644 index 47ad2be5a9..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 1.6-SNAPSHOT - ../pom.xml - - tuscany-policy-resolutiontrees - Apache Tuscany SCA Resolution Tree Policy Model - - - - - org.apache.tuscany.sca - tuscany-contribution - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-assembly-xml - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy - 1.6-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution-impl - 1.6-SNAPSHOT - test - - - - org.apache.ws.commons.axiom - axiom-impl - 1.2.7 - - - org.apache.tuscany.sca - tuscany-guardian - 1.6-SNAPSHOT - - - - - - - org.apache.felix - maven-bundle-plugin - - - - ${tuscany.version} - org.apache.tuscany.sca.policy.resolutiontree - ${pom.name} - org.apache.tuscany.sca.policy.resolutiontree* - - - - - - - - - - - - diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicy.java b/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicy.java deleted file mode 100644 index 2a2972c8ca..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicy.java +++ /dev/null @@ -1,49 +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.policy.resolutiontrees; - -import java.util.Hashtable; -import java.util.Map; -import javax.xml.namespace.QName; -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.policy.Policy; -import org.apache.tuscany.sca.assembly.xml.Constants; - -public class ResolutionTreesPolicy implements Policy { - - public static final QName RESOLUTION_TREES_POLICY_QNAME = - new QName(Constants.SCA10_TUSCANY_NS, org.apache.tuscany.sca.guardian.Constants.RESOLUTION_TREES); - - private Map resolutionTreeElements = new Hashtable(); - - public QName getSchemaName() { - return RESOLUTION_TREES_POLICY_QNAME; - } - - public void setUnresolved(boolean unresolved) { - } - - public boolean isUnresolved() { - return false; - } - - public Map getResolutionTreeElements() { - return resolutionTreeElements; - } -} diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyDefinitionsProvider.java b/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyDefinitionsProvider.java deleted file mode 100644 index 000979ddfc..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyDefinitionsProvider.java +++ /dev/null @@ -1,59 +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.policy.resolutiontrees; - -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 ResolutionTreesPolicyDefinitionsProvider implements SCADefinitionsProvider { - - private String definitionsFile = "org/apache/tuscany/sca/policy/resolutiontrees/definitions.xml"; - URLArtifactProcessor urlArtifactProcessor = null; - - public ResolutionTreesPolicyDefinitionsProvider(ExtensionPointRegistry registry) { - URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - urlArtifactProcessor = (URLArtifactProcessor) documentProcessors.getProcessor(SCADefinitions.class); - } - - public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { - URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction() { - - public URL run() { - return getClass().getClassLoader().getResource(definitionsFile); - } - }); - - try { - URI uri = new URI(definitionsFile); - return (SCADefinitions) urlArtifactProcessor.read(null, - uri, - definitionsFileUrl); - } catch (Exception e) { - throw new SCADefinitionsProviderException(e); - } - } -} diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProcessor.java b/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProcessor.java deleted file mode 100644 index ef0f8e9cea..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProcessor.java +++ /dev/null @@ -1,157 +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.policy.resolutiontrees; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.guardian.Constants; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.monitor.Monitor; - -public class ResolutionTreesPolicyProcessor implements StAXArtifactProcessor, Constants { - - private static final QName RESOLUTION_TREES_POLICY_QNAME = ResolutionTreesPolicy.RESOLUTION_TREES_POLICY_QNAME; - - public ResolutionTreesPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - } - - public ResolutionTreesPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - ResolutionTreesPolicy policy = new ResolutionTreesPolicy(); - QName name = null; - String ruleName = null; - OMElement ruleElement = null; - while (reader.hasNext()) { - - if (reader.isStartElement()) { - - name = reader.getName(); - if (RESOLUTION_TREE.equals(name.getLocalPart())) { - - ruleName = reader.getAttributeValue(null, Constants.EXCEPTION_LEVEL); - ruleElement = loadElement(reader); - - policy.getResolutionTreeElements().put(ruleName, ruleElement); - } - } else if (reader.isEndElement()) { - if (RESOLUTION_TREES_POLICY_QNAME.equals(reader.getName())) { - break; - } - } - - reader.next(); - } - - return policy; - } - - public void write(ResolutionTreesPolicy policy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - throw new UnsupportedOperationException("Not supported yet."); - } - - public QName getArtifactType() { - return RESOLUTION_TREES_POLICY_QNAME; - } - - public void resolve(ResolutionTreesPolicy arg0, ModelResolver arg1) throws ContributionResolveException { - throw new UnsupportedOperationException("Not supported yet."); - } - - public Class getModelType() { - return ResolutionTreesPolicy.class; - } - - private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { - OMFactory fac = OMAbstractFactory.getOMFactory(); - OMElement head = fac.createOMElement(reader.getName()); - - //Load the attributes for the rule tag - loadAttributes(reader, head, fac); - - OMElement current = head; - while (true) { - - switch (reader.next()) { - case XMLStreamConstants.START_ELEMENT: - - QName name = new QName(reader.getName().getLocalPart()); - OMElement child = fac.createOMElement(name, current); - - int count = reader.getNamespaceCount(); - for (int i = 0; i < count; i++) { - String prefix = reader.getNamespacePrefix(i); - String ns = reader.getNamespaceURI(i); - child.declareNamespace(ns, prefix); - } - - if (!"".equals(name.getNamespaceURI())) { - child.declareNamespace(name.getNamespaceURI(), name.getPrefix()); - } - - // add the attributes for this element - loadAttributes(reader, child, fac); - current = child; - break; - case XMLStreamConstants.CDATA: - fac.createOMText(current, reader.getText()); - break; - case XMLStreamConstants.CHARACTERS: - String text = reader.getText().trim(); - if (text.length() != 0) { - fac.createOMText(current, reader.getText()); - } - break; - case XMLStreamConstants.END_ELEMENT: - if (current == head) { - return head; - } else { - current = (OMElement) current.getParent(); - } - } - } - } - - private void loadAttributes(XMLStreamReader reader, OMElement elem, OMFactory fac) { - int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - String ns = reader.getAttributeNamespace(i); - String prefix = reader.getAttributePrefix(i); - String qname = reader.getAttributeLocalName(i); - String value = reader.getAttributeValue(i); - - if (ns != null) { - elem.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); - elem.declareNamespace(ns, prefix); - } else { - elem.addAttribute(qname, value, null); - } - } - } -} diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProviderFactory.java b/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProviderFactory.java deleted file mode 100644 index 23e1513f84..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProviderFactory.java +++ /dev/null @@ -1,55 +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.policy.resolutiontrees; - -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 ResolutionTreesPolicyProviderFactory implements PolicyProviderFactory { - - public ResolutionTreesPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - } - - public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return null; - } - - public PolicyProvider createServicePolicyProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return null; - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { - return null; - } - - public Class getModelType() { - return ResolutionTreesPolicy.class; - } -} diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index d8a0e92b7d..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,19 +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. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#recovery_rules,model=org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicy diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory deleted file mode 100644 index e69892dcbf..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory +++ /dev/null @@ -1,19 +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. - -# Implementation class for the policy extension -org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicyProviderFactory;model=org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicy diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider deleted file mode 100644 index ee7c2b6e4f..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider +++ /dev/null @@ -1,19 +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. - -# Implementation class for SCA Definitions Providers -org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicyDefinitionsProvider diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/org/apache/tuscany/sca/policy/resolutiontrees/definitions.xml b/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/org/apache/tuscany/sca/policy/resolutiontrees/definitions.xml deleted file mode 100644 index df47c23460..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/org/apache/tuscany/sca/policy/resolutiontrees/definitions.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - Describe the resolution trees for the guardian group - - - diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/test/java/org/apache/tuscany/sca/policy/resolutiontrees/PolicyReadTestCase.java b/sandbox/dougsleite/policy-resolutiontrees/src/test/java/org/apache/tuscany/sca/policy/resolutiontrees/PolicyReadTestCase.java deleted file mode 100644 index 766d4020b0..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/test/java/org/apache/tuscany/sca/policy/resolutiontrees/PolicyReadTestCase.java +++ /dev/null @@ -1,96 +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.policy.resolutiontrees; - -import java.io.InputStream; -import java.io.StringWriter; -import java.net.URL; -import java.util.Iterator; -import java.util.Map; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import org.junit.Test; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.guardian.Constants; - -public class PolicyReadTestCase { - - @Test - public void testPolicyReading() throws Exception { - ResolutionTreesPolicyProcessor processor = new ResolutionTreesPolicyProcessor(null, null); - - URL url = getClass().getResource("test_policies.xml"); - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - - InputStream urlStream = url.openStream(); - XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream); - - - ResolutionTreesPolicy policy = processor.read(reader); - Map map = policy.getResolutionTreeElements(); - - StringWriter sw = new StringWriter(); - - XMLStreamWriter writter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw); - writter.writeStartDocument(); - writter.writeStartElement(Constants.RECOVERY_RULES); - - writeElements(map.values().iterator(), writter); - - writter.writeEndElement(); - writter.writeEndDocument(); - writter.close(); - - System.out.println(sw.toString()); - } - - private void writeElements(Iterator elements, XMLStreamWriter writer) throws Exception { - - OMElement el; - OMAttribute at; - - while (elements.hasNext()) { - el = (OMElement) elements.next(); - - //write the element's name - writer.writeStartElement(el.getLocalName()); - - //write the attributes - Iterator attributes = el.getAllAttributes(); - while (attributes.hasNext()) { - at = (OMAttribute) attributes.next(); - writer.writeAttribute(at.getLocalName(), at.getAttributeValue()); - } - - //write texts - if (el.getText().length() != 0) { - writer.writeCharacters(el.getText()); - } - - Iterator children = el.getChildElements(); - writeElements(children, writer); - - writer.writeEndElement(); - } - - } -} diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/test/resources/org/apache/tuscany/sca/policy/resolutiontrees/test_policies.xml b/sandbox/dougsleite/policy-resolutiontrees/src/test/resources/org/apache/tuscany/sca/policy/resolutiontrees/test_policies.xml deleted file mode 100644 index 405dcde1ae..0000000000 --- a/sandbox/dougsleite/policy-resolutiontrees/src/test/resources/org/apache/tuscany/sca/policy/resolutiontrees/test_policies.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3