Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2011-01-15 21:44:54 -0500
committerslewis2011-01-15 21:44:54 -0500
commit3e76ae79008c561fd08f52f2142a742e37f39cd6 (patch)
tree5d70b6c53c19091760496637fabfb4258975fee0 /incubation
parent4ea18483de635d61ee8289eafb310ed2787f78d4 (diff)
downloadorg.eclipse.ecf-3e76ae79008c561fd08f52f2142a742e37f39cd6.tar.gz
org.eclipse.ecf-3e76ae79008c561fd08f52f2142a742e37f39cd6.tar.xz
org.eclipse.ecf-3e76ae79008c561fd08f52f2142a742e37f39cd6.zip
rsa simplifications and test additions
Diffstat (limited to 'incubation')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java62
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java11
2 files changed, 29 insertions, 44 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
index 3d357321d..9c496f5c1 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
@@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -113,10 +112,10 @@ public class EndpointDescriptionLocator {
// Create thread group, event manager, and eventQueue, and setup to
// dispatch EndpointListenerEvents
ThreadGroup eventGroup = new ThreadGroup(
- "EventAdmin EndpointDescriptionLocator EndpointListener Dispatcher"); //$NON-NLS-1$
+ "RSA EndpointDescriptionLocator ThreadGroup"); //$NON-NLS-1$
eventGroup.setDaemon(true);
eventManager = new EventManager(
- "EventAdmin EndpointListener Dispatcher", eventGroup); //$NON-NLS-1$
+ "RSA EndpointDescriptionLocator Dispatcher", eventGroup); //$NON-NLS-1$
eventQueue = new ListenerQueue(eventManager);
CopyOnWriteIdentityMap listeners = new CopyOnWriteIdentityMap();
listeners.put(this, this);
@@ -170,7 +169,29 @@ public class EndpointDescriptionLocator {
EndpointListener.class.getName(),
new ServiceTrackerCustomizer() {
public Object addingService(ServiceReference reference) {
- return addingEndpointListener(reference);
+ if (context == null)
+ return null;
+ EndpointListener listener = (EndpointListener) context
+ .getService(reference);
+ if (listener == null)
+ return null;
+ Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> allDiscoveredEndpointDescriptions = getAllDiscoveredEndpointDescriptions();
+ for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : allDiscoveredEndpointDescriptions) {
+ EndpointDescriptionLocator.EndpointListenerHolder[] endpointListenerHolders = getMatchingEndpointListenerHolders(
+ new ServiceReference[] { reference }, ed);
+ if (endpointListenerHolders != null) {
+ for (int i = 0; i < endpointListenerHolders.length; i++) {
+ queueEndpointDescription(
+ endpointListenerHolders[i]
+ .getListener(),
+ endpointListenerHolders[i]
+ .getDescription(),
+ endpointListenerHolders[i]
+ .getMatchingFilter(), true);
+ }
+ }
+ }
+ return listener;
}
public void modifiedService(ServiceReference reference,
@@ -211,31 +232,6 @@ public class EndpointDescriptionLocator {
bundleTracker.open();
}
- private EndpointListener addingEndpointListener(
- ServiceReference serviceReference) {
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> allDiscoveredEndpointDescriptions = getAllDiscoveredEndpointDescriptions();
- if (context == null)
- return null;
- EndpointListener listener = (EndpointListener) context
- .getService(serviceReference);
- if (listener == null)
- return null;
- for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : allDiscoveredEndpointDescriptions) {
- EndpointDescriptionLocator.EndpointListenerHolder[] endpointListenerHolders = getMatchingEndpointListenerHolders(
- new ServiceReference[] { serviceReference }, ed);
- if (endpointListenerHolders != null) {
- for (int i = 0; i < endpointListenerHolders.length; i++) {
- queueEndpointDescription(
- endpointListenerHolders[i].getListener(),
- endpointListenerHolders[i].getDescription(),
- endpointListenerHolders[i].getMatchingFilter(),
- true);
- }
- }
- }
- return listener;
- }
-
private void logError(String methodName, String message, Throwable e) {
LogUtility.logError(methodName, DebugOptions.DISCOVERY,
this.getClass(), message, e);
@@ -588,7 +584,7 @@ public class EndpointDescriptionLocator {
.getService(refs[i]);
if (listener == null)
continue;
- List filters = PropertiesUtil.getStringPlusProperty(
+ List<String> filters = PropertiesUtil.getStringPlusProperty(
getMapFromProperties(refs[i]),
EndpointListener.ENDPOINT_LISTENER_SCOPE);
String matchingFilter = isMatch(description, filters);
@@ -600,12 +596,10 @@ public class EndpointDescriptionLocator {
.toArray(new EndpointListenerHolder[results.size()]);
}
- private String isMatch(EndpointDescription description, List filters) {
- for (Iterator j = filters.iterator(); j.hasNext();) {
- String filter = (String) j.next();
+ private String isMatch(EndpointDescription description, List<String> filters) {
+ for (String filter : filters)
if (description.matches(filter))
return filter;
- }
return null;
}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
index f864286ed..f1bb631f4 100644
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
+++ b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
@@ -13,7 +13,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.ServiceInfoFactory;
-public class ServiceInfoFactoryTest extends AbstractMetadataFactoryTest {
+public abstract class ServiceInfoFactoryTest extends AbstractMetadataFactoryTest {
protected void setUp() throws Exception {
super.setUp();
@@ -41,13 +41,4 @@ public class ServiceInfoFactoryTest extends AbstractMetadataFactoryTest {
}
}
- public void testCreateBadECFEndpointDescription() throws Exception {
- try{
- createBadECFEndpointDescrption();
- fail();
- } catch (Exception e) {
- // this is test success
- }
- }
-
}

Back to the top