Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Problems with IRemoteServiceContainerAdapter

Hi Scott,

The code in red is for getting local access to published remote service references...it shouldn't block (but apparently is in this case...or is it failing outright?).  

Well it doesn't really block anything but once this code is executed it does search for local remote services and finds some (because we have registred them as remote services) but then 
 (that's what we guess) the connection between service provider and service consumer is never established as the AddRegistrationRequests are never sent. Again, this is just what we could observe. When we comment out this part everything works fine.

Could you please describe how you are calling getRemoteServiceReferences...i.e. what thread(s))...whether from listeners, etc?  Also what the values of the parameters are?

Our client does call getRemoteServiceReferences in a UI thread. Therefore he retrieves a local OSGi-SessionService, where our IContainer instance is stored (in order to make the container available for the whole application). Our SessionService forwards client requests to the IContainer instance and returns the results to UI.

Our client has got a contacts list with online users and wants to see which remote services a user offers. The parameters are:

public <T> List<T> getRemoteService(Class<T> service, ID[] filterIDs,
String filter)

IRemoteServiceReference[] refs = remoteServiceContainerAdapter
.getRemoteServiceReferences(filterIDs, service.getName(),
filter);


1. service: the service interface, will be used to find a service using: service.getName()
2. filterIDs: self constructed IDs

public ECFUserID(Namespace namespace, String username, String server)
throws URISyntaxException {
super(namespace);
this.username = username;
this.connectionData = username + "@" + server + "/" + username + System.currentTimeMillis();
}


3. filter: is always null


A couple of questions about this:

1) Which kind of container (e.g. XMPP, ECF Generic, R-OSGi, etc) is created?

we use the XMPP "ecf.xmpp.smack" container

2) Does this container get connected before calling getRemoteServiceReferences?

The container does get connected before calling getRemoteServiceReferences.  We do the connection  this way:

public void connect(ID targetID, IConnectContext connectContext,
String containerType) throws IDCreateException,
ContainerCreateException, ContainerConnectException,
URISyntaxException {
this.container = ContainerFactory.getDefault().createContainer(
containerType);

ID newID = IDFactory.getDefault().createID(
container.getConnectNamespace(),
((ECFUserID) targetID).getConnectionData());

container.connect(newID, connectContext);
}

3) How are the filterUserIDs constructed...i.e. are they gotten from the provider or constructed 'by hand'?

We retrieve the filterUserIDs from our IRosterItems. But as we could see they are the same as the containerIDs. We would like to use constructed IDs but we do need to add resources to an ID:
this.connectionData = username + "@" + server + "/" + username + System.currentTimeMillis();

If you could please tell us how to achieve that, we would switch to constructed IDs in order to avoid errors.

Thanks Scott!

Regards,
Eugen

Am May 14, 2009 um 16:58  schrieb Scott Lewis:

Hi Eugen,

The code in red is for getting local access to published remote service references...it shouldn't block (but apparently is in this case...or is it failing outright?).  Could you please describe how you are calling getRemoteServiceReferences...i.e. what thread(s))...whether from listeners, etc?  Also what the values of the parameters are?

If I read your note correctly this is what you are doing on the client side

// This method does not work. It doesn't matter which filterIDs we provide, our remote services can not be found!
// The remoteServiceContainerAdapter always finds his own registered remote service but not the those other clients offer
IRemoteServiceReference[] refs = remoteServiceContainerAdapter
.getRemoteServiceReferences(filterUserIDs, service.getName(),
filter);

A couple of questions about this:

1) Which kind of container (e.g. XMPP, ECF Generic, R-OSGi, etc) is created?
2) Does this container get connected before calling getRemoteServiceReferences?
3) How are the filterUserIDs constructed...i.e. are they gotten from the provider or constructed 'by hand'?

Thanks...we'll track down and fix the problem.

Scott


Eugen Reiswich wrote:
We could probably identify the source of our problems in the following ECF code:

*org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject*

   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$
       if (clazz == null)
           return null;
       final IRemoteFilter remoteFilter = (filter == null) ? null : new RemoteFilterImpl(filter);
       final List references = new ArrayList();
       // Lookup from remote registrys...add to given references List
       addReferencesFromRemoteRegistrys(idFilter, clazz, remoteFilter, references);
       // Add any from local registry

// If we comment out this code our remote service retrieving seems to work fine. In our opinion this part prevents the execution of the code marked in blue. As we understand the blue code is neccessary in order to get proper working remote services. Could you please comment our suspicion?

       //        synchronized (localRegistry) {
       //            addReferencesFromRegistry(clazz, remoteFilter, localRegistry, references);
       //        }

       // If none found the first time we send a registration request and wait
       if (references.size() == 0) {
           AddRegistrationRequest first = null;
           List ourAddRegistrationRequests = new ArrayList();
           // It's not already here...so send out AddRegistrationRequests
           if (idFilter == null) {
               first = new AddRegistrationRequest(null, clazz, filter, first);
               ourAddRegistrationRequests.add(first);
           } else {
               for (int i = 0; i < idFilter.length; i++) {
                   ID target = idFilter[i];
                   if (target != null) {
                       AddRegistrationRequest request = new AddRegistrationRequest(target, clazz, filter, first);
                       if (i == 0)
                           first = request;
                       // Add to list of all know
                       ourAddRegistrationRequests.add(request);
                       addRegistrationRequests.put(request.getId(), request);
                       sendAddRegistrationRequest(target, request, getAddRegistrationRequestCredentials(request));
                   }
               }
           }
           // Wait here for timeout or response
           first.waitForResponse(ADD_REGISTRATION_REQUEST_TIMEOUT);
           // Now look again
           addReferencesFromRemoteRegistrys(idFilter, clazz, remoteFilter, references);
           // In either case, remove all the addRegistrationRequests
           for (Iterator i = ourAddRegistrationRequests.iterator(); i.hasNext();) {
               AddRegistrationRequest request = (AddRegistrationRequest) i.next();
               addRegistrationRequests.remove(request.getId());
           }

       }
       final IRemoteServiceReference[] result = (IRemoteServiceReference[]) references.toArray(new IRemoteServiceReference[references.size()]);
       Trace.exiting(Activator.PLUGIN_ID, IRemoteServiceProviderDebugOptions.METHODS_EXITING, this.getClass(), "getRemoteServiceReferences", result); //$NON-NLS-1$
       return (result.length == 0) ? null : result;
   }

Any answer would be appreciated.

Regards,
Eugen

Am May 14, 2009 um 11:25  schrieb Eugen Reiswich:

Hi,

we are trying now for hours to get an example running with ECF. We would like to use remote services in hour application and thus do the following stuff:

1. Register remote services:
public void registerRemoteService(String serviceName, Object impl,
ID[] targetUserIDs) {

Dictionary<String, ID[]> props = new Hashtable<String, ID[]>();
props.put(Constants.SERVICE_REGISTRATION_TARGETS, targetUserIDs);

// register ECF remote service
getRemoteServiceContainerAdapter().registerRemoteService(
new String[] { serviceName }, impl, props);
}

2. Retrieve remote services:
public <T> List<T> getRemoteService(Class<T> service, ID[] filterUserIDs,
String filter) throws ECFException, InvalidSyntaxException {
List<T> remoteServices = new ArrayList<T>();

IRemoteServiceContainerAdapter remoteServiceContainerAdapter = getRemoteServiceContainerAdapter();

// This method does not work. It doesn't matter which filterIDs we provide, our remote services can not be found!
// The remoteServiceContainerAdapter always finds his own registered remote service but not the those other clients offer
IRemoteServiceReference[] refs = remoteServiceContainerAdapter
.getRemoteServiceReferences(filterUserIDs, service.getName(),
filter);


Is this a known issue or should I open a bug? We are using ECF 3.0.v20090513-0832 with Eclipse 3.5
Regards,
Eugen
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx <mailto:ecf-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/ecf-dev

------------------------------------------------------------------------

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev
 

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev


Back to the top