Exemplo n.º 1
0
  @Override
  public ImportRegistration importService(EndpointDescription endpoint) {
    Class<?> interfaceClass = (Class<?>) endpoint.getProperties().get("interface");
    String baseUrl = endpoint.getId();

    RESTImportProxyHandler proxyhandler = new RESTImportProxyHandler(interfaceClass, baseUrl);

    return proxyhandler.getImportRegistration(context, endpoint);
  }
Exemplo n.º 2
0
 /** @since 3.0 */
 public ServiceInfoKey(
     org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
     Namespace discoveryNamespace) {
   this.endpointDescription = endpointDescription;
   this.discoveryNamespace = discoveryNamespace;
   this.hashCode = 31 * this.hashCode + endpointDescription.hashCode();
   this.hashCode = 31 * this.hashCode + discoveryNamespace.hashCode();
 }
Exemplo n.º 3
0
 protected void writeProperties(
     int indentLevel,
     Writer writer,
     org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription)
     throws IOException {
   Map<String, Object> properties = endpointDescription.getProperties();
   for (String name : properties.keySet())
     writeProperty(indentLevel + 1, writer, name, properties.get(name));
 }
Exemplo n.º 4
0
 /** @since 3.0 */
 protected URI createURI(
     org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
     IDiscoveryAdvertiser advertiser,
     IServiceTypeID serviceTypeID,
     String serviceName)
     throws URISyntaxException {
   String path = "/" + serviceName; // $NON-NLS-1$
   String str = endpointDescription.getId();
   URI uri = null;
   while (true) {
     try {
       uri = new URI(str);
       if (uri.getHost() != null) {
         break;
       } else {
         final String rawSchemeSpecificPart = uri.getRawSchemeSpecificPart();
         // make sure we break eventually
         if (str.equals(rawSchemeSpecificPart)) {
           uri = null;
           break;
         } else {
           str = rawSchemeSpecificPart;
         }
       }
     } catch (URISyntaxException e) {
       uri = null;
       break;
     }
   }
   String scheme = RemoteConstants.DISCOVERY_SERVICE_TYPE;
   int port = 32565;
   if (uri != null) {
     port = uri.getPort();
     if (port == -1) port = 32565;
   }
   String host = null;
   if (uri != null) {
     host = uri.getHost();
   } else {
     try {
       host = InetAddress.getLocalHost().getHostAddress();
     } catch (Exception e) {
       logWarning(
           "createURI", //$NON-NLS-1$
           "failed to get local host adress, falling back to \'localhost\'.",
           e); //$NON-NLS-1$
       host = "localhost"; // $NON-NLS-1$
     }
   }
   return new URI(scheme, null, host, port, path, null, null);
 }
Exemplo n.º 5
0
 /** @since 3.0 */
 protected String createServiceName(
     org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
     IDiscoveryAdvertiser advertiser,
     IServiceTypeID serviceTypeID) {
   // First create unique default name
   String defaultServiceName =
       createDefaultServiceName(endpointDescription, advertiser, serviceTypeID);
   // Look for service name that was explicitly set
   String serviceName =
       PropertiesUtil.getStringWithDefault(
           endpointDescription.getProperties(),
           RemoteConstants.DISCOVERY_SERVICE_NAME,
           defaultServiceName);
   return serviceName;
 }
Exemplo n.º 6
0
 /** @since 3.0 */
 protected IServiceTypeID createServiceTypeID(
     org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
     IDiscoveryAdvertiser advertiser) {
   Map props = endpointDescription.getProperties();
   String[] scopes =
       PropertiesUtil.getStringArrayWithDefault(
           props, RemoteConstants.DISCOVERY_SCOPE, IServiceTypeID.DEFAULT_SCOPE);
   String[] protocols =
       PropertiesUtil.getStringArrayWithDefault(
           props, RemoteConstants.DISCOVERY_PROTOCOLS, IServiceTypeID.DEFAULT_SCOPE);
   String namingAuthority =
       PropertiesUtil.getStringWithDefault(
           props, RemoteConstants.DISCOVERY_NAMING_AUTHORITY, IServiceTypeID.DEFAULT_NA);
   return ServiceIDFactory.getDefault()
       .createServiceTypeID(
           advertiser.getServicesNamespace(),
           new String[] {RemoteConstants.DISCOVERY_SERVICE_TYPE},
           scopes,
           protocols,
           namingAuthority);
 }
Exemplo n.º 7
0
 private String getProp(EndpointDescription ep, String key) {
   Object value = ep.getProperties().get(key);
   return value == null ? "" : value.toString();
 }
Exemplo n.º 8
0
 private void print(ShellTable table, EndpointDescription ep) {
   String compName = getProp(ep, "component.name");
   table.addRow().addContent(ep.getId(), ep.getInterfaces(), ep.getFrameworkUUID(), compName);
 }