Package org.codehaus.plexus.component.factory

Examples of org.codehaus.plexus.component.factory.ComponentFactory


    public Object createComponentInstance( ComponentDescriptor componentDescriptor )
        throws ComponentInstantiationException, ComponentLifecycleException
    {
        String componentFactoryId = componentDescriptor.getComponentFactory();

        ComponentFactory componentFactory = null;
        Object component = null;

        try
        {
            if ( componentFactoryId != null )
            {
                componentFactory = componentFactoryManager.findComponentFactory( componentFactoryId );
            }
            else
            {
                componentFactory = componentFactoryManager.getDefaultComponentFactory();
            }

            component = componentFactory.newInstance( componentDescriptor, plexusRealm, this );
        }
        catch ( UndefinedComponentFactoryException e )
        {
            throw new ComponentInstantiationException( "Unable to create component as factory '" + componentFactoryId + "' could not be found", e );
        }
View Full Code Here


        Thread.currentThread().setContextClassLoader(realm);
        try {
            ObjectRecipe recipe = createObjectRecipe(descriptor, realm);

            T instance;
            ComponentFactory componentFactory = container.getComponentFactoryManager().findComponentFactory(descriptor.getComponentFactory());
            if (JavaComponentFactory.class.equals(componentFactory.getClass())) {
                // xbean-reflect will create object and do injection
                instance = (T) recipe.create();
            } else {
                // todo figure out how to easily let xbean use the factory to construct the component
                // use object factory to construct component and then inject into that object
                instance = (T) componentFactory.newInstance(descriptor, realm, container);
                recipe.setProperties( instance );
            }

            // todo figure out how to easily let xbean do this map oriented stuff (if it is actually used in plexus)
            if ( instance instanceof MapOrientedComponent) {
View Full Code Here

        Thread.currentThread().setContextClassLoader(realm);
        try {
            ObjectRecipe recipe = createObjectRecipe(descriptor, realm);

            T instance;
            ComponentFactory componentFactory = container.getComponentFactoryManager().findComponentFactory(descriptor.getComponentFactory());
            if (JavaComponentFactory.class.equals(componentFactory.getClass())) {
                // xbean-reflect will create object and do injection
                instance = (T) recipe.create();
            } else {
                // todo figure out how to easily let xbean use the factory to construct the component
                // use object factory to construct component and then inject into that object
                instance = (T) componentFactory.newInstance(descriptor, realm, container);
                recipe.setProperties( instance );
            }

            // todo figure out how to easily let xbean do this map oriented stuff (if it is actually used in plexus)
            if ( instance instanceof MapOrientedComponent) {
View Full Code Here

    public Object createComponentInstance( ComponentDescriptor componentDescriptor )
        throws ComponentInstantiationException, ComponentLifecycleException
    {
        String componentFactoryId = componentDescriptor.getComponentFactory();

        ComponentFactory componentFactory = null;
        Object component = null;

        try
        {
            if ( componentFactoryId != null )
            {
                componentFactory = componentFactoryManager.findComponentFactory( componentFactoryId );
            }
            else
            {
                componentFactory = componentFactoryManager.getDefaultComponentFactory();
            }

            component = componentFactory.newInstance( componentDescriptor, plexusRealm, this );
        }
        catch ( UndefinedComponentFactoryException e )
        {
            throw new ComponentInstantiationException( "Unable to create component as factory '" + componentFactoryId + "' could not be found", e );
        }
View Full Code Here

        Thread.currentThread().setContextClassLoader(realm);
        try {
            ObjectRecipe recipe;

            T instance;
            ComponentFactory componentFactory = container.getComponentFactoryManager().findComponentFactory(descriptor.getComponentFactory());
            if (JavaComponentFactory.class.equals(componentFactory.getClass())) {
                // xbean-reflect will create object and do injection
                recipe = createObjectRecipe( null, descriptor, realm );
                instance = (T) recipe.create();
            } else {
                // todo figure out how to easily let xbean use the factory to construct the component
                // use object factory to construct component and then inject into that object
                instance = (T) componentFactory.newInstance(descriptor, realm, container);
                recipe = createObjectRecipe( instance, descriptor, realm );
                recipe.setProperties( instance );
            }

            // todo figure out how to easily let xbean do this map oriented stuff (if it is actually used in plexus)
View Full Code Here

                                              ClassRealm realm )
        throws ComponentInstantiationException, ComponentLifecycleException
    {
        String componentFactoryId = componentDescriptor.getComponentFactory();

        ComponentFactory componentFactory;

        Object component;

        try
        {
            if ( componentFactoryId != null )
            {
                componentFactory = container.getComponentFactoryManager().findComponentFactory( componentFactoryId );
            }
            else
            {
                componentFactory = container.getComponentFactoryManager().getDefaultComponentFactory();
            }

            ClassRealm componentRealm;

            if ( realm == null )
            {
                componentRealm = container.getComponentRealm( componentDescriptor.getRealmId() );
            }
            else
            {
                componentRealm = realm;
            }

            try
            {
                component = componentFactory.newInstance( componentDescriptor, componentRealm, container );
            }
            catch ( AbstractMethodError e )
            {
                // ----------------------------------------------------------------------------
                // For compatibility with old ComponentFactories that use old ClassWorlds
                // ----------------------------------------------------------------------------

                org.codehaus.classworlds.ClassRealm cr = ClassRealmAdapter.getInstance( componentRealm );

                Method method;

                try
                {
                    method = componentFactory.getClass().getMethod( "newInstance", new Class[]{
                        ComponentDescriptor.class, org.codehaus.classworlds.ClassRealm.class, PlexusContainer.class} );

                    component = method.invoke( componentFactory, new Object[]{componentDescriptor, cr, container} );
                }
                catch ( Exception mnfe )
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.component.factory.ComponentFactory

Copyright © 2018 www.massapicom. 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.