public Object get( Object key ) { Map descriptorMap = getComponentDescriptorMap(); if ( descriptorMap.containsKey( key ) ) { Map lookupRealms = getLookupRealmMap(); ComponentDescriptor desc = (ComponentDescriptor) descriptorMap.get( key ); ClassRealm realm = (ClassRealm) lookupRealms.get( desc.getRealmId() ); return lookup( role, (String) key, realm ); } return null; }
public void validateComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentImplementationNotFoundException { if ( componentDescriptor.getRealmId() == null ) { // component descriptors are required to have a realmId set. componentDescriptor.setRealmId( classRealm.getId() ); // log.warn( "Componentdescriptor " + componentDescriptor + " is missing realmId - using " + // componentDescriptor.getRealmId() ); // throw new ComponentImplementationNotFoundException( "ComponentDescriptor is missing realmId" ); } // Make sure the component implementation classes can be found. // Make sure ComponentManager implementation can be found. // Validate lifecycle. // Validate the component configuration. // Validate the component profile if one is used. }
ClassRealm realm = (ClassRealm) lookupRealms.get( cd.getRealmId() ); String realmId = ( (ComponentDescriptor) entry.getValue() ).getRealmId();
ClassRealm realm = (ClassRealm) lookupRealms.get( cd.getRealmId() ); String realmId = ( (ComponentDescriptor) entry.getValue() ).getRealmId();
public Object getComponent( ClassRealm realm ) throws ComponentInstantiationException, ComponentLifecycleException { synchronized( lock ) { Object singleton = findSingleton( realm ); if ( singleton == null ) { singleton = createComponentInstance( realm ); if ( getLogger() != null ) { getLogger().debug( "Registering at " + componentDescriptor.getRealmId() + ": " + singleton.getClass().getName() + " (object realm: " + singleton.getClass().getClassLoader() + "), lookuprealm=" + realm.getId() ); } singletonMap.put( componentDescriptor.getRealmId(), singleton ); } incrementConnectionCount(); return singleton; } }
protected Object createComponentInstance(ComponentDescriptor descriptor, ClassRealm realm) throws ComponentInstantiationException, ComponentLifecycleException { MutablePlexusContainer container = getContainer(); if (realm == null) { realm = container.getComponentRealm(descriptor.getRealmId());
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 ComponentManager createComponentManager( ComponentDescriptor descriptor, MutablePlexusContainer container, String role, String roleHint ) throws UndefinedComponentManagerException, UndefinedLifecycleHandlerException { String componentManagerId = descriptor.getInstantiationStrategy(); ComponentManager componentManager; if ( componentManagerId == null ) { componentManagerId = defaultComponentManagerId; } componentManager = copyComponentManager( componentManagerId ); componentManager.setup( container, findLifecycleHandler( descriptor ), descriptor ); componentManager.initialize(); if ( StringUtils.equals( role, descriptor.getRole() ) && StringUtils.equals( roleHint, descriptor.getRoleHint() ) ) { activeComponentManagers.put( descriptor.getRealmId() + "/" + descriptor.getRole() + "/" + descriptor.getRoleHint(), componentManager ); } else { activeComponentManagers.put( descriptor.getRealmId() + "/" + role + "/" + roleHint, componentManager ); } return componentManager; }
if ( orig.getRealmId() != null && !orig.getRealmId().equals( componentDescriptor.getRealmId() ) ) "Duplicate component found, merging:" + "\n Original: " + orig.getRealmId() + ": " + orig.getRole() + " [" + orig.getRoleHint() + "] impl=" + orig.getImplementation() + "\n Config: " + orig.getConfiguration() + "\n New: " + componentDescriptor.getRealmId() + ": " + componentDescriptor.getRole() + " [" + orig.getRoleHint() + "] impl=" + componentDescriptor.getImplementation() + "\n Config: " else if ( orig.getRealmId() != null && orig.getRealmId().equals( componentDescriptor.getRealmId() ) ) + orig.getRealmId() + ": " + orig.getRole() + " [" + orig.getRoleHint() + "] impl=" + orig.getImplementation() + "\n Config: " + orig.getConfiguration() + "\n New: " + componentDescriptor.getRealmId() + ": " + componentDescriptor.getRole() + " [" + orig.getRoleHint() + "] impl=" + componentDescriptor.getImplementation() + "\n Config: "
componentRealm = container.getComponentRealm( componentDescriptor.getRealmId() );
ClassRealm realm = manager.getContainer().getComponentRealm( manager.getComponentDescriptor().getRealmId() );