avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject [Proposal] AvailabilityAware
Date Fri, 30 Jul 2004 09:37:23 GMT

Gang,

I am now back to the Availability contract, where components can be aware of 
that its dependent components are NOT available at all times. 
I want to add this to Framework, suggesting ver 4.5, and the change AFAICT is 
100% compatible with both existing containers and existing components, as 
well as new components that implements the interface will still work in 
containers that doesn't support the feature.

This can be achieved by introducing a fairly simple interface and tying the 
semantics back to the ServiceManager.lookup(). Also needed is a new 
RuntimeException called UnavailableException, which will only throw by 
capable containers and only to components that are AvailableAware, if the 
component is still called after being unavailable. This exception could also 
be thrown if a component's method are called before the component becomes 
unavailable, potentially during the network layer.

You can find the interface below.

Rationale; Containers that supports dynamic loading/unloading, hot-deploy, 
networked components, and other situations where components can become 
intermittently unavailable for extended period of times, doesn't have any way 
to signal availability other than through a RuntimeException, which is not 
very graceful nor semantically specified at Framework level.

Please note that this proposal does NOT cover any ways for the component to 
signal its own, or other component's, availability. That is a container 
specific feature.

I will start looking into an implementation for Merlin about this as soon as I 
get a 'go ahead' with the Framework change.


package org.apache.avalon.framework.availability;

/** An Availability contract between the container and the component.
 *
 * <p>A component that implements AvailabilityAware, is capable to be notified
 * that components that it has previously looked up via the 
 * ServiceManager.lookup() method are made available and non-available, 
 * and can gracefully handle unavailability.</p>
 *
 * <p>Containers are only required to support this interface, if the
 * container supports dynamic loading/unloading of components, hot-deploys,
 * remote components and similar cases where components may disappear for
 * a shorter or longer period of time.</p>
 *
 * @since 4.5
 *
 * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
 * @version $Id$
 */
public interface AvailabilityAware
{
    /** Notification that component is available.
     * <p>The component that previously has been looked up in the
     * ServiceManager, using <i>key</i> is now available. This method 
     * can either be called after the componentUnavailable() method 
     * signalled that a component is no longer available, OR if 
     * the ServiceManager.lookup() returned a null (optional lookup)
     * indicating that the requested component didn't exist.</p>
     * <p>
     *   This method will NOT be called with a <i>key</i> argument that has
     *   not previously been used in a ServiceManager.lookup().
     * </p>
     * @param key The key that was used to lookup the component in the 
     *            ServiceManager earlier.
     */
    void componentAvailable( String key );
    
    /** Notification that component is no longer available.
     * <p>The component that previously has been looked up in the
     * ServiceManager, using <i>key</i> is no longer available. The 
     * container does not place any restrictions on how long the 
     * component will be unavailble, and the AvailabilityAware component 
     * must employ one or more strategies on how to gracefully handle 
     * short and long absences of dependent components. </p>
     * <p>
     *   This method will NOT be called with a <i>key</i> argument that has
     *   not previously been used in a ServiceManager.lookup().
     * </p>
     * @param key The key that was used to lookup the component in the 
     *            ServiceManager earlier.
     */
    void componentUnavailble( String key );
}

-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message