/**
 * Copyright (c) 2005-2012 EBM WebSourcing, 2012-2015 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.microkernel.container;

import org.objectweb.fractal.api.Component;
import org.ow2.petals.basisapi.exception.PetalsException;
import org.ow2.petals.jbi.descriptor.original.generated.Jbi.SharedLibrary;
import org.ow2.petals.jbi.descriptor.original.generated.ServiceAssembly;

/**
 * This {@link ContainerService} interface allow to create and handle JBI containers.
 * @author Nicolas SALATGE - EBM WebSourcing
 */
public interface ContainerService {
    

    static final String COMPONENT_LOGGER_PREFIX = "Petals.Container.Components";
    
    /**
     * Prefix of the installler name.
     */
    static final String PREFIX_INSTALLER_NAME = "Installer.";

    /**
     * Prefix of the component life cycle name.
     */
    static final String PREFIX_COMPONENT_LIFE_CYCLE_NAME = "ComponentLifeCycle.";

    /**
     * Prefix of the service assembly life cycle name.
     */
    static final String PREFIX_SERVICE_ASSEMBLY_LIFE_CYCLE_NAME = "ServiceAssemblyLifeCycle.";

    /**
     * Prefix of the shared library life cycle name.
     */
    static final String PREFIX_SHARED_LIBRARY_LIFE_CYCLE_NAME = "SharedLibraryLifeCycle.";

    /**
     * Create an installer from the component description of the component.
     * @param componentDescription
     *            the component description of the component
     * @return the fractal component of the installer
     * @throws PetalsException : occurs when it is impossible to create an installer
     */
    Component createInstaller(org.ow2.petals.jbi.descriptor.original.generated.Component componentDescription)
            throws PetalsException;

    /**
     * Remove an installer from the name of the component.
     * @param name
     *            the name of the component
     * @throws PetalsException : occurs when it is impossible to remove an installer
     */
    void removeInstaller(String name) throws PetalsException;

    /**
     * Create a component life cycle from the component description of the component.
     * @param componentDescription
     *            the component description of the component
     * @return the fractal component of the component life cycle
     * @throws PetalsException : occurs when it is impossible to create a component life cycle
     */
    Component createComponentLifeCycle(
            org.ow2.petals.jbi.descriptor.original.generated.Component componentDescription) throws PetalsException;

    /**
     * Remove a component life cycle from the component description of the component.
     * @param componentDescription
     *            the component description of the component
     * @throws PetalsException : occurs when it is impossible to remove a component life cycle
     */
    void removeComponentLifeCycle(
            org.ow2.petals.jbi.descriptor.original.generated.Component componentDescription) throws PetalsException;

    /**
     * Get the container component.
     * @return the parent component (the fractal container)
     */
    Component getParentContainer();

    /**
     * Create a service assembly life cycle.
     * It is realize from the component description of the component.
     * @param sa
     *            the service assembly of the component
     * @return the fractal component of the service assembly life cycle
     * @throws PetalsException : occurs when it is impossible to create a service assembly
     */
    Component createServiceAssemblyLifeCycle(ServiceAssembly sa) throws PetalsException;

    /**
     * remove a service assembly life cycle Fractal component.
     * 
     * @param sa
     *            the service assembly name
     * @throws PetalsException
     *             occurs when it is impossible to remove a service assembly
     *             life cycle Fractal component
     */
    void removeServiceAssemblyLifeCycle(final String saName) throws PetalsException;


    /**
     * Create a shared library life cycle component.
     * @param sl
     *            the shared library
     * @return the fractal component of the shared library
     * @throws PetalsException : occurs when it is impossible to create a shared library
     */
    Component createSharedLibraryLifeCycle(SharedLibrary sl)
            throws PetalsException;

    /**
     * Remove a shared library life cycle Fractal component.
     * 
     * @param slName
     *            the shared library name
     * @throws PetalsException
     *             occurs when it is impossible to remove a shared library life
     *             cycle Fractal component
     */
    void removeSharedLibraryLifeCycle(String slName) throws PetalsException;

}
