org.apache.avalon.framework.component (Avalon Framework API)
Keywords: org.apache.avalon.framework.component package

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package org.apache.avalon.framework.component

Deprecated: use the interfaces in the `org.apache.avalon.framework.service` package instead.

See:
Description

Interface Summary
Component | This interface identifies classes that can be used as `Components` by a `Composable`.
ComponentManager | A `ComponentManager` selects `Component`s based on a role.
ComponentSelector | A `ComponentSelector` selects `Component`s based on a hint.
Composable | A `Composable` class is one that needs to connect to software components using a "role" abstraction, thus not depending on particular implementations but on behavioral interfaces.
Recomposable | Deprecated. Deprecated with no replacement.

Class Summary
DefaultComponentManager | This class is a static implementation of a ComponentManager.
DefaultComponentSelector | This is the default implementation of the ComponentSelector.
WrapperComponentManager | This is a `ComponentManager` implementation that can wrap around a `ServiceManager` object effectively adapting a `ServiceManager` interface to a `ComponentManager` interface.
WrapperComponentSelector | This is a `ServiceSelector` implementation that can wrap around a legacy `ComponentSelector` object effectively adapting a `ComponentSelector` interface to a `ServiceSelector` interface.

Exception Summary
ComponentException | The exception thrown to indicate a problem with Components.

## Package org.apache.avalon.framework.component Description

Deprecated: use the interfaces in the `org.apache.avalon.framework.service` package instead. Interfaces and implementation of the component management services supporting container based management of componet lookup and decommissioning.

# Migration from This Package

The Avalon team has determined that the best way to remove the need for this package in projects that existed before the team deprecated the package is to use a dynamic proxy. There are two ways of defining a dynamic proxy: using JDK 1.3's dynamic proxy generation code, and using BCEL to write a special purpose proxy.

All the Avalon containers now employ this technique so that you can confidently remove all deprecation warnings from your code by removing the `Component` interface.

The code snippet below describes how to use JDK 1.3 to create a dynamic proxy at runtime. The method `getProxy` is where the proxy is actually created. The class `ComponentInvocationHandler` takes care of handling the method calls.

        /**
         * Get the Component wrapped in the proxy.  The role must be the service
         * interface's fully qualified classname to work.
         */
        public Component getProxy( String role, Object service ) throws Exception
        {
            Class serviceInterface = m_classLoader.loadClass( role );

            return (Component)Proxy.newProxyInstance( m_classLoader,
                                                      new Class[]{Component.class, serviceInterface},
                                                      new ComponentInvocationHandler( service ) );
        }

        /**
         * Internal class to handle the wrapping with Component
         */
        private final static class ComponentInvocationHandler
            implements InvocationHandler
        {
            private final Object m_delagate;

            public ComponentInvocationHandler( final Object delegate )
            {
                if( null == delegate )
                {
                    throw new NullPointerException( "delegate" );
                }

                m_delagate = delegate;
            }

            public Object invoke( final Object proxy,
                                  final Method meth,
                                  final Object[] args )
                throws Throwable
            {
                try
                {
                    return meth.invoke( m_delagate, args );
                }
                catch( final InvocationTargetException ite )
                {
                    throw ite.getTargetException();
                }
            }
        }

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

Copyright © The Apache Software Foundation. All Rights Reserved.