Package de.odysseus.calyxo.control.conf.impl

Source Code of de.odysseus.calyxo.control.conf.impl.DispatchConfigImpl

/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.control.conf.impl;

import de.odysseus.calyxo.control.conf.DispatchConfig;
import de.odysseus.calyxo.base.conf.ConfigException;

/**
* Dispatch configuration implementation.
*
* @author Christoph Beck
*/
public class DispatchConfigImpl extends ParamsConfigImpl implements DispatchConfig {
  private String name;
  private String module;
  private String path;
  private String action;
  private boolean redirect;
  private String dispatcher;

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_getDynamicAttributes()
   */
  protected String[] _getDynamicAttributes() {
    return new String[]{ "path" };
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_getElementName()
   */
  protected String _getElementName() {
    return "dispatch";
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_putAttributes(de.odysseus.calyxo.base.conf.impl.ConfigImpl.Attributes)
   */
  protected void _putAttributes(Attributes map) {
    super._putAttributes(map);
    map.put("name", getName());
    map.put("module", module);
    map.put("path", path);
    map.put("action", action);
    map.put("dispatcher", dispatcher);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_addChildren(de.odysseus.calyxo.base.conf.impl.ConfigImpl.Elements)
   */
  protected void _addChildren(Elements list) {
    super._addChildren(list);
    // no child elements
  }

  /**
   * Check that exactly one of <code>action</code> and <code>path</code>
   * is specified.
   * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_init()
   */
  protected void _init() throws ConfigException {
    super._init();
    if ((action == null) == (path == null)) {
      throw new ConfigException("Either path or action must be specified in dispatch '" + toInlineString() + "'");
    }
    if (path != null && module != null) {
      throw new ConfigException("Cannot specify module with path in dispatch '" + toInlineString());
    }
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.DispatchConfig#getName()
   */
  public String getName() {
    return name;
  }

  /**
   * Set name property
   */
  public void setName(String string) {
    name = string;
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.DispatchConfig#getModule()
   */
  public String getModule() {
    return module;
  }

  /**
   * Set target module
   */
  public void setModule(String string) {
    module = string;
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.DispatchConfig#getPath()
   */
  public String getPath() {
    return path;
  }

  /**
   * Set resource path
   */
  public void setPath(String string) {
    path = string;
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.DispatchConfig#getAction()
   */
  public String getAction() {
    return action;
  }

  /**
   * Set target action
   */
  public void setAction(String string) {
    action = string;
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.DispatchConfig#isRedirect()
   */
  public boolean isRedirect() {
    return redirect;
  }

  /**
   * Set redirection flag
   */
  public void setRedirect(boolean value) {
    redirect = value;
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.ActionConfig#getDispatcher()
   */
  public String getDispatcher() {
    return dispatcher;
  }

  /**
   * Set dispatcher name
   */
  public void setDispatcher(String string) {
    dispatcher = string;
  }
}
TOP

Related Classes of de.odysseus.calyxo.control.conf.impl.DispatchConfigImpl

TOP
Copyright © 2018 www.massapi.com. 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.