Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-01-21 19:16:09 +0000
committerslewis2008-01-21 19:16:09 +0000
commit8b2682b869600262dcae1f288620b0c8a2a06d9b (patch)
treee0d29441d75a0b3973dca3bc254239a0d913014c /providers/bundles/org.eclipse.ecf.provider.remoteservice
parentbfb8ffe3a9002ade517f9e0516a73869279a821d (diff)
downloadorg.eclipse.ecf-8b2682b869600262dcae1f288620b0c8a2a06d9b.tar.gz
org.eclipse.ecf-8b2682b869600262dcae1f288620b0c8a2a06d9b.tar.xz
org.eclipse.ecf-8b2682b869600262dcae1f288620b0c8a2a06d9b.zip
Added support for filtering in queries via getRemoteReferences(ID [], String, String (filter).
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.remoteservice')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Activator.java11
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Messages.java1
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/messages.properties1
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java18
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteFilterImpl.java90
5 files changed, 107 insertions, 14 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Activator.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Activator.java
index 2448950a0..ee225cf4c 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Activator.java
@@ -8,8 +8,7 @@
******************************************************************************/
package org.eclipse.ecf.internal.provider.remoteservice;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
+import org.osgi.framework.*;
/**
* The activator class controls the plug-in life cycle
@@ -56,4 +55,12 @@ public class Activator implements BundleActivator {
return plugin;
}
+ /**
+ * @param filter
+ * @return Fileter created via context
+ */
+ public Filter createFilter(String filter) throws InvalidSyntaxException {
+ return context.createFilter(filter);
+ }
+
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Messages.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Messages.java
index 58a250573..f317a703a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/Messages.java
@@ -24,6 +24,7 @@ public class Messages extends NLS {
public static String RegistrySharedObject_20;
public static String RegistrySharedObject_7;
public static String RegistrySharedObject_EXCEPTION_IN_REMOTE_CALL;
+ public static String RemoteFilter_EXCEPTION_FILTER_NOT_NULL;
public static String RemoteServiceImpl_EXCEPTION_CREATING_PROXY;
public static String RegistrySharedObject_EXCEPTION_INVALID_RESPONSE;
public static String RegistrySharedObject_EXCEPTION_INVOKING_SERVICE;
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/messages.properties b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/messages.properties
index 8a8010d7d..b5f6fae53 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/messages.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/internal/provider/remoteservice/messages.properties
@@ -4,6 +4,7 @@ RegistrySharedObject_19=Request timed out after
RegistrySharedObject_20=\ ms
RegistrySharedObject_7=Service is not valid:
RegistrySharedObject_EXCEPTION_IN_REMOTE_CALL=Exception in remote call
+RemoteFilter_EXCEPTION_FILTER_NOT_NULL=Filter cannot be null
RemoteServiceImpl_EXCEPTION_CREATING_PROXY=Exception creating proxy for remote service
RegistrySharedObject_EXCEPTION_INVALID_RESPONSE=Response to request is null
RegistrySharedObject_EXCEPTION_INVOKING_SERVICE=Exception invoking service
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
index 20f8c081b..01ba10587 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
@@ -21,8 +21,7 @@ import org.eclipse.ecf.core.util.*;
import org.eclipse.ecf.internal.provider.remoteservice.*;
import org.eclipse.ecf.remoteservice.*;
import org.eclipse.ecf.remoteservice.events.*;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.*;
public class RegistrySharedObject extends BaseSharedObject implements IRemoteServiceContainerAdapter {
@@ -72,9 +71,9 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
return remoteService;
}
- public IRemoteServiceReference[] getRemoteServiceReferences(ID[] idFilter, String clazz, String filter) {
+ public IRemoteServiceReference[] getRemoteServiceReferences(ID[] idFilter, String clazz, String filter) throws InvalidSyntaxException {
Trace.entering(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_ENTERING, this.getClass(), "getRemoteServiceReferences", new Object[] {idFilter, clazz, filter}); //$NON-NLS-1$
- final IRemoteFilter remoteFilter = createRemoteFilterFromString(filter);
+ final IRemoteFilter remoteFilter = (filter == null) ? null : new RemoteFilterImpl(filter);
final List references = new ArrayList();
synchronized (remoteRegistrys) {
if (idFilter == null) {
@@ -248,11 +247,6 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
return null;
}
- private IRemoteFilter createRemoteFilterFromString(String filter) {
- // XXX make remote filter
- return null;
- }
-
private void addReferencesFromRegistry(String clazz, IRemoteFilter remoteFilter, RemoteServiceRegistryImpl registry, List references) {
final IRemoteServiceReference[] rs = registry.lookupServiceReferences(clazz, remoteFilter);
if (rs != null) {
@@ -517,7 +511,7 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
}
private void localRegisterService(RemoteServiceRegistrationImpl registration) {
- final Object localServiceRegistrationValue = registration.getProperty(Constants.AUTOREGISTER_REMOTE_PROXY);
+ final Object localServiceRegistrationValue = registration.getProperty(org.eclipse.ecf.remoteservice.Constants.AUTOREGISTER_REMOTE_PROXY);
if (localServiceRegistrationValue != null) {
final BundleContext context = Activator.getDefault().getContext();
if (context == null)
@@ -540,8 +534,8 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
}
}
final ID remoteContainerID = registration.getContainerID();
- properties.put(Constants.REMOTE_SERVICE_CONTAINER_ID, remoteContainerID.getName());
- properties.put(Constants.REMOTE_SERVICE, remoteServiceImpl);
+ properties.put(org.eclipse.ecf.remoteservice.Constants.REMOTE_SERVICE_CONTAINER_ID, remoteContainerID.getName());
+ properties.put(org.eclipse.ecf.remoteservice.Constants.REMOTE_SERVICE, remoteServiceImpl);
final ServiceRegistration serviceRegistration = context.registerService(registration.getClasses(), service, properties);
addLocalServiceRegistration(remoteContainerID, serviceRegistration);
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteFilterImpl.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteFilterImpl.java
new file mode 100644
index 000000000..e48f0e4a7
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteFilterImpl.java
@@ -0,0 +1,90 @@
+/****************************************************************************
+ * Copyright (c) 2008 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.provider.remoteservice.generic;
+
+import java.util.Dictionary;
+import org.eclipse.ecf.internal.provider.remoteservice.Activator;
+import org.eclipse.ecf.internal.provider.remoteservice.Messages;
+import org.eclipse.ecf.remoteservice.IRemoteFilter;
+import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ *
+ */
+public class RemoteFilterImpl implements IRemoteFilter {
+
+ Filter filter;
+
+ /**
+ * @param createFilter
+ */
+ public RemoteFilterImpl(String createFilter) throws InvalidSyntaxException {
+ if (createFilter == null)
+ throw new InvalidSyntaxException(Messages.RemoteFilter_EXCEPTION_FILTER_NOT_NULL, createFilter);
+ this.filter = Activator.getDefault().createFilter(createFilter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.remoteservice.IRemoteFilter#match(org.eclipse.ecf.remoteservice.IRemoteServiceReference)
+ */
+ public boolean match(IRemoteServiceReference reference) {
+ if (reference == null)
+ return false;
+ if (reference instanceof RemoteServiceReferenceImpl) {
+ RemoteServiceReferenceImpl impl = (RemoteServiceReferenceImpl) reference;
+ return match(impl.getRegistration().properties);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.remoteservice.IRemoteFilter#match(java.util.Dictionary)
+ */
+ public boolean match(Dictionary dictionary) {
+ return filter.match(dictionary);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.remoteservice.IRemoteFilter#matchCase(java.util.Dictionary)
+ */
+ public boolean matchCase(Dictionary dictionary) {
+ return filter.matchCase(dictionary);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof RemoteFilterImpl)) {
+ return false;
+ }
+
+ return this.toString().equals(obj.toString());
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return this.toString().hashCode();
+ }
+
+ public String toString() {
+ return filter.toString();
+ }
+}

Back to the top