Examples of FactoryDescriptor


Examples of org.apache.avalon.repository.meta.FactoryDescriptor

        // Build the url to access the properties of the implementation artifact
        // which is default mechanism dependent.
        //

        Attributes attributes = loadAttributes( m_cache, m_hosts, implementation );
        FactoryDescriptor descriptor = new FactoryDescriptor( attributes );
        String factory = descriptor.getFactory();
        if( null == factory )
        {
            final String error =
              "Required property 'avalon.artifact.factory' not present in artifact: "
              + implementation + " under the active cache: [" + m_cache + "] using the "
              + "attribute sequence: " + attributes;
            throw new IllegalArgumentException( error );
        }

        //
        // Grab all of the dependents in one hit because this is
        // the implementation so we can ignore api/spi spread.
        //

        Artifact[] dependencies = descriptor.getDependencies();

        int n = dependencies.length;
        URL[] urls = new URL[ n + 1];
        for( int i=0; i<n; i++ )
        {
            urls[i] = LoaderUtils.getResource(
              dependencies[i], m_hosts, m_cache, true );
        }

        urls[ n ] = LoaderUtils.getResource(
            implementation, m_hosts, m_cache, true );

        //
        // create the classloader
        //
       
        ClassLoader classloader = new URLClassLoader( urls, parent );
        Class clazz = loadFactoryClass( classloader, factory );

        //
        // load the actual repository implementation
        //

        try
        {
            m_delegate = createDelegate( classloader, factory, this );
        }
        catch( Throwable e )
        {
            final String error =
              "Unable to establish a factory for the supplied artifact:";
            StringBuffer buffer = new StringBuffer( error );
            buffer.append( "\n artifact: " + implementation );
            buffer.append( "\n build: " + descriptor.getBuild() );
            buffer.append( "\n factory: " + descriptor.getFactory() );
            buffer.append( "\n source: "
              + clazz.getProtectionDomain().getCodeSource().getLocation() );
            buffer.append( "\n cache: " + m_cache );
            throw new RepositoryException( buffer.toString(), e );
        }
View Full Code Here

Examples of org.apache.avalon.repository.meta.FactoryDescriptor

          throw new NullPointerException( "parent" );
        if( null == artifact )
          throw new NullPointerException( "artifact" );

        Attributes attributes = getAttributes( artifact );
        FactoryDescriptor relational = null;
        try
        {
            relational = new FactoryDescriptor( attributes );
        }
        catch( MetaException me )
        {
            final String error =
              "Could not create a relational descriptor from the artifact: "
              + artifact;
            throw new RepositoryException( error, me );
        }
      
        URL[] apis =
          getURLs(
            relational.getDependencies(
              FactoryDescriptor.API_KEY ) );
        ClassLoader api = buildClassLoader( apis, parent );

        URL[] spis =
          getURLs(
            relational.getDependencies(
              FactoryDescriptor.SPI_KEY ) );
        ClassLoader spi = buildClassLoader( spis, api );

        URL[] imps =
          getURLs( artifact,
            relational.getDependencies(
              FactoryDescriptor.IMP_KEY ) );

        return buildClassLoader( imps, spi );
    }
View Full Code Here

Examples of org.apache.avalon.repository.meta.FactoryDescriptor

              "Internal error while attempt to construct initial repository.";
            throw new RepositoryException( error, e );          
        }

        Attributes attributes = m_repository.getAttributes( artifact );
        FactoryDescriptor descriptor = new FactoryDescriptor( attributes );
        String classname = descriptor.getFactory();
        if( null == classname )
        {
            final String error =
              "Required property 'avalon.artifact.factory' not present in artifact: ["
              + artifact + "] under the active repository: [" + m_repository + "].";
            throw new IllegalArgumentException( error );
        }

        m_classloader = m_repository.getClassLoader( parent, artifact );
        Class clazz = loadFactoryClass( m_classloader, classname );

        try
        {
            m_delegate = createDelegate( m_classloader, classname, m_context );
        }
        catch( Throwable e )
        {
            final String error =
              "Unable to establish a factory for the supplied artifact:";
            StringBuffer buffer = new StringBuffer( error );
            buffer.append( "\n artifact: " + artifact );
            buffer.append( "\n build: " + descriptor.getBuild() );
            buffer.append( "\n factory: " + descriptor.getFactory() );
            buffer.append( "\n source: "
              + clazz.getProtectionDomain().getCodeSource().getLocation() );
            buffer.append( "\n repository: " + m_repository );
            throw new RepositoryException( buffer.toString(), e );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.