/** * @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; }
/** * @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(); }