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/05 04:26:25 UTC
svn commit: r601198 - 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/schema/
camel/src/test/resources/org/apache/servicemi...
Author: ffang
Date: Tue Dec 4 19:26:25 2007
New Revision: 601198
URL: http://svn.apache.org/viewvc?rev=601198&view=rev
Log:
fix Flow configurable problem in my previous commit
Modified:
servicemix/branches/servicemix-4.0/camel/pom.xml
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd
servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml
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=601198&r1=601197&r2=601198&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/pom.xml (original)
+++ servicemix/branches/servicemix-4.0/camel/pom.xml Tue Dec 4 19:26:25 2007
@@ -118,21 +118,6 @@
</instructions>
</configuration>
</plugin>
- <!--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>
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=601198&r1=601197&r2=601198&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 19:26:25 2007
@@ -16,7 +16,6 @@
*/
package org.apache.servicemix.camel;
-
import org.apache.camel.component.cxf.CxfConstants;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.spring.SpringCamelContext;
@@ -27,78 +26,100 @@
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.api.internal.Flow;
+import org.apache.servicemix.nmr.api.service.ServiceHelper;
import org.apache.servicemix.nmr.core.ServiceMix;
-
+import org.apache.servicemix.nmr.core.StraightThroughFlow;
/**
- * Created by IntelliJ IDEA.
- * User: gnodet
- * Date: Sep 19, 2007
- * Time: 8:54:34 AM
- * To change this template use File | Settings | File Templates.
+ * Created by IntelliJ IDEA. User: gnodet 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;
- }
-
- public Producer createProducer() throws Exception {
- return new ServiceMixProducer(this);
- }
-
- public Consumer createConsumer(Processor processor) throws Exception {
- return new ServiceMixConsumer(this, processor);
- }
-
- public ServiceMixExchange createExchange(Exchange exchange) {
- return new ServiceMixExchange(getContext(), getExchangePattern(), exchange);
- }
-
- public ServiceMixExchange createExchange(ExchangePattern pattern, Exchange exchange) {
- return new ServiceMixExchange(getContext(), pattern, exchange);
- }
-
- public ServiceMixExchange createExchange(org.apache.servicemix.nmr.api.Message inMessage, Exchange exchange) {
- return new ServiceMixExchange(getContext(), getExchangePattern(), inMessage, exchange);
- }
+ 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();
+ Flow flow = smxEndpointBean.getFlow();
+ if (nmr != null) {
+ if (nmr.getFlowRegistry() != null) {
+ if (flow != null) {
+ // set Flow we get from configuration file
+ nmr.getFlowRegistry().register(
+ flow,
+ ServiceHelper.createMap(Flow.ID, flow
+ .getClass().getName()));
+ } else {
+ // set defaule Flow
+ nmr.getFlowRegistry().register(
+ new StraightThroughFlow(),
+ ServiceHelper.createMap(Flow.ID,
+ StraightThroughFlow.class.getName()));
+ }
+ }
+
+ ((ServiceMix) nmr).init();
+ getComponent().setNmr(nmr);
+ }
+
+ }
+ }
+
+ public ServiceMixEndpoint() {
+ super("uri", new ServiceMixComponent());
+ }
+
+ public ServiceMixComponent getComponent() {
+ return (ServiceMixComponent) super.getComponent();
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public Producer createProducer() throws Exception {
+ return new ServiceMixProducer(this);
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return new ServiceMixConsumer(this, processor);
+ }
+
+ public ServiceMixExchange createExchange(Exchange exchange) {
+ return new ServiceMixExchange(getContext(), getExchangePattern(),
+ exchange);
+ }
+
+ public ServiceMixExchange createExchange(ExchangePattern pattern,
+ Exchange exchange) {
+ return new ServiceMixExchange(getContext(), pattern, exchange);
+ }
+
+ public ServiceMixExchange createExchange(
+ org.apache.servicemix.nmr.api.Message inMessage, Exchange exchange) {
+ return new ServiceMixExchange(getContext(), getExchangePattern(),
+ inMessage, exchange);
+ }
public void setEndpointName(String endpointName) {
this.endpointName = endpointName;
Modified: 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=601198&r1=601197&r2=601198&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java (original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java Tue Dec 4 19:26:25 2007
@@ -17,16 +17,41 @@
package org.apache.servicemix.camel.spring;
import org.apache.servicemix.nmr.api.NMR;
+import org.apache.servicemix.nmr.api.internal.Flow;
+import org.apache.servicemix.nmr.api.service.ServiceHelper;
+import org.apache.servicemix.nmr.core.StraightThroughFlow;
public class ServiceMixEndpointBean {
private NMR nmr;
-
+ private Flow flow;
+
+ public ServiceMixEndpointBean() {
+ if (getNmr() != null && getNmr().getFlowRegistry() != null) {
+ if (getFlow() != null) {
+ // set Flow we get from configuration file
+ getNmr().getFlowRegistry().register(getFlow(),
+ ServiceHelper.createMap(Flow.ID, getFlow().getClass().getName()));
+ } else {
+ // set defaule Flow
+ getNmr().getFlowRegistry().register(
+ new StraightThroughFlow(), ServiceHelper.createMap(Flow.ID, StraightThroughFlow.class.getName()));
+ }
+ }
+ }
public void setNmr(NMR nmr) {
this.nmr = nmr;
}
public NMR getNmr() {
return nmr;
+ }
+
+ public void setFlow(Flow flow) {
+ this.flow = flow;
+ }
+
+ public Flow getFlow() {
+ return flow;
}
Modified: 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=601198&r1=601197&r2=601198&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd (original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/resources/schema/smxEndpoint.xsd Tue Dec 4 19:26:25 2007
@@ -42,6 +42,7 @@
<xs:attribute name='executorService' type='xs:string'/>
<xs:attribute name='uri' type='xs:string'/>
<xs:attribute name='nmr' type='xs:string'/>
+ <xs:attribute name='flow' type='xs:string'/>
<xs:attribute name='id' type='xs:ID'/>
<xs:anyAttribute namespace='##other' processContents='lax'/>
</xs:complexType>
Modified: 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=601198&r1=601197&r2=601198&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml (original)
+++ servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/EndpointBeans.xml Tue Dec 4 19:26:25 2007
@@ -33,11 +33,8 @@
<cxf:cxfEndpoint id="serviceEndpoint" address="local://smx/helloworld"
serviceClass="org.apache.servicemix.camel.HelloService"/>
- <smx:smxEndpoint id="testEndpoint" nmr="#servicemix"/>
+ <smx:smxEndpoint id="testEndpoint" nmr="#servicemix" flow="#staightThroughFlow"/>
- <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" />
@@ -48,4 +45,5 @@
</bean>
<bean id="listenerRegistry" class="org.apache.servicemix.nmr.core.ListenerRegistryImpl" />
<bean id="flowRegistry" class="org.apache.servicemix.nmr.core.FlowRegistryImpl" />
+ <bean id="staightThroughFlow" class="org.apache.servicemix.nmr.core.StraightThroughFlow" />
</beans>
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=601198&r1=601197&r2=601198&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 19:26:25 2007
@@ -46,9 +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()));
+
}
/**