Package org.nanocontainer.script

Examples of org.nanocontainer.script.NanoContainerMarkupException


                container.registerComponent((ComponentAdapter) nested.getComponentInstanceOfType(clazz));
            } else {
                container.registerComponent((ComponentAdapter) nested.getComponentInstanceOfType(ComponentAdapter.class));
            }
        } catch (ClassNotFoundException ex) {
            throw new NanoContainerMarkupException(ex);
        }

    }
View Full Code Here


    protected void insertImplementation(MutablePicoContainer container, Element rootElement) throws ClassNotFoundException {
        String key = rootElement.getAttribute(KEY);
        String klass = rootElement.getAttribute(CLASS);
        String constructor = rootElement.getAttribute(CONSTRUCTOR);
        if (klass == null || "".equals(klass)) {
            throw new NanoContainerMarkupException("class specification is required for component implementation");
        }

        Class clazz = getClassLoader().loadClass(klass);

        List parameters = new ArrayList();

        NodeList children = rootElement.getChildNodes();
        Node child;
        String name;
        String dependencyKey;
        String dependencyClass;
        Object parseResult;

        for (int i = 0; i < children.getLength(); i++) {
            child = children.item(i);
            if (child.getNodeType() == Document.ELEMENT_NODE) {
                name = child.getNodeName();
                // constant parameter. it does not have any attributes.
                if (CONSTANT.equals(name)) {
                    // create constant with xstream
                    parseResult = parseElementChild((Element) child);
                    if (parseResult == null) {
                        throw new NanoContainerMarkupException("could not parse constant parameter");
                    }
                    parameters.add(new ConstantParameter(parseResult));
                } else if (DEPENDENCY.equals(name)) {
                    // either key or class must be present. not both
                    // key has prececence
                    dependencyKey = ((Element) child).getAttribute(KEY);
                    if (dependencyKey == null || "".equals(dependencyKey)) {
                        dependencyClass = ((Element) child).getAttribute(CLASS);
                        if (dependencyClass == null || "".equals(dependencyClass)) {
                            throw new NanoContainerMarkupException("either key or class must be present for dependency");
                        } else {
                            parameters.add(new ComponentParameter(getClassLoader().loadClass(dependencyClass)));
                        }
                    } else {
                        parameters.add(new ComponentParameter(dependencyKey));
View Full Code Here

     */
    protected void insertInstance(MutablePicoContainer container, Element rootElement) {
        String key = rootElement.getAttribute(KEY);
        Object result = parseElementChild(rootElement);
        if (result == null) {
            throw new NanoContainerMarkupException("no content could be parsed in instance");
        }
        if (key != null && !"".equals(key)) {
            // insert with key
            container.registerComponentInstance(key, result);
        } else {
View Full Code Here

            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) {
            throw new NanoContainerMarkupException(e);
        }
    }
View Full Code Here

        if (name.equals("aspect")) {
            return createAspectNode(attributes, name);
        } else if (name.equals("pointcut")) {
            return createPointcutNode(attributes, name);
        } else {
            throw new NanoContainerMarkupException("Don't know how to create a '" + name + "' child of a '" + parentElement.toString() + "' element");
        }
    }
View Full Code Here

        if (interceptor != null || interceptorKey != null) {
            registerInterceptor(currentPico, currentClassCut, componentCut, currentMethodCut, interceptor, interceptorKey);
        } else if (mixinClass != null) {
            registerMixin(currentPico, currentClassCut, componentCut, toClassArray(mixinInterfaces), mixinClass);
        } else {
            throw new NanoContainerMarkupException("No advice specified - must specify one of interceptor, interceptorKey, mixinClass, or mixinKey");
        }

        return name;
    }
View Full Code Here

            throw new RuntimeException("assertion failed -- non-null interceptor or interceptorKey expected");
        }

        // validate script:
        if (classCut == null && componentCut == null) {
            throw new NanoContainerMarkupException("currentClassCut or componentCut required for interceptor advice");
        }
        if (methodCut == null) {
            throw new NanoContainerMarkupException("currentMethodCut required for interceptor advice");
        }

        if (classCut != null) {
            if (interceptor != null) {
                pico.registerInterceptor(classCut, methodCut, interceptor);
View Full Code Here

            throw new RuntimeException("assertion failed -- mixinClass required");
        }

        // validate script:
        if (classCut == null && componentCut == null) {
            throw new NanoContainerMarkupException("currentClassCut or componentCut required for mixin advice");
        }

        if (classCut != null) {
            if (mixinInterfaces != null) {
                pico.registerMixin(classCut, mixinInterfaces, mixinClass);
View Full Code Here

                    //Execute.
                    return nodeHandler.createNewNode(parent, attributes);
                }

            } catch (ClassNotFoundException e) {
                throw new NanoContainerMarkupException("ClassNotFoundException: " + e.getMessage(), e);
            }
        } else if (current instanceof ClassPathElement) {
            if (name.equals(GRANT)) {
                return createGrantPermission(attributes, (ClassPathElement) current);
            }
View Full Code Here

    private NanoContainer extractOrCreateValidNanoContainer(final Map attributes,
        final Object current) throws NanoContainerMarkupException {
        NanoContainer parent = (NanoContainer) current;
        Object parentAttribute = attributes.get(PARENT);
        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);
        }
View Full Code Here

TOP

Related Classes of org.nanocontainer.script.NanoContainerMarkupException

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.