@SuppressWarnings( "unchecked" ) public Class<T> load() { return (Class<T>) space.loadClass( name ); }
@Override protected synchronized Class<?> loadClass( final String name, final boolean resolve ) throws ClassNotFoundException { if ( !name.contains( CLONE_MARKER ) ) { return space.loadClass( name ); } return super.loadClass( name, resolve ); }
public Component getComponent( final ClassSpace space ) { return null != role ? new ComponentImpl( space.loadClass( role ), hint, strategy, description ) : null; } }
@Override public AnnotationVisitor visitAnnotation( final String desc, final boolean visible ) { if ( null != clazzName ) { final Class<Annotation> qualifierType = qualifierCache.qualify( space, desc ); if ( null != qualifierType ) { if ( null == clazz ) { clazz = space.loadClass( clazzName.replace( '/', '.' ) ); } listener.hear( clazz.getAnnotation( qualifierType ), clazz, location.toString() ); } } return null; } }
/** * Attempts to load the potential {@link Qualifier} annotation and return its class. * * @param space The class space * @param desc The annotation descriptor * @return Qualified annotation class; {@code null} if the annotation is not a qualifier */ @SuppressWarnings( "unchecked" ) public Class<Annotation> qualify( final ClassSpace space, final String desc ) { if ( !cachedResults.containsKey( desc ) ) { isQualified = false; final String name = desc.substring( 1, desc.length() - 1 ); ClassSpaceScanner.accept( this, space.getResource( name + ".class" ) ); cachedResults.put( desc, isQualified ? space.loadClass( name.replace( '/', '.' ) ) : null ); } return (Class<Annotation>) cachedResults.get( desc ); }
/** * Attempts to load the given Plexus role, checks constructors for concrete types. * * @param role The Plexus role * @param implementation The implementation * @return Loaded Plexus role */ private Class<?> loadRole( final String role, final String implementation ) { try { final Class<?> clazz = space.loadClass( role ); if ( implementation.equals( role ) ) { // direct binding, make sure it's valid InjectionPoint.forConstructorOf( clazz ); } return clazz; } catch ( final Throwable e ) { if ( LOGGER.isLoggable( Level.FINE ) ) { LOGGER.fine( "Ignoring Plexus role: " + role + " cause: " + e ); } } return null; }
/** * Get the live annotated element. * @return a {@link Class}, {@link Method}, or {@link Field} * @throws InstantiationException if the class cannot be loaded or there is some other reflective problem */ public AnnotatedElement element() throws InstantiationException { if (element == null) { try { Class<?> impl = space.loadClass(className()); if (structure.isMethod) { element = impl.getMethod(structure.memberName); } else if (structure.memberName != null) { element = impl.getField(structure.memberName); } else { element = impl; } LOGGER.log(Level.FINER, "Loaded annotated element: {0}", element); } catch (Exception x) { throw (InstantiationException) new InstantiationException(labelFor(resource) + " might need to be rebuilt: " + x).initCause(x); } catch (LinkageError x) { throw (InstantiationException) new InstantiationException(x.toString()).initCause(x); } } return element; }
/** * Get the live annotated element. * @return a {@link Class}, {@link Method}, or {@link Field} * @throws InstantiationException if the class cannot be loaded or there is some other reflective problem */ public AnnotatedElement element() throws InstantiationException { if (element == null) { try { Class<?> impl = space.loadClass(className()); if (structure.isMethod) { element = impl.getMethod(structure.memberName); } else if (structure.memberName != null) { element = impl.getField(structure.memberName); } else { element = impl; } LOGGER.log(Level.FINER, "Loaded annotated element: {0}", element); } catch (Exception x) { throw (InstantiationException) new InstantiationException(labelFor(resource) + " might need to be rebuilt: " + x).initCause(x); } catch (LinkageError x) { throw (InstantiationException) new InstantiationException(x.toString()).initCause(x); } } return element; }
@Override public void visitEnd() { if ( null != implementation ) { final Component component = componentVisitor.getComponent( space ); if ( null != component ) { final Class<?> role = component.role(); if ( implementation.equals( role.getName() ) ) { // direct binding, make sure it's valid InjectionPoint.forConstructorOf( role ); } plexusTypeListener.hear( component, new LoadedClass<Object>( space.loadClass( implementation ) ), space ); } implementation = null; } }