| Commit in servicemix/base on MAIN | |||
| src/test/resources/org/servicemix/jbi/config/subscription.xml | +15 | added 1.1 | |
| /subscription-spring.xml | +40 | added 1.1 | |
| src/main/java/org/servicemix/jbi/config/SubscriptionElementProcessor.java | +78 | added 1.1 | |
| /ComponentElementProcessor.java | +26 | -13 | 1.12 -> 1.13 |
| /ContainerElementProcessor.java | +2 | -1 | 1.3 -> 1.4 |
| src/test/java/org/servicemix/jbi/config/XmlParseWithNormalSpringTest.java | +31 | added 1.1 | |
| /XmlParseTest.java | +54 | added 1.1 | |
| src/main/java/org/servicemix/jbi/config/spring/QNameElementProcessor.java | +9 | -1 | 1.3 -> 1.4 |
| project.xml | +34 | -9 | 1.83 -> 1.84 |
| src/main/java/org/servicemix/jbi/container/SubscriptionSpec.java | +76 | added 1.1 | |
| /ActivationSpec.java | +10 | -1 | 1.10 -> 1.11 |
| /SpringJBIContainer.java | +5 | -1 | 1.17 -> 1.18 |
| +380 | -26 | ||
added support for a <subscription> element in the custom XML configuration format along with a subscriptions property on the ActivationSpec so we can add subscriptions to endpoint output
servicemix/base/src/test/resources/org/servicemix/jbi/config
subscription.xml added at 1.1
diff -N subscription.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ subscription.xml 20 Sep 2005 10:46:03 -0000 1.1 @@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns:foo="http://servicemix.org/cheese/"> + + <!-- the JBI container --> + <container id="jbi"> + <components> + + <component id="receiver" service="foo:receiver" class="org.servicemix.examples.ReceiverComponent"> + <subscription service="foo:producer"/> + </component> + </components> + </container> + + +</beans>
servicemix/base/src/test/resources/org/servicemix/jbi/config
subscription-spring.xml added at 1.1
diff -N subscription-spring.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ subscription-spring.xml 20 Sep 2005 10:46:03 -0000 1.1 @@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns:foo="http://servicemix.org/cheese/"> + + <!-- the JBI container --> + <bean id="jbi" + class="org.servicemix.jbi.container.SpringJBIContainer"> + <property name="activationSpecs"> + <list> + <bean class="org.servicemix.jbi.container.ActivationSpec"> + <property name="id" value="receiver" /> + <property name="service" ref="receiverServiceName" /> + + <property name="component"> + <bean class="org.servicemix.examples.ReceiverComponent" /> + </property> + + <property name="subscriptions"> + <list> + <bean name="subscription" + class="org.servicemix.jbi.container.SubscriptionSpec"> + <property name="service" ref="producerServiceName" /> + </bean> + </list> + </property> + </bean> + </list> + </property> + </bean> + + + <bean id="receiverServiceName" class="javax.xml.namespace.QName"> + <constructor-arg value="http://servicemix.org/cheese/" /> + <constructor-arg value="receiver" /> + </bean> + + <bean id="producerServiceName" class="javax.xml.namespace.QName"> + <constructor-arg value="http://servicemix.org/cheese/" /> + <constructor-arg value="producer" /> + </bean> +</beans>
servicemix/base/src/main/java/org/servicemix/jbi/config
SubscriptionElementProcessor.java added at 1.1
diff -N SubscriptionElementProcessor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SubscriptionElementProcessor.java 20 Sep 2005 10:46:05 -0000 1.1 @@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * 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.
+ *
+ **/
+package org.servicemix.jbi.config;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.servicemix.jbi.config.spring.QNameElementProcessor;
+import org.servicemix.jbi.util.DOMUtil;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.support.BeanDefinitionReader;
+import org.springframework.beans.factory.xml.ElementProcessor;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Handles the 'subscription' element
+ *
+ * @version $Revision$
+ */
+public class SubscriptionElementProcessor extends QNameElementProcessor implements ElementProcessor {
+ private static final Log log = LogFactory.getLog(SubscriptionElementProcessor.class);
+
+ public void processElement(Element element, BeanDefinitionReader beanDefinitionReader, Resource resource) {
+ // lets add a new bean element
+ Document document = element.getOwnerDocument();
+
+ Element root = (Element) element.getParentNode();
+
+ Element registration = addBeanElement(root, "org.servicemix.jbi.container.SubscriptionSpec");
+
+ // lets remove any attributes we need
+ String service = element.getAttribute("service");
+ if (service != null) {
+ element.removeAttribute("service");
+ addQNameProperty(registration, "service", service, element);
+ }
+ String interfaceName = element.getAttribute("interface");
+ if (interfaceName != null) {
+ element.removeAttribute("interface");
+ addQNameProperty(registration, "interfaceName", interfaceName, element);
+ }
+ String operation = element.getAttribute("operation");
+ if (operation != null) {
+ element.removeAttribute("operation");
+ addQNameProperty(registration, "operation", operation, element);
+ }
+
+ String endpoint = element.getAttribute("endpoint");
+ if (endpoint != null) {
+ element.removeAttribute("endpoint");
+ if (endpoint.length() > 0) {
+ addPropertyElement(registration, "endpoint", endpoint);
+ }
+ }
+
+ DOMUtil.copyAttributes(element, registration);
+ DOMUtil.moveContent(element, registration);
+ root.removeChild(element);
+
+ logXmlGenerated(log, "subscription generated", registration);
+ }
+}
servicemix/base/src/main/java/org/servicemix/jbi/config
diff -u -r1.12 -r1.13 --- ComponentElementProcessor.java 4 Aug 2005 16:08:21 -0000 1.12 +++ ComponentElementProcessor.java 20 Sep 2005 10:46:05 -0000 1.13 @@ -27,13 +27,13 @@
import org.springframework.core.io.Resource; import org.w3c.dom.Document; import org.w3c.dom.Element;
- -import javax.xml.namespace.QName;
+import org.w3c.dom.Node; +import org.w3c.dom.NodeList;
/** * Handles the 'component' element
- * - * @version $Revision: 1.12 $
+ * + * @version $Revision: 1.13 $
*/
public class ComponentElementProcessor extends QNameElementProcessor implements ElementProcessor {
@@ -103,20 +103,33 @@
addQNameProperty(registration, "destinationOperation", destinationOperation, element);
}
+ // lets move any subscriptions into a new property
+ Element list = root.getOwnerDocument().createElement("list");
+ boolean hasSubscriptions = false;
+ NodeList childNodes = element.getChildNodes();
+ for (int index = 0; index < childNodes.getLength() - 1; ) {
+ Node node = childNodes.item(index);
+ if (node.getNodeType() == Node.ELEMENT_NODE && node.getLocalName().equals("subscription")) {
+ element.removeChild(node);
+ list.appendChild(node);
+ hasSubscriptions = true;
+ }
+ else {
+ index++;
+ }
+
+ }
+ if (hasSubscriptions) {
+ Element subscriptions = addPropertyElement(root, "subscriptions");
+ subscriptions.appendChild(list);
+ registration.appendChild(subscriptions);
+ }
+
DOMUtil.copyAttributes(element, bean);
DOMUtil.moveContent(element, bean);
root.removeChild(element);
logXmlGenerated(log, "component generated", registration);
}
-
- protected void addQNameProperty(Element registration, String propertyName, String qnameText, Element namespaceContext) {
- if (qnameText != null && qnameText.length() > 0) {
- Element property = addPropertyElement(registration, propertyName);
- QName qname = DOMUtil.createQName(namespaceContext, qnameText);
- addQNameBeanElement(property, qname);
- }
- }
-
}
servicemix/base/src/main/java/org/servicemix/jbi/config
diff -u -r1.3 -r1.4 --- ContainerElementProcessor.java 12 Jul 2005 14:54:17 -0000 1.3 +++ ContainerElementProcessor.java 20 Sep 2005 10:46:05 -0000 1.4 @@ -33,7 +33,7 @@
/** * Handles the 'container' element *
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class ContainerElementProcessor extends QNameElementProcessor implements ElementProcessor {
@@ -43,6 +43,7 @@
protected void loadLocalNameToProcessorMap() {
registerProcessor("component", new ComponentElementProcessor());
registerProcessor("components", new ComponentsElementProcessor());
+ registerProcessor("subscription", new SubscriptionElementProcessor());
registerProcessor("qname", new QNameElementProcessor());
}
};
servicemix/base/src/test/java/org/servicemix/jbi/config
XmlParseWithNormalSpringTest.java added at 1.1
diff -N XmlParseWithNormalSpringTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ XmlParseWithNormalSpringTest.java 20 Sep 2005 10:46:05 -0000 1.1 @@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * 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.
+ *
+ **/
+package org.servicemix.jbi.config;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class XmlParseWithNormalSpringTest extends XmlParseTest {
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new DebugClassPathXmlApplicationContext("org/servicemix/jbi/config/subscription-spring.xml");
+ }
+}
servicemix/base/src/test/java/org/servicemix/jbi/config
XmlParseTest.java added at 1.1
diff -N XmlParseTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ XmlParseTest.java 20 Sep 2005 10:46:05 -0000 1.1 @@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * 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.
+ *
+ **/
+package org.servicemix.jbi.config;
+
+import org.servicemix.SpringTestSupport;
+import org.servicemix.jbi.container.ActivationSpec;
+import org.servicemix.jbi.container.SubscriptionSpec;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+import javax.xml.namespace.QName;
+
+import java.util.List;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class XmlParseTest extends SpringTestSupport {
+
+ protected static final String NAMESPACE = "http://servicemix.org/cheese/";
+
+ public void testParse() throws Exception {
+ List activationSpecs = jbi.getActivationSpecs();
+ assertEquals("Size of activation specs: " + activationSpecs, 1, activationSpecs.size());
+
+ ActivationSpec activationSpec = (ActivationSpec) activationSpecs.get(0);
+ SubscriptionSpec[] subscriptions = activationSpec.getSubscriptions();
+ assertEquals("Size of subscriptions", 1, subscriptions.length);
+
+ SubscriptionSpec subscription = subscriptions[0];
+
+ QName producer = new QName(NAMESPACE, "producer");
+ assertEquals("subscriber.service", producer, subscription.getService());
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new DebugClassPathXmlApplicationContext("org/servicemix/jbi/config/subscription.xml");
+ }
+}
servicemix/base/src/main/java/org/servicemix/jbi/config/spring
diff -u -r1.3 -r1.4 --- QNameElementProcessor.java 2 Aug 2005 12:50:19 -0000 1.3 +++ QNameElementProcessor.java 20 Sep 2005 10:46:05 -0000 1.4 @@ -36,7 +36,7 @@
/** * Handles the 'qname' element *
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class QNameElementProcessor extends ElementProcessorSupport implements ElementProcessor {
private static final transient Log log = LogFactory.getLog(QNameElementProcessor.class);
@@ -71,6 +71,14 @@
}
}
return bean;
+ }
+
+ protected void addQNameProperty(Element registration, String propertyName, String qnameText, Element namespaceContext) {
+ if (qnameText != null && qnameText.length() > 0) {
+ Element property = addPropertyElement(registration, propertyName);
+ QName qname = DOMUtil.createQName(namespaceContext, qnameText);
+ addQNameBeanElement(property, qname);
+ }
} }
servicemix/base
diff -u -r1.83 -r1.84 --- project.xml 13 Sep 2005 10:51:56 -0000 1.83 +++ project.xml 20 Sep 2005 10:46:05 -0000 1.84 @@ -622,29 +622,54 @@
<!-- default JMS provider used for implementation -->
+ + <!-- for ActiveMQ 4.x -->
<dependency>
- <id>activemq</id> - <version>3.1-M6</version>
+ <id>activemq+core</id> + <version>4.0-SNAPSHOT</version>
<properties>
<lib>true</lib>
</properties>
</dependency>
- - <!-- For clustering services -->
<dependency>
- <id>activecluster</id> - <version>1.1-SNAPSHOT</version>
+ <id>activemq+ra</id> + <version>4.0-SNAPSHOT</version>
<properties>
- <optional>true</optional>
+ <lib>true</lib> + </properties> + </dependency> + <dependency> + <id>activeio</id> + <version>2.0-SNAPSHOT</version> + <properties> + <lib>true</lib> + </properties> + </dependency> + + <!-- for ActiveMQ 3.x --> + <!-- + <dependency> + <id>activemq</id> + <version>3.1-M6</version> + <properties> + <lib>true</lib>
</properties>
</dependency>
- - <!-- JCA RA for testing -->
<dependency>
<id>activemq+ra</id>
<version>3.1-M6</version>
<properties>
<lib>true</lib>
+ </properties> + </dependency> + --> + + <!-- For clustering services --> + <dependency> + <id>activecluster</id> + <version>1.1-SNAPSHOT</version> + <properties> + <optional>true</optional>
</properties>
</dependency>
servicemix/base/src/main/java/org/servicemix/jbi/container
SubscriptionSpec.java added at 1.1
diff -N SubscriptionSpec.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SubscriptionSpec.java 20 Sep 2005 10:46:05 -0000 1.1 @@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * 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.
+ *
+ **/
+package org.servicemix.jbi.container;
+
+import org.servicemix.jbi.resolver.EndpointFilter;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a subscription to a JBI endpoint.
+ *
+ * @version $Revision$
+ */
+public class SubscriptionSpec {
+
+ private QName service;
+ private QName interfaceName;
+ private QName operation;
+ private String endpoint;
+ private EndpointFilter filter;
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public EndpointFilter getFilter() {
+ return filter;
+ }
+
+ public void setFilter(EndpointFilter filter) {
+ this.filter = filter;
+ }
+
+ public QName getInterfaceName() {
+ return interfaceName;
+ }
+
+ public void setInterfaceName(QName interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ public QName getOperation() {
+ return operation;
+ }
+
+ public void setOperation(QName operation) {
+ this.operation = operation;
+ }
+
+ public QName getService() {
+ return service;
+ }
+
+ public void setService(QName service) {
+ this.service = service;
+ }
+}
servicemix/base/src/main/java/org/servicemix/jbi/container
diff -u -r1.10 -r1.11 --- ActivationSpec.java 2 Aug 2005 17:05:17 -0000 1.10 +++ ActivationSpec.java 20 Sep 2005 10:46:05 -0000 1.11 @@ -29,7 +29,7 @@
/** * Represents the registration of a component with the [EMAIL PROTECTED] JBIContainer} *
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
*/
public class ActivationSpec {
private String id;
@@ -47,6 +47,7 @@
private QName destinationOperation;
private String destinationEndpoint;
private Marshaler marshaler;
+ private SubscriptionSpec[] subscriptions = {};
public ActivationSpec() {
@@ -223,6 +224,14 @@
public void setMarshaler(Marshaler marshaler) {
this.marshaler = marshaler;
+ }
+
+ public SubscriptionSpec[] getSubscriptions() {
+ return subscriptions;
+ }
+
+ public void setSubscriptions(SubscriptionSpec[] subscriptions) {
+ this.subscriptions = subscriptions;
}
/**
servicemix/base/src/main/java/org/servicemix/jbi/container
diff -u -r1.17 -r1.18 --- SpringJBIContainer.java 27 Jul 2005 09:27:44 -0000 1.17 +++ SpringJBIContainer.java 20 Sep 2005 10:46:05 -0000 1.18 @@ -19,7 +19,7 @@
* An enhanced JBI container which adds some Spring helper methods for * easier configuration through spring's XML configuration file. *
- * @version $Revision: 1.17 $
+ * @version $Revision: 1.18 $
*/
public class SpringJBIContainer extends JBIContainer implements InitializingBean, BeanFactoryAware {
private String[] componentNames;
@@ -108,6 +108,10 @@
public void setServiceManager(ServiceUnitManager serviceManager) {
this.serviceManager = serviceManager;
+ }
+
+ public List getActivationSpecs() {
+ return activationSpecs;
}
public void setActivationSpecs(List activationSpecs) throws JBIException {
