コード例 #1
0
 /**
  * Activate this component. Open the session and register event listeners.
  *
  * @param context The component context
  */
 protected void activate(final ComponentContext context) {
   reverseReplicate =
       OsgiUtil.toBoolean(
           context.getProperties().get(PROPERTY_REVERSE_REPLICATE), DEFAULT_REVERSE_REPLICATE);
   fieldWhitelist = OsgiUtil.toStringArray(context.getProperties().get(PROPERTY_FIELD_WHITELIST));
   attachmentTypeBlacklist =
       OsgiUtil.toStringArray(context.getProperties().get(PROPERTY_ATTACHMENT_TYPE_BLACKLIST));
 }
コード例 #2
0
ファイル: SlingDavExServlet.java プロジェクト: JEBailey/sling
  @Activate
  protected void activate(final BundleContext bundleContext, final Map<String, ?> config) {
    final String davRoot = OsgiUtil.toString(config.get(PROP_DAV_ROOT), DEFAULT_DAV_ROOT);
    final boolean createAbsoluteUri =
        OsgiUtil.toBoolean(config.get(PROP_CREATE_ABSOLUTE_URI), DEFAULT_CREATE_ABSOLUTE_URI);

    final AuthHttpContext context = new AuthHttpContext(davRoot);
    context.setAuthenticationSupport(authSupport);

    // prepare DavEx servlet config
    final Dictionary<String, String> initProps = new Hashtable<String, String>();

    // prefix to the servlet
    initProps.put(INIT_PARAM_RESOURCE_PATH_PREFIX, davRoot);

    // create absolute URIs (or absolute paths)
    initProps.put(INIT_PARAM_CREATE_ABSOLUTE_URI, Boolean.toString(createAbsoluteUri));

    // disable CSRF checks for now (should be handled by Sling)
    initProps.put(INIT_PARAM_CSRF_PROTECTION, CSRFUtil.DISABLED);

    // register and handle registration failure
    try {
      this.httpService.registerServlet(davRoot, this, initProps, context);
      this.servletAlias = davRoot;

      java.util.Properties dummyServiceProperties = new java.util.Properties();
      dummyServiceProperties.put(Constants.SERVICE_VENDOR, config.get(Constants.SERVICE_VENDOR));
      dummyServiceProperties.put(
          Constants.SERVICE_DESCRIPTION, "Helper for " + config.get(Constants.SERVICE_DESCRIPTION));
      dummyServiceProperties.put(PAR_AUTH_REQ, "-" + davRoot);
      this.dummyService =
          bundleContext.registerService("java.lang.Object", new Object(), dummyServiceProperties);
    } catch (Exception e) {
      log.error("activate: Failed registering DavEx Servlet at " + davRoot, e);
    }
  }