public Iterator getAttributeNames(Configuration modeConf, Map objectModel)
      throws ConfigurationException {

    if (!this.initialized) {
      this.lazy_initialize();
    }
    if (this.defaultInput == null) {
      if (getLogger().isWarnEnabled()) getLogger().warn("No input module given");
    }

    // obtain correct configuration objects
    // default vs dynamic
    Configuration inputConfig = this.inputConf;
    Configuration mConf = null;
    String inputName = null;
    if (modeConf != null) {
      mConf = modeConf.getChild("input-module");
      inputName = modeConf.getChild("input-module").getAttribute("name", null);
      if (inputName != null) {
        inputConfig = modeConf.getChild("input-module");
      }
    }

    // done reading configuration
    // setup modules and read values
    Iterator enumeration =
        getNames(objectModel, this.input, this.defaultInput, inputConfig, null, inputName, mConf);
    return enumeration;
  }
  public void configure(Configuration config) throws ConfigurationException {

    // It seems that even if there is no config, we'll get an empty
    // input-module element here, so it will never be null (JT)
    this.inputConf = config.getChild("input-module");
    this.defaultInput = this.inputConf.getAttribute("name", this.defaultInput);
    this.prefix = config.getChild("prefix").getValue(null);
    this.suffix = config.getChild("suffix").getValue(null);
    this.rmPrefix = config.getChild("rm-prefix").getValue(null);
    this.rmSuffix = config.getChild("rm-suffix").getValue(null);
    this.mapping = new Mapping(config);
  }
  /** @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) */
  public void configure(final Configuration configuration) throws ConfigurationException {

    super.configure(configuration);
    if (isEnabled()) {
      Configuration handlerConfiguration = configuration.getChild("handler");
      Configuration admin = handlerConfiguration.getChild("administrator_accounts");
      Configuration[] accounts = admin.getChildren("account");
      for (int i = 0; i < accounts.length; i++) {
        adminAccounts.put(accounts[i].getAttribute("login"), accounts[i].getAttribute("password"));
      }
      Configuration promtConfiguration = handlerConfiguration.getChild("prompt", false);
      if (promtConfiguration != null) prompt = promtConfiguration.getValue();
      if (prompt == null) prompt = "";
      else if (!prompt.equals("") && !prompt.endsWith(" ")) prompt += " ";
    }
  }
Example #4
0
  /** Configure this transformer, possibly passing to it a jtidy configuration file location. */
  public void configure(Configuration config) throws ConfigurationException {
    super.configure(config);

    String configUrl = config.getChild("jtidy-config").getValue(null);
    if (configUrl != null) {
      org.apache.excalibur.source.SourceResolver resolver = null;
      Source configSource = null;
      try {
        resolver =
            (org.apache.excalibur.source.SourceResolver)
                this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
        configSource = resolver.resolveURI(configUrl);
        if (getLogger().isDebugEnabled()) {
          getLogger().debug("Loading configuration from " + configSource.getURI());
        }
        this.properties = new Properties();
        this.properties.load(configSource.getInputStream());

      } catch (Exception e) {
        getLogger().warn("Cannot load configuration from " + configUrl);
        throw new ConfigurationException("Cannot load configuration from " + configUrl, e);
      } finally {
        if (null != resolver) {
          this.manager.release(resolver);
          resolver.release(configSource);
        }
      }
    }
  }
  /** Create root jxpath configuration */
  public JXPathHelperConfiguration(Configuration config) throws ConfigurationException {
    this.lenient = config.getChild("lenient").getValueAsBoolean(true);
    this.library = new FunctionLibrary();
    setup(config);

    // the following is necessary to be able to use methods on objects without
    // explicitely registering extension functions (see PackageFunctions javadoc)
    this.library.addFunctions(new PackageFunctions("", null));
  }
  public void configure(Configuration config) throws ConfigurationException {

    this.inputConf = config.getChild("input-module");
    this.defaultInput = this.inputConf.getAttribute("name", this.defaultInput);
    this.defaultFormat = this.inputConf.getAttribute("format", this.defaultFormat);
    if (this.defaultFormat != null) {
      this.defaultFormatter = new SimpleDateFormat(this.defaultFormat);
    }
  }
Example #7
0
 /** Configures this instance. See class decription for details. */
 public void configure(Configuration configuration) throws ConfigurationException {
   final String METHOD_NAME = "configure";
   this.logDebug(METHOD_NAME + " 1/2: Started");
   try {
     this.offset = Long.parseLong(configuration.getChild("offset").getValue("0").trim());
     this.logDebug(METHOD_NAME + " 2/2: Done. offset = " + offset);
   } catch (Exception exception) {
     throw new ConfigurationException("Wrapped exception", exception);
   }
 }
Example #8
0
 /* (non-Javadoc)
  * @see org.apache.lenya.cms.usecase.AbstractUsecase#configure(org.apache.avalon.framework.configuration.Configuration)
  */
 public void configure(Configuration config) throws ConfigurationException {
   super.configure(config);
   Configuration newsletterConfig = config.getChild(NEWSLETTER_ELEMENT_NAME);
   Configuration senderConfig = newsletterConfig.getChild(SENDER_ELEMENT_NAME);
   if (senderConfig == null) {
     throw new ConfigurationException("A newsletter must have a sender");
   }
   this.senderName = senderConfig.getAttribute(NAME_ATTRIBUTE_NAME);
   if (this.senderName == null) {
     throw new ConfigurationException("The sender name has to be specified");
   }
   this.senderEmailAddress = senderConfig.getAttribute(ADDR_ATTRIBUTE_NAME);
   if (this.senderEmailAddress == null) {
     throw new ConfigurationException("The sender email address has to be specified");
   }
   Configuration formatConfiguration = newsletterConfig.getChild(FORMAT_ELEMENT_NAME);
   this.formatName = formatConfiguration.getAttribute(NAME_ATTRIBUTE_NAME);
   if (this.formatName == null) {
     throw new ConfigurationException("The format name must be specified");
   }
 }
Example #9
0
  public void configure(Configuration configuration) throws ConfigurationException {
    configure = true;

    plexusHome = configuration.getChild("plexus-home").getValue();
  }
Example #10
0
  /** Configure this transformer. */
  public void configure(Configuration conf) throws ConfigurationException {
    Configuration child;

    child = conf.getChild("use-request-parameters");
    this.useParameters = child.getValueAsBoolean(false);
    this._useParameters = this.useParameters;

    child = conf.getChild("use-cookies");
    this.useCookies = child.getValueAsBoolean(false);
    this._useCookies = this.useCookies;

    child = conf.getChild("use-session-info");
    this.useSessionInfo = child.getValueAsBoolean(false);
    this._useSessionInfo = this.useSessionInfo;

    child = conf.getChild("transformer-factory");
    // traxFactory is null, if transformer-factory config is unspecified
    final String traxFactory = child.getValue(null);

    child = conf.getChild("xslt-processor-role");
    String xsltProcessorRole = child.getValue(XSLTProcessor.ROLE);
    if (!xsltProcessorRole.startsWith(XSLTProcessor.ROLE)) {
      xsltProcessorRole = XSLTProcessor.ROLE + '/' + xsltProcessorRole;
    }

    child = conf.getChild("check-includes");
    this.checkIncludes = child.getValueAsBoolean(this.checkIncludes);

    child = conf.getChild("default-src", false);
    if (child != null) {
      this.defaultSrc = child.getValue();
    }

    if (getLogger().isDebugEnabled()) {
      getLogger().debug("Use parameters is " + this.useParameters);
      getLogger().debug("Use cookies is " + this.useCookies);
      getLogger().debug("Use session info is " + this.useSessionInfo);
      getLogger().debug("Use TrAX Processor " + xsltProcessorRole);
      getLogger().debug("Check for included stylesheets is " + this.checkIncludes);
      if (traxFactory != null) {
        getLogger().debug("Use TrAX Transformer Factory " + traxFactory);
      } else {
        getLogger().debug("Use default TrAX Transformer Factory.");
      }
      getLogger().debug("Default source = " + this.defaultSrc);
    }

    try {
      this.xsltProcessor = (XSLTProcessor) this.manager.lookup(xsltProcessorRole);
      if (traxFactory != null) {
        this.xsltProcessor.setTransformerFactory(traxFactory);
      }
    } catch (ServiceException e) {
      throw new ConfigurationException("Cannot load XSLT processor", e);
    }

    try {
      // see the recyle() method to see what we need this for
      Class dtmManagerClass = Class.forName("org.apache.xml.dtm.DTMManager");
      xalanDtmManagerGetIncrementalMethod = dtmManagerClass.getMethod("getIncremental", null);
    } catch (ClassNotFoundException e) {
      // do nothing -- user does not use xalan, so we don't need the dtm manager
    } catch (NoSuchMethodException e) {
      throw new ConfigurationException(
          "Was not able to get getIncremental method from Xalan's DTMManager.", e);
    }
  }
 public void configure(Configuration config) throws ConfigurationException {
   this.defaultName = config.getChild("parameter-name").getValue(null);
 }
  public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
      throws ConfigurationException {

    if (!this.initialized) {
      this.lazy_initialize();
    }
    if (this.defaultInput == null) {
      if (getLogger().isWarnEnabled()) getLogger().warn("No input module given");
    }

    // obtain correct configuration objects
    // default vs dynamic
    Configuration mConf = null;
    String inputName = null;
    String parameter = name;
    String format = this.defaultFormat;
    DateFormat formatter = null;
    if (modeConf != null) {
      mConf = modeConf.getChild("input-module");
      inputName = modeConf.getChild("input-module").getAttribute("name", null);
      parameter = modeConf.getAttribute("parameter", parameter);
      format = modeConf.getAttribute("format", format);
      // preferred:
      parameter = modeConf.getChild("parameter").getValue(parameter);
      format = modeConf.getChild("format").getValue(format);
    }
    if (this.defaultFormat.equals(format)) {
      formatter = this.defaultFormatter;
    } else {
      formatter = new SimpleDateFormat(format);
    }

    Object[] values =
        getValues(
            parameter,
            objectModel,
            this.input,
            this.defaultInput,
            this.inputConf,
            null,
            inputName,
            mConf);

    Object[] dates = null;
    if (values != null) {
      dates = new Object[values.length];
      for (int i = 0; i < values.length; i++)
        try {
          dates[i] = formatter.parse(String.valueOf(values[i]));
        } catch (Exception e) {
          if (getLogger().isWarnEnabled())
            getLogger()
                .warn(
                    "Problem: Aquired '"
                        + values[i]
                        + "' from '"
                        + inputName
                        + "' for '"
                        + name
                        + "' using format '"
                        + format
                        + "' : "
                        + e.getMessage());
        }
    }
    return dates;
  }
 /** @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) */
 public void configure(Configuration conf) throws ConfigurationException {
   this.conf = conf;
   numThreads = conf.getChild("threads").getValueAsInteger(1);
 }
 /**
  * Configures the factory.
  *
  * @param configuration the Configuration
  * @exception ConfigurationException if an error occurs
  */
 public void configure(final Configuration configuration) throws ConfigurationException {
   super.configure(configuration);
   m_verifyServerIdentity =
       configuration.getChild("verify-server-identity").getValueAsBoolean(false);
 }
  public Iterator getAttributeNames(Configuration modeConf, Map objectModel)
      throws ConfigurationException {

    if (!this.initialized) {
      this.lazy_initialize();
    }
    if (this.defaultInput == null) {
      if (getLogger().isWarnEnabled()) getLogger().warn("No input module given. FAILING");
      return null;
    }

    Configuration inputConfig = null;
    String inputName = null;
    Mapping mapping = this.mapping;
    String prefix = this.prefix;
    String suffix = this.suffix;
    String rmPrefix = this.rmPrefix;
    String rmSuffix = this.rmSuffix;
    if (modeConf != null && modeConf.getChildren().length > 0) {
      inputName = modeConf.getChild("input-module").getAttribute("name", null);
      if (inputName != null) {
        inputConfig = modeConf.getChild("input-module");
      }
      mapping = new Mapping(modeConf);
      prefix = modeConf.getChild("prefix").getValue(null);
      suffix = modeConf.getChild("suffix").getValue(null);
      rmPrefix = modeConf.getChild("rm-prefix").getValue(null);
      rmSuffix = modeConf.getChild("rm-suffix").getValue(null);
    }

    Iterator names =
        getNames(
            objectModel,
            this.input,
            this.defaultInput,
            this.inputConf,
            null,
            inputName,
            inputConfig);

    Set set = new HashSet();
    while (names.hasNext()) {
      String param = (String) names.next();
      if (getLogger().isDebugEnabled())
        getLogger().debug("reverse mapping starts with ['" + param + "']");
      if (prefix != null)
        if (param.startsWith(prefix)) param = param.substring(prefix.length());
        else continue; // prefix is set but parameter does not start with it.

      // if (getLogger().isDebugEnabled())
      //    getLogger().debug("reverse mapping after remove prefix ['"+param+"']");

      if (suffix != null)
        if (param.endsWith(suffix)) param = param.substring(0, param.length() - suffix.length());
        else continue; // suffix is set but parameter does not end with it.

      // if (getLogger().isDebugEnabled())
      //    getLogger().debug("reverse mapping after remove suffix ['"+param+"']");

      if (param.length() < 1) continue; // nothing left

      String newName = mapping.mapFrom(param);

      if (rmPrefix != null) newName = rmPrefix + newName;
      if (rmSuffix != null) newName = newName + rmSuffix;

      if (getLogger().isDebugEnabled())
        getLogger().debug("reverse mapping results in ['" + newName + "']");

      set.add(newName);
    }

    return set.iterator();
  }
  public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
      throws ConfigurationException {

    if (!this.initialized) {
      this.lazy_initialize();
    }
    if (this.defaultInput == null) {
      if (getLogger().isWarnEnabled()) getLogger().warn("No input module given. FAILING");
      return null;
    }

    Configuration inputConfig = null;
    String inputName = null;
    Mapping mapping = this.mapping;
    String prefix = this.prefix;
    String suffix = this.suffix;
    String rmPrefix = this.rmPrefix;
    String rmSuffix = this.rmSuffix;

    if (modeConf != null && modeConf.getChildren().length > 0) {
      inputName = modeConf.getChild("input-module").getAttribute("name", null);
      if (inputName != null) {
        inputConfig = modeConf.getChild("input-module");
      }
      mapping = new Mapping(modeConf);
      prefix = modeConf.getChild("prefix").getValue(null);
      suffix = modeConf.getChild("suffix").getValue(null);
      rmPrefix = modeConf.getChild("rm-prefix").getValue(null);
      rmSuffix = modeConf.getChild("rm-suffix").getValue(null);
    }

    // remove rm-prefix and rm-suffix
    if (rmPrefix != null && name.startsWith(rmPrefix)) {
      name = name.substring(rmPrefix.length());
    }
    if (rmSuffix != null && name.endsWith(rmSuffix)) {
      name = name.substring(0, name.length() - rmSuffix.length());
    }
    // map
    String param = mapping.mapTo(name);
    // add prefix and suffix
    if (prefix != null) param = prefix + param;
    if (suffix != null) param = param + suffix;
    if (getLogger().isDebugEnabled())
      getLogger().debug("mapping ['" + name + "'] to ['" + param + "']");

    Object[] res =
        getValues(
            param,
            objectModel,
            this.input,
            this.defaultInput,
            this.inputConf,
            null,
            inputName,
            inputConfig);
    if (getLogger().isDebugEnabled())
      getLogger().debug("getting for real attribute ['" + param + "'] value: " + res);

    return res;
  }