1 8 package org.apache.avalon.excalibur.system; 9 10 import java.util.Collections ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 import org.apache.avalon.framework.configuration.Configurable; 14 import org.apache.avalon.framework.configuration.Configuration; 15 import org.apache.avalon.framework.configuration.ConfigurationException; 16 import org.apache.avalon.framework.logger.AbstractLoggable; 17 18 27 public class ConfigurableRoleManager 28 extends AbstractRoleManager 29 implements Configurable 30 { 31 34 public ConfigurableRoleManager() 35 { 36 super( null ); 37 } 38 39 40 46 public ConfigurableRoleManager(RoleManager parent) 47 { 48 super( parent, Thread.currentThread().getContextClassLoader() ); 49 } 50 51 57 public ConfigurableRoleManager(RoleManager parent, ClassLoader loader) 58 { 59 super( parent, loader ); 60 } 61 62 63 70 public final void configure( final Configuration configuration ) 71 throws ConfigurationException 72 { 73 final Map shorts = new HashMap (); 74 final Map classes = new HashMap (); 75 final Map handlers = new HashMap (); 76 final Map hintclasses = new HashMap (); 77 78 final Configuration[] roles = configuration.getChildren( "role" ); 79 80 for( int i = 0; i < roles.length; i++ ) 81 { 82 final String role = roles[ i ].getAttribute( "name" ); 83 Configuration[] components = roles[i].getChildren( "component" ); 84 85 for ( int j = 0; i < components.length; j++) 86 { 87 final String shorthand = components[ j ].getAttribute( "shorthand" ); 88 final String className = 89 components[ j ].getAttribute( "class", null ); 90 final String handlerClassName = 91 components[ j ].getAttribute( "handler", 92 "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" ); 93 94 setup( shorts, classes, handlers, shorthand, role, className, handlerClassName ); 95 } 96 } 97 98 m_shorthands = Collections.unmodifiableMap( shorts ); 99 m_classNames = Collections.unmodifiableMap( classes ); 100 m_handlerNames = Collections.unmodifiableMap( handlers ); 101 } 102 } 103 | Popular Tags |