diff options
92 files changed, 1247 insertions, 1677 deletions
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/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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (thea - * "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. ---> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" - targetNamespace="http://serverbackup" - name="serverbackup"> - - <component name="Participant1"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember1"/> - <reference name="nodes" target="Participant2 Participant3 Participant4"/> - </component> - - <component name="Participant2"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember2"/> - <reference name="nodes" target="Participant1 Participant3 Participant4"/> - </component> - - <component name="Participant3"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember3"/> - <reference name="nodes" target="Participant1 Participant2 Participant4"/> - </component> - - <component name="Participant4"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember4"/> - <reference name="nodes" target="Participant1 Participant2 Participant3"/> - </component> - - <component name="GuardianMember1"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> - </component> - - <component name="GuardianMember2"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> - </component> - - <component name="GuardianMember3"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> - </component> - - <component name="GuardianMember4"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> - </component> - - <component name="GuardianGroup"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianGroupImpl"/> - <property name="recovery_rules">src/main/resources/recoveryrules_nbackpus.xml</property> - </component> - -</composite> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (thea - * "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. ---> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" - targetNamespace="http://serverbackup" - name="serverbackup"> -<!-- - <component name="Participant1"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember1"/> - <reference name="node" target="Participant2"/> - </component> - - <component name="Participant2"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.NodeImpl"/> - <reference name="guardian_member" target="GuardianMember2"/> - <reference name="node" target="Participant1"/> - </component> - - <component name="GuardianMember1"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group"> - <interface.java interface="org.apache.tuscany.sca.guardian.GuardianGroup"/> - <binding.ws uri="http://localhost:8085/GuardianGroup" requires="MTOM"/> - </reference> - </component> - - <component name="GuardianMember2"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group"> - <interface.java interface="org.apache.tuscany.sca.guardian.GuardianGroup"/> - <binding.ws uri="http://localhost:8085/GuardianGroup" requires="MTOM"/> - </reference> - </component> ---> - - <component name="GuardianGroupComponent"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianGroupImpl"/> - <property name="recovery_rules">src/main/resources/recoveryrules.xml</property> - <service name="GuardianGroup"> - <interface.java interface="org.apache.tuscany.sca.guardian.GuardianGroup"/> - <binding.ws uri="http://localhost:8085/GuardianGroup" requires="MTOM"/> - </service> - </component> - -</composite> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (thea - * "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. ---> - -<recovery_rules> - - <rule name="Rule1" signaled_exception="org.apache.tuscany.sca.guardian.JoinException"> - - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"/> - </participant> - - <participant match="!SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupJoinedException" target_context="PRIMARY" min_participant_joined="2"/> - </participant> - </rule> - - <rule name="Rule2" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> - </participant> - - <participant match="*.BACKUP"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"/> - </participant> - </rule> - - <rule name="Rule3" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="PRIMARY"/> - </participant> - - <participant match="*.BACKUP"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> - </participant> - </rule> - -</recovery_rules> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (thea - * "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. ---> - -<recovery_rules> - - <rule name="Rule1" signaled_exception="org.apache.tuscany.sca.guardian.JoinException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupJoinedException" target_context="PRIMARY"/> - </participant> - - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"/> - </participant> - </rule> - - <rule name="Rule2" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> - </participant> - - <participant match="*.BACKUP"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"> - <affected_participants>FIRST</affected_participants> - </throw_exception> - </participant> - </rule> - - <rule name="Rule3" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="PRIMARY"/> - </participant> - - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> - </participant> - </rule> - -</recovery_rules> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (thea - * "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. ---> - -<recovery_rules> - - <!-- A new participant joins in the group --> - <rule name="Rule1" signaled_exception="org.apache.tuscany.sca.guardian.JoinException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupJoinedException" target_context="PRIMARY"/> - </participant> - - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"/> - </participant> - </rule> - - <!-- The Primary fails --> - <rule name="Rule2" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> - </participant> - - <participant match="*.BACKUP"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"> - <affected_participants>FIRST</affected_participants> - </throw_exception> - </participant> - </rule> - - <!-- The Backup fails --> - <rule name="Rule3" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="PRIMARY"/> - </participant> - - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> - </participant> - </rule> - - <!-- The Primary and Backup fail together --> - <rule name="Rule4" signaled_exception="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryBackupFailedTogetherException"> - - <participant match="*.PRIMARY"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> - </participant> - - <!-- Backup signaler --> - <participant match="*.BACKUP,SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> - </participant> - - <!-- Excluding the backup signaler --> - <participant match="*.BACKUP,!SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"> - <affected_participants>FIRST</affected_participants> - </throw_exception> - </participant> - - </rule> - -</recovery_rules> 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 @@ -<resolution_trees> - <resolution_tree exception_level="1"> - <exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryBackupFailedTogetherException"> - <exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryFailedException"/> - <exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.BackupFailedException"/> - </exception> - </resolution_tree> -</resolution_trees> 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/.classpath b/sandbox/dougsleite/implementation-guardian/.classpath index 554ad2954f..554ad2954f 100644 --- a/sandbox/dougsleite/guardian-model/.classpath +++ b/sandbox/dougsleite/implementation-guardian/.classpath diff --git a/sandbox/dougsleite/guardian-model/.project b/sandbox/dougsleite/implementation-guardian/.project index a5f54ef1d3..a5f54ef1d3 100644 --- a/sandbox/dougsleite/guardian-model/.project +++ b/sandbox/dougsleite/implementation-guardian/.project diff --git a/sandbox/dougsleite/guardian-model/pom.xml b/sandbox/dougsleite/implementation-guardian/pom.xml index a204957231..dcd91936e6 100644 --- a/sandbox/dougsleite/guardian-model/pom.xml +++ b/sandbox/dougsleite/implementation-guardian/pom.xml @@ -25,8 +25,8 @@ <version>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>tuscany-guardian</artifactId>
- <name>Apache Tuscany SCA Guardian Model</name>
+ <artifactId>tuscany-implementation-guardian</artifactId>
+ <name>Apache Tuscany SCA Implementation Guardian Model</name>
<repositories>
<repository>
@@ -68,18 +68,6 @@ <version>1.5</version>
</dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-resolutiontrees</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-recoveryrules</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
</dependencies>
<build>
@@ -91,9 +79,9 @@ <configuration>
<instructions>
<Bundle-Version>${tuscany.version}</Bundle-Version>
- <Bundle-SymbolicName>org.apache.tuscany.sca.guardian</Bundle-SymbolicName>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.implementation.guardian</Bundle-SymbolicName>
<Bundle-Description>${pom.name}</Bundle-Description>
- <Export-Package>org.apache.tuscany.sca.guardian*</Export-Package>
+ <Export-Package>org.apache.tuscany.sca.implementation.guardian*</Export-Package>
</instructions>
</configuration>
</plugin>
diff --git a/sandbox/dougsleite/guardian-model/sequenceDiagram-externalException.jpg b/sandbox/dougsleite/implementation-guardian/sequenceDiagram-externalException.jpg Binary files differindex 60060ca0e2..60060ca0e2 100644 --- a/sandbox/dougsleite/guardian-model/sequenceDiagram-externalException.jpg +++ b/sandbox/dougsleite/implementation-guardian/sequenceDiagram-externalException.jpg diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/BlockingInterface.java index 848c4a874d..1bb1066435 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/BlockingInterface.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/BlockingInterface.java @@ -16,8 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian; +@Deprecated public interface BlockingInterface { //@OneWay diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroup.java index 5119390a14..2775699843 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroup.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianGroup.java @@ -16,11 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian; -import org.osoa.sca.annotations.Remotable; - -//@Remotable public interface GuardianGroup extends GuardianPrimitives { public static int NORMAL_PARTICIPANT_STATE = 0; 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/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java index 48dad22bff..b82bf082b1 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMember.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianMember.java @@ -16,19 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +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 void setService(BlockingInterface service); - - public void removeService(); - - public Context getCurrentContext(); - - public BlockingInterface getService(); + public Context getCurrentContext(); public String getParticipantIdentifier(); diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java index 9ddd22a2fd..c50e855d30 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianPrimitives.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/GuardianPrimitives.java @@ -16,9 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +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 { diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicy.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/RecoveryRules.java index a2497935e2..4757615c21 100644 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicy.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/RecoveryRules.java @@ -16,34 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.policy.recoveryrules; +package org.apache.tuscany.sca.implementation.guardian; -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 interface RecoveryRules { public static final QName RECOVERY_RULES_POLICY_QNAME = - new QName(Constants.SCA10_TUSCANY_NS, org.apache.tuscany.sca.guardian.Constants.RECOVERY_RULES); - - private Map<String, OMElement> ruleElements = new Hashtable<String, OMElement>(); + new QName(Constants.SCA10_TUSCANY_NS, org.apache.tuscany.sca.implementation.guardian.common.Constants.RECOVERY_RULES); - public QName getSchemaName() { - return RECOVERY_RULES_POLICY_QNAME; - } - - public void setUnresolved(boolean unresolved) { - } - - public boolean isUnresolved() { - return false; - } - - public Map<String, OMElement> getRuleElements() { - return ruleElements; - } + public Map<String, OMElement> 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<String, OMElement> getResolutionTreeElements(); +} diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ConcurrentExceptionOcurrenceException.java index 30584f2d78..4bfe1320b4 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ConcurrentExceptionOcurrenceException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ConcurrentExceptionOcurrenceException.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; -class ConcurrentExceptionOcurrenceException extends Exception { +public class ConcurrentExceptionOcurrenceException extends Exception { public ConcurrentExceptionOcurrenceException() { super(); diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Constants.java index 9fa4db4f78..cf5d56179d 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Constants.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Constants.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; import javax.xml.namespace.QName; @@ -78,4 +78,5 @@ public interface Constants { 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/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java index 3ac5d63a42..95c6f3bed6 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/Context.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/Context.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; import java.util.LinkedList; import java.util.List; diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalException.java index b880db6aa1..022fe1a5f8 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalException.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; import java.util.LinkedList; import java.util.List; diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalExceptionInterface.java index 68a09a9bc8..450d4ae18b 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GlobalExceptionInterface.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/GlobalExceptionInterface.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; import java.util.List; diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidNodeException.java index 3df76b0596..ed85661dbf 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidNodeException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidNodeException.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; public class InvalidNodeException extends RuntimeException { diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidRegularExpressionException.java index 30e750941e..99aa027fb8 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/InvalidRegularExpression.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/InvalidRegularExpressionException.java @@ -16,15 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; -public class InvalidRegularExpression extends RuntimeException { +public class InvalidRegularExpressionException extends RuntimeException { - public InvalidRegularExpression() { + public InvalidRegularExpressionException() { super(); } - public InvalidRegularExpression(String message) { + public InvalidRegularExpressionException(String message) { super(message); } } diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/JoinException.java index b14ebeac2b..890b8704ee 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/JoinException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/JoinException.java @@ -17,9 +17,9 @@ * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; -class JoinException extends GlobalException { +public class JoinException extends GlobalException { public JoinException() { super(); diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/LeaveException.java index 04e892f4bd..9684de22ad 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/LeaveException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/LeaveException.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; -class LeaveException extends GlobalException { +public class LeaveException extends GlobalException { public LeaveException() { super(); diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ResolutionTreeUtils.java index 09dd0673eb..fbf147285e 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/ResolutionTreeUtils.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/ResolutionTreeUtils.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; import java.util.Collections; import java.util.Hashtable; diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/SuspendException.java index b7ede6d530..5ce2f5afd9 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/SuspendException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/SuspendException.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; -class SuspendException extends GlobalException { +public class SuspendException extends GlobalException { public SuspendException() { super(); diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/UnhandledException.java index 81e3844280..a8f9cdfad6 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/UnhandledException.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/common/UnhandledException.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.common; public class UnhandledException extends GlobalException { diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java index f9fe5c2c59..5a243560e3 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianGroupImpl.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianGroupImpl.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.impl; -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; @@ -33,13 +31,21 @@ 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; +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; -@Service(GuardianGroup.class) -@Scope("COMPOSITE") public class GuardianGroupImpl implements GuardianGroup { private List<GuardianMember> guardianList; @@ -49,20 +55,22 @@ public class GuardianGroupImpl implements GuardianGroup { private ResolutionTreeUtils resolutionTreeUtils; private Map<String, OMElement> ruleElements; - public GuardianGroupImpl() { + public GuardianGroupImpl(String recoveryRules, String resolutionTrees) { guardianList = new LinkedList<GuardianMember>(); concurrentExList = new LinkedList<GlobalExceptionInterface>(); innerThread = new InnerGuardianGroupThread(); resolutionTreeUtils = new ResolutionTreeUtils(); + + setRecoveryRules(recoveryRules); + setResolutionTree(resolutionTrees); } - @Property(name = "recovery_rules", required = false) - public void setRecoveryRules(String recoveryRules) { + private void setRecoveryRules(String recoveryRules) { try { FileInputStream fileInputStream = new FileInputStream(recoveryRules); XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); - RecoveryRulesPolicyProcessor processor = new RecoveryRulesPolicyProcessor(null, null); + RecoveryRulesProcessor processor = new RecoveryRulesProcessor(); ruleElements = processor.read(xmlReader).getRuleElements(); } catch (ContributionReadException ex) { @@ -74,14 +82,13 @@ public class GuardianGroupImpl implements GuardianGroup { } } - @Property(name = "resolution_tree", required = false) - public void setResolutionTree(String resolutionTree) { + private void setResolutionTree(String resolutionTree) { try { FileInputStream fileInputStream = new FileInputStream(resolutionTree); XMLStreamReader resolutionTreeReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); - ResolutionTreesPolicyProcessor processor = new ResolutionTreesPolicyProcessor(null, null); + ResolutionTreesProcessor processor = new ResolutionTreesProcessor(); resolutionTreeElements = processor.read(resolutionTreeReader).getResolutionTreeElements(); } catch (ContributionReadException ex) { @@ -98,9 +105,12 @@ public class GuardianGroupImpl implements GuardianGroup { guardianMember.setUniqueParticipantID(guardianList.size() - 1); } + public boolean removeGuardianMember(GuardianMember guardianMember) { + throw new UnsupportedOperationException("Not supported yet."); + } + public void enableContext(Context context) { - System.out.println("Enable Context.. nothing to do!"); - //throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } public void removeContext() { @@ -132,6 +142,7 @@ public class GuardianGroupImpl implements GuardianGroup { innerThread.setGlobalException(ex); new Thread(innerThread).start(); } + } public boolean propagate(GlobalExceptionInterface ex) { @@ -142,10 +153,6 @@ public class GuardianGroupImpl implements GuardianGroup { throw new UnsupportedOperationException("Not supported yet."); } - public boolean removeGuardianMember(GuardianMember guardianMember) { - return this.guardianList.remove(guardianMember); - } - private class InnerGuardianGroupThread implements Runnable { private boolean isRunning; @@ -485,7 +492,7 @@ public class GuardianGroupImpl implements GuardianGroup { //Invalid regular expression if (splitByComma.length > 2) { - throw new InvalidRegularExpression("The comma ',' operator can only be applied for two expressions"); + throw new InvalidRegularExpressionException("The comma ',' operator can only be applied for two expressions"); } //There is no comma on the regular expression @@ -533,7 +540,7 @@ public class GuardianGroupImpl implements GuardianGroup { //Invalid expression if (index == -1) { - throw new InvalidRegularExpression("The comma ',' requires a SIGNALER or !SIGNALER element in one side of the expression"); + throw new InvalidRegularExpressionException("The comma ',' requires a SIGNALER or !SIGNALER element in one side of the expression"); } String re = createJavaRegularExpression(splitByComma[1 - index]); @@ -570,7 +577,7 @@ public class GuardianGroupImpl implements GuardianGroup { * * Not supported yet: !<Context>, !<Context> || <Context>, !(<Context> || <Context>) */ - private String createJavaRegularExpression(String regularExpression) throws InvalidRegularExpression { + private String createJavaRegularExpression(String regularExpression) throws InvalidRegularExpressionException { StringBuffer re = new StringBuffer(); String[] splitByBar = regularExpression.split("\\|\\|"); @@ -592,7 +599,7 @@ public class GuardianGroupImpl implements GuardianGroup { //Validate the regular expression if (j + 1 != splitByPeriod.length && splitByPeriod[j + 1].equals("*")) { - throw new InvalidRegularExpression(); + throw new InvalidRegularExpressionException(); } //* @@ -634,4 +641,4 @@ public class GuardianGroupImpl implements GuardianGroup { return re.toString(); } } -}
\ No newline at end of file +} 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<Service> services = new ArrayList<Service>(); + 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<Service> getServices() { + if (services == null || services.size() == 0) { + introspectServices(assemblyFactory, javaFactory); + } + return services; + } + + @Override + public List<Reference> getReferences() { + // The Guardian Model implementation does not support references + return Collections.emptyList(); + } + + @Override + public List<Property> 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/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java index 893d5fcb1b..80b9321e79 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian; +package org.apache.tuscany.sca.implementation.guardian.impl; import java.util.LinkedList; import java.util.List; @@ -24,10 +24,17 @@ 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.Destroy; import org.osoa.sca.annotations.Service; @Service(GuardianMember.class) @@ -36,7 +43,7 @@ public class GuardianMemberImpl implements GuardianMember { private int participantState; private Stack<Context> contextList; - private BlockingInterface service; + private Queue<GlobalException> exceptionQueue; @Reference(name = "guardian_group", required = true) public GuardianGroup guardianGroup; @@ -66,17 +73,10 @@ public class GuardianMemberImpl implements GuardianMember { 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 @@ -109,9 +109,6 @@ public class GuardianMemberImpl implements GuardianMember { guardianGroup.gthrow(ex, participantList); exceptionThrown = true; } else { - /*if (service instanceof BlockingInterface && !service.isBlocked()) { - service.block(); - }*/ setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE); } } @@ -170,10 +167,6 @@ public class GuardianMemberImpl implements GuardianMember { this.id = id; } - public void removeService() { - this.service = null; - } - public int getParticipantState() { return participantState; } 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<String, OMElement> ruleElements = new Hashtable<String, OMElement>(); + + public Map<String, OMElement> getRuleElements() { + return ruleElements; + } +} diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicy.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/ResolutionTreesImpl.java index 2a2972c8ca..669f06b1ef 100644 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicy.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/ResolutionTreesImpl.java @@ -16,33 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.policy.resolutiontrees; +package org.apache.tuscany.sca.implementation.guardian.impl; 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; +import org.apache.tuscany.sca.implementation.guardian.ResolutionTrees; -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); +public class ResolutionTreesImpl implements ResolutionTrees { private Map<String, OMElement> resolutionTreeElements = new Hashtable<String, OMElement>(); - public QName getSchemaName() { - return RESOLUTION_TREES_POLICY_QNAME; - } - - public void setUnresolved(boolean unresolved) { - } - - public boolean isUnresolved() { - return false; - } - public Map<String, OMElement> 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<String> 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<GuardianGroupImplementation> { + public GuardianGroupImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, GuardianGroupImplementation implementation) { + return new GuardianGroupImplementationProvider(component, implementation); + } + + public Class<GuardianGroupImplementation> 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<String> participantList = (List<String>) ((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<GuardianGroupImplementation> { + + 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<GuardianGroupImplementation> getModelType() { + return GuardianGroupImplementation.class; + } +} diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProcessor.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/RecoveryRulesProcessor.java index 44e6e04594..7d82f356de 100644 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/java/org/apache/tuscany/sca/policy/recoveryrules/RecoveryRulesPolicyProcessor.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/RecoveryRulesProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.policy.recoveryrules; +package org.apache.tuscany.sca.implementation.guardian.xml; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamConstants; @@ -31,20 +31,20 @@ 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; +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 RecoveryRulesPolicyProcessor implements StAXArtifactProcessor<RecoveryRulesPolicy>, Constants { +public class RecoveryRulesProcessor implements StAXArtifactProcessor<RecoveryRules>, Constants { - private static final QName RECOVERY_RULES_POLICY_QNAME = RecoveryRulesPolicy.RECOVERY_RULES_POLICY_QNAME; + private static final QName RECOVERY_RULES_POLICY_QNAME = RecoveryRules.RECOVERY_RULES_POLICY_QNAME; - public RecoveryRulesPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + public RecoveryRulesProcessor() { } - public RecoveryRulesPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public RecoveryRules read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - RecoveryRulesPolicy policy = new RecoveryRulesPolicy(); + RecoveryRules policy = new RecoveryRulesImpl(); QName name = null; String ruleName = null; OMElement ruleElement = null; @@ -72,20 +72,20 @@ public class RecoveryRulesPolicyProcessor implements StAXArtifactProcessor<Recov return policy; } - public void write(RecoveryRulesPolicy policy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - throw new UnsupportedOperationException("Not supported yet."); + 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(RecoveryRulesPolicy arg0, ModelResolver arg1) throws ContributionResolveException { - throw new UnsupportedOperationException("Not supported yet."); + public void resolve(RecoveryRules arg0, ModelResolver arg1) throws ContributionResolveException { + } - public Class<RecoveryRulesPolicy> getModelType() { - return RecoveryRulesPolicy.class; + public Class<RecoveryRules> getModelType() { + return RecoveryRules.class; } private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { @@ -154,4 +154,5 @@ public class RecoveryRulesPolicyProcessor implements StAXArtifactProcessor<Recov } } } + } diff --git a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProcessor.java b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/ResolutionTreesProcessor.java index ef0f8e9cea..b9cfe647b4 100644 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/java/org/apache/tuscany/sca/policy/resolutiontrees/ResolutionTreesPolicyProcessor.java +++ b/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/xml/ResolutionTreesProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.policy.resolutiontrees; +package org.apache.tuscany.sca.implementation.guardian.xml; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamConstants; @@ -31,20 +31,20 @@ 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; +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 ResolutionTreesPolicyProcessor implements StAXArtifactProcessor<ResolutionTreesPolicy>, Constants { +public class ResolutionTreesProcessor implements StAXArtifactProcessor<ResolutionTrees>, Constants { - private static final QName RESOLUTION_TREES_POLICY_QNAME = ResolutionTreesPolicy.RESOLUTION_TREES_POLICY_QNAME; + private static final QName RESOLUTION_TREES_POLICY_QNAME = ResolutionTrees.RESOLUTION_TREES_POLICY_QNAME; - public ResolutionTreesPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + public ResolutionTreesProcessor() { } - public ResolutionTreesPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public ResolutionTrees read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - ResolutionTreesPolicy policy = new ResolutionTreesPolicy(); + ResolutionTrees policy = new ResolutionTreesImpl(); QName name = null; String ruleName = null; OMElement ruleElement = null; @@ -72,20 +72,20 @@ public class ResolutionTreesPolicyProcessor implements StAXArtifactProcessor<Res return policy; } - public void write(ResolutionTreesPolicy policy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - throw new UnsupportedOperationException("Not supported yet."); + 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(ResolutionTreesPolicy arg0, ModelResolver arg1) throws ContributionResolveException { - throw new UnsupportedOperationException("Not supported yet."); + public void resolve(ResolutionTrees arg0, ModelResolver arg1) throws ContributionResolveException { + //throw new UnsupportedOperationException("Not supported yet."); } - public Class<ResolutionTreesPolicy> getModelType() { - return ResolutionTreesPolicy.class; + public Class<ResolutionTrees> getModelType() { + return ResolutionTrees.class; } private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { diff --git a/sandbox/dougsleite/policy-recoveryrules/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 index 9fc1126935..b489bb90fc 100644 --- a/sandbox/dougsleite/policy-recoveryrules/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 @@ -16,4 +16,4 @@ # 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 +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/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory index ee7c2b6e4f..744815a572 100644 --- a/sandbox/dougsleite/policy-resolutiontrees/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.guardian.GuardianGroupImplementationFactory @@ -5,15 +5,15 @@ # 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. +# under the License. -# Implementation class for SCA Definitions Providers -org.apache.tuscany.sca.policy.resolutiontrees.ResolutionTreesPolicyDefinitionsProvider +# Implementation class for implementation model factory +org.apache.tuscany.sca.implementation.guardian.impl.GuardianGroupImplementationFactoryImpl diff --git a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory index e67f25b9c0..4ab8d2e6a3 100644 --- a/sandbox/dougsleite/policy-recoveryrules/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -15,5 +15,5 @@ # 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
+# 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> + +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://guardianTest" + name="guardianTest"> + + <component name="GuardianComponent"> + <tuscany:implementation.guardian> + + <tuscany:guardianProperties + recovery_rules="src/main/resources/recoveryrules_nbackpus_concurrent.xml" + resolution_trees="src/main/resources/resolutionTree.xml"/> + + </tuscany:implementation.guardian> + </component> + +</composite> diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups-concurrent.composite b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite index 7cd28ff085..fcb78e3879 100644 --- a/sandbox/dougsleite/guardian-model/src/main/resources/primaryNbackups-concurrent.composite +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/primaryBackup.composite @@ -17,59 +17,65 @@ * specific language governing permissions and limitations * under the License. --> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" - targetNamespace="http://serverbackup" - name="serverbackup"> + +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://guardianTest" + name="guardianTest"> <component name="Participant1"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> <reference name="guardian_member" target="GuardianMember1"/> <reference name="nodes" target="Participant2 Participant3 Participant4"/> </component> <component name="Participant2"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> <reference name="guardian_member" target="GuardianMember2"/> <reference name="nodes" target="Participant1 Participant3 Participant4"/> </component> <component name="Participant3"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> <reference name="guardian_member" target="GuardianMember3"/> <reference name="nodes" target="Participant1 Participant2 Participant4"/> </component> <component name="Participant4"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> <reference name="guardian_member" target="GuardianMember4"/> <reference name="nodes" target="Participant1 Participant2 Participant3"/> </component> <component name="GuardianMember1"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> + <reference name="guardian_group" target="GuardianComponent"/> </component> <component name="GuardianMember2"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> + <reference name="guardian_group" target="GuardianComponent"/> </component> <component name="GuardianMember3"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> + <reference name="guardian_group" target="GuardianComponent"/> </component> <component name="GuardianMember4"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> + <reference name="guardian_group" target="GuardianComponent"/> </component> - <component name="GuardianGroup"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianGroupImpl"/> - <property name="recovery_rules">src/main/resources/recoveryrules_nbackpus_concurrent.xml</property> - <property name="resolution_tree">src/main/resources/resolutionTree.xml</property> + <component name="GuardianComponent"> + <tuscany:implementation.guardian> + + <tuscany:guardianProperties + recovery_rules="src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/recoveryRules.xml" + resolution_trees="src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/resolutionTrees.xml"/> + + </tuscany:implementation.guardian> + </component> </composite> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (thea + * "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. +--> + +<recovery_rules> + + <!-- A new participant joins in the group --> + <rule name="Rule1" signaled_exception="org.apache.tuscany.sca.implementation.guardian.common.JoinException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupJoinedException" target_context="PRIMARY"/> + </participant> + + <participant match="SIGNALER"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"/> + </participant> + </rule> + + <!-- The Primary fails --> + <rule name="Rule2" signaled_exception="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> + </participant> + + <participant match="*.BACKUP"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"> + <affected_participants>FIRST</affected_participants> + </throw_exception> + </participant> + </rule> + + <!-- The Backup fails --> + <rule name="Rule3" signaled_exception="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException" target_context="PRIMARY"/> + </participant> + + <participant match="SIGNALER"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> + </participant> + </rule> + + <!-- The Primary and Backup fail together --> + <rule name="Rule4" signaled_exception="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryBackupFailedTogetherException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> + </participant> + + <!-- Backup signaler --> + <participant match="*.BACKUP,SIGNALER"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> + </participant> + + <!-- Excluding the backup signaler --> + <participant match="*.BACKUP,!SIGNALER"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"> + <affected_participants>FIRST</affected_participants> + </throw_exception> + </participant> + + </rule> + +</recovery_rules> 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 @@ +<resolution_trees> + <resolution_tree exception_level="1"> + <exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryBackupFailedTogetherException"> + <exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException"/> + <exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException"/> + </exception> + </resolution_tree> +</resolution_trees> diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup.composite b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite index 9160a070c8..85af4efd48 100644 --- a/sandbox/dougsleite/guardian-model/src/main/resources/primarybackup.composite +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/primaryBackup.composite @@ -18,35 +18,41 @@ * under the License. --> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" - targetNamespace="http://primarybackup" - name="primarybackup"> + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://guardianTest" + name="guardianTest"> <component name="Participant1"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> <reference name="guardian_member" target="GuardianMember1"/> <reference name="nodes" target="Participant2"/> </component> <component name="Participant2"> - <implementation.java class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.NodeImpl"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.NodeImpl"/> <reference name="guardian_member" target="GuardianMember2"/> <reference name="nodes" target="Participant1"/> </component> <component name="GuardianMember1"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> + <reference name="guardian_group" target="GuardianComponent"/> </component> <component name="GuardianMember2"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianMemberImpl"/> - <reference name="guardian_group" target="GuardianGroup"/> + <implementation.java class="org.apache.tuscany.sca.implementation.guardian.impl.GuardianMemberImpl"/> + <reference name="guardian_group" target="GuardianComponent"/> </component> - <component name="GuardianGroup"> - <implementation.java class="org.apache.tuscany.sca.guardian.GuardianGroupImpl"/> - <property name="recovery_rules">src/main/resources/recoveryrules.xml</property> + <component name="GuardianComponent"> + <tuscany:implementation.guardian> + + <tuscany:guardianProperties + recovery_rules="src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/recoveryRules.xml" + resolution_trees="src/main/resources/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/resolutionTrees.xml"/> + + </tuscany:implementation.guardian> + </component> </composite> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (thea + * "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. +--> + +<recovery_rules> + + <rule name="Rule1" signaled_exception="org.apache.tuscany.sca.implementation.guardian.common.JoinException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupJoinedException" target_context="PRIMARY"/> + </participant> + + <participant match="SIGNALER"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"/> + </participant> + </rule> + + <rule name="Rule2" signaled_exception="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="INIT_CONTEXT"/> + </participant> + + <participant match="*.BACKUP"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.PrimaryFailedException" target_context="MAIN"/> + </participant> + </rule> + + <rule name="Rule3" signaled_exception="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException"> + + <participant match="*.PRIMARY"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException" target_context="PRIMARY"/> + </participant> + + <participant match="*.BACKUP"> + <throw_exception class="org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common.BackupFailedException" target_context="INIT_CONTEXT"/> + </participant> + </rule> + +</recovery_rules> diff --git a/sandbox/dougsleite/guardian-model/src/main/resources/lcaTest.xml b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/lcaTest.xml index e528760ad8..e528760ad8 100644 --- a/sandbox/dougsleite/guardian-model/src/main/resources/lcaTest.xml +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/org/apache/tuscany/sca/implementation/guardian/lcaTest.xml diff --git a/sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz b/sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz Binary files differnew file mode 100644 index 0000000000..8845a544fe --- /dev/null +++ b/sandbox/dougsleite/implementation-guardian/src/main/resources/resources.tar.gz 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/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/LCATestCase.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/LCATestCase.java index bdcb7ac97d..3c5e6b1b19 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/LCATestCase.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/LCATestCase.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests; +package org.apache.tuscany.sca.implementation.guardian; import java.io.FileInputStream; -import org.apache.tuscany.sca.policy.resolutiontrees.*; -import org.apache.tuscany.sca.guardian.ResolutionTreeUtils; +import org.apache.tuscany.sca.implementation.guardian.common.ResolutionTreeUtils; import java.util.Collection; import java.util.LinkedList; import java.util.Map; @@ -30,6 +29,7 @@ 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 { @@ -38,13 +38,14 @@ public class LCATestCase { @Before public void init() throws Exception { - ResolutionTreesPolicyProcessor processor = new ResolutionTreesPolicyProcessor(null, null); + ResolutionTreesProcessor processor = new ResolutionTreesProcessor(); - FileInputStream fileInputStream = new FileInputStream("src/main/resources/lcaTest.xml"); + FileInputStream fileInputStream = new FileInputStream("src/main/resources/org/apache/" + + "tuscany/sca/implementation/guardian/lcaTest.xml"); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); - ResolutionTreesPolicy policy = processor.read(reader); + ResolutionTrees policy = processor.read(reader); Map<String, OMElement> resolutionTrees = policy.getResolutionTreeElements(); List<OMElement> rootElements = getRootElements(resolutionTrees.values()); diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 index d7f0f763e2..b08b26942d 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupFailedException.java index 6660d6b42f..25adf1d739 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.*; +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; 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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/BackupJoinedException.java index 6d81d1933e..f0d29f461f 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/Node.java index 9fb6a27a45..6aa9456816 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,12 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.BlockingInterface; import org.osoa.sca.annotations.OneWay; -public interface Node extends BlockingInterface { +public interface Node { @OneWay public void execute(); @@ -31,4 +30,8 @@ public interface Node extends BlockingInterface { public void applyUpdate(); public String getID(); + + public void kill(); + + public boolean isDead(); } diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/common/NodeImpl.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/NodeImpl.java index 00880352b8..37f4f529f0 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,28 +16,26 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +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.guardian.Context; -import org.apache.tuscany.sca.guardian.GuardianMember; +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.Destroy; import org.osoa.sca.annotations.OneWay; @Scope("COMPOSITE") -//public class NodeImpl implements Node, TestInterface { -public class NodeImpl implements Node { +public class NodeImpl implements Node, TestInterface { private static int PRIMARY = 0; private static int BACKUP = 1; - private boolean isBlocked; + private boolean isDead; private Context mainContext; private Context primaryContext; private Context backupContext; @@ -67,7 +65,7 @@ public class NodeImpl implements Node { updates = new LinkedList(); - isBlocked = true; + isDead = true; nodeList = new LinkedList<Node>(); @@ -77,18 +75,12 @@ public class NodeImpl implements Node { @Init public void init() { - gm.setService(this); pID = gm.getParticipantIdentifier(); } - @Destroy - public void destroy() { - gm.removeService(); - } - @OneWay public void execute() { - isBlocked = false; + isDead = false; gm.enableContext(mainContext); role = PRIMARY; @@ -113,20 +105,15 @@ public class NodeImpl implements Node { } 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(); + this.kill(); ex.printStackTrace(); return; } @@ -139,7 +126,7 @@ public class NodeImpl implements Node { if (gm.propagate(ex)) { //throw ex; - this.block(); + this.kill(); ex.printStackTrace(); return; } @@ -204,7 +191,7 @@ public class NodeImpl implements Node { boolean flag = false; for (Node n : nodeList) { - if (!n.isBlocked()) { + if (!n.isDead()) { n.sendUpdate("Update " + upcount); flag = true; } @@ -258,36 +245,19 @@ public class NodeImpl implements Node { private boolean isThereBackupAvailable() { for (Node n : nodeList) { - if (!n.isBlocked()) { + if (!n.isDead()) { return true; } } return false; } - public void block() { - isBlocked = true; + public void kill() { + isDead = 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 boolean isDead() { + return isDead; } public void sendUpdate(String update) { diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 index d2ce160bd7..5521caa550 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -17,9 +17,9 @@ * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryExistsException.java index 935c97966e..d6297a1012 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryFailedException.java index 00f2f84c00..cc1715d077 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/PrimaryServiceFailureException.java index 46f52ea198..0bcfb72bc8 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; -import org.apache.tuscany.sca.guardian.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.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/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/common/TestInterface.java index f659a15530..7e7bd35cd2 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.common; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.common; public interface TestInterface { diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/concurrentexceptions/Launch.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java index 9ac2e9113b..ab0c21dba6 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/concurrentexceptions/Launch.java +++ b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/concurrentExceptions/Launch.java @@ -16,17 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.concurrentexceptions; +package org.apache.tuscany.sca.implementation.guardian.itests.primaryBackup.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.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("primaryNbackups-concurrent.composite"); + 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"); diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch.java index 66b7d0a18d..86df9bc5f9 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,17 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.simple; +package org.apache.tuscany.sca.implementation.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.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("primarybackup.composite"); + 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"); @@ -43,6 +45,7 @@ public class Launch { System.out.println("Forcing exception ocurrence at participant1..."); TestInterface t = scaDomain.getService(TestInterface.class, "Participant1"); t.forcePrimaryServiceFailureException(); + System.in.read(); diff --git a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/guardian/itests/primaryBackup/simple/Launch2.java b/sandbox/dougsleite/implementation-guardian/src/test/java/org/apache/tuscany/sca/implementation/guardian/itests/primaryBackup/simple/Launch2.java index 34eedcaa13..1c5fd26745 100644 --- a/sandbox/dougsleite/guardian-model/src/test/java/org/apache/tuscany/sca/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 @@ -16,17 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.guardian.itests.primaryBackup.simple; +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.guardian.itests.primaryBackup.common.Node; -import org.apache.tuscany.sca.guardian.itests.primaryBackup.common.TestInterface; +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("primarybackup.composite"); + 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"); 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 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-modules</artifactId>
- <version>1.6-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-policy-recoveryrules</artifactId>
- <name>Apache Tuscany SCA Recovery Rules Policy Model</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly-xml</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution-impl</artifactId>
- <version>1.6-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-guardian</artifactId> - <version>1.6-SNAPSHOT</version> - </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
-
- <configuration>
- <instructions>
- <Bundle-Version>${tuscany.version}</Bundle-Version>
- <Bundle-SymbolicName>org.apache.tuscany.sca.policy.recoveryrules</Bundle-SymbolicName>
- <Bundle-Description>${pom.name}</Bundle-Description>
- <Export-Package>org.apache.tuscany.sca.policy.recoveryrules*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
-
-
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<URL>() { - - public URL run() { - return getClass().getClassLoader().getResource(definitionsFile); - } - }); - - try { - URI uri = new URI(definitionsFile); - return (SCADefinitions) urlArtifactProcessor.read(null, - uri, - definitionsFileUrl); - } catch (Exception e) { - throw new SCADefinitionsProviderException(e); - } - } -} diff --git a/sandbox/dougsleite/policy-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<RecoveryRulesPolicy> { - - 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<RecoveryRulesPolicy> getModelType() { - return RecoveryRulesPolicy.class; - } -} 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 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" - targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0" - xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"> - - <!-- Policy Intents Defined by the SCA Runtime --> - <intent name="recoveryRules" constrains="sca:implementation.java"> - <description> - Describe the recovery rules for the guardian group - </description> - </intent> -</definitions>
\ 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<String, OMElement> 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 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<recovery_rules> - <rule name="Rule1" signaled_exception="org.apache.tuscany.sca.guardian.JoinException"> - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"/> - </participant> - </rule> - <rule name="Rule2" signaled_exception="org.apache.tuscany.sca.guardian.JoinException"> - <participant match="SIGNALER"> - <throw_exception class="org.apache.tuscany.sca.guardian.itests.primaryBackup.common.PrimaryExistsException" target_context="MAIN" min_participant_joined="2"> - <affected_participants>FIRST</affected_participants> - </throw_exception> - </participant> - </rule> -</recovery_rules>
\ 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/classes" path="src/main/java"/> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> - <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> - <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/sandbox/dougsleite/policy-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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>tuscany-policy-recoveryrules</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.maven.ide.eclipse.maven2Builder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.maven.ide.eclipse.maven2Nature</nature> - </natures> -</projectDescription> diff --git a/sandbox/dougsleite/policy-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 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-modules</artifactId>
- <version>1.6-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-policy-resolutiontrees</artifactId>
- <name>Apache Tuscany SCA Resolution Tree Policy Model</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly-xml</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution-impl</artifactId>
- <version>1.6-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-impl</artifactId>
- <version>1.2.7</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-guardian</artifactId>
- <version>1.6-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
-
- <configuration>
- <instructions>
- <Bundle-Version>${tuscany.version}</Bundle-Version>
- <Bundle-SymbolicName>org.apache.tuscany.sca.policy.resolutiontree</Bundle-SymbolicName>
- <Bundle-Description>${pom.name}</Bundle-Description>
- <Export-Package>org.apache.tuscany.sca.policy.resolutiontree*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
-
-
-
-
-
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<URL>() { - - public URL run() { - return getClass().getClassLoader().getResource(definitionsFile); - } - }); - - try { - URI uri = new URI(definitionsFile); - return (SCADefinitions) urlArtifactProcessor.read(null, - uri, - definitionsFileUrl); - } catch (Exception e) { - throw new SCADefinitionsProviderException(e); - } - } -} diff --git a/sandbox/dougsleite/policy-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<ResolutionTreesPolicy> { - - 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<ResolutionTreesPolicy> 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/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 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" - targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0" - xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"> - - <!-- Policy Intents Defined by the SCA Runtime --> - <intent name="resolutionTrees" constrains="sca:implementation.java"> - <description> - Describe the resolution trees for the guardian group - </description> - </intent> -</definitions> 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<String, OMElement> 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 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<resolution_trees> - <resolution_tree exception_level="1"> - <exception class="org.exceptions.PrimaryBackupFailedTogetherException"> - <exception class="org.exceptions.PrimaryFailedException"/> - <exception class="org.exceptions.BackupFailedException"/> - </exception> - </resolution_tree> - - <resolution_tree exception_level="2"> - <exception class="org.exceptions.UnavailableException"> - <exception class="org.exceptions.HotelServiceFailedException"> - <exception class="org.exceptions.RoomBookFailedException"/> - </exception> - <exception class="org.exceptions.CarServiceFailedException"/> - </exception> - </resolution_tree> -</resolution_trees> |