You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2007/12/04 11:09:53 UTC
svn commit: r600866 - in /servicemix/branches/servicemix-4.0: camel/
camel/src/main/java/org/apache/servicemix/camel/
camel/src/main/java/org/apache/servicemix/camel/spring/
camel/src/main/resources/META-INF/ camel/src/main/resources/schema/
camel/src/...
Author: ffang
Date: Tue Dec 4 02:09:51 2007
New Revision: 600866
URL: http://svn.apache.org/viewvc?rev=600866&view=rev
Log:
[SM-1154] add spring support for servicemix camel component
Added:
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java (with props)
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java (with props)
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java (with props)
servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.handlers
servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.schemas
servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/
servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd (with props)
servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java (with props)
servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java (with props)
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml (with props)
Modified:
servicemix/branches/servicemix-4.0/camel/pom.xml
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixComponent.java
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java
servicemix/branches/servicemix-4.0/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java
Modified: servicemix/branches/servicemix-4.0/camel/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/pom.xml?rev=600866&r1=600865&r2=600866&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/pom.xml (original)
+++ servicemix/branches/servicemix-4.0/camel/pom.xml Tue Dec 4 02:09:51 2007
@@ -118,7 +118,22 @@
</instructions>
</configuration>
</plugin>
- </plugins>
+ <!--plugin>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>maven-xbean-plugin</artifactId>
+ <version>3.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>mapping</goal>
+ </goals>
+ <configuration>
+ <namespace>http://servicemix.apache.org/camelEndpoint/</namespace>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin-->
+ </plugins>
</build>
</project>
Modified: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixComponent.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixComponent.java?rev=600866&r1=600865&r2=600866&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixComponent.java (original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixComponent.java Tue Dec 4 02:09:51 2007
@@ -19,6 +19,7 @@
import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
import org.apache.servicemix.nmr.api.NMR;
+import org.apache.servicemix.nmr.core.ServiceMix;
import java.util.Map;
@@ -32,6 +33,13 @@
public class ServiceMixComponent extends DefaultComponent {
private NMR nmr;
+
+ public ServiceMixComponent() {
+ if (nmr == null) {
+ nmr = new ServiceMix();
+ ((ServiceMix)nmr).init();
+ }
+ }
public NMR getNmr() {
return nmr;
Modified: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java?rev=600866&r1=600865&r2=600866&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java (original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java Tue Dec 4 02:09:51 2007
@@ -17,12 +17,17 @@
package org.apache.servicemix.camel;
+import org.apache.camel.component.cxf.CxfConstants;
import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Producer;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
+import org.apache.servicemix.camel.spring.ServiceMixEndpointBean;
import org.apache.servicemix.nmr.api.Exchange;
+import org.apache.servicemix.nmr.api.NMR;
+import org.apache.servicemix.nmr.core.ServiceMix;
/**
@@ -31,20 +36,45 @@
* Date: Sep 19, 2007
* Time: 8:54:34 AM
* To change this template use File | Settings | File Templates.
+ * @org.apache.xbean.XBean element="smxEndpoint"
*/
public class ServiceMixEndpoint extends DefaultEndpoint {
+ public static final String SPRING_CONTEXT_ENDPOINT = "bean:";
private String endpointName;
public ServiceMixEndpoint(ServiceMixComponent component, String uri, String endpointName) {
super(uri, component);
this.setEndpointName(endpointName);
+ if (endpointName.startsWith(CxfConstants.SPRING_CONTEXT_ENDPOINT)) {
+ String beanId = endpointName.substring(CxfConstants.SPRING_CONTEXT_ENDPOINT.length());
+ if (beanId.startsWith("//")) {
+ beanId = beanId.substring(2);
+ }
+ SpringCamelContext context = (SpringCamelContext) this.getContext();
+
+ ServiceMixEndpointBean smxEndpointBean = (ServiceMixEndpointBean) context.getApplicationContext().getBean(beanId);
+
+ assert(smxEndpointBean != null);
+ NMR nmr = smxEndpointBean.getNmr();
+ if (nmr != null) {
+ ((ServiceMix)nmr).init();
+ getComponent().setNmr(nmr);
+ }
+
+ }
}
+ public ServiceMixEndpoint() {
+ super("uri", new ServiceMixComponent());
+ }
+
+
public ServiceMixComponent getComponent() {
return (ServiceMixComponent) super.getComponent();
}
-
+
+
public boolean isSingleton() {
return true;
}
Added: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java (added)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java Tue Dec 4 02:09:51 2007
@@ -0,0 +1,27 @@
+/*
+ * 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.servicemix.camel.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+public class NamespaceHandler extends NamespaceHandlerSupport {
+
+ public void init() {
+ registerBeanDefinitionParser("smxEndpoint", new SmxEndpointBeanDefinitionParser());
+ }
+
+}
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/NamespaceHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java (added)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java Tue Dec 4 02:09:51 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.camel.spring;
+
+import org.apache.servicemix.nmr.api.NMR;
+
+public class ServiceMixEndpointBean {
+ private NMR nmr;
+
+ public void setNmr(NMR nmr) {
+ this.nmr = nmr;
+ }
+
+ public NMR getNmr() {
+ return nmr;
+ }
+
+
+}
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java (added)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java Tue Dec 4 02:09:51 2007
@@ -0,0 +1,226 @@
+/*
+ * 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.servicemix.camel.spring;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class SmxEndpointBeanDefinitionParser extends
+ AbstractSingleBeanDefinitionParser {
+
+ @Override
+ protected void doParse(Element element, ParserContext ctx,
+ BeanDefinitionBuilder bean) {
+ parseAttributes(element, ctx, bean);
+ parseChildElements(element, ctx, bean);
+ bean.setLazyInit(false);
+ }
+
+ @Override
+ protected Class getBeanClass(Element arg0) {
+ return ServiceMixEndpointBean.class;
+ }
+
+ @Override
+ protected String resolveId(Element elem, AbstractBeanDefinition definition,
+ ParserContext ctx) throws BeanDefinitionStoreException {
+ String id = super.resolveId(elem, definition, ctx);
+ if (id == null || id.length() == 0) {
+ throw new BeanDefinitionStoreException("The bean id is needed.");
+ }
+
+ return id;
+ }
+
+ protected void mapAttribute(BeanDefinitionBuilder bean, Element e,
+ String name, String val) {
+ if ("serviceName".equals(name)) {
+ QName q = parseQName(e, val);
+ bean.addPropertyValue(name, q);
+ } else {
+ mapToProperty(bean, name, val);
+ }
+ }
+
+ protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean,
+ Element el, String name) {
+ if ("properties".equals(name)) {
+ Map map = ctx.getDelegate().parseMapElement(el,
+ bean.getBeanDefinition());
+ bean.addPropertyValue("properties", map);
+ } else {
+ setFirstChildAsProperty(el, ctx, bean, name);
+ }
+ }
+
+ protected QName parseQName(Element element, String t) {
+ String ns = null;
+ String pre = null;
+ String local = null;
+
+ if (t.startsWith("{")) {
+ int i = t.indexOf('}');
+ if (i == -1) {
+ throw new RuntimeException(
+ "Namespace bracket '{' must having a closing bracket '}'.");
+ }
+
+ ns = t.substring(1, i);
+ t = t.substring(i + 1);
+ }
+
+ int colIdx = t.indexOf(':');
+ if (colIdx == -1) {
+ local = t;
+ pre = "";
+
+ ns = DOMUtils.getNamespace(element, "");
+ } else {
+ pre = t.substring(0, colIdx);
+ local = t.substring(colIdx + 1);
+
+ ns = DOMUtils.getNamespace(element, pre);
+ }
+
+ return new QName(ns, local, pre);
+ }
+
+ protected void parseChildElements(Element element, ParserContext ctx,
+ BeanDefinitionBuilder bean) {
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node n = children.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ String name = n.getLocalName();
+
+ mapElement(ctx, bean, (Element) n, name);
+ }
+ }
+ }
+
+ protected void parseAttributes(Element element, ParserContext ctx,
+ BeanDefinitionBuilder bean) {
+ NamedNodeMap atts = element.getAttributes();
+ for (int i = 0; i < atts.getLength(); i++) {
+ Attr node = (Attr) atts.item(i);
+ String val = node.getValue();
+ String name = node.getLocalName();
+
+ mapAttribute(bean, element, name, val);
+
+ }
+
+ }
+
+ protected void mapToProperty(BeanDefinitionBuilder bean,
+ String propertyName, String val) {
+ if (ID_ATTRIBUTE.equals(propertyName)) {
+ return;
+ }
+
+ if (StringUtils.hasText(val)) {
+ if (val.startsWith("#")) {
+ bean.addPropertyReference(propertyName, val.substring(1));
+ } else {
+ bean.addPropertyValue(propertyName, val);
+ }
+ }
+ }
+
+ protected void setFirstChildAsProperty(Element element, ParserContext ctx,
+ BeanDefinitionBuilder bean, String propertyName) {
+ String id = getAndRegisterFirstChild(element, ctx, bean, propertyName);
+ bean.addPropertyReference(propertyName, id);
+
+ }
+
+ protected String getAndRegisterFirstChild(Element element,
+ ParserContext ctx, BeanDefinitionBuilder bean, String propertyName) {
+ Element first = getFirstChild(element);
+
+ if (first == null) {
+ throw new IllegalStateException(propertyName
+ + " property must have child elements!");
+ }
+
+ // Seems odd that we have to do the registration, I wonder if there is a
+ // better way
+ String id;
+ BeanDefinition child;
+ if (first.getNamespaceURI().equals(
+ BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI)) {
+ String name = first.getLocalName();
+ if ("ref".equals(name)) {
+ id = first.getAttribute("bean");
+ if (id == null) {
+ throw new IllegalStateException(
+ "<ref> elements must have a \"bean\" attribute!");
+ }
+ return id;
+ } else if ("bean".equals(name)) {
+ BeanDefinitionHolder bdh = ctx.getDelegate()
+ .parseBeanDefinitionElement(first);
+ child = bdh.getBeanDefinition();
+ id = bdh.getBeanName();
+ } else {
+ throw new UnsupportedOperationException(
+ "Elements with the name " + name
+ + " are not currently "
+ + "supported as sub elements of "
+ + element.getLocalName());
+ }
+
+ } else {
+ child = ctx.getDelegate().parseCustomElement(first,
+ bean.getBeanDefinition());
+ id = child.toString();
+ }
+
+ ctx.getRegistry().registerBeanDefinition(id, child);
+ return id;
+ }
+
+ protected Element getFirstChild(Element element) {
+ Element first = null;
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node n = children.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ first = (Element) n;
+ }
+ }
+ return first;
+ }
+}
\ No newline at end of file
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/SmxEndpointBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.handlers
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.handlers?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.handlers (added)
+++ servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.handlers Tue Dec 4 02:09:51 2007
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+http\://servicemix.apache.org/camelEndpoint/=org.apache.servicemix.camel.spring.NamespaceHandler
Added: servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.schemas
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.schemas?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.schemas (added)
+++ servicemix/branches/servicemix-4.0/camel/src/main/resources/META-INF/spring.schemas Tue Dec 4 02:09:51 2007
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+http\://servicemix.apache.org/camelEndpoint/.xsd=schema/smxEndpoint.xsd
Added: servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd (added)
+++ servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd Tue Dec 4 02:09:51 2007
@@ -0,0 +1,51 @@
+<?xml version='1.0'?>
+<!-- NOTE: this file is autogenerated by Apache XBean -->
+
+<xs:schema elementFormDefault='qualified'
+ targetNamespace='http://servicemix.apache.org/camelEndpoint/'
+ xmlns:xs='http://www.w3.org/2001/XMLSchema'
+ xmlns:tns='http://servicemix.apache.org/camelEndpoint/'>
+
+ <!-- element for type: org.apache.servicemix.camel.ServiceMixEndpoint -->
+ <xs:element name='smxEndpoint'>
+ <xs:annotation>
+ <xs:documentation><![CDATA[
+ Created by IntelliJ IDEA.
+User: gnodet
+Date: Sep 19, 2007
+Time: 8:54:34 AM
+To change this template use File | Settings | File Templates.
+ ]]></xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name='component' minOccurs='0' maxOccurs='1'>
+ <xs:complexType>
+ <xs:sequence minOccurs='0' maxOccurs='1'><xs:any namespace='##other'/></xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name='exchangePattern' minOccurs='0' maxOccurs='1'>
+ <xs:complexType>
+ <xs:sequence minOccurs='0' maxOccurs='1'><xs:any namespace='##other'/></xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name='executorService' minOccurs='0' maxOccurs='1'>
+ <xs:complexType>
+ <xs:sequence minOccurs='0' maxOccurs='1'><xs:any namespace='##other'/></xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/>
+ </xs:sequence>
+ <xs:attribute name='component' type='xs:string'/>
+ <xs:attribute name='endpointName' type='xs:string'/>
+ <xs:attribute name='exchangePattern' type='xs:string'/>
+ <xs:attribute name='executorService' type='xs:string'/>
+ <xs:attribute name='uri' type='xs:string'/>
+ <xs:attribute name='nmr' type='xs:string'/>
+ <xs:attribute name='id' type='xs:ID'/>
+ <xs:anyAttribute namespace='##other' processContents='lax'/>
+ </xs:complexType>
+ </xs:element>
+
+
+</xs:schema>
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java (added)
+++ servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java Tue Dec 4 02:09:51 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.camel;
+
+import org.apache.servicemix.camel.spring.ServiceMixEndpointBean;
+import org.apache.servicemix.nmr.core.ServiceMix;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import junit.framework.TestCase;
+
+public class ServiceMixEndpointBeanTest extends TestCase {
+
+ public void testEndpointBeanDefinitionParser() {
+ ClassPathXmlApplicationContext ctx =
+ new ClassPathXmlApplicationContext(new String[]{"org/apache/servicemix/camel/spring/EndpointBeans.xml"});
+
+ ServiceMixEndpointBean testEndpoint = (ServiceMixEndpointBean)ctx.getBean("testEndpoint");
+ assertNotNull(testEndpoint);
+ assertNotNull(testEndpoint.getNmr());
+ assertTrue(testEndpoint.getNmr() instanceof ServiceMix);
+ }
+
+}
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/ServiceMixEndpointBeanTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java (added)
+++ servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java Tue Dec 4 02:09:51 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.servicemix.camel;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SmxToCxfSpringTest extends SmxToCxfTest {
+protected AbstractXmlApplicationContext applicationContext;
+
+ @Override
+ protected void setUp() throws Exception {
+ applicationContext = createApplicationContext();
+ super.setUp();
+ assertNotNull("Should have created a valid spring context", applicationContext);
+
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (applicationContext != null) {
+ applicationContext.destroy();
+ }
+ super.tearDown();
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("cxf:bean:routerEndpoint").to("smx:bean:testEndpoint");
+ from("smx:bean:testEndpoint").to("cxf:bean:serviceEndpoint");
+ }
+ };
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ return SpringCamelContext.springCamelContext(applicationContext);
+ }
+
+
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/EndpointBeans.xml");
+ }
+}
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfSpringTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java?rev=600866&r1=600865&r2=600866&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java (original)
+++ servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java Tue Dec 4 02:09:51 2007
@@ -89,13 +89,7 @@
protected CamelContext createCamelContext() throws Exception {
camelContext = new DefaultCamelContext();
-
- smxComponent = new ServiceMixComponent();
- nmr = new ServiceMix();
- ((ServiceMix)nmr).init();
- smxComponent.setNmr(nmr);
- camelContext.addComponent("smx", smxComponent);
- return camelContext;
+ return camelContext;
}
Added: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml?rev=600866&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml (added)
+++ servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml Tue Dec 4 02:09:51 2007
@@ -0,0 +1,51 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"
+ xmlns:smx="http://servicemix.apache.org/camelEndpoint/"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
+ http://servicemix.apache.org/camelEndpoint/ http://servicemix.apache.org/camelEndpoint/.xsd
+ ">
+
+
+ <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9000/router"
+ serviceClass="org.apache.servicemix.camel.HelloService"/>
+
+
+ <cxf:cxfEndpoint id="serviceEndpoint" address="local://smx/helloworld"
+ serviceClass="org.apache.servicemix.camel.HelloService"/>
+
+ <smx:smxEndpoint id="testEndpoint" nmr="#servicemix"/>
+
+ <bean id="smxComponent" class="org.apache.servicemix.camel.ServiceMixComponent">
+ <property name="nmr" ref="servicemix"/>
+ </bean>
+ <bean id="servicemix" class="org.apache.servicemix.nmr.core.ServiceMix">
+ <property name="endpointRegistry" ref="endpointRegistry" />
+ <property name="listenerRegistry" ref="listenerRegistry" />
+ <property name="flowRegistry" ref="flowRegistry" />
+ </bean>
+ <bean id="endpointRegistry" class="org.apache.servicemix.nmr.core.EndpointRegistryImpl">
+ <property name="nmr" ref="servicemix" />
+ </bean>
+ <bean id="listenerRegistry" class="org.apache.servicemix.nmr.core.ListenerRegistryImpl" />
+ <bean id="flowRegistry" class="org.apache.servicemix.nmr.core.FlowRegistryImpl" />
+</beans>
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: servicemix/branches/servicemix-4.0/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java?rev=600866&r1=600865&r2=600866&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java (original)
+++ servicemix/branches/servicemix-4.0/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java Tue Dec 4 02:09:51 2007
@@ -46,8 +46,9 @@
}
if (flows == null) {
flows = new FlowRegistryImpl();
- flows.register(new StraightThroughFlow(), ServiceHelper.createMap(Flow.ID, StraightThroughFlow.class.getName()));
+
}
+ flows.register(new StraightThroughFlow(), ServiceHelper.createMap(Flow.ID, StraightThroughFlow.class.getName()));
}
/**