role, roleHints, componentDescriptor.getHumanReadableKey()); role, roleHints, componentDescriptor.getHumanReadableKey()); } else if (Logger.class.equals(propertyType)) { assignment = container.getLoggerManager().getLoggerForComponent(componentDescriptor.getRole()); } else if (PlexusContainer.class.equals(propertyType)) { + "in object of type " + componentDescriptor.getImplementation() + " because the requirement " + requirement + " was missing)", e);
cd = new ComponentDescriptor(implementationClass, realm); cd = new ComponentDescriptor(); cd.setImplementation( implementation ); cd.setRole( configuration.getChild( "role" ).getValue() ); cd.setRoleHint( configuration.getChild( "role-hint" ).getValue() ); cd.setVersion( configuration.getChild( "version" ).getValue() ); cd.setComponentType( configuration.getChild( "component-type" ).getValue() ); cd.setInstantiationStrategy( configuration.getChild( "instantiation-strategy" ).getValue() ); cd.setLifecycleHandler( configuration.getChild( "lifecycle-handler" ).getValue() ); cd.setComponentProfile( configuration.getChild( "component-profile" ).getValue() ); cd.setComponentComposer( configuration.getChild( "component-composer" ).getValue() ); cd.setComponentConfigurator( configuration.getChild( "component-configurator" ).getValue() ); cd.setComponentFactory( configuration.getChild( "component-factory" ).getValue() ); cd.setDescription( configuration.getChild( "description" ).getValue() ); cd.setAlias( configuration.getChild( "alias" ).getValue() );
overrideDom = Xpp3DomBuilder.build( new StringReader( override.getConfiguration().toString() ) ); if ( target.getConfiguration() != null ) targetDom = Xpp3DomBuilder.build( new StringReader( target.getConfiguration().toString() ) ); target.setConfiguration( new XmlPlexusConfiguration( targetDom ) );
public PlexusConfiguration getConfiguration( ComponentDescriptor componentDescriptor ) { if ( componentDescriptor.hasConfiguration() ) { return componentDescriptor.getConfiguration(); } return null; } }
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() ); }
ComponentDescriptor<?> componentDescriptor = new ComponentDescriptor<Object>(); componentDescriptor.setImplementation( fqn ); componentDescriptor.setRole( role ); componentDescriptor.setRoleHint( roleHint ); componentDescriptor.setVersion( version ); componentDescriptor.setLifecycleHandler( lifecycleHandler ); componentDescriptor.setInstantiationStrategy( instatiationStrategy ); componentDescriptor.setAlias( getParameter( parameters, PLEXUS_ALIAS_PARAMETER ) ); componentDescriptor.setDescription( comment ); componentDescriptor.setConfiguration( configuration );
new org.codehaus.plexus.component.repository.ComponentDescriptor(); pcd.setRole(componentDescriptor.getRole().getName()); pcd.setRoleHint(componentDescriptor.getRoleHint()); pcd.setImplementation(componentDescriptor.getImplementation().getName()); pcd.setInstantiationStrategy("per-lookup"); break; default: pcd.setInstantiationStrategy("singleton"); requirement.setFieldName(dependency.getName()); pcd.addRequirement(requirement);
public void customize(PlexusContainer plexusContainer) { try { ComponentDescriptor desc = new ComponentDescriptor(); desc.setRole(TransferListener.class.getName()); plexusContainer.addComponentDescriptor(desc); desc.setImplementation("org.codehaus.mevenide.netbeans.embedder.exec.ProgressTransferListener"); //NOI18N desc = plexusContainer.getComponentDescriptor(WagonManager.ROLE); ComponentRequirement requirement = new ComponentRequirement(); requirement.setRole(TransferListener.class.getName()); desc.addRequirement(requirement); //MEVENIDE-634 desc = plexusContainer.getComponentDescriptor(KnownHostsProvider.ROLE, "file"); desc.getConfiguration().getChild("hostKeyChecking").setValue("no"); //MEVENIDE-634 desc = plexusContainer.getComponentDescriptor(KnownHostsProvider.ROLE, "null"); desc.getConfiguration().getChild("hostKeyChecking").setValue("no"); } catch (ComponentRepositoryException ex) { ex.printStackTrace(); } } });
ComponentDescriptor cd = new ComponentDescriptor(); cd.setRole( LoggerManager.ROLE ); cd.setRoleHint( PlexusConstants.PLEXUS_DEFAULT_HINT ); cd.setImplementation( ConsoleLoggerManager.class.getName() );
element( w, "role", cd.getRole() ); element( w, "role-hint", cd.getRoleHint() ); element( w, "implementation", cd.getImplementation() ); element( w, "version", cd.getVersion() ); element( w, "component-type", cd.getComponentType() ); element( w, "instantiation-strategy", cd.getInstantiationStrategy() ); element( w, "lifecycle-handler", cd.getLifecycleHandler() ); element( w, "component-profile", cd.getComponentProfile() ); element( w, "component-composer", cd.getComponentComposer() ); element( w, "component-configurator", cd.getComponentConfigurator() ); element( w, "component-factory", cd.getComponentFactory() ); element( w, "description", cd.getDescription() ); element( w, "alias", cd.getAlias() ); element( w, "isolated-realm", Boolean.toString( cd.isIsolatedRealm() ) ); writeRequirements( w, cd.getRequirements() );
public String toString() { return getClass().getName() + " [role: '" + getRole() + "', hint: '" + getRoleHint() + "', realm: " + ( realm == null ? "NULL" : "'" + realm + "'" ) + "]"; }
private void writeComponents( XMLWriter w, List componentDescriptors ) throws ComponentDescriptorCreatorException, PlexusConfigurationException { w.startElement( "components" ); for ( Iterator i = componentDescriptors.iterator(); i.hasNext(); ) { w.startElement( "component" ); ComponentDescriptor cd = (ComponentDescriptor) i.next(); element( w, "role", cd.getRole() ); element( w, "role-hint", cd.getRoleHint() ); element( w, "implementation", cd.getImplementation() ); element( w, "instantiation-strategy", cd.getInstantiationStrategy() ); element( w, "lifecycle-handler", cd.getLifecycleHandler() ); writeRequirements( w, cd.getRequirements() ); writeConfiguration( w, cd.getConfiguration() ); w.endElement(); } w.endElement(); }
ComponentDescriptor<ConfigurationSource> cd = new ComponentDescriptor<ConfigurationSource>(); cd.setRole( ConfigurationSource.ROLE ); cd.setRoleHint( PlexusConstants.PLEXUS_DEFAULT_HINT ); cd.setImplementationClass( context.getContainer().getConfigurationSource().getClass() );
@SuppressWarnings("unchecked") private <T> ComponentDescriptor<T> createXWikiComponentDescriptor( org.codehaus.plexus.component.repository.ComponentDescriptor pcd) { DefaultComponentDescriptor<T> descriptor = null; if (pcd != null) { descriptor = new DefaultComponentDescriptor<T>(); descriptor.setImplementation((Class< ? extends T>) loadClass(pcd.getImplementation())); descriptor.setRoleHint(pcd.getRoleHint()); descriptor.setRole((Class<T>) loadClass(pcd.getRole())); if ("per-lookup".equals(pcd.getInstantiationStrategy())) { descriptor.setInstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP); } else { descriptor.setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON); } // Copy dependencies for (ComponentRequirement requirement : (List<ComponentRequirement>) pcd.getRequirements()) { DefaultComponentDependency dependency = new DefaultComponentDependency(); dependency.setRole(loadClass(requirement.getRole())); dependency.setRoleHint(requirement.getRoleHint()); dependency.setMappingType(loadClass(requirement.getFieldMappingType())); dependency.setName(requirement.getFieldName()); // TODO: Handle specific hints when we move to a more recent Plexus version. // See createPlexusComponentDescriptor descriptor.addComponentDependency(dependency); } } return descriptor; }
Class[] constructorArgTypes = null; Class<?> implClass = ( instance != null ) ? instance.getClass() : descriptor.getImplementationClass(); realm.loadClass( descriptor.getImplementation() ); + descriptor.getHumanReadableKey() + " from class realm " + realm, e ); + descriptor.getHumanReadableKey() + " from class realm " + realm, e ); for (ComponentRequirement requirement : descriptor.getRequirements() ) { String name = requirement.getFieldName(); RequirementRecipe requirementRecipe = new RequirementRecipe(descriptor, requirement, getContainer(), name == null); PlexusConfiguration configuration = descriptor.getConfiguration(); if (configuration != null) { for (String name : configuration.getAttributeNames()) {
componentDescriptor.setComponentSetDescriptor( componentSet ); ComponentDescriptor orig = container.getComponentDescriptor( componentDescriptor.getRole(), componentDescriptor.getRoleHint(), realm ); componentDescriptor.setRealmId( realm.getId() ); 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: " + orig.getConfiguration() ); 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: " + orig.getConfiguration() );
@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 ); }
/** * Returns a human-friendly key, suitable for display. * * @return a human-friendly key */ public String getHumanReadableKey() { StringBuilder key = new StringBuilder(); key.append( "role: '" ).append( getRole() ).append( "'" ); key.append( ", implementation: '" ).append( getImplementation() ).append( "'" ); if ( roleHint != null ) { key.append( ", role hint: '" ).append( getRoleHint() ).append( "'" ); } if ( alias != null ) { key.append( ", alias: '" ).append( getAlias() ).append( "'" ); } return key.toString(); }
String implementation = componentDescriptor.getImplementation();