Package org.xeustechnologies.jcl.exception

Examples of org.xeustechnologies.jcl.exception.JclContextException


        validate();
    }

    private void validate() {
        if( isLoaded() ) {
            throw new JclContextException( "Context already loaded. Destroy the existing context to create a new one." );
        }
    }
View Full Code Here


     * @param name
     * @param jcl
     */
    public void addJcl(String name, JarClassLoader jcl) {
        if( loaders.containsKey( name ) )
            throw new JclContextException( "JarClassLoader[" + name + "] already exist. Name must be unique" );

        loaders.put( name, jcl );
    }
View Full Code Here

        try {
            factory.setSchema( schemaFactory.newSchema( new Source[] { new StreamSource( getClass().getClassLoader()
                    .getResourceAsStream( JCL_CONTEXT_SCHEMA ) ) } ) );
        } catch (SAXException e) {
            throw new JclContextException( e );
        }

        try {
            DocumentBuilder builder = factory.newDocumentBuilder();

            Document d = null;

            if (file.startsWith( CLASSPATH ))
                d = builder.parse( getClass().getClassLoader().getResourceAsStream( file.split( CLASSPATH )[1] ) );
            else {
                d = builder.parse( file );
            }

            NodeList nl = d.getElementsByTagName( ELEMENT_JCL );
            for (int i = 0; i < nl.getLength(); i++) {
                Node n = nl.item( i );

                String name = n.getAttributes().getNamedItem( ATTRIBUTE_NAME ).getNodeValue();

                JarClassLoader jcl = new JarClassLoader();

                NodeList config = n.getChildNodes();

                for (int j = 0; j < config.getLength(); j++) {
                    Node c = config.item( j );
                    if (c.getNodeName().equals( ELEMENT_LOADERS )) {
                        processLoaders( jcl, c );
                    } else if (c.getNodeName().equals( ELEMENT_SOURCES )) {
                        processSources( jcl, c );
                    }
                }

                jclContext.addJcl( name, jcl );

                if (logger.isLoggable( Level.FINER ))
                    logger.finer( "JarClassLoader[" + name + "] loaded into context." );
            }

        } catch (SAXParseException e) {
            JclContextException we = new JclContextException( e.getMessage() + " [" + file + " (" + e.getLineNumber()
                    + ", " + e.getColumnNumber() + ")]" );
            we.setStackTrace( e.getStackTrace() );

            throw we;
        } catch (JclContextException e) {
            throw e;
        } catch (Exception e) {
            throw new JclContextException( e );
        }
    }
View Full Code Here

                    Class<?> clazz = null;
                    try {
                        clazz = getClass().getClassLoader().loadClass(
                                l.getAttributes().getNamedItem( ATTRIBUTE_CLASS ).getNodeValue() );
                    } catch (Exception e) {
                        throw new JclContextException( e );
                    }

                    ProxyClassLoader pcl = (ProxyClassLoader) objenesis.newInstance( clazz );
                    jcl.addLoader( pcl );
View Full Code Here

TOP

Related Classes of org.xeustechnologies.jcl.exception.JclContextException

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.