Author: gnodet
Date: Wed Oct 24 03:07:15 2007
New Revision: 587846
URL: http://svn.apache.org/viewvc?rev=587846&view=rev
Log:
Fix some bugs
Modified:
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ChannelImpl.java
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ClientChannel.java
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/EndpointRegistryImpl.java
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/FlowRegistryImpl.java
Modified:
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ChannelImpl.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ChannelImpl.java?rev=587846&r1=587845&r2=587846&view=diff
==============================================================================
---
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ChannelImpl.java
(original)
+++
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ChannelImpl.java
Wed Oct 24 03:07:15 2007
@@ -57,6 +57,15 @@
}
/**
+ * Access to the endpoint
+ *
+ * @return the endpoint for which this channel has been created
+ */
+ public InternalEndpoint getEndpoint() {
+ return endpoint;
+ }
+
+ /**
* Creates a new exchange.
*
* @param pattern specify the InOnly / InOut / RobustInOnly / RobustInOut
@@ -178,7 +187,9 @@
*/
protected void dispatch(InternalExchange exchange) {
// Set source endpoint
- exchange.setSource(endpoint);
+ if (exchange.getSource() == null) {
+ exchange.setSource(endpoint);
+ }
// Call listeners
for (ExchangeListener l :
nmr.getListenerRegistry().getListeners(ExchangeListener.class)) {
l.exchangeSent(exchange);
Modified:
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ClientChannel.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ClientChannel.java?rev=587846&r1=587845&r2=587846&view=diff
==============================================================================
---
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ClientChannel.java
(original)
+++
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/ClientChannel.java
Wed Oct 24 03:07:15 2007
@@ -31,6 +31,7 @@
public ClientChannel(NMR nmr) {
super(new ClientEndpoint(), Executors.newCachedThreadPool(), nmr);
+ getEndpoint().setChannel(this);
}
protected static class ClientEndpoint implements InternalEndpoint {
@@ -38,7 +39,7 @@
private InternalChannel channel;
public void setChannel(Channel channel) {
- this.channel = (InternalChannel) channel;
+ this.channel = (InternalChannel) channel;
}
public InternalChannel getChannel() {
Modified:
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/EndpointRegistryImpl.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/EndpointRegistryImpl.java?rev=587846&r1=587845&r2=587846&view=diff
==============================================================================
---
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/EndpointRegistryImpl.java
(original)
+++
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/EndpointRegistryImpl.java
Wed Oct 24 03:07:15 2007
@@ -16,14 +16,6 @@
*/
package org.apache.servicemix.core;
-import org.apache.servicemix.api.Endpoint;
-import org.apache.servicemix.api.EndpointRegistry;
-import org.apache.servicemix.api.NMR;
-import org.apache.servicemix.api.Reference;
-import org.apache.servicemix.api.internal.InternalEndpoint;
-import org.apache.servicemix.api.service.ServiceRegistry;
-import org.w3c.dom.Document;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -32,6 +24,16 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import org.w3c.dom.Document;
+
+import org.apache.servicemix.api.Endpoint;
+import org.apache.servicemix.api.EndpointRegistry;
+import org.apache.servicemix.api.NMR;
+import org.apache.servicemix.api.Reference;
+import org.apache.servicemix.api.ServiceMixException;
+import org.apache.servicemix.api.internal.InternalEndpoint;
+import org.apache.servicemix.api.service.ServiceRegistry;
+
/**
* @version $Revision: $
* @since 4.0
@@ -103,11 +105,17 @@
/**
* Retrieve the metadata associated to a registered service.
*
- * @param service the service for which to retrieve metadata
- * @return the metadata associated with the service
+ * @param endpoint the service for which to retrieve metadata
+ * @return the metadata associated with the=is endpoint
*/
- public Map<String, ?> getProperties(Endpoint service) {
- return null; // TODO
+ public Map<String, ?> getProperties(Endpoint endpoint) {
+ InternalEndpoint wrapper;
+ if (endpoint instanceof InternalEndpoint) {
+ wrapper = (InternalEndpoint) endpoint;
+ } else {
+ wrapper = endpoints.get(endpoint);
+ }
+ return registry.getProperties(wrapper);
}
/**
@@ -130,6 +138,9 @@
if (match) {
endpoints.add(e);
}
+ }
+ if (endpoints.isEmpty()) {
+ throw new ServiceMixException("No matching endpoints");
}
return new ReferenceImpl(endpoints);
}
Modified:
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/FlowRegistryImpl.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/FlowRegistryImpl.java?rev=587846&r1=587845&r2=587846&view=diff
==============================================================================
---
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/FlowRegistryImpl.java
(original)
+++
incubator/servicemix/branches/servicemix-4.0/core/src/main/java/org/apache/servicemix/core/FlowRegistryImpl.java
Wed Oct 24 03:07:15 2007
@@ -41,6 +41,7 @@
if (exchange.getRole() == Role.Consumer) {
if (exchange.getDestination() == null) {
InternalReference target = (InternalReference)
exchange.getTarget();
+ assert target != null;
for (InternalEndpoint endpoint : target.choose()) {
for (Flow flow : getServices()) {
if (flow.canDispatch(exchange, endpoint)) {