Package org.xeustechnologies.jcl.exception

Examples of org.xeustechnologies.jcl.exception.JclException


                fis = new FileInputStream( f );
                if (fis.read( content ) != -1) {
                    return content;
                }
            } catch (IOException e) {
                throw new JclException( e );
            } finally {
                if (fis != null)
                    try {
                        fis.close();
                    } catch (IOException e) {
                        throw new JclException( e );
                    }
            }
           
        }
        return null;
View Full Code Here


    public Object create(JarClassLoader jcl, String className, Object... args) {
        if (args == null || args.length == 0) {
            try {
                return newInstance( jcl.loadClass( className ).newInstance() );
            } catch (Throwable e) {
                throw new JclException( e );
            }
        }

        Class[] types = new Class[args.length];
View Full Code Here

        if (args == null || args.length == 0) {
            try {
                obj = jcl.loadClass( className ).newInstance();
            } catch (Throwable e) {
                throw new JclException( e );
            }
        } else {
            try {
                obj = jcl.loadClass( className ).getConstructor( types ).newInstance( args );
            } catch (Exception e) {
                throw new JclException( e );
            }
        }

        return newInstance( obj );
    }
View Full Code Here

    public Object create(JarClassLoader jcl, String className, String methodName, Object... args) {
        if (args == null || args.length == 0) {
            try {
                return newInstance( jcl.loadClass( className ).getMethod( methodName ).invoke( null ) );
            } catch (Exception e) {
                throw new JclException( e );
            }
        }
        Class[] types = new Class[args.length];

        for (int i = 0; i < args.length; i++)
View Full Code Here

        Object obj = null;
        if (args == null || args.length == 0) {
            try {
                obj = jcl.loadClass( className ).getMethod( methodName ).invoke( null );
            } catch (Exception e) {
                throw new JclException( e );
            }
        } else {
            try {
                obj = jcl.loadClass( className ).getMethod( methodName, types ).invoke( null, args );
            } catch (Exception e) {
                throw new JclException( e );
            }
        }

        return newInstance( obj );
    }
View Full Code Here

                logger.finer( "Class: " + superClass );
                logger.finer( "Class Interfaces: " + il );
            }

            if (superClass == null && il.size() == 0) {
                throw new JclException( "Neither the class [" + object.getClass().getSuperclass().getName()
                        + "] nor all the implemented interfaces found in the current classloader" );
            }

            return JclUtils.createProxy( object, superClass, il.toArray( new Class[il.size()] ), null );
        }
View Full Code Here

     * @param name
     * @return URL
     */
    public URL getResourceURL(String name) {
        if (baseUrl == null) {
            throw new JclException( "non-URL accessible resource" );
        }
        if (jarEntryContents.get( name ) != null) {
            try {
                return new URL( baseUrl.toString() + name );
            } catch (MalformedURLException e) {
                throw new JclException( e );
            }
        }

        return null;
    }
View Full Code Here

            baseUrl = "jar:" + file.toURI().toString() + "!/";
            fis = new FileInputStream( file );
            loadJar( fis );
        } catch (IOException e) {
            baseUrl = null;
            throw new JclException( e );
        } finally {
            if (fis != null)
                try {
                    fis.close();
                } catch (IOException e) {
                    throw new JclException( e );
                }
        }
    }
View Full Code Here

            baseUrl = "jar:" + url.toString() + "!/";
            in = url.openStream();
            loadJar( in );
        } catch (IOException e) {
            baseUrl = null;
            throw new JclException( e );
        } finally {
            if (in != null)
                try {
                    in.close();
                } catch (IOException e) {
                    throw new JclException( e );
                }
        }
    }
View Full Code Here

                    continue;
                }

                if (jarEntryContents.containsKey( jarEntry.getName() )) {
                    if (!collisionAllowed)
                        throw new JclException( "Class/Resource " + jarEntry.getName() + " already loaded" );
                    else {
                        if (logger.isLoggable( Level.FINEST ))
                            logger.finest( "Class/Resource " + jarEntry.getName()
                                    + " already loaded; ignoring entry..." );
                        continue;
                    }
                }

                if (logger.isLoggable( Level.FINEST ))
                    logger.finest( "Entry Name: " + jarEntry.getName() + ", " + "Entry Size: " + jarEntry.getSize() );

                byte[] b = new byte[2048];
                ByteArrayOutputStream out = new ByteArrayOutputStream();

                int len = 0;
                while (( len = jis.read( b ) ) > 0) {
                    out.write( b, 0, len );
                }

                // add to internal resource HashMap
                jarEntryContents.put( jarEntry.getName(), out.toByteArray() );

                if (logger.isLoggable( Level.FINEST ))
                    logger.finest( jarEntry.getName() + ": size=" + out.size() + " ,csize="
                            + jarEntry.getCompressedSize() );

                out.close();
            }
        } catch (IOException e) {
            throw new JclException( e );
        } catch (NullPointerException e) {
            if (logger.isLoggable( Level.FINEST ))
                logger.finest( "Done loading." );
        } finally {
            if (jis != null)
                try {
                    jis.close();
                } catch (IOException e) {
                    throw new JclException( e );
                }

            if (bis != null)
                try {
                    bis.close();
                } catch (IOException e) {
                    throw new JclException( e );
                }
        }
    }
View Full Code Here

TOP

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

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.