コード例 #1
0
  public ServiceRegistrationImpl(
      BundleImpl bundle,
      long serviceId,
      String[] classNames,
      Object service,
      Dictionary<String, ?> properties) {
    this.bundle = bundle;
    this.serviceId = serviceId;
    this.classNames = classNames;
    this.service = service;

    if ((properties == null) || properties.isEmpty()) this.properties = EMPTY_PROPERTIES;
    else {
      Enumeration<String> keys = properties.keys();
      Map<String, Object> thisProperties = newCaseInsensitiveMapInstance();

      while (keys.hasMoreElements()) {
        String key = keys.nextElement();

        if (Constants.OBJECTCLASS.equalsIgnoreCase(key)
            || Constants.SERVICE_ID.equalsIgnoreCase(key)) continue;
        else if (thisProperties.containsKey(key)) throw new IllegalArgumentException(key);
        else thisProperties.put(key, properties.get(key));
      }

      this.properties = thisProperties.isEmpty() ? EMPTY_PROPERTIES : thisProperties;
    }
  }
コード例 #2
0
    public Object getProperty(String key) {
      Object value;

      if (Constants.OBJECTCLASS.equalsIgnoreCase(key)) value = classNames;
      else if (Constants.SERVICE_ID.equalsIgnoreCase(key)) value = serviceId;
      else
        synchronized (properties) {
          value = properties.get(key);
        }
      return value;
    }