Esempio n. 1
0
 /**
  * @param serviceURI
  * @return
  */
 private static String getChannelURI(final URI serviceURI) {
   return URI.create(
           serviceURI.getScheme()
               + "://"
               + serviceURI.getHost()
               + ":" //$NON-NLS-1$ //$NON-NLS-2$
               + serviceURI.getPort())
       .toString();
 }
Esempio n. 2
0
  /**
   * connect to a remote OSGi host.
   *
   * @param host the address of the remote OSGi peer.
   * @param port the port of the remote OSGi peer.
   * @param protocol the protocol to be used or <code>null</code> for default.
   * @return the array of service urls of services offered by the remote peer.
   * @throws RemoteOSGiException in case of errors.
   * @since 0.6
   */
  public RemoteServiceReference[] connect(final URI uri) throws RemoteOSGiException, IOException {

    final URI endpoint = URI.create(getChannelURI(uri));
    final ChannelEndpointImpl test = (ChannelEndpointImpl) channels.get(endpoint.toString());
    if (test != null) {
      test.usageCounter++;
      return test.getAllRemoteReferences(null);
    }

    final ChannelEndpointImpl channel;
    final String protocol = endpoint.getScheme();

    final NetworkChannelFactory factory = getNetworkChannelFactory(protocol);
    channel = new ChannelEndpointImpl(factory, endpoint);

    return channel.sendLease(getServices(), getTopics());
  }