Package org.nanocontainer

Examples of org.nanocontainer.DefaultNanoContainer$URLPrintingClassLoader


            if (parent != null && parentAttribute != null) {
                throw new NanoContainerMarkupException("You can't explicitly specify a parent in a child element.");
            }
            if (parent == null && (parentAttribute instanceof MutablePicoContainer)) {
                // we're not in an enclosing scope - look at parent attribute instead
                parent = new DefaultNanoContainer((MutablePicoContainer) parentAttribute);
            }
            if (parent == null && (parentAttribute instanceof NanoContainer)) {
                // we're not in an enclosing scope - look at parent attribute instead
                parent = (NanoContainer) parentAttribute;
            }
View Full Code Here


    }

    private Object createNewBuilderNode(Map attributes, NanoContainer parentContainer) {
        String builderClass = (String) attributes.remove(CLASS);
        NanoContainer factory = new DefaultNanoContainer();
        MutablePicoContainer parentPico = parentContainer.getPico();
        factory.getPico().registerComponentInstance(MutablePicoContainer.class, parentPico);
        try {
            factory.registerComponentImplementation(GroovyObject.class, builderClass);
        } catch (ClassNotFoundException e) {
            throw new NanoContainerMarkupException("ClassNotFoundException " + builderClass);
        }
        Object componentInstance = factory.getPico().getComponentInstance(GroovyObject.class);
        return componentInstance;
    }
View Full Code Here

        MutablePicoContainer decoratedPico = decorationDelegate.decorate(childContainer);
        if ( isAttribute(attributes, CLASS) )  {
            Class clazz = (Class) attributes.get(CLASS);
            return createNanoContainer(clazz, decoratedPico, parentClassLoader);
        } else {
            return new DefaultNanoContainer(parentClassLoader, decoratedPico);
        }
    }
View Full Code Here

        }
        return monitor;
    }

    protected NanoContainer createComponentClassLoader(NanoContainer parent) {
        return new DefaultNanoContainer(parent.getComponentClassLoader(), parent.getPico());
    }
View Full Code Here

                cafName = DefaultComponentAdapterFactory.class.getName();
            }
            Class cafClass = getClassLoader().loadClass(cafName);
            ComponentAdapterFactory componentAdapterFactory = (ComponentAdapterFactory) cafClass.newInstance();
            MutablePicoContainer picoContainer = new DefaultPicoContainer(componentAdapterFactory);
            NanoContainer nano = new DefaultNanoContainer(getClassLoader(), picoContainer);
            populateContainer(nano.getPico());
            return nano.getPico();
        } catch (ClassNotFoundException e) {
            throw new NanoContainerMarkupException(e);
        } catch (InstantiationException e) {
            throw new NanoContainerMarkupException(e);
        } catch (IllegalAccessException e) {
View Full Code Here

//    protected AbstractNanoPicoContainer() {
//    }

    protected AbstractNanoPicoContainer(MutablePicoContainer delegate, ClassLoader classLoader) {
        super(delegate);
        container = new DefaultNanoContainer(classLoader, delegate);
    }
View Full Code Here

    public ScriptedContainerBuilderFactory(URL compositionURL, String builderClassName, ClassLoader contextClassLoader) throws ClassNotFoundException {
        createContainerBuilder(compositionURL, contextClassLoader, builderClassName);
    }

    private void createContainerBuilder(Object composition, ClassLoader classLoader, String builderClass) throws ClassNotFoundException {
        DefaultNanoContainer defaultNanoContainer;
        {
            // transient.
            DefaultPicoContainer factory = new DefaultPicoContainer();
            if(composition == null) {
                throw new NullPointerException("composition can't be null");
            }
            factory.registerComponentInstance(composition);

            if(classLoader == null) {
                // on some weird JVMs (like jeode) Thread.currentThread().getContextClassLoader() returns null !?!?
                classLoader = getClass().getClassLoader();
            }
            factory.registerComponentInstance(classLoader);
            defaultNanoContainer = new DefaultNanoContainer(factory);
        }
        ComponentAdapter componentAdapter = defaultNanoContainer.registerComponentImplementation(builderClass);
        containerBuilder = (ScriptedContainerBuilder) componentAdapter.getComponentInstance(defaultNanoContainer.getPico());
    }
View Full Code Here

        if (parent != null && parentAttribute != null) {
            throw new NanoContainerMarkupException("You can't explicitly specify a parent in a child element.");
        }
        if (parent == null && (parentAttribute instanceof MutablePicoContainer)) {
            // we're not in an enclosing scope - look at parent attribute instead
            parent = new DefaultNanoContainer((MutablePicoContainer) parentAttribute);
        }
        if (parent == null && (parentAttribute instanceof NanoContainer)) {
            // we're not in an enclosing scope - look at parent attribute instead
            parent = (NanoContainer) parentAttribute;
        }
View Full Code Here

        return container;
    }

    public void populateContainer(MutablePicoContainer container) {
        try {
            NanoContainer nanoContainer = new DefaultNanoContainer(getClassLoader(), container);
            registerComponentsAndChildContainers(nanoContainer, rootElement);
        } catch (ClassNotFoundException e) {
            throw new NanoContainerMarkupException("Class not found: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new NanoContainerMarkupException(e);
View Full Code Here

            if (children.item(i) instanceof Element) {
                Element childElement = (Element) children.item(i);
                String name = childElement.getNodeName();
                if (CONTAINER.equals(name)) {
                    MutablePicoContainer childContainer = parentContainer.getPico().makeChildContainer();
                    NanoContainer childNanoContainer = new DefaultNanoContainer(parentContainer.getComponentClassLoader(), childContainer);
                    registerComponentsAndChildContainers(childNanoContainer, childElement);
                } else if (COMPONENT_IMPLEMENTATION.equals(name)
                        || COMPONENT.equals(name)) {
                    registerComponentImplementation(parentContainer, childElement);
                } else if (COMPONENT_INSTANCE.equals(name)) {
View Full Code Here

TOP

Related Classes of org.nanocontainer.DefaultNanoContainer$URLPrintingClassLoader

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.