/**
 * Copyright (c) 2009-2012 EBM WebSourcing, 2012-2013 Linagora
 * 
 * This program/library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * This program/library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program/library; If not, see <http://www.gnu.org/licenses/>
 * for the GNU Lesser General Public License version 2.1.
 */
package org.ow2.petals.se.validation;

import java.util.concurrent.ConcurrentHashMap;

import org.ow2.petals.component.framework.bc.AbstractBindingComponent;
import org.ow2.petals.component.framework.su.AbstractServiceUnitManager;
import org.ow2.petals.se.validation.model.ValidationConfigurationHandler;

/**
 * @author Roland Naudin - EBM WebSourcing
 * @author Vincent Zurczak - EBM WebSourcing
 */
public class ValidationSe extends AbstractBindingComponent {

	/**
	 * This map is used to get the Validation configuration associated with an end-point name.
	 */
	private final ConcurrentHashMap<String,ValidationConfigurationHandler> endpointNameToValidationConfigurationHandler =
		new ConcurrentHashMap<String,ValidationConfigurationHandler> ();


	/*
	 * (non-Javadoc)
	 * @see org.ow2.petals.component.framework.bc.AbstractBindingComponent
	 * #createServiceUnitManager()
	 */
	@Override
	protected AbstractServiceUnitManager createServiceUnitManager() {
		return new ValidationSuManager( this );
	}


	/**
	 * @param endpointName the end-point name
	 * @param ValidationConfigurationHandler the Validation configuration handler
	 * @return the previous Validation configuration handler that was registered for this end-point name
	 * @see java.util.concurrent.ConcurrentHashMap#put(java.lang.Object, java.lang.Object)
	 */
	public ValidationConfigurationHandler registerValidationConfigurationHandler(
			String endpointName,
			ValidationConfigurationHandler ValidationConfigurationHandler ) {

		return this.endpointNameToValidationConfigurationHandler.put( endpointName, ValidationConfigurationHandler );
	}


	/**
	 * @param endpointName the end-point name
	 * @return the Validation configuration handler that was registered for this end-point name
	 * @see java.util.concurrent.ConcurrentHashMap#remove(java.lang.Object)
	 */
	public ValidationConfigurationHandler removeValidationConfigurationHandler( String endpointName ) {
		return this.endpointNameToValidationConfigurationHandler.remove( endpointName );
	}


	/**
	 * @param endpointName the end-point name
	 * @return the Validation configuration handler associated with this end-point name
	 * @see java.util.Map#get(java.lang.Object)
	 */
	public ValidationConfigurationHandler getValidationConfigurationHandler( String endpointName ) {
		return this.endpointNameToValidationConfigurationHandler.get( endpointName );
	}
}
