001/*
002 *  Copyright 2023 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.runtime.plugin.component;
017
018import org.apache.avalon.framework.service.ServiceException;
019import org.apache.avalon.framework.service.ServiceManager;
020import org.apache.avalon.framework.service.Serviceable;
021
022/**
023 * Just like a {@link Serviceable}, a DeferredServiceable is a component that need to connect to other components. <br>
024 * Unlike a standard {@link Serviceable}, which {@link Serviceable#service(ServiceManager)} method is called during component initialization,
025 * the {@link #deferredService(ServiceManager)} method of a DeferredServiceable is called *after* component initialization.<br>
026 * The drawback is that it cannot use other components during initialization.<br>
027 * This interface is mainly used to avoid circular dependencies during initialization.
028 */
029public interface DeferredServiceable
030{
031    /**
032     * Pass the {@link ServiceManager} used to access other components.
033     * @param manager The {@link ServiceManager} which this {@link DeferredServiceable} uses. Must not be <code>null</code>.
034     * @throws ServiceException if an error occurs
035     */
036    public void deferredService(ServiceManager manager) throws ServiceException;
037}