/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container;
import org.jicarilla.lang.Switch;
/**
* Represents the contract between a {@link DefaultContainer} or
* {@link DefaultKeyRelayingContainer} and the associated {@link Resolver}.
* This class is not part of the public API on purpose -- it is an
* implementation detail associated with the way the default implementation
* package divides functionality.
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: ResolverCallback.java,v 1.3 2004/03/23 13:37:51 lsimons Exp $
*/
public interface ResolverCallback
{
/**
* Called by the resolver to retrieve a reference to the {@link Switch}
* that contains the mapping from keys to adapters used by the container.
* The reference that is retrieved should not be stored in the resolver.
*
* @return the reference to the switch that contains the mapping from keys
* to adapters used by the container.
*/
Switch getSwitch();
/**
* Called by the resolver whenever it retrieves an instance from an
* adapter that it retrieved from the switch provided by
* {@link #getSwitch()}.
*
* @param instance the instance that was retrieved.
* @param adapter the adapter from which the instance was retrieved.
*/
void providedInstance( Object instance, Object adapter );
/**
* Called by the resolver whenever an instance retrieved from an adapter
* that was retrieved from the switch provided by {@link #getSwitch()}
* needs to be returned.
*
* @param instance the instance that was retrieved.
* @throws Exception if {@link Adapter#releaseInstance(Object)}
* throws an exception. The container should not normally throw
* an Exception otherwise.
*/
void returnedInstance( Object instance ) throws Exception;
}
|