/** OSGi clue code to evict RefreshSfOptionSet instances from 'optionSets' */
 protected final void unbindOptionSets(
     final RefreshSfOptionSet service, final Map<Object, Object> props) {
   final String name = PropertiesUtil.toString(props.get(RefreshSfOptionSetImpl.PROP_NAME), null);
   if (name != null) {
     optionSets.remove(name);
   }
 }
 @Activate
 protected void activate(ComponentContext context) {
   this.propOpt =
       PropertiesUtil.toString(
           context.getProperties().get(PROPERTY_OPTIMIZATION), DEFAULT_OPTIMIZATION);
   this.optimization = ClosureOptimizationLevel.fromString(this.propOpt);
 }
 protected final void unbindTagDataConverter(
     final TagDataConverter service, final Map<Object, Object> props) {
   final String type = PropertiesUtil.toString(props.get(TagDataConverter.PROP_NAME), null);
   if (type != null) {
     this.tagDataConverters.remove(type);
   }
 }
 protected final void unbindImageTransformers(
     final ImageTransformer service, final Map<Object, Object> props) {
   final String type = PropertiesUtil.toString(props.get(ImageTransformer.PROP_TYPE), null);
   if (type != null) {
     imageTransformers.remove(type);
   }
 }
  @Activate
  protected final void activate(final Map<String, String> properties) throws Exception {
    this.transformName = PropertiesUtil.toString(properties.get(PROP_NAME), DEFAULT_TRANSFORM_NAME);

    log.info("Registering Named Image Transfomer: {}", this.transformName);

    final Map<String, String> map =
        OsgiPropertyUtil.toMap(
            PropertiesUtil.toStringArray(properties.get(PROP_TRANSFORMS), new String[] {}),
            ":",
            true,
            null);

    for (final Map.Entry<String, String> entry : map.entrySet()) {
      final String[] params = StringUtils.split(entry.getValue(), "&");
      final Map<String, String> values = OsgiPropertyUtil.toMap(params, "=", true, null);

      log.debug("ImageTransform params for [ {} ] ~> {}", entry.getKey(), values);

      // Order matters so use a LinkedHashMap
      this.transforms.put(entry.getKey(), TypeUtil.toValueMap(values));
    }

    log.info("Named Images Transforms: {}", this.transforms.size());
    for (final Map.Entry<String, ValueMap> entry : this.transforms.entrySet()) {
      log.info("{} ~> {}", entry.getKey(), entry.getValue());
    }
  }
 @SuppressWarnings("rawtypes")
 @Activate
 protected void activate(ComponentContext context) {
   Dictionary props = context.getProperties();
   noUserRedirectLocationFormat =
       PropertiesUtil.toString(
           props.get(NO_USER_REDIRECT_LOCATION_FORMAT), DEFAULT_NO_USER_REDIRECT_FORMAT);
   registrationPath = PropertiesUtil.toString(props.get(REGISTRATION_PATH), "/system/trustedauth");
   defaultDestination = PropertiesUtil.toString(props.get(DEFAULT_DESTINATION), "/dev");
   try {
     httpService.registerServlet(registrationPath, this, null, null);
     LOGGER.info("Registered {} at {} ", this, registrationPath);
   } catch (ServletException e) {
     LOGGER.error(e.getMessage(), e);
   } catch (NamespaceException e) {
     LOGGER.error(e.getMessage(), e);
   }
 }
  @Activate
  protected final void activate(Map<String, Object> config) throws RepositoryException {
    if (!capabilityHelper.isOak()) {
      log.info("Cowardly refusing to create indexes on non-Oak instance.");
      return;
    }

    final String ensureDefinitionsPath =
        PropertiesUtil.toString(
            config.get(PROP_ENSURE_DEFINITIONS_PATH), DEFAULT_ENSURE_DEFINITIONS_PATH);

    final String oakIndexesPath =
        PropertiesUtil.toString(config.get(PROP_OAK_INDEXES_PATH), DEFAULT_OAK_INDEXES_PATH);

    log.info("Ensuring Oak Indexes [ {} ~> {} ]", ensureDefinitionsPath, oakIndexesPath);

    if (StringUtils.isBlank(ensureDefinitionsPath)) {
      throw new IllegalArgumentException(
          "OSGi Configuration Property `"
              + PROP_ENSURE_DEFINITIONS_PATH
              + "` "
              + "cannot be blank.");
    } else if (StringUtils.isBlank(oakIndexesPath)) {
      throw new IllegalArgumentException(
          "OSGi Configuration Property `" + PROP_OAK_INDEXES_PATH + "` " + "cannot be blank.");
    }

    // Start the indexing process asynchronously, so the activate won't get blocked
    // by rebuilding a synchronous index

    EnsureOakIndexJobHandler sih =
        new EnsureOakIndexJobHandler(this, oakIndexesPath, ensureDefinitionsPath);
    ScheduleOptions options = scheduler.NOW();
    String name =
        String.format(
            "Ensure index %s => %s", new Object[] {oakIndexesPath, ensureDefinitionsPath});
    options.name(name);
    options.canRunConcurrently(false);
    scheduler.schedule(sih, options);
    log.info("Job scheduled to update the index");
  }
  /**
   * Get the value of an OSGi configuration string property for a given PID.
   *
   * @param pid The PID of the OSGi component to retrieve
   * @param property The property of the config to retrieve
   * @param value The value to assign the provided property
   * @return The property value
   */
  public String getStringProperty(
      final String pid, final String property, final String defaultValue) {
    try {
      Configuration conf = configAdmin.getConfiguration(pid);

      @SuppressWarnings("unchecked")
      Dictionary<String, Object> props = conf.getProperties();

      if (props != null) {
        return PropertiesUtil.toString(props.get(property), defaultValue);
      }
    } catch (IOException e) {
      LOGGER.error("Could not get property", e);
    }

    return defaultValue;
  }
  @SuppressWarnings("rawtypes")
  protected void activate(ComponentContext context) {
    Dictionary props = context.getProperties();
    usingSession = PropertiesUtil.toBoolean(props.get(USE_SESSION), false);
    secureCookie = PropertiesUtil.toBoolean(props.get(SECURE_COOKIE), false);
    ttl = PropertiesUtil.toLong(props.get(TTL), 1200000);
    trustedAuthCookieName = PropertiesUtil.toString(props.get(COOKIE_NAME), "");
    sharedSecret =
        PropertiesUtil.toString(
            props.get(SERVER_TOKEN_SHARED_SECRET), "default-setting-change-before-use");
    trustedTokenEnabled = PropertiesUtil.toBoolean(props.get(SERVER_TOKEN_ENABLED), true);
    debugCookies = PropertiesUtil.toBoolean(props.get(DEBUG_COOKIES), false);
    tokenStore.setDebugCookies(debugCookies);
    String safeHostsAddr = PropertiesUtil.toString(props.get(SERVER_TOKEN_SAFE_HOSTS_ADDR), "");
    safeHostAddrSet.clear();
    if (safeHostsAddr != null) {
      for (String address : StringUtils.split(safeHostsAddr, ';')) {
        safeHostAddrSet.add(address);
      }
    }
    String trustedProxyServerAddr =
        PropertiesUtil.toString(props.get(TRUSTED_PROXY_SERVER_ADDR), "");
    trustedProxyServerAddrSet.clear();
    if (trustedProxyServerAddr != null) {
      for (String address : StringUtils.split(trustedProxyServerAddr, ';')) {
        trustedProxyServerAddrSet.add(address);
      }
    }
    String wrappers = PropertiesUtil.toString(props.get(SERVER_TOKEN_SAFE_WRAPPERS), "");
    if (wrappers == null || wrappers.length() == 0) {
      wrappers = DEFAULT_WRAPPERS;
    }
    safeWrappers = StringUtils.split(wrappers, ";");

    String tokenFile = PropertiesUtil.toString(props.get(TOKEN_FILE_NAME), "");
    String serverId = clusterTrackingService.getCurrentServerId();
    tokenStore.doInit(cacheManager, tokenFile, serverId, ttl);

    trustedHeaderName = PropertiesUtil.toString(props.get(TRUSTED_HEADER_NAME), "");
    trustedParameterName = PropertiesUtil.toString(props.get(TRUSTED_PARAMETER_NAME), "");
  }
示例#10
0
 @Activate
 protected void activate(Map<String, Object> config) throws ServletException, NamespaceException {
   message = PropertiesUtil.toString(config.get(PROP_MESSAGE), "no message");
   path = PropertiesUtil.toString(config.get(PROP_PATH), "no path");
   register();
 }
 @Activate
 public void activate(Map<String, ?> config) throws Exception {
   queueName = PropertiesUtil.toString(config.get(QUEUE_NAME), "");
 }
 private void configure(final Map<String, Object> config) {
   myParameter = PropertiesUtil.toString(config.get(MY_PARAMETER), null);
   logger.debug("configure: myParameter='{}''", myParameter);
 }
 /** OSGi clue code to inject RefreshSfClient instances into 'clients' */
 protected final void bindClients(final RefreshSfClient service, final Map<Object, Object> props) {
   final String name = PropertiesUtil.toString(props.get(RefreshSfClientImpl.PROP_NAME), null);
   if (name != null) {
     clients.put(name, service);
   }
 }