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

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

/*
* 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 java.util.HashMap;
import java.util.Iterator;

import de.odysseus.calyxo.control.conf.ExceptionHandlerConfig;
import de.odysseus.calyxo.control.conf.ExceptionHandlersConfig;
import de.odysseus.calyxo.base.conf.ConfigException;
import de.odysseus.calyxo.base.conf.impl.ConfigImpl;

/**
* Exception handlers configuration implementation.
*
* @author Christoph Beck
*/
public class ExceptionHandlersConfigImpl extends ConfigImpl implements ExceptionHandlersConfig {
  private HashMap exceptions = new HashMap();

  /**
   * Merge other exceptions element into the receiver.
   * Add all exception configs from other element.
   */
  void merge(ExceptionHandlersConfigImpl other) throws ConfigException {
    if (other != null) {
      Iterator otherExceptions = other.getExceptionHandlerConfigs();
      while (otherExceptions.hasNext()) {
        add((ExceptionHandlerConfigImpl)otherExceptions.next());
      }
    }
  }

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

  /*
   * (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);
    list.add(getExceptionHandlerConfigs());
  }

  /*
   * (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);
    // no attributes
  }

  /**
   * Add exception element.
   */
  public void add(ExceptionHandlerConfigImpl value) throws ConfigException {
    if (exceptions.containsKey(value.getType())) {
      throw new ConfigException("Duplicate exception type '" + value.getClassName() + "' in " + toInlineString());
    }
    exceptions.put(value.getType(), value);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.ExceptionHandlersConfig#getExceptionHandlerConfig(java.lang.String)
   */
  public ExceptionHandlerConfig getExceptionHandlerConfig(String type) {
    return (ExceptionHandlerConfig)exceptions.get(type);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.control.conf.ExceptionHandlersConfig#getExceptionHandlerConfigs()
   */
  public Iterator getExceptionHandlerConfigs() {
    return exceptions.values().iterator();
  }
}
TOP

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

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.