public ComponentRepository getComponentRepository() { if ( componentRepository == null ) { componentRepository = new DefaultComponentRepository(); } return componentRepository; }
public <T> List<ComponentDescriptor<T>> getComponentDescriptorList( Class<T> type, String role ) { List<ComponentDescriptor<T>> descriptors = new ArrayList<ComponentDescriptor<T>>(); for ( ComponentDescriptor<?> descriptor : getComponentDescriptors( role ).values() ) { if ( isAssignableFrom( type, descriptor.getImplementationClass() ) ) { descriptors.add( (ComponentDescriptor<T>) descriptor ); } } return descriptors; }
private void initializeComponentDescriptorsFromUserConfiguration() throws ComponentRepositoryException { PlexusConfiguration[] componentConfigurations = configuration.getChild( COMPONENTS ).getChildren( COMPONENT ); for ( int i = 0; i < componentConfigurations.length; i++ ) { addComponentDescriptor( componentConfigurations[i] ); } }
public void initializeComponentDescriptors() throws ComponentRepositoryException { initializeComponentDescriptorsFromUserConfiguration(); }
public void initialize() throws ComponentRepositoryException { initializeComponentDescriptors(); }
public ComponentDescriptor getComponentDescriptor( String role, ClassRealm realm ) { return getComponentDescriptor( role, PlexusConstants.PLEXUS_DEFAULT_HINT, realm ); }
public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException { try { validateComponentDescriptor( componentDescriptor ); } catch ( ComponentImplementationNotFoundException e ) { throw new ComponentRepositoryException( "Component descriptor validation failed: ", e ); } Map maps = componentRealmDescriptorMaps.getRealmMap( componentDescriptor.getRealmId() ); String role = componentDescriptor.getRole(); String roleHint = componentDescriptor.getRoleHint(); Map map = (Map) maps.get( role ); if ( map == null ) { map = new HashMap(); maps.put( role, map ); } map.put( roleHint, componentDescriptor ); try { compositionResolver.addComponentDescriptor( componentDescriptor ); } catch ( CompositionException e ) { throw new ComponentRepositoryException( e.getMessage(), e ); } }
public void addComponentDescriptor( PlexusConfiguration configuration ) throws ComponentRepositoryException { ComponentDescriptor componentDescriptor = null; try { componentDescriptor = PlexusTools.buildComponentDescriptor( configuration ); } catch ( PlexusConfigurationException e ) { throw new ComponentRepositoryException( "Cannot unmarshall component descriptor:", e ); } componentDescriptor.setRealmId( classRealm.getId() ); addComponentDescriptor( componentDescriptor ); }
public ComponentRepository getComponentRepository() { if ( componentRepository == null ) { componentRepository = new DefaultComponentRepository(); } return componentRepository; }
@Deprecated public ComponentDescriptor<?> getComponentDescriptor( String role, String roleHint, ClassRealm realm ) { // find all realms from our realm to the root realm Set<ClassRealm> realms = new HashSet<ClassRealm>(); for ( ClassRealm r = realm; r != null; r = r.getParentRealm() ) { realms.add( r ); } // get the component descriptors by roleHint for ( ComponentDescriptor<?> componentDescriptor : getComponentDescriptors( role ).get( roleHint ) ) { // return the first descriptor from our target realms if ( realms.contains( componentDescriptor.getRealm() ) ) { return componentDescriptor; } } return null; }
public <T> Map<String, ComponentDescriptor<T>> getComponentDescriptorMap( Class<T> type, String role ) { Map<String, ComponentDescriptor<T>> descriptors = new TreeMap<String, ComponentDescriptor<T>>(); for ( ComponentDescriptor<?> descriptor : getComponentDescriptors( role ).values() ) { if ( !descriptors.containsKey( descriptor.getRoleHint() ) ) { if ( isAssignableFrom( type, descriptor.getImplementationClass() ) ) { descriptors.put( descriptor.getRoleHint(), (ComponentDescriptor<T>) descriptor ); } } } return descriptors; }
public <T> ComponentDescriptor<T> getComponentDescriptor( Class<T> type, String role, String roleHint ) Multimap<String, ComponentDescriptor<?>> roleHintIndex = getComponentDescriptors( role );