summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sca/itest/jms/src/main/resources/policyHeaders/definitions.xml41
-rw-r--r--java/sca/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite46
-rw-r--r--java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java97
-rw-r--r--java/sca/modules/binding-jms-policy/pom.xml6
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/JMSBindingDefinitionsProvider.java66
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java10
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java93
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java110
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider19
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/resources/binding-jms-policy-validation-messages.properties23
-rw-r--r--java/sca/modules/binding-jms-policy/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml61
-rw-r--r--java/sca/modules/binding-jms-policy/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java91
-rw-r--r--java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/jms/policy/mock_policy_definitions.xml39
-rw-r--r--java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml36
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java42
-rw-r--r--java/sca/modules/policy-reliability/LICENSE205
-rw-r--r--java/sca/modules/policy-reliability/NOTICE6
-rw-r--r--java/sca/modules/policy-reliability/pom.xml70
-rw-r--r--java/sca/modules/policy-reliability/src/main/java/org/apache/tuscany/sca/policy/reliability/ReliabilityPolicyDefinitionsProvider.java72
-rw-r--r--java/sca/modules/policy-reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider19
-rw-r--r--java/sca/modules/policy-reliability/src/main/resources/org/apache/tuscany/sca/policy/reliability/definitions.xml62
-rw-r--r--java/sca/modules/pom.xml1
22 files changed, 1152 insertions, 63 deletions
diff --git a/java/sca/itest/jms/src/main/resources/policyHeaders/definitions.xml b/java/sca/itest/jms/src/main/resources/policyHeaders/definitions.xml
new file mode 100644
index 0000000000..0cdda97a11
--- /dev/null
+++ b/java/sca/itest/jms/src/main/resources/policyHeaders/definitions.xml
@@ -0,0 +1,41 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <policySet name="JMSPolicySet"
+ provides="priority"
+ appliesTo="sca:binding.jms">
+ <intentMap provides="priority" default="medium">
+ <qualifier name="high">
+ <tuscany:jmsHeader JMSPriority="9"/>
+ </qualifier>
+ <qualifier name="medium">
+ <tuscany:jmsHeader JMSPriority="4"/>
+ </qualifier>
+ <qualifier name="low">
+ <tuscany:jmsHeader JMSPriority="0"/>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/java/sca/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite b/java/sca/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
new file mode 100644
index 0000000000..6fb6330a21
--- /dev/null
+++ b/java/sca/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
@@ -0,0 +1,46 @@
+<?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"
+ targetNamespace="http://jms"
+ name="PropertiesClientComposite">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgClientImpl" />
+ <reference name="myService" requires="priority.medium">
+ <binding.jms uri="jms:ServiceQueue">
+ <!-- headers JMSType="myType"
+ JMSCorrelationID="xyz"
+ JMSDeliveryMode="PERSISTENT"
+ JMSTimeToLive="4321"
+ JMSPriority="7">
+ <property name="headP1">myHeadP1</property>
+ </headers-->
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="ServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgServiceImpl" />
+ <service name="MsgService">
+ <binding.jms uri="jms:ServiceQueue"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java b/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
new file mode 100644
index 0000000000..c0c90cea95
--- /dev/null
+++ b/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
@@ -0,0 +1,97 @@
+/*
+ * 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.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.jms.DeliveryMode;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ */
+public class PolicyHeadersTestCase {
+
+ private static SCADomain scaDomain;
+
+ @Before
+ public void init() {
+ scaDomain = SCADomain.newInstance("http://localhost", "/", "policyHeaders/policyHeaders.composite");
+ }
+
+ @Test
+ public void testProps1() throws Exception {
+ JMSClient client = scaDomain.getService(JMSClient.class, "ClientComponent");
+
+ client.aClientMethod();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(MsgServiceImpl.lock) {
+ if (MsgServiceImpl.msg == null) {
+ MsgServiceImpl.lock.wait(5000);
+ }
+ }
+ assertNotNull(MsgServiceImpl.msg);
+
+
+ assertEquals(4, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ
+ /*
+ assertEquals("myType", MsgServiceImpl.msg.getJMSType());
+ assertEquals("xyz", MsgServiceImpl.msg.getJMSCorrelationID());
+ assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+ assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+ */
+ }
+
+ @Test
+ @Ignore
+ public void testOp2() throws Exception {
+ MsgClient client = scaDomain.getService(MsgClient.class, "ClientComponent");
+
+ client.op2();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(MsgServiceImpl.lock) {
+ if (MsgServiceImpl.msg == null) {
+ MsgServiceImpl.lock.wait(5000);
+ }
+ }
+ assertNotNull(MsgServiceImpl.msg);
+
+ assertEquals("op2Type", MsgServiceImpl.msg.getJMSType());
+ assertEquals("op2CID", MsgServiceImpl.msg.getJMSCorrelationID());
+ // assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); // Doesn't seem to work with ActiveMQ
+ // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ
+ assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+ assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2"));
+ assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName"));
+ }
+
+ @After
+ public void end() {
+ if (scaDomain != null) {
+ scaDomain.close();
+ }
+ }
+}
diff --git a/java/sca/modules/binding-jms-policy/pom.xml b/java/sca/modules/binding-jms-policy/pom.xml
index fced6ee53a..9d9fe5c8d9 100644
--- a/java/sca/modules/binding-jms-policy/pom.xml
+++ b/java/sca/modules/binding-jms-policy/pom.xml
@@ -43,6 +43,12 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-reliability</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-policy-security</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/JMSBindingDefinitionsProvider.java b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/JMSBindingDefinitionsProvider.java
new file mode 100644
index 0000000000..de54545f7e
--- /dev/null
+++ b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/JMSBindingDefinitionsProvider.java
@@ -0,0 +1,66 @@
+/*
+ * 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.binding.jms.policy;
+
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+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;
+
+/**
+ * Provider for Policy Intents and PolicySet definitions for the JMS binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingDefinitionsProvider implements SCADefinitionsProvider {
+ private String definitionsFile = "org/apache/tuscany/sca/binding/jms/policy/definitions.xml";
+ URLArtifactProcessor urlArtifactProcessor = null;
+
+ public JMSBindingDefinitionsProvider(ExtensionPointRegistry registry) {
+ URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class);
+ }
+
+ public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException {
+ final URL definitionsFileUrl = getClass().getClassLoader().getResource(definitionsFile);
+ SCADefinitions scaDefn = null;
+ try {
+ final URI uri = new URI(definitionsFile);
+ // Allow bindings to read properties. Requires PropertyPermission read in security policy.
+ scaDefn = AccessController.doPrivileged(new PrivilegedExceptionAction<SCADefinitions>() {
+ public SCADefinitions run() throws ContributionReadException {
+ return (SCADefinitions)urlArtifactProcessor.read(null, uri, definitionsFileUrl);
+ }
+ });
+ } catch (Exception e) {
+ throw new SCADefinitionsProviderException(e);
+ }
+ return scaDefn;
+ }
+
+}
diff --git a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java
index 2d63fd5a16..11747914da 100644
--- a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java
+++ b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -91,11 +92,10 @@ public class JMSTokenAuthenticationPolicyProcessor extends BaseStAXArtifactProce
writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS);
if ( policy.getTokenName() != null ) {
- writer.writeStartElement(prefix,
- JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_TOKEN_NAME,
- getArtifactType().getNamespaceURI());
- writer.writeCharacters(policy.getTokenName().toString());
- writer.writeEndElement();
+ writer.writeAttribute(prefix,
+ getArtifactType().getNamespaceURI(),
+ JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_TOKEN_NAME,
+ policy.getTokenName().toString());
}
writer.writeEndElement();
diff --git a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java
index c51e33fb53..e109c52fba 100644
--- a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java
+++ b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.sca.binding.jms.policy.header;
+import java.util.Hashtable;
+import java.util.Map;
+
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.xml.Constants;
@@ -30,21 +33,68 @@ import org.apache.tuscany.sca.policy.Policy;
* @version $Rev$ $Date$
*/
public class JMSHeaderPolicy implements Policy {
- public static final QName AXIS2_HEADER_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "axis2Header");
- public static final String AXIS2_HEADER_NAME = "headerName";
-
- private QName headerName;
+ public static final QName JMS_HEADER_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "jmsHeader");
+ public static final String JMS_HEADER_JMS_TYPE = "JMSType";
+ public static final String JMS_HEADER_JMS_CORRELATION_ID = "JMSDeliveryMode";
+ public static final String JMS_HEADER_JMS_DELIVERY_MODE = "JMSDeliveryMode";
+ public static final String JMS_HEADER_JMS_TIME_TO_LIVE = "JMSTimeToLive";
+ public static final String JMS_HEADER_JMS_PRIORITY = "JMSPriority";
+ public static final String JMS_HEADER_JMS_PROPERTY = "property";
+ public static final String JMS_HEADER_JMS_PROPERTY_NAME = "name";
- public QName getHeaderName() {
- return headerName;
+ private String jmsType = null;
+ private String jmsCorrelationId = null;
+ private Boolean deliveryModePersistent = null;
+ private Long timeToLive = null;
+ private Integer jmsPriority = null;
+ private Map<String, String> properties = new Hashtable<String, String>();
+
+ public String getJmsType() {
+ return jmsType;
+ }
+
+ public void setJmsType(String jmsType) {
+ this.jmsType = jmsType;
+ }
+
+ public String getJmsCorrelationId() {
+ return jmsCorrelationId;
+ }
+
+ public void setJmsCorrelationId(String jmsCorrelationId) {
+ this.jmsCorrelationId = jmsCorrelationId;
+ }
+
+ public Boolean getDeliveryModePersistent() {
+ return deliveryModePersistent;
}
- public void setHeaderName(QName headerName) {
- this.headerName = headerName;
+ public void setDeliveryModePersistent(Boolean deliveryModePersistent) {
+ this.deliveryModePersistent = deliveryModePersistent;
}
+ public Long getTimeToLive() {
+ return timeToLive;
+ }
+
+ public void setTimeToLive(Long timeToLive) {
+ this.timeToLive = timeToLive;
+ }
+
+ public Integer getJmsPriority() {
+ return jmsPriority;
+ }
+
+ public void setJmsPriority(Integer jmsPriority) {
+ this.jmsPriority = jmsPriority;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
public QName getSchemaName() {
- return AXIS2_HEADER_POLICY_QNAME;
+ return JMS_HEADER_POLICY_QNAME;
}
public boolean isUnresolved() {
@@ -53,4 +103,29 @@ public class JMSHeaderPolicy implements Policy {
public void setUnresolved(boolean unresolved) {
}
+
+ @Override
+ public String toString() {
+ String result = "jmsHeader";
+
+ result += " JMSType ";
+ result += getJmsType();
+ result += " JMSDeliveryMode ";
+ result += getJmsCorrelationId();
+ result += " JMSDeliveryMode ";
+ result += getDeliveryModePersistent();
+ result += " JMSTimeToLive ";
+ result += getTimeToLive();
+ result += " JMSPriority ";
+ result += getJmsPriority();
+
+ for (String propertyName : properties.keySet()){
+ result += " property ";
+ result += propertyName;
+ result += " ";
+ result += properties.get(propertyName);
+ }
+
+ return result;
+ }
}
diff --git a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java
index f8186470c8..d6167b4895 100644
--- a/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java
+++ b/java/sca/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java
@@ -21,6 +21,8 @@ package org.apache.tuscany.sca.binding.jms.policy.header;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import java.util.Hashtable;
+import java.util.Map;
import java.util.logging.Level;
import javax.xml.namespace.QName;
@@ -28,6 +30,7 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
@@ -37,6 +40,8 @@ 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.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
*
@@ -44,12 +49,43 @@ import org.apache.tuscany.sca.monitor.Monitor;
*/
public class JMSHeaderPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<JMSHeaderPolicy> {
+ private Monitor monitor;
+
public QName getArtifactType() {
- return JMSHeaderPolicy.AXIS2_HEADER_POLICY_QNAME;
+ return JMSHeaderPolicy.JMS_HEADER_POLICY_QNAME;
}
public JMSHeaderPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ /**
+ * Marshals warnings into the monitor
+ *
+ * @param message
+ * @param model
+ * @param messageParameters
+ */
+ protected void warning(String message, Object model, String... messageParameters) {
+ if (monitor != null){
+ Problem problem = new ProblemImpl(this.getClass().getName(), "assembly-xml-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
+
+ /**
+ * Marshals errors into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "assembly-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
public JMSHeaderPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
@@ -63,7 +99,44 @@ public class JMSHeaderPolicyProcessor extends BaseStAXArtifactProcessor implemen
case START_ELEMENT : {
name = reader.getName();
if ( name.equals(getArtifactType()) ) {
- policy.setHeaderName(getQName(reader, JMSHeaderPolicy.AXIS2_HEADER_NAME));
+
+ policy.setJmsType(getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_TYPE));
+ policy.setJmsCorrelationId(getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_CORRELATION_ID));
+
+ String deliveryMode = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_DELIVERY_MODE);
+ if (deliveryMode != null){
+ if (deliveryMode.equals("PERSISTENT")) {
+ policy.setDeliveryModePersistent(true);
+ } else if (deliveryMode.equals("NON_PERSISTENT")){
+ policy.setDeliveryModePersistent(false);
+ } else {
+ error("InvalidDeliveryMode", policy, deliveryMode);
+ }
+ }
+
+ String timeToLive = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_TIME_TO_LIVE);
+
+ if ( timeToLive != null){
+ try {
+ policy.setTimeToLive(Long.valueOf(timeToLive));
+ } catch (NumberFormatException ex){
+ error("InvalidTimeToLive", policy, timeToLive);
+ }
+ }
+
+ String priority = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_PRIORITY);
+
+ if ( priority != null){
+ try {
+ policy.setJmsPriority(Integer.valueOf(priority));
+ } catch (NumberFormatException ex){
+ error("InvalidPriority", policy, priority);
+ }
+ }
+ } else if (name.getLocalPart().equals(JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY)) {
+ String propertyName = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY_NAME);
+ String propertyValue = reader.getElementText();
+ policy.getProperties().put(propertyName, propertyValue);
}
break;
}
@@ -91,14 +164,37 @@ public class JMSHeaderPolicyProcessor extends BaseStAXArtifactProcessor implemen
getArtifactType().getLocalPart(),
getArtifactType().getNamespaceURI());
writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS);
-
- if ( policy.getHeaderName() != null ) {
+
+ if (policy.getJmsType() != null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_TYPE, policy.getJmsType());
+ }
+
+ if (policy.getJmsCorrelationId() != null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_CORRELATION_ID, policy.getJmsCorrelationId());
+ }
+
+ if (policy.getDeliveryModePersistent() == true){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_DELIVERY_MODE, "PERSISTENT");
+ } else {
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_DELIVERY_MODE, "NON_PERSISTENT");
+ }
+
+ if (policy.getTimeToLive()!= null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_TIME_TO_LIVE, policy.getTimeToLive().toString());
+ }
+
+ if (policy.getJmsPriority()!= null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_PRIORITY, policy.getJmsPriority().toString());
+ }
+
+ for (String propertyName : policy.getProperties().keySet()){
writer.writeStartElement(prefix,
- JMSHeaderPolicy.AXIS2_HEADER_NAME,
+ JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY,
getArtifactType().getNamespaceURI());
- writer.writeCharacters(policy.getHeaderName().toString());
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY_NAME, propertyName);
+ writer.writeCharacters(policy.getProperties().get(propertyName));
writer.writeEndElement();
- }
+ }
writer.writeEndElement();
}
diff --git a/java/sca/modules/binding-jms-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/java/sca/modules/binding-jms-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider
new file mode 100644
index 0000000000..0598cdc368
--- /dev/null
+++ b/java/sca/modules/binding-jms-policy/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.binding.jms.policy.JMSBindingDefinitionsProvider \ No newline at end of file
diff --git a/java/sca/modules/binding-jms-policy/src/main/resources/binding-jms-policy-validation-messages.properties b/java/sca/modules/binding-jms-policy/src/main/resources/binding-jms-policy-validation-messages.properties
new file mode 100644
index 0000000000..fd43b2c4e9
--- /dev/null
+++ b/java/sca/modules/binding-jms-policy/src/main/resources/binding-jms-policy-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# 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.
+#
+#
+InvalidDeliveryMode = JMSDeliveryMode must be either PERSISTENT or NON_PERSISTENT but found {0}
+InvalidTimeToLive = JMSTimeToLive must be a long integer but found {0}
+InvalidPriority = JMSPriority must be a integer but found {0}
diff --git a/java/sca/modules/binding-jms-policy/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml b/java/sca/modules/binding-jms-policy/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml
new file mode 100644
index 0000000000..044ed834e6
--- /dev/null
+++ b/java/sca/modules/binding-jms-policy/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml
@@ -0,0 +1,61 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <!-- intents not yet enabled -->
+ <!--sca:bindingType type="sca:binding.jms"
+ alwaysProvides="JMS"
+ mayProvide="atLeastOnce atMostOnce ordered conversation" /-->
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for JMS Binding -->
+ <sca:intent name="JMS" constrains="sca:binding.jms">
+ <sca:description>
+ Communication through this binding requires JMS
+ </sca:description>
+ </sca:intent>
+
+ <intent name="priority"
+ constrains="sca:binding">
+ <description>
+ This intent is used to indicate the priority of the
+ sent message
+ </description>
+ </intent>
+
+ <intent name="priority.high">
+ <description>
+ Messages are high priority
+ </description>
+ </intent>
+
+ <intent name="priority.medium">
+ <description>
+ Messages are meduim priority
+ </description>
+ </intent>
+
+ <intent name="priority.low">
+ <description>
+ Messages are low priority
+ </description>
+ </intent>
+</definitions> \ No newline at end of file
diff --git a/java/sca/modules/binding-jms-policy/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java b/java/sca/modules/binding-jms-policy/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..4c0e3d2e11
--- /dev/null
+++ b/java/sca/modules/binding-jms-policy/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java
@@ -0,0 +1,91 @@
+/*
+ * 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.binding.jms.policy;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicyProcessor;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicyProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.policy.Policy;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PolicyProcessorTestCase {
+ private final static List<String> SEQ =
+ Arrays.asList("<tuscany:jmsHeader xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" JMSType=\"ABC\" JMSDeliveryMode=\"PERSISTENT\" JMSDeliveryMode=\"PERSISTENT\" JMSTimeToLive=\"123\" JMSPriority=\"4\"><tuscany:property name=\"aProperty\">property value</tuscany:property></tuscany:jmsHeader>",
+ "<tuscany:jmsTokenAuthentication xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" tuscany:tokenName=\"{http://tuscany.apache.org/foo}myname\" />");
+
+ @Test
+ public void testRead() throws Exception {
+ List<String> results = new ArrayList<String>();
+ Map<QName, StAXArtifactProcessor> processors = new HashMap<QName, StAXArtifactProcessor>();
+ processors.put(JMSHeaderPolicy.JMS_HEADER_POLICY_QNAME, new JMSHeaderPolicyProcessor(null, null));
+ processors.put(JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_POLICY_QNAME, new JMSTokenAuthenticationPolicyProcessor(null, null));
+
+ InputStream is = getClass().getResourceAsStream("mock_policy_definitions.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+
+ while (true) {
+ int event = reader.getEventType();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ if ("policySet".equals(reader.getName().getLocalPart())) {
+ reader.nextTag();
+ StAXArtifactProcessor processor = processors.get(reader.getName());
+ Policy policy = (Policy)processor.read(reader);
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(outputStream);
+ processor.write(policy, writer);
+ writer.flush();
+ results.add(outputStream.toString());
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ Assert.assertEquals(SEQ, results);
+ }
+}
diff --git a/java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/jms/policy/mock_policy_definitions.xml b/java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/jms/policy/mock_policy_definitions.xml
new file mode 100644
index 0000000000..3631c682aa
--- /dev/null
+++ b/java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/jms/policy/mock_policy_definitions.xml
@@ -0,0 +1,39 @@
+<?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:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <!-- POLICY SETS -->
+ <policySet name="ps1" provides="authorization" appliesTo="sca:implementation">
+ <tuscany:jmsHeader JMSType="ABC"
+ JMSCorrelattionID="DEF"
+ JMSDeliveryMode="PERSISTENT"
+ JMSTimeToLive="123"
+ JMSPriority="4">
+ <property name="aProperty">property value</property>
+ </tuscany:jmsHeader>
+ </policySet>
+
+ <policySet name="ps2" provides="authorization" appliesTo="sca:implementation">
+ <tuscany:jmsTokenAuthentication xmlns:foo="http://tuscany.apache.org/foo" tokenName="foo:myname"/>
+ </policySet>
+</definitions> \ No newline at end of file
diff --git a/java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml b/java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml
deleted file mode 100644
index 77f750cd0d..0000000000
--- a/java/sca/modules/binding-jms-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_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.
--->
-<tuscany:wsConfigParam xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
- <parameter name="InflowSecurity">
- <action>
- <items>Timestamp Signature</items>
- <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties</signaturePropFile>
- </action>
- </parameter>
- <parameter name="OutflowSecurity">
- <action>
- <items>Timestamp Signature</items>
- <user>TuscanyWsUser</user>
- <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties</signaturePropFile>
- <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.IntegrityPWCBHandler</passwordCallbackClass>" +
- <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
- </action>
- </parameter>
-</tuscany:wsConfigParam> \ No newline at end of file
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
index 5d8053e02d..cfa099e875 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
@@ -35,6 +35,7 @@ import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException;
import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
@@ -64,6 +65,7 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
protected Destination bindingReplyDest;
protected RuntimeComponentReference reference;
protected JMSTokenAuthenticationPolicy jmsTokenAuthenticationPolicy = null;
+ protected JMSHeaderPolicy jmsHeaderPolicy = null;
public JMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) {
@@ -83,7 +85,9 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
for (Object p : ps.getPolicies()) {
if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
jmsTokenAuthenticationPolicy = (JMSTokenAuthenticationPolicy)p;
- }else {
+ }else if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
+ jmsHeaderPolicy = (JMSHeaderPolicy)p;
+ } else {
// etc. check for other types of policy being present
}
}
@@ -321,7 +325,15 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
requestMessageProcessor.setOperationName(jmsBinding.getNativeOperationName(operationName), jmsMsg);
- if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) {
+ if ((jmsHeaderPolicy != null) &&
+ (jmsHeaderPolicy.getDeliveryModePersistent() != null)) {
+ if (jmsHeaderPolicy.getDeliveryModePersistent()) {
+ jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
+ } else {
+ jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ }
+
+ } else if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) {
if (jmsBinding.getOperationJMSDeliveryMode(operationName)) {
jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
} else {
@@ -329,15 +341,24 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
}
}
- if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) {
+ if ((jmsHeaderPolicy != null) &&
+ (jmsHeaderPolicy.getJmsCorrelationId() != null)) {
+ jmsMsg.setJMSCorrelationID(jmsHeaderPolicy.getJmsCorrelationId());
+ } else if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) {
jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName));
}
- if (jmsBinding.getOperationJMSPriority(operationName) != null) {
+ if ((jmsHeaderPolicy != null) &&
+ (jmsHeaderPolicy.getJmsPriority() != null)) {
+ jmsMsg.setJMSPriority(jmsHeaderPolicy.getJmsPriority());
+ } else if (jmsBinding.getOperationJMSPriority(operationName) != null) {
jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName));
}
- if (jmsBinding.getOperationJMSType(operationName) != null) {
+ if ((jmsHeaderPolicy != null) &&
+ (jmsHeaderPolicy.getJmsType() != null)) {
+ jmsMsg.setJMSType(jmsHeaderPolicy.getJmsType());
+ } else if (jmsBinding.getOperationJMSType(operationName) != null) {
jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName));
}
@@ -360,6 +381,12 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
}
}
+ if (jmsHeaderPolicy != null){
+ for (String propName : jmsHeaderPolicy.getProperties().keySet()) {
+ jmsMsg.setObjectProperty(propName, jmsHeaderPolicy.getProperties().get(propName));
+ }
+ }
+
for (String propName : jmsBinding.getPropertyNames()) {
Object value = jmsBinding.getProperty(propName);
jmsMsg.setObjectProperty(propName, value);
@@ -394,7 +421,10 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
MessageConsumer consumer = session.createConsumer(replyToDest, msgSelector);
long receiveWait;
- if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) {
+ if ((jmsHeaderPolicy != null) &&
+ (jmsHeaderPolicy.getTimeToLive() != null)) {
+ receiveWait = jmsHeaderPolicy.getTimeToLive();
+ } else if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) {
receiveWait = jmsBinding.getOperationJMSTimeToLive(operationName) * 2;
} else {
receiveWait = JMSBindingConstants.DEFAULT_TIME_TO_LIVE;
diff --git a/java/sca/modules/policy-reliability/LICENSE b/java/sca/modules/policy-reliability/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/java/sca/modules/policy-reliability/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/java/sca/modules/policy-reliability/NOTICE b/java/sca/modules/policy-reliability/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/java/sca/modules/policy-reliability/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/policy-reliability/pom.xml b/java/sca/modules/policy-reliability/pom.xml
new file mode 100644
index 0000000000..b1cf5a48bb
--- /dev/null
+++ b/java/sca/modules/policy-reliability/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-reliability</artifactId>
+ <name>Apache Tuscany Reliability Policy Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </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.reliability</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.policy.reliability*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/policy-reliability/src/main/java/org/apache/tuscany/sca/policy/reliability/ReliabilityPolicyDefinitionsProvider.java b/java/sca/modules/policy-reliability/src/main/java/org/apache/tuscany/sca/policy/reliability/ReliabilityPolicyDefinitionsProvider.java
new file mode 100644
index 0000000000..60e28f5231
--- /dev/null
+++ b/java/sca/modules/policy-reliability/src/main/java/org/apache/tuscany/sca/policy/reliability/ReliabilityPolicyDefinitionsProvider.java
@@ -0,0 +1,72 @@
+/*
+ * 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.reliability;
+
+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;
+
+/**
+ * Provider for Policy Intents and PolicySet definitions related to security
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReliabilityPolicyDefinitionsProvider implements SCADefinitionsProvider {
+ private String definitionsFile = "org/apache/tuscany/sca/policy/reliability/definitions.xml";
+ URLArtifactProcessor urlArtifactProcessor = null;
+
+ public ReliabilityPolicyDefinitionsProvider(ExtensionPointRegistry registry) {
+ URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class);
+ }
+
+ public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException {
+ SCADefinitions scaDefns = null;
+ SCADefinitions tuscanyDefns = null;
+ try {
+ // 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);
+ }
+ });
+
+ URI uri = new URI(definitionsFile);
+
+ scaDefns = (SCADefinitions)urlArtifactProcessor.read(null,
+ uri,
+ definitionsFileUrl);
+
+ return scaDefns;
+
+ } catch ( Exception e ) {
+ throw new SCADefinitionsProviderException(e);
+ }
+ }
+
+}
diff --git a/java/sca/modules/policy-reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/java/sca/modules/policy-reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider
new file mode 100644
index 0000000000..7f616cb3d4
--- /dev/null
+++ b/java/sca/modules/policy-reliability/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.reliability.ReliabilityPolicyDefinitionsProvider \ No newline at end of file
diff --git a/java/sca/modules/policy-reliability/src/main/resources/org/apache/tuscany/sca/policy/reliability/definitions.xml b/java/sca/modules/policy-reliability/src/main/resources/org/apache/tuscany/sca/policy/reliability/definitions.xml
new file mode 100644
index 0000000000..df87906ab8
--- /dev/null
+++ b/java/sca/modules/policy-reliability/src/main/resources/org/apache/tuscany/sca/policy/reliability/definitions.xml
@@ -0,0 +1,62 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+
+ <!-- Policy Intents Defined by the SCA Runtime -->
+ <intent name="atLeastOnce"
+ constrains="sca:binding">
+ <description>
+ This intent is used to indicate that a message sent
+ by a client is always delivered to the component.
+ </description>
+ </intent>
+
+ <intent name="atMostOnce"
+ constrains="sca:binding">
+ <description>
+ This intent is used to indicate that a message that was
+ successfully sent by a client is not delivered more than
+ once to the component.
+ </description>
+ </intent>
+
+ <intent name="ordered"
+ constrains="sca:binding">
+ <description>
+ This intent is used to indicate that all the messages
+ are delivered to the component in the order they were
+ sent by the client.
+ </description>
+ </intent>
+
+ <intent name="exactlyOnce"
+ constrains="sca:binding"
+ requires="atLeastOnce atMostOnce">
+ <description>
+ This profile intent is used to indicate that a message
+ sent by a client is always delivered to the component.
+ It also indicates that duplicate messages are not
+ delivered to the component.
+ </description>
+ </intent>
+</definitions> \ No newline at end of file
diff --git a/java/sca/modules/pom.xml b/java/sca/modules/pom.xml
index 2077298a97..b4b3b292c5 100644
--- a/java/sca/modules/pom.xml
+++ b/java/sca/modules/pom.xml
@@ -169,6 +169,7 @@
<module>policy-xml</module>
<module>policy-xml-ws</module>
<module>policy-logging</module>
+ <module>policy-reliability</module>
<module>policy-security</module>
<module>policy-security-jsr250</module>
<!--module>policy-security-ws</module-->