1 55 56 package org.apache.avalon.framework.service; 57 58 import org.apache.avalon.framework.component.Component; 59 import org.apache.avalon.framework.component.ComponentException; 60 import org.apache.avalon.framework.component.ComponentSelector; 61 62 73 public class WrapperServiceSelector 74 implements ServiceSelector 75 { 76 79 private final ComponentSelector m_selector; 80 81 84 private final String m_key; 85 86 92 public WrapperServiceSelector( final String key, 93 final ComponentSelector selector ) 94 { 95 if( null == key ) 96 { 97 throw new NullPointerException ( "key" ); 98 } 99 if( null == selector ) 100 { 101 throw new NullPointerException ( "selector" ); 102 } 103 104 m_key = key + "/"; 105 m_selector = selector; 106 } 107 108 115 public Object select( final Object policy ) 116 throws ServiceException 117 { 118 try 119 { 120 return m_selector.select( policy ); 121 } 122 catch( final ComponentException ce ) 123 { 124 throw new ServiceException( m_key + policy, ce.getMessage(), ce ); 125 } 126 } 127 128 134 public boolean isSelectable( final Object policy ) 135 { 136 return m_selector.hasComponent( policy ); 137 } 138 139 148 public void release( Object object ) 149 { 150 m_selector.release( (Component)object ); 151 } 152 153 160 ComponentSelector getWrappedSelector() 161 { 162 return m_selector; 163 } 164 } 165 | Popular Tags |