Package de.odysseus.calyxo.control.conf

Examples of de.odysseus.calyxo.control.conf.ParamConfig


   * The default filter name is <code>branch</code>, which may be overridden
   * by specifying the <code>name</code> plugin parameter.
   * @see de.odysseus.calyxo.control.Plugin#init(de.odysseus.calyxo.control.conf.PluginConfig, de.odysseus.calyxo.control.PluginContext)
   */
  public void init(PluginConfig config, PluginContext context) throws Exception {
    ParamConfig param = config.getParamConfig("name");
    String name = param == null ? "branch" : param.getValue();
    context.setFilterClass(name, getClass());
  }
View Full Code Here


  /**
   * Resolve dispatch configuration.
   */
  public void init(FilterConfig config, ModuleContext module) throws ConfigException {
    dispatch = config.getDispatchConfig(null);
    ParamConfig param = config.getParamConfig("target");
    if ((param == null) == (dispatch == null)) {
      throw new ConfigException("One of 'target' parameter or anonymous <dispatch> child must be given for filter '" + config.toInlineString() + "'");
    }
    if (param != null) {
      String target = param.getValue();
      dispatch = config.getActionConfig().findDispatchConfig(target);
      if (dispatch == null) {
        throw new ConfigException("Cannot find dispatch '" + target + "' for filter '" + config.toInlineString() + "'");
      }
    }
View Full Code Here

   * The filter name defaults to <code>no-cache</code> and may be overridden
   * in parameter <code>name</code>.
   * @see de.odysseus.calyxo.control.Plugin#init(de.odysseus.calyxo.control.conf.PluginConfig, de.odysseus.calyxo.control.PluginContext)
   */
  public void init(PluginConfig config, PluginContext context) throws Exception {
    ParamConfig param = config.getParamConfig("name");
    String name = param == null ? "no-cache" : param.getValue();
    context.setFilterClass(name, getClass());
  }
View Full Code Here

   * Initialize the <code>bundle</code>, <code>key</code> and <code>target</code>
   * parameters.
   * @see de.odysseus.calyxo.control.ExceptionHandler#init(de.odysseus.calyxo.control.conf.ExceptionHandlerConfig, de.odysseus.calyxo.base.ModuleContext)
   */
  public void init(ExceptionHandlerConfig config, ModuleContext module) throws ConfigException {
    ParamConfig param = null;
   
    param = config.getParamConfig("bundle");
    if (param == null) {
      throw new ConfigException("Missing parameter 'bundle'!");
    }
    bundle = param.getValue();
 
    param = config.getParamConfig("key");
    if (param == null) {
      throw new ConfigException("Missing parameter 'key'!");
    }
    key = param.getValue();

    dispatch = config.getDispatchConfig(null);
    param = config.getParamConfig("target");
    if ((param == null) == (dispatch == null)) {
      throw new ConfigException("One of 'target' parameter or anonymous <dispatch> child must be given for filter '" + config.toInlineString() + "'");
    }
    if (param != null) {
      target = param.getValue();
    }
   
    messages = MessageSupport.getInstance(module);
  }
View Full Code Here

   * The default filter name is <code>cancel</code>, which may be overridden
   * by specifying the <code>name</code> plugin parameter.
   * @see de.odysseus.calyxo.control.Plugin#init(de.odysseus.calyxo.control.conf.PluginConfig, de.odysseus.calyxo.control.PluginContext)
   */
  public void init(PluginConfig config, PluginContext context) throws Exception {
    ParamConfig param = config.getParamConfig("name");
    String name = param == null ? "cancel" : param.getValue();
    context.setFilterClass(name, getClass());
  }
View Full Code Here

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.Filter#init(de.odysseus.calyxo.control.conf.FilterConfig, de.odysseus.calyxo.base.ModuleContext)
   */
  public void init(FilterConfig config, ModuleContext module) throws ConfigException {
    ParamConfig param;
   
    name1 = "cancel";
    param = config.getParamConfig("parameter");
    if (param != null) {
      name1 = param.getValue();
    }
    name2 = name1.endsWith(".x") || name1.endsWith(".y") ? null : name1 + ".x";

    dispatch = config.getDispatchConfig(null);
    param = config.getParamConfig("target");
    if (param != null && dispatch != null) {
      throw new ConfigException("At most one of 'target' parameter or anonymous <dispatch> child must be given for filter '" + config.toInlineString() + "'");
    }
    if (dispatch == null) {
      String target = param == null ? "cancel" : param.getValue();
      dispatch = config.getActionConfig().findDispatchConfig(target);
      if (dispatch == null) {
        throw new ConfigException("Cannot find dispatch '" + target + "' for filter '" + config.toInlineString() + "'");
      }
    }
View Full Code Here

        anchor = path.substring(hash);
        buf.setLength(hash);
      }
      buf.append(path.indexOf('?') > 0 ? '&' : '?');
      do {
        ParamConfig param = (ParamConfig)params.next();
        buf.append(URLEncoder.encode(param.getName(), encoding));
        buf.append('=');
        buf.append(URLEncoder.encode(param.getValue(), encoding));
        if (params.hasNext()) {
          buf.append('&');
        } else {
          break;
        }
View Full Code Here

    if (config.getParamConfig("form") == null) {
      throw new ConfigException("Missing parameter 'form' in " + config.toInlineString());
    }
    Iterator params = config.getParamConfigs();
    while (params.hasNext()) {
      ParamConfig param = (ParamConfig)params.next();
      if ("scope".equals(param.getName())) {
        String scope = param.getValue();
        if (!"request".equals(scope) && !"session".equals(scope)) {
          throw new ConfigException("Bad scope '" + scope + "' in " + config.toInlineString());
        }
        if (config.getParamConfig("attribute") == null) {
          throw new ConfigException("Parameter 'scope' without 'attribute' in " + config.toInlineString());
        }     
      } else if ("class".equals(param.getName())) {
        String clazz = param.getValue();
        try {
          loader.loadClass(clazz);
        } catch (Exception e) {
          throw new ConfigException("Bad class '" + clazz + "' in " + config.toInlineString(), e);
        }
View Full Code Here

  FormData getFormData(HttpServletRequest request, FilterConfig filterConfig, boolean create) throws Exception {
    if (filterConfig == null) {
      return null;
    }
    Object data = null;
    ParamConfig attribute = filterConfig.getParamConfig("attribute");
    if (attribute != null) {
      ParamConfig scope = filterConfig.getParamConfig("scope");
      if (scope != null && "request".equals(scope.getValue())) {
        data = request.getAttribute(attribute.getValue());
      } else {
        data = request.getSession().getAttribute(attribute.getValue());
      }
    }
    if (data == null && create) {
      ParamConfig clazz = filterConfig.getParamConfig("class");
      if (clazz != null) {
        data = loader.loadClass(clazz.getValue()).newInstance();
      } else if (defaultDataClass != null) { // use default class
        data = defaultDataClass.newInstance();
      }
      if (data != null) {
        if (attribute != null) {
          ParamConfig scope = filterConfig.getParamConfig("scope");
          if (scope != null && "request".equals(scope.getValue())) {
            request.setAttribute(attribute.getValue(), data);
          } else {
            request.getSession().setAttribute(attribute.getValue(), data);
          }
        }
View Full Code Here

   */
  void removeFormData(HttpServletRequest request, FilterConfig filterConfig) throws Exception {
    if (filterConfig == null) {
      return;
    }
    ParamConfig attribute = filterConfig.getParamConfig("attribute");
    if (attribute != null) {
      ParamConfig scope = filterConfig.getParamConfig("scope");
      if (scope == null || "session".equals(scope.getValue())) {
        request.getSession().removeAttribute(attribute.getValue());
      } else if ("request".equals(scope.getValue())) {
        request.removeAttribute(attribute.getValue());
      } else {
        throw new ConfigException("Bad scope '" +  scope.getValue() + "' in " + filterConfig.toInlineString());
      }
    }
  }
View Full Code Here

TOP

Related Classes of de.odysseus.calyxo.control.conf.ParamConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.