1 17 18 package org.apache.avalon.fortress.impl.handler; 19 20 import org.apache.avalon.fortress.util.LifecycleExtensionManager; 21 import org.apache.avalon.framework.activity.Disposable; 22 import org.apache.avalon.framework.container.ContainerUtil; 23 import org.apache.avalon.framework.context.Context; 24 25 32 public final class LEAwareComponentHandler 33 implements ComponentHandler, Disposable 34 { 35 private final ComponentHandler m_componentHandler; 36 private final LifecycleExtensionManager m_extManager; 37 private final Context m_context; 38 39 45 public LEAwareComponentHandler( final ComponentHandler componentHandler, 46 final LifecycleExtensionManager extManager, 47 final Context context ) 48 { 49 if ( null == componentHandler ) 50 { 51 throw new NullPointerException ( "componentHandler" ); 52 } 53 if ( null == extManager ) 54 { 55 throw new NullPointerException ( "extManager" ); 56 } 57 if ( null == context ) 58 { 59 throw new NullPointerException ( "context" ); 60 } 61 62 m_componentHandler = componentHandler; 63 m_extManager = extManager; 64 m_context = context; 65 } 66 67 73 public Class getComponentClass() 74 { 75 return m_componentHandler.getComponentClass(); 76 } 77 78 82 public void prepareHandler() 83 throws Exception 84 { 85 m_componentHandler.prepareHandler(); 86 } 87 88 94 public Object get() throws Exception 95 { 96 final Object object = m_componentHandler.get(); 97 m_extManager.executeAccessExtensions( object, m_context ); 98 return object; 99 } 100 101 106 public void put( final Object component ) 107 { 108 try 109 { 110 m_extManager.executeReleaseExtensions( component, m_context ); 111 } 112 catch ( Exception e ) 113 { 114 } 116 m_componentHandler.put( component ); 117 } 118 119 122 public void dispose() 123 { 124 ContainerUtil.dispose( m_componentHandler ); 125 } 126 } 127 | Popular Tags |