diff options
Diffstat (limited to '')
11 files changed, 616 insertions, 32 deletions
diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java new file mode 100644 index 0000000000..01ca3a0166 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingImplementationPolicyProvider.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; + +public class GuardianExceptionHandlingImplementationPolicyProvider implements PolicyProvider { + + private MessageFactory messageFactory; + private RuntimeComponent component; + private RuntimeComponentService service; + private Binding binding; + + public GuardianExceptionHandlingImplementationPolicyProvider(ExtensionPointRegistry extensionPoints, + RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + messageFactory = modelFactories.getFactory(MessageFactory.class); + + this.component = component; + this.service = service; + this.binding = binding; + } + + public Interceptor createInterceptor(Operation operation) { + + return new GuardianExceptionHandlingPolicyInterceptor(service, service.getRuntimeWire(binding)); + } + + public String getPhase() { + return Phase.IMPLEMENTATION_POLICY; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java new file mode 100644 index 0000000000..a4179bd666 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicy.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.policy.Policy; + +public class GuardianExceptionHandlingPolicy implements Policy { + + public QName getSchemaName() { + return null; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java new file mode 100644 index 0000000000..b1ca3f2edc --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyDefinitionsProvider.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.definitions.SCADefinitions; +import org.apache.tuscany.sca.provider.SCADefinitionsProvider; +import org.apache.tuscany.sca.provider.SCADefinitionsProviderException; + +public class GuardianExceptionHandlingPolicyDefinitionsProvider implements SCADefinitionsProvider { + private String definitionsFile = "org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml"; + URLArtifactProcessor urlArtifactProcessor = null; + + public GuardianExceptionHandlingPolicyDefinitionsProvider(ExtensionPointRegistry registry) { + URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class); + } + + public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { + // Allow privileged access to load resource. Requires RuntimePermssion in security policy. + URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction<URL>() { + public URL run() { + return getClass().getClassLoader().getResource(definitionsFile); + } + }); + + try { + URI uri = new URI(definitionsFile); + return (SCADefinitions)urlArtifactProcessor.read(null, + uri, + definitionsFileUrl); + } catch ( Exception e ) { + throw new SCADefinitionsProviderException(e); + } + } + +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java new file mode 100644 index 0000000000..a98b300aae --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyInterceptor.java @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.tuscany.sca.implementation.guardian.common.Context; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.implementation.guardian.GuardianMember; +import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; +import org.apache.tuscany.sca.implementation.guardian.common.GlobalExceptionInterface; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +public class GuardianExceptionHandlingPolicyInterceptor implements Interceptor { + + public static final String ENABLE_CONTEXT = "enableContext"; + public static final String REMOVE_CONTEXT = "removeContext"; + public static final String GTHROW = "gthrow"; + public static final String PROPAGATE = "propagate"; + public static final String CHECK_EXCEPTION_STATUS = "checkExceptionStatus"; + private Invoker next; + private RuntimeWire runtimeWire; + private RuntimeComponentService service; + + public GuardianExceptionHandlingPolicyInterceptor(RuntimeComponentService service, RuntimeWire runtimeWire) { + super(); + this.runtimeWire = runtimeWire; + this.service = service; + } + + //IMPLEMENTAR A LOGICA ENTRE {P <-> GM <-> GG} + public Message invoke(Message msg) { + + Class targetComponentImplClass = msg.getTo().getComponent().getImplementation().getClass(); + + String implementationGuardian = "org.apache.tuscany.sca.implementation.guardian.impl.GuardianGroupImplementationImpl"; + Message responseMsg = null; + +// //Test the target component - must be a implemenation.guardian +// try { +// if (!targetComponentImplClass.equals(Class.forName(implementationJava))) { +// throw new InvalidPolicyAssociationException("The target component must be a implementation.guardian"); +// } +// } catch (ClassNotFoundException ex) { +// Logger.getLogger(GuardianExceptionHandlingPolicyInterceptor.class.getName()).log(Level.SEVERE, null, ex); +// } + + try { + if (targetComponentImplClass.equals(Class.forName(implementationGuardian))) { + + String msgOperationName = msg.getOperation().getName(); + String componentName = msg.getFrom().getComponent().getName(); + + GuardianMemberFactoryImpl factory = GuardianMemberFactoryImpl.getInstance(); + GuardianMember gm = factory.createGuardianMember(componentName, msg, this); + + Object msgBody = msg.getBody(); + + if (msgOperationName.equals(ENABLE_CONTEXT)) { + Context context = (Context)((Object[]) msg.getBody())[0]; + gm.enableContext(context); + msg.setBody(null); + return msg; + } else if (msgOperationName.equals(REMOVE_CONTEXT)) { + Context removedContext = gm.removeContext(); + msg.setBody(removedContext); + + //All the contexts were removed + if(gm.getCurrentContext().equals(Context.INIT_CONTEXT)) { + factory.removeGuardianMember(componentName, msg, this); + } + + return msg; + } else if (msgOperationName.equals(GTHROW)) { + GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msgBody)[0]; + List<String> participantList = (List<String>) ((Object[]) msgBody)[1]; + gm.gthrow(ex, participantList); + msg.setBody(null); + return msg; + } else if (msgOperationName.equals(PROPAGATE)) { + GlobalExceptionInterface ex = (GlobalExceptionInterface) ((Object[]) msgBody)[0]; + boolean response = gm.propagate(ex); + msg.setBody(response); + return msg; + } else if (msgOperationName.equals(CHECK_EXCEPTION_STATUS)) { + try { + gm.checkExceptionStatus(); + msg.setBody(null); + } catch (GlobalException ex) { + msg.setFaultBody(ex); + } + return msg; + } + } else { + //throw new UnsupportedOperationException("Invocation of " + msgOperationName + " is not allowed"); + responseMsg = getNext().invoke(msg); + } + } catch (ClassNotFoundException ex) { + Logger.getLogger(GuardianExceptionHandlingPolicyInterceptor.class.getName()).log(Level.SEVERE, null, ex); + } + + return responseMsg; + } + + public Message invokeGuardianGroupOperation(String operationName, Message msg) { + + //Changing the operation + Operation desiredOperation = findOperation(operationName); + + msg.setOperation(desiredOperation); + + RuntimeComponent component = msg.getTo().getComponent(); + ImplementationProvider implProvider = component.getImplementationProvider(); + + Message responseMsg = implProvider.createInvoker(this.service, desiredOperation).invoke(msg); + + return responseMsg; + } + + private Operation findOperation(String method) { + if (method.contains(".")) { + method = method.substring(method.lastIndexOf(".") + 1); + } + + List<Operation> operations = runtimeWire.getTarget().getInterfaceContract().getInterface().getOperations(); + + Operation result = null; + for (Operation o : operations) { + if (o.getName().equalsIgnoreCase(method)) { + result = o; + break; + } + } + + return result; + } + + + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java new file mode 100644 index 0000000000..bd2d67ad6f --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianExceptionHandlingPolicyProviderFactory.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +public class GuardianExceptionHandlingPolicyProviderFactory implements PolicyProviderFactory<GuardianExceptionHandlingPolicy> { + + private ExtensionPointRegistry extensionPoints; + + public GuardianExceptionHandlingPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.extensionPoints = registry; + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + return null; + } + + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return null; + } + + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return new GuardianExceptionHandlingImplementationPolicyProvider(extensionPoints, component, service, binding); + } + + public Class getModelType() { + return null; + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java new file mode 100644 index 0000000000..2f5e9617ed --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberFactoryImpl.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + +import java.util.HashMap; +import java.util.Map; +import org.apache.tuscany.sca.implementation.guardian.GuardianMember; +import org.apache.tuscany.sca.invocation.Message; + +public class GuardianMemberFactoryImpl { + + Map<String, GuardianMember> guardianMembers; + private static GuardianMemberFactoryImpl instance = null; + + public static GuardianMemberFactoryImpl getInstance() { + if (instance == null) { + instance = new GuardianMemberFactoryImpl(); + } + return instance; + } + + protected GuardianMemberFactoryImpl() { + guardianMembers = new HashMap<String, GuardianMember>(); + } + + public GuardianMember createGuardianMember(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) { + GuardianMemberImpl gm = (GuardianMemberImpl) guardianMembers.get(componentName); + + if (gm == null) { + gm = new GuardianMemberImpl(componentName, msg, interceptor); + guardianMembers.put(componentName, gm); + + //Inform the Guardian Group of the new Guardian Member + Object msgBody = msg.getBody(); + + msg.setBody(gm); + interceptor.invokeGuardianGroupOperation("addGuardianMember", msg); + + msg.setBody(msgBody); + } + + gm.setMessage(msg); + gm.setGuardianExceptionHandlingPolicyInterceptor(interceptor); + + return gm; + } + + public GuardianMember removeGuardianMember(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) { + + GuardianMember gm = guardianMembers.remove(componentName); + + if (gm != null) { + + Object msgBody = msg.getBody(); + + msg.setBody(gm); + interceptor.invokeGuardianGroupOperation("removeGuardianMember", msg); + + msg.setBody(msgBody); + } + + return gm; + } +} diff --git a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java index 80b9321e79..5e9ae7853c 100644 --- a/sandbox/dougsleite/implementation-guardian/src/main/java/org/apache/tuscany/sca/implementation/guardian/impl/GuardianMemberImpl.java +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/GuardianMemberImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tuscany.sca.implementation.guardian.impl; +package org.apache.tuscany.sca.policy.guardianExceptionHandling; import java.util.LinkedList; import java.util.List; @@ -31,42 +31,46 @@ import org.apache.tuscany.sca.implementation.guardian.common.Context; import org.apache.tuscany.sca.implementation.guardian.common.GlobalException; import org.apache.tuscany.sca.implementation.guardian.common.JoinException; import org.apache.tuscany.sca.implementation.guardian.common.SuspendException; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -@Service(GuardianMember.class) -@Scope("COMPOSITE") +import org.apache.tuscany.sca.invocation.Message; + public class GuardianMemberImpl implements GuardianMember { private int participantState; private Stack<Context> contextList; - private Queue<GlobalException> exceptionQueue; - @Reference(name = "guardian_group", required = true) - public GuardianGroup guardianGroup; - private int id; + private String id; + //FIXME: Review the usage of this variable private boolean exceptionThrown; + private Message msg; + private GuardianExceptionHandlingPolicyInterceptor interceptor; - public GuardianMemberImpl() { + protected GuardianMemberImpl(String componentName, Message msg, GuardianExceptionHandlingPolicyInterceptor interceptor) { contextList = new Stack<Context>(); contextList.add(Context.INIT_CONTEXT); exceptionQueue = new LinkedList<GlobalException>(); participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE; exceptionThrown = false; + + this.id = componentName; + this.msg = msg; + this.interceptor = interceptor; + } + + public void setGuardianExceptionHandlingPolicyInterceptor(GuardianExceptionHandlingPolicyInterceptor interceptor) { + this.interceptor = interceptor; + } + + public GuardianExceptionHandlingPolicyInterceptor getGuardianExceptionHandlingPolicyInterceptor() { + return this.interceptor; } - @Init - public void init() { - guardianGroup.addGuardianMember(this); + public void setMessage(Message msg) { + this.msg = msg; } - @Destroy - public void destroy() { - guardianGroup.removeGuardianMember(this); + public Message getMessage() { + return this.msg; } public void addException(GlobalException ex) { @@ -76,25 +80,28 @@ public class GuardianMemberImpl implements GuardianMember { public Context getCurrentContext() { return contextList.peek(); } - public void enableContext(Context context) { //Update the context list with the related set of exceptions - contextList.push(context); - if (contextList.size() == 2) { + if (contextList.size() == 1) { + contextList.push(context); + JoinException ex = new JoinException(); ex.setSignalingContext(context); ex.putSignalingParticipant(getParticipantIdentifier()); gthrow(ex, null); + } else { + contextList.push(context); } } - public void removeContext() { - if (!contextList.isEmpty()) { - contextList.pop(); - } + public Context removeContext() { +// if (contextList.size() > 1) { +// return contextList.pop(); +// } + return contextList.pop(); } //If participantList is null then signal to ALL participants @@ -106,7 +113,13 @@ public class GuardianMemberImpl implements GuardianMember { ex.setSignalingContext(getCurrentContext()); ex.putSignalingParticipant(getParticipantIdentifier()); - guardianGroup.gthrow(ex, participantList); + //Prepare the parameters + Object[] params = {ex, participantList}; + msg.setBody(params); + + interceptor.invokeGuardianGroupOperation("gthrow", msg); + //guardianGroup.gthrow(ex, participantList); + exceptionThrown = true; } else { setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE); @@ -163,10 +176,6 @@ public class GuardianMemberImpl implements GuardianMember { return participantIdentifier.toString(); } - public void setUniqueParticipantID(int id) { - this.id = id; - } - public int getParticipantState() { return participantState; } diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java new file mode 100644 index 0000000000..183e60c8be --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/java/org/apache/tuscany/sca/policy/guardianExceptionHandling/InvalidPolicyAssociationException.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.guardianExceptionHandling; + +public class InvalidPolicyAssociationException extends RuntimeException { + + public InvalidPolicyAssociationException() { + super(); + } + + public InvalidPolicyAssociationException(String message) { + super(message); + } + + public InvalidPolicyAssociationException(String message, Throwable cause) { + super(message, cause); + } + + public InvalidPolicyAssociationException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..7365a52151 --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the policy extension
+org.apache.tuscany.sca.policy.guardianExceptionHandling.GuardianExceptionHandlingPolicyProviderFactory;model=org.apache.tuscany.sca.policy.guardianExceptionHandling.GuardianExceptionHandlingPolicy
diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..30c8b4f8fd --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for SCA Definitions Providers +org.apache.tuscany.sca.policy.guardianExceptionHandling.GuardianExceptionHandlingPolicyDefinitionsProvider
\ No newline at end of file diff --git a/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml new file mode 100644 index 0000000000..94bc0c023a --- /dev/null +++ b/sandbox/dougsleite/policy-guardianExceptionHandling/src/main/resources/org/apache/tuscany/sca/policy/guardianExceptionHandling/definitions.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+
+ <!-- Policy Intents Defined by the SCA Runtime -->
+ <intent name="guardianExceptionHandling" constrains="sca:implementation.java/sca:reference">
+ <description>
+ All messages to the guardian group implementation will be intercepted by the guardian member
+ </description>
+ </intent>
+</definitions>
\ No newline at end of file |