private void attemptImplementationLoad() { if ( implementationClass == null && getImplementation() != null && getRealm() != null ) { try { implementationClass = (Class<? extends T>) getRealm().loadClass( getImplementation() ); Thread.currentThread(); } catch ( Throwable ignored ) { Thread.currentThread(); } } }
public void start( Object component ) throws PhaseExecutionException { startId = NEXT_START_ID.getAndIncrement(); getLifecycleHandler().start( component, this, componentDescriptor.getRealm() ); }
public void addComponentDescriptor( ComponentDescriptor<?> componentDescriptor ) throws CycleDetectedInComponentGraphException { ClassRealm classRealm = componentDescriptor.getRealm(); SortedMap<String, Multimap<String, ComponentDescriptor<?>>> roleIndex = index.get( classRealm ); if (roleIndex == null) { roleIndex = new TreeMap<String, Multimap<String, ComponentDescriptor<?>>>(); index.put(classRealm, roleIndex); } String role = componentDescriptor.getRole(); Multimap<String, ComponentDescriptor<?>> roleHintIndex = roleIndex.get( role ); if ( roleHintIndex == null ) { roleHintIndex = LinkedHashMultimap.create(); roleIndex.put( role, roleHintIndex ); } roleHintIndex.put( componentDescriptor.getRoleHint(), componentDescriptor ); compositionResolver.addComponentDescriptor( componentDescriptor ); } }
@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 void addComponentDescriptor( ComponentDescriptor<?> componentDescriptor ) throws CycleDetectedInComponentGraphException { if ( componentDescriptor.getRealm() == null ) { componentDescriptor.setRealm( this.containerRealm ); // throw new ComponentImplementationNotFoundException( "ComponentDescriptor is missing realmId" ); } componentRegistry.addComponentDescriptor( componentDescriptor ); }
this.realm = componentDescriptor.getRealm();
@SuppressWarnings("unchecked") public synchronized <T> void addComponent( T component, String role, String roleHint ) { ComponentDescriptor descriptor = new ComponentDescriptor(component.getClass(), null ); descriptor.setRole( role ); descriptor.setRoleHint( roleHint ); Key key = new Key( descriptor.getRealm(), role, roleHint ); unmanagedComponents.put( key, component ); }
public boolean equals( Object other ) { if ( this == other ) { return true; } if ( !( other instanceof ComponentDescriptor ) ) { return false; } ComponentDescriptor<?> that = (ComponentDescriptor<?>) other; return eq( getRole(), that.getRole() ) && eq( getRoleHint(), that.getRoleHint() ) && eq( getRealm(), that.getRealm() ); }
public int hashCode() { int hash = 17; hash = hash * 31 + hash( getRole() ); hash = hash * 31 + hash( getRoleHint() ); hash = hash * 31 + hash( getRealm() ); return hash; }
protected T createComponentInstance(ComponentDescriptor<T> descriptor, ClassRealm realm) throws ComponentInstantiationException, ComponentLifecycleException { MutablePlexusContainer container = getContainer(); if (realm == null) { realm = descriptor.getRealm();
public <T> void addComponentDescriptor( final ComponentDescriptor<T> descriptor ) { ClassRealm realm = descriptor.getRealm(); if ( null == realm ) { realm = containerRealm; descriptor.setRealm( realm ); } synchronized ( descriptorMap ) { List<ComponentDescriptor<?>> descriptors = descriptorMap.get( realm ); if ( null == descriptors ) { descriptors = new ArrayList<ComponentDescriptor<?>>(); descriptorMap.put( realm, descriptors ); } descriptors.add( descriptor ); } if ( containerRealm == realm ) { discoverComponents( containerRealm ); // for Maven3 testing } }