1 8 package org.codehaus.loom.components.util.metadata; 9 10 import java.util.ArrayList ; 11 import java.util.List ; 12 import org.apache.avalon.framework.parameters.Parameters; 13 import org.codehaus.dna.Configuration; 14 15 25 public class ComponentTemplate 26 { 27 28 public static final ComponentTemplate[] EMPTY_SET = new ComponentTemplate[ 0 ]; 29 30 34 private final String m_name; 35 36 41 private final String m_implementationKey; 42 43 44 private final DependencyDirective[] m_dependencies; 45 46 47 private final Parameters m_parameters; 48 49 50 private final Configuration m_configuration; 51 52 53 private final boolean m_disableProxy; 54 55 68 public ComponentTemplate( final String name, 69 final String implementationKey, 70 final DependencyDirective[] dependencies, 71 final Parameters parameters, 72 final Configuration configuration, 73 final boolean disableProxy ) 74 { 75 if( null == name ) 76 { 77 throw new NullPointerException ( "name" ); 78 } 79 if( null == dependencies ) 80 { 81 throw new NullPointerException ( "dependencies" ); 82 } 83 if( null == implementationKey ) 84 { 85 throw new NullPointerException ( "implementationKey" ); 86 } 87 88 m_name = name; 89 m_dependencies = dependencies; 90 m_parameters = parameters; 91 m_configuration = configuration; 92 m_implementationKey = implementationKey; 93 m_disableProxy = disableProxy; 94 } 95 96 101 public boolean isDisableProxy() 102 { 103 return m_disableProxy; 104 } 105 106 111 public String getName() 112 { 113 return m_name; 114 } 115 116 121 public String getImplementationKey() 122 { 123 return m_implementationKey; 124 } 125 126 131 public DependencyDirective[] getDependencies() 132 { 133 return m_dependencies; 134 } 135 136 141 public Parameters getParameters() 142 { 143 return m_parameters; 144 } 145 146 151 public Configuration getConfiguration() 152 { 153 return m_configuration; 154 } 155 156 161 public DependencyDirective getDependency( final String key ) 162 { 163 for( int i = 0; i < m_dependencies.length; i++ ) 164 { 165 if( m_dependencies[ i ].getKey().equals( key ) ) 166 { 167 return m_dependencies[ i ]; 168 } 169 } 170 171 return null; 172 } 173 174 180 public DependencyDirective[] getDependencies( final String key ) 181 { 182 final List result = new ArrayList (); 183 184 for( int i = 0; i < m_dependencies.length; i++ ) 185 { 186 final DependencyDirective dependency = m_dependencies[ i ]; 187 if( dependency.getKey().equals( key ) ) 188 { 189 result.add( dependency ); 190 } 191 } 192 193 return (DependencyDirective[])result. 194 toArray( new DependencyDirective[ result.size() ] ); 195 } 196 } 197 | Popular Tags |