You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/03/10 19:40:13 UTC
svn commit: r752210 - in /servicemix/smx4/nmr/trunk/nmr:
api/src/main/java/org/apache/servicemix/nmr/api/internal/
core/src/main/java/org/apache/servicemix/nmr/core/
core/src/test/java/org/apache/servicemix/nmr/core/ osgi/
osgi/src/main/resources/META-...
Author: gnodet
Date: Tue Mar 10 18:40:12 2009
New Revision: 752210
URL: http://svn.apache.org/viewvc?rev=752210&view=rev
Log:
SMX4NMR-117: Refactor the InternalReference to allow references to be serializable
Added:
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/CacheableReference.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReference.java
- copied, changed from r752029, servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReferenceImpl.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FilterMatchingReference.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/PropertyMatchingReference.java
Removed:
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReferenceImpl.java
Modified:
servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/internal/InternalReference.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ExchangeImpl.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java
servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/StaticReferenceImpl.java
servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java
servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml
servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml
Modified: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/internal/InternalReference.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/internal/InternalReference.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/internal/InternalReference.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/internal/InternalReference.java Tue Mar 10 18:40:12 2009
@@ -16,6 +16,7 @@
*/
package org.apache.servicemix.nmr.api.internal;
+import org.apache.servicemix.nmr.api.EndpointRegistry;
import org.apache.servicemix.nmr.api.Reference;
/**
@@ -33,6 +34,6 @@
*
* @return an iterator on matching endpoints
*/
- Iterable<InternalEndpoint> choose();
+ Iterable<InternalEndpoint> choose(EndpointRegistry registry);
}
Added: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/CacheableReference.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/CacheableReference.java?rev=752210&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/CacheableReference.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/CacheableReference.java Tue Mar 10 18:40:12 2009
@@ -0,0 +1,15 @@
+package org.apache.servicemix.nmr.core;
+
+import org.apache.servicemix.nmr.api.internal.InternalReference;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Mar 10, 2009
+ * Time: 6:04:14 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface CacheableReference extends InternalReference {
+
+ void setDirty();
+}
Copied: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReference.java (from r752029, servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReferenceImpl.java)
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReference.java?p2=servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReference.java&p1=servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReferenceImpl.java&r1=752029&r2=752210&rev=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReferenceImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/DynamicReference.java Tue Mar 10 18:40:12 2009
@@ -18,31 +18,27 @@
*/
package org.apache.servicemix.nmr.core;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.w3c.dom.Document;
import org.apache.servicemix.nmr.api.Endpoint;
import org.apache.servicemix.nmr.api.EndpointRegistry;
import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
-import org.apache.servicemix.nmr.api.internal.InternalReference;
import org.apache.servicemix.nmr.core.util.Filter;
/**
* A dynamic reference that holds a transient list of matching endpoints.
* This list will be refreshed when #setDirty() has been called previsouly.
*/
-public class DynamicReferenceImpl implements InternalReference {
+public class DynamicReference implements CacheableReference {
private final Filter<InternalEndpoint> filter;
- private final EndpointRegistry registry;
private transient volatile List<InternalEndpoint> matches;
+ private transient EndpointRegistry registry;
- public DynamicReferenceImpl(EndpointRegistry registry, Filter<InternalEndpoint> filter) {
+ public DynamicReference(Filter<InternalEndpoint> filter) {
this.filter = filter;
- this.registry = registry;
}
public Document toXml() {
@@ -50,21 +46,22 @@
return null;
}
- public synchronized Iterable<InternalEndpoint> choose() {
- if (this.matches == null) {
- List<InternalEndpoint> eps = new ArrayList<InternalEndpoint>();
- for (Endpoint ep : registry.query((Map<String, ?>) null)) {
+ public synchronized Iterable<InternalEndpoint> choose(EndpointRegistry registry) {
+ List<InternalEndpoint> result = matches;
+ if (result == null || this.registry != registry) {
+ for (Endpoint ep : registry.query(null)) {
InternalEndpoint iep = (InternalEndpoint) ep;
if (filter.match(iep)) {
- eps.add(iep);
+ result.add(iep);
}
}
- this.matches = eps;
+ this.registry = registry;
+ this.matches = result;
}
- return matches;
+ return result;
}
- protected synchronized void setDirty() {
+ public synchronized void setDirty() {
this.matches = null;
}
Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java Tue Mar 10 18:40:12 2009
@@ -23,8 +23,8 @@
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import org.w3c.dom.Document;
@@ -37,8 +37,6 @@
import org.apache.servicemix.nmr.api.event.EndpointListener;
import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
import org.apache.servicemix.nmr.api.service.ServiceRegistry;
-import org.apache.servicemix.nmr.core.util.Filter;
-import org.apache.servicemix.nmr.core.util.MapToDictionary;
/**
* Implementation of {@link EndpointRegistry} interface that defines
@@ -52,7 +50,7 @@
private NMR nmr;
private ConcurrentMap<Endpoint, InternalEndpoint> endpoints = new ConcurrentHashMap<Endpoint, InternalEndpoint>();
private Map<InternalEndpoint, Endpoint> wrappers = new ConcurrentHashMap<InternalEndpoint, Endpoint>();
- private Map<DynamicReferenceImpl, Boolean> references = new WeakHashMap<DynamicReferenceImpl, Boolean>();
+ private Map<CacheableReference, Boolean> references = new WeakHashMap<CacheableReference, Boolean>();
private ServiceRegistry<InternalEndpoint> registry;
public EndpointRegistryImpl() {
@@ -109,7 +107,7 @@
listener.endpointRegistered(wrapper);
}
synchronized (this.references) {
- for (DynamicReferenceImpl ref : references.keySet()) {
+ for (CacheableReference ref : references.keySet()) {
ref.setDirty();
}
}
@@ -146,7 +144,7 @@
}
}
synchronized (this.references) {
- for (DynamicReferenceImpl ref : references.keySet()) {
+ for (CacheableReference ref : references.keySet()) {
ref.setDirty();
}
}
@@ -216,20 +214,7 @@
*/
public Reference lookup(Map<String, ?> props) {
final Map<String, ?> properties = handleWiring(props);
- DynamicReferenceImpl ref = new DynamicReferenceImpl(this, new Filter<InternalEndpoint>() {
- public boolean match(InternalEndpoint endpoint) {
- Map<String, ?> epProps = registry.getProperties(endpoint);
- for (Map.Entry<String, ?> name : properties.entrySet()) {
- if (!name.getValue().equals(epProps.get(name.getKey()))) {
- return false;
- }
- }
- return true;
- }
- public String toString() {
- return properties.toString();
- }
- });
+ CacheableReference ref = new PropertyMatchingReference(properties);
synchronized (this.references) {
this.references.put(ref, true);
}
@@ -258,16 +243,7 @@
public Reference lookup(final String filter) {
try {
try {
- final org.osgi.framework.Filter flt = org.osgi.framework.FrameworkUtil.createFilter(filter);
- DynamicReferenceImpl ref = new DynamicReferenceImpl(this, new Filter<InternalEndpoint>() {
- public boolean match(InternalEndpoint endpoint) {
- Map<String, ?> props = EndpointRegistryImpl.this.getProperties(endpoint);
- return flt.match(new MapToDictionary(props));
- }
- public String toString() {
- return filter;
- }
- });
+ FilterMatchingReference ref = new FilterMatchingReference(filter);
synchronized (this.references) {
this.references.put(ref, true);
}
Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ExchangeImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ExchangeImpl.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ExchangeImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ExchangeImpl.java Tue Mar 10 18:40:12 2009
@@ -59,10 +59,10 @@
private Message out;
private Message fault;
private Exception error;
- private InternalEndpoint source;
- private InternalEndpoint destination;
- private Semaphore consumerLock;
- private Semaphore providerLock;
+ private transient InternalEndpoint source;
+ private transient InternalEndpoint destination;
+ private transient Semaphore consumerLock;
+ private transient Semaphore providerLock;
private static transient Converter converter;
Added: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FilterMatchingReference.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FilterMatchingReference.java?rev=752210&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FilterMatchingReference.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FilterMatchingReference.java Tue Mar 10 18:40:12 2009
@@ -0,0 +1,81 @@
+package org.apache.servicemix.nmr.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.io.Serializable;
+
+import org.w3c.dom.Document;
+
+import org.apache.servicemix.nmr.api.Endpoint;
+import org.apache.servicemix.nmr.api.EndpointRegistry;
+import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
+import org.apache.servicemix.nmr.core.util.MapToDictionary;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Mar 10, 2009
+ * Time: 6:07:57 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class FilterMatchingReference implements CacheableReference, Serializable {
+
+ private final String filter;
+ private transient Filter osgiFilter;
+ private transient volatile List<InternalEndpoint> matches;
+ private transient EndpointRegistry registry;
+
+ public FilterMatchingReference(String filter) throws InvalidSyntaxException {
+ this.filter = filter;
+ this.osgiFilter = org.osgi.framework.FrameworkUtil.createFilter(filter);
+ }
+
+ public Iterable<InternalEndpoint> choose(EndpointRegistry registry) {
+ List<InternalEndpoint> result = matches;
+ if (result == null || this.registry != registry) {
+ result = new ArrayList<InternalEndpoint>();
+ for (Endpoint ep : registry.query(null)) {
+ InternalEndpoint iep = (InternalEndpoint) ep;
+ if (match(registry, iep)) {
+ result.add(iep);
+ }
+ }
+ this.registry = registry;
+ this.matches = result;
+ }
+ return result;
+ }
+
+ protected boolean match(EndpointRegistry registry, InternalEndpoint endpoint) {
+ Map<String, ?> epProps = registry.getProperties(endpoint);
+ if (osgiFilter == null) {
+ synchronized (this) {
+ if (osgiFilter == null) {
+ try {
+ this.osgiFilter = org.osgi.framework.FrameworkUtil.createFilter(filter);
+ } catch (InvalidSyntaxException e) {
+ // should not happen as this has been checked in the constructor
+ }
+ }
+ }
+ }
+ return osgiFilter.match(new MapToDictionary(epProps));
+ }
+
+ public Document toXml() {
+ // TODO
+ return null;
+ }
+
+ public void setDirty() {
+ matches = null;
+ }
+
+ @Override
+ public String toString() {
+ return "FilterMatchingReference[" + filter + "]";
+ }
+}
Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java Tue Mar 10 18:40:12 2009
@@ -16,21 +16,21 @@
*/
package org.apache.servicemix.nmr.core;
-import java.util.Set;
import java.util.Collection;
-import java.security.Principal;
+import java.util.Set;
import javax.security.auth.Subject;
+import org.apache.servicemix.nmr.api.EndpointRegistry;
import org.apache.servicemix.nmr.api.Role;
import org.apache.servicemix.nmr.api.ServiceMixException;
-import org.apache.servicemix.nmr.api.security.AuthorizationService;
-import org.apache.servicemix.nmr.api.security.GroupPrincipal;
import org.apache.servicemix.nmr.api.internal.Flow;
import org.apache.servicemix.nmr.api.internal.FlowRegistry;
import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
import org.apache.servicemix.nmr.api.internal.InternalExchange;
import org.apache.servicemix.nmr.api.internal.InternalReference;
+import org.apache.servicemix.nmr.api.security.AuthorizationService;
+import org.apache.servicemix.nmr.api.security.GroupPrincipal;
/**
* The default implementation of {@link FlowRegistry}.
@@ -40,8 +40,17 @@
*/
public class FlowRegistryImpl extends ServiceRegistryImpl<Flow> implements FlowRegistry {
+ private EndpointRegistry registry;
private AuthorizationService authorizationService;
+ public EndpointRegistry getRegistry() {
+ return registry;
+ }
+
+ public void setRegistry(EndpointRegistry registry) {
+ this.registry = registry;
+ }
+
public AuthorizationService getAuthorizationService() {
return authorizationService;
}
@@ -73,7 +82,7 @@
assert target != null;
boolean match = false;
boolean securityMatch = false;
- for (InternalEndpoint endpoint : target.choose()) {
+ for (InternalEndpoint endpoint : target.choose(registry)) {
match = true;
if (authorizationService != null) {
Set<GroupPrincipal> acls = authorizationService.getAcls(endpoint.getId(), exchange.getOperation());
Added: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/PropertyMatchingReference.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/PropertyMatchingReference.java?rev=752210&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/PropertyMatchingReference.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/PropertyMatchingReference.java Tue Mar 10 18:40:12 2009
@@ -0,0 +1,69 @@
+package org.apache.servicemix.nmr.core;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+import org.apache.servicemix.nmr.api.Endpoint;
+import org.apache.servicemix.nmr.api.EndpointRegistry;
+import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Mar 10, 2009
+ * Time: 5:57:14 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class PropertyMatchingReference implements CacheableReference, Serializable {
+
+ private final Map<String, ?> properties;
+ private transient volatile List<InternalEndpoint> matches;
+ private transient EndpointRegistry registry;
+
+ public PropertyMatchingReference(Map<String, ?> properties) {
+ this.properties = properties;
+ }
+
+ public Iterable<InternalEndpoint> choose(EndpointRegistry registry) {
+ if (this.matches == null || this.registry != registry) {
+ List<InternalEndpoint> eps = new ArrayList<InternalEndpoint>();
+ for (Endpoint ep : registry.query(null)) {
+ InternalEndpoint iep = (InternalEndpoint) ep;
+ if (match(registry, iep)) {
+ eps.add(iep);
+ }
+ }
+ this.registry = registry;
+ this.matches = eps;
+ }
+ return matches;
+ }
+
+ protected boolean match(EndpointRegistry registry, InternalEndpoint endpoint) {
+ Map<String, ?> epProps = registry.getProperties(endpoint);
+ for (Map.Entry<String, ?> name : properties.entrySet()) {
+ if (!name.getValue().equals(epProps.get(name.getKey()))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Document toXml() {
+ // TODO
+ return null;
+ }
+
+ public void setDirty() {
+ matches = null;
+ }
+
+ @Override
+ public String toString() {
+ return "PropertyMatchingReference[" + properties + "]";
+ }
+}
Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java Tue Mar 10 18:40:12 2009
@@ -48,7 +48,9 @@
listeners = new ListenerRegistryImpl();
}
if (flows == null) {
- flows = new FlowRegistryImpl();
+ FlowRegistryImpl reg = new FlowRegistryImpl();
+ reg.setRegistry(endpoints);
+ flows = reg;
flows.register(new StraightThroughFlow(), ServiceHelper.createMap(Flow.ID, StraightThroughFlow.class.getName()));
}
if (wires == null) {
Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/StaticReferenceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/StaticReferenceImpl.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/StaticReferenceImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/StaticReferenceImpl.java Tue Mar 10 18:40:12 2009
@@ -20,6 +20,7 @@
import org.w3c.dom.Document;
+import org.apache.servicemix.nmr.api.EndpointRegistry;
import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
import org.apache.servicemix.nmr.api.internal.InternalReference;
@@ -59,7 +60,7 @@
*
* @return an endpoint that will be used as the physical target
*/
- public Iterable<InternalEndpoint> choose() {
+ public Iterable<InternalEndpoint> choose(EndpointRegistry registry) {
return endpoints;
}
Modified: servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java Tue Mar 10 18:40:12 2009
@@ -22,16 +22,17 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import junit.framework.TestCase;
import org.apache.servicemix.nmr.api.Channel;
import org.apache.servicemix.nmr.api.Endpoint;
import org.apache.servicemix.nmr.api.EndpointRegistry;
import org.apache.servicemix.nmr.api.Exchange;
import org.apache.servicemix.nmr.api.NMR;
import org.apache.servicemix.nmr.api.Reference;
-import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
import org.apache.servicemix.nmr.api.event.EndpointListener;
+import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
+import org.apache.servicemix.nmr.api.internal.InternalReference;
import org.apache.servicemix.nmr.api.service.ServiceHelper;
-import junit.framework.TestCase;
public class EndpointRegistryImplTest extends TestCase {
@@ -63,16 +64,16 @@
Endpoint endpoint = new DummyEndpoint();
Reference ref = registry.lookup(ServiceHelper.createMap(Endpoint.NAME, "id"));
assertNotNull(ref);
- assertTrue(ref instanceof DynamicReferenceImpl);
- DynamicReferenceImpl r = (DynamicReferenceImpl) ref;
- assertNotNull(r.choose());
- assertFalse(r.choose().iterator().hasNext());
+ assertTrue(ref instanceof InternalReference);
+ InternalReference r = (InternalReference) ref;
+ assertNotNull(r.choose(registry));
+ assertFalse(r.choose(registry).iterator().hasNext());
registry.register(endpoint, ServiceHelper.createMap(Endpoint.NAME, "id"));
- assertNotNull(r.choose());
- assertTrue(r.choose().iterator().hasNext());
+ assertNotNull(r.choose(registry));
+ assertTrue(r.choose(registry).iterator().hasNext());
registry.unregister(endpoint, null);
- assertNotNull(r.choose());
- assertFalse(r.choose().iterator().hasNext());
+ assertNotNull(r.choose(registry));
+ assertFalse(r.choose(registry).iterator().hasNext());
}
public void testLdapFilter() throws Exception {
@@ -81,16 +82,16 @@
Endpoint endpoint = new DummyEndpoint();
Reference ref = registry.lookup("(NAME=id)");
assertNotNull(ref);
- assertTrue(ref instanceof DynamicReferenceImpl);
- DynamicReferenceImpl r = (DynamicReferenceImpl) ref;
- assertNotNull(r.choose());
- assertFalse(r.choose().iterator().hasNext());
+ assertTrue(ref instanceof InternalReference);
+ InternalReference r = (InternalReference) ref;
+ assertNotNull(r.choose(registry));
+ assertFalse(r.choose(registry).iterator().hasNext());
registry.register(endpoint, ServiceHelper.createMap(Endpoint.NAME, "id"));
- assertNotNull(r.choose());
- assertTrue(r.choose().iterator().hasNext());
+ assertNotNull(r.choose(registry));
+ assertTrue(r.choose(registry).iterator().hasNext());
registry.unregister(endpoint, null);
- assertNotNull(r.choose());
- assertFalse(r.choose().iterator().hasNext());
+ assertNotNull(r.choose(registry));
+ assertFalse(r.choose(registry).iterator().hasNext());
}
public void testEndpointListener() throws Exception {
@@ -140,9 +141,9 @@
// make sure that the query for the wire's from returns the target endpoint
Reference ref = registry.lookup(from);
assertNotNull(ref);
- assertTrue(ref instanceof DynamicReferenceImpl);
- DynamicReferenceImpl reference = (DynamicReferenceImpl) ref;
- Iterable<InternalEndpoint> endpoints = reference.choose();
+ assertTrue(ref instanceof InternalReference);
+ InternalReference reference = (InternalReference) ref;
+ Iterable<InternalEndpoint> endpoints = reference.choose(registry);
assertNotNull(endpoints);
assertTrue(endpoints.iterator().hasNext());
assertEquals(endpoint, endpoints.iterator().next().getEndpoint());
Modified: servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml Tue Mar 10 18:40:12 2009
@@ -89,7 +89,7 @@
org.apache.servicemix.nmr.osgi,
*
</Import-Package>
- <Spring-Context>*;publish-context:=false;create-asynchronously:=true</Spring-Context>
+
</instructions>
</configuration>
</plugin>
Modified: servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml?rev=752210&r1=752209&r2=752210&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml (original)
+++ servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml Tue Mar 10 18:40:12 2009
@@ -44,6 +44,7 @@
<!-- Flow registry and service tracker -->
<bean id="flowRegistry" class="org.apache.servicemix.nmr.core.FlowRegistryImpl">
+ <property name="registry" ref="endpointRegistry" />
<property name="authorizationService" ref="authorizationService" />
<property name="nonOsgiFlows">
<list>