Exemplo n.º 1
0
 /**
  * fetch the discovered remote service. The service will be fetched from the service providing
  * host and a proxy bundle is registered with the local framework.
  *
  * @param service the <code>ServiceURL</code>.
  * @throws RemoteOSGiException if the fetching fails.
  * @see ch.ethz.iks.r_osgi.RemoteOSGiService#getProxyBundle(ch.ethz.iks.slp.ServiceURL)
  * @since 0.1
  * @category RemoteOSGiService
  */
 private void fetchService(final RemoteServiceReference ref) throws RemoteOSGiException {
   try {
     ChannelEndpointImpl channel;
     channel = ((RemoteServiceReferenceImpl) ref).getChannel();
     channel.getProxyBundle(ref);
   } catch (final UnknownHostException e) {
     throw new RemoteOSGiException("Cannot resolve host " + ref.getURI(), e); // $NON-NLS-1$
   } catch (final IOException ioe) {
     throw new RemoteOSGiException("Proxy generation error", ioe); // $NON-NLS-1$
   }
 }
Exemplo n.º 2
0
 /**
  * @throws InterruptedException
  * @see
  *     ch.ethz.iks.r_osgi.RemoteOSGiService#getRemoteServiceBundle(ch.ethz.iks.r_osgi.RemoteServiceReference)
  * @since 1.0.0.RC4
  */
 public Object getRemoteServiceBundle(final RemoteServiceReference ref, final int timeout)
     throws InterruptedException {
   if (ref == null) {
     throw new IllegalArgumentException("Remote Reference is null."); // $NON-NLS-1$
   }
   getChannel(ref.getURI()).getCloneBundle(ref);
   if (timeout < 0) {
     return null;
   }
   // TODO: FIXME use at least all service interfaces
   final ServiceTracker tracker =
       new ServiceTracker(
           RemoteOSGiActivator.getActivator().getContext(), ref.getServiceInterfaces()[0], null);
   tracker.open();
   tracker.waitForService(0);
   // TODO: FIXME compare that the service is actually the one from the
   // fetched
   // bundle!
   return tracker.getService();
 }
Exemplo n.º 3
0
 /**
  * @param ref the <code>RemoteServiceReference</code> to the service.
  * @return the service reference of the service (or service proxy) or <code>null</code> if the
  *     service is not (yet) present.
  * @see
  *     ch.ethz.iks.r_osgi.RemoteOSGiService#getFetchedServiceReference(ch.ethz.iks.r_osgi.RemoteServiceReference)
  * @category RemoteOSGiService
  * @since 0.6
  */
 private ServiceReference getFetchedServiceReference(final RemoteServiceReference ref) {
   try {
     final ServiceReference[] refs =
         RemoteOSGiActivator.getActivator()
             .getContext()
             .getServiceReferences(
                 ref.getServiceInterfaces()[0],
                 "(" //$NON-NLS-1$
                     + SERVICE_URI
                     + "="
                     + ref.getURI()
                     + ")"); //$NON-NLS-1$ //$NON-NLS-2$
     if (refs != null) {
       return refs[0];
     }
   } catch (final InvalidSyntaxException doesNotHappen) {
     doesNotHappen.printStackTrace();
   }
   return null;
 }
Exemplo n.º 4
0
 /**
  * @see
  *     ch.ethz.iks.r_osgi.RemoteOSGiService#ungetRemoteService(ch.ethz.iks.r_osgi.RemoteServiceReference)
  * @category RemoteOSGiService
  */
 public void ungetRemoteService(final RemoteServiceReference remoteServiceReference) {
   ((RemoteServiceReferenceImpl) remoteServiceReference)
       .getChannel()
       .ungetRemoteService(remoteServiceReference.getURI());
 }