Search in sources :

Example 1 with MultiException

use of org.eclipse.jetty.util.MultiException in project hadoop by apache.

the class HttpServer2 method stop.

/**
   * stop the server
   */
public void stop() throws Exception {
    MultiException exception = null;
    for (ServerConnector c : listeners) {
        try {
            c.close();
        } catch (Exception e) {
            LOG.error("Error while stopping listener for webapp" + webAppContext.getDisplayName(), e);
            exception = addMultiException(exception, e);
        }
    }
    try {
        // explicitly destroy the secret provider
        secretProvider.destroy();
        // clear & stop webAppContext attributes to avoid memory leaks.
        webAppContext.clearAttributes();
        webAppContext.stop();
    } catch (Exception e) {
        LOG.error("Error while stopping web app context for webapp " + webAppContext.getDisplayName(), e);
        exception = addMultiException(exception, e);
    }
    try {
        webServer.stop();
    } catch (Exception e) {
        LOG.error("Error while stopping web server for webapp " + webAppContext.getDisplayName(), e);
        exception = addMultiException(exception, e);
    }
    if (exception != null) {
        exception.ifExceptionThrow();
    }
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) MultiException(org.eclipse.jetty.util.MultiException) ServletException(javax.servlet.ServletException) MultiException(org.eclipse.jetty.util.MultiException) FileNotFoundException(java.io.FileNotFoundException) BindException(java.net.BindException) InterruptedIOException(java.io.InterruptedIOException) HadoopIllegalArgumentException(org.apache.hadoop.HadoopIllegalArgumentException) IOException(java.io.IOException)

Example 2 with MultiException

use of org.eclipse.jetty.util.MultiException in project hbase by apache.

the class HttpServer method stop.

/**
   * stop the server
   */
public void stop() throws Exception {
    MultiException exception = null;
    for (ListenerInfo li : listeners) {
        if (!li.isManaged) {
            continue;
        }
        try {
            li.listener.close();
        } catch (Exception e) {
            LOG.error("Error while stopping listener for webapp" + webAppContext.getDisplayName(), e);
            exception = addMultiException(exception, e);
        }
    }
    try {
        // clear & stop webAppContext attributes to avoid memory leaks.
        webAppContext.clearAttributes();
        webAppContext.stop();
    } catch (Exception e) {
        LOG.error("Error while stopping web app context for webapp " + webAppContext.getDisplayName(), e);
        exception = addMultiException(exception, e);
    }
    try {
        webServer.stop();
    } catch (Exception e) {
        LOG.error("Error while stopping web server for webapp " + webAppContext.getDisplayName(), e);
        exception = addMultiException(exception, e);
    }
    if (exception != null) {
        exception.ifExceptionThrow();
    }
}
Also used : MultiException(org.eclipse.jetty.util.MultiException) ServletException(javax.servlet.ServletException) URISyntaxException(java.net.URISyntaxException) MultiException(org.eclipse.jetty.util.MultiException) FileNotFoundException(java.io.FileNotFoundException) BindException(java.net.BindException) InterruptedIOException(java.io.InterruptedIOException) HadoopIllegalArgumentException(org.apache.hadoop.HadoopIllegalArgumentException) IOException(java.io.IOException)

Example 3 with MultiException

use of org.eclipse.jetty.util.MultiException in project jetty.project by eclipse.

the class AnnotationParser method parse.

/**
     * Parse classes in the supplied classloader. 
     * Only class files in jar files will be scanned.
     * 
     * @param handlers the handlers to look for classes in 
     * @param loader the classloader for the classes
     * @param visitParents if true, visit parent classloaders too
     * @param nullInclusive if true, an empty pattern means all names match, if false, none match
     * @throws Exception if unable to parse
     */
public void parse(final Set<? extends Handler> handlers, ClassLoader loader, boolean visitParents, boolean nullInclusive) throws Exception {
    if (loader == null)
        return;
    if (!(loader instanceof URLClassLoader))
        //can't extract classes?
        return;
    final MultiException me = new MultiException();
    JarScanner scanner = new JarScanner() {

        @Override
        public void processEntry(URI jarUri, JarEntry entry) {
            try {
                parseJarEntry(handlers, Resource.newResource(jarUri), entry);
            } catch (Exception e) {
                me.add(new RuntimeException("Error parsing entry " + entry.getName() + " from jar " + jarUri, e));
            }
        }
    };
    scanner.scan(null, loader, nullInclusive, visitParents);
    me.ifExceptionThrow();
}
Also used : URLClassLoader(java.net.URLClassLoader) JarEntry(java.util.jar.JarEntry) MultiException(org.eclipse.jetty.util.MultiException) JarScanner(org.eclipse.jetty.webapp.JarScanner) URI(java.net.URI) MultiException(org.eclipse.jetty.util.MultiException) IOException(java.io.IOException)

Example 4 with MultiException

use of org.eclipse.jetty.util.MultiException in project jetty.project by eclipse.

the class AnnotationParser method parse.

/**
     * Parse classes in the supplied uris.
     * 
     * @param handlers the handlers to look for classes in  
     * @param uris the uris for the jars
     * @throws Exception if unable to parse
     */
public void parse(final Set<? extends Handler> handlers, final URI[] uris) throws Exception {
    if (uris == null)
        return;
    MultiException me = new MultiException();
    for (URI uri : uris) {
        try {
            parse(handlers, uri);
        } catch (Exception e) {
            me.add(new RuntimeException("Problem parsing classes from " + uri, e));
        }
    }
    me.ifExceptionThrow();
}
Also used : MultiException(org.eclipse.jetty.util.MultiException) URI(java.net.URI) MultiException(org.eclipse.jetty.util.MultiException) IOException(java.io.IOException)

Example 5 with MultiException

use of org.eclipse.jetty.util.MultiException in project jetty.project by eclipse.

the class AnnotationParser method parseDir.

/**
     * Parse all classes in a directory
     * 
     * @param handlers the set of handlers to look for classes in 
     * @param dir the resource directory to look for classes
     * @throws Exception if unable to parse
     */
protected void parseDir(Set<? extends Handler> handlers, Resource dir) throws Exception {
    // skip dirs whose name start with . (ie hidden)
    if (!dir.isDirectory() || !dir.exists() || dir.getName().startsWith("."))
        return;
    if (LOG.isDebugEnabled()) {
        LOG.debug("Scanning dir {}", dir);
    }
    ;
    MultiException me = new MultiException();
    String[] files = dir.list();
    for (int f = 0; files != null && f < files.length; f++) {
        Resource res = dir.addPath(files[f]);
        if (res.isDirectory())
            parseDir(handlers, res);
        else {
            //we've already verified the directories, so just verify the class file name
            File file = res.getFile();
            if (isValidClassFileName((file == null ? null : file.getName()))) {
                try {
                    String name = res.getName();
                    if (!isParsed(name)) {
                        Resource r = Resource.newResource(res.getURL());
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("Scanning class {}", r);
                        }
                        ;
                        try (InputStream is = r.getInputStream()) {
                            scanClass(handlers, dir, is);
                        }
                    }
                } catch (Exception ex) {
                    if (LOG.isDebugEnabled())
                        LOG.debug("Error scanning file " + files[f], ex);
                    me.add(new RuntimeException("Error scanning file " + files[f], ex));
                }
            } else {
                if (LOG.isDebugEnabled())
                    LOG.debug("Skipping scan on invalid file {}", res);
            }
        }
    }
    me.ifExceptionThrow();
}
Also used : JarInputStream(java.util.jar.JarInputStream) InputStream(java.io.InputStream) Resource(org.eclipse.jetty.util.resource.Resource) MultiException(org.eclipse.jetty.util.MultiException) File(java.io.File) MultiException(org.eclipse.jetty.util.MultiException) IOException(java.io.IOException)

Aggregations

MultiException (org.eclipse.jetty.util.MultiException)18 IOException (java.io.IOException)14 ServletException (javax.servlet.ServletException)7 FileNotFoundException (java.io.FileNotFoundException)4 InterruptedIOException (java.io.InterruptedIOException)4 BindException (java.net.BindException)4 HadoopIllegalArgumentException (org.apache.hadoop.HadoopIllegalArgumentException)4 InputStream (java.io.InputStream)3 MalformedURLException (java.net.MalformedURLException)3 JarInputStream (java.util.jar.JarInputStream)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 JarEntry (java.util.jar.JarEntry)2 UnavailableException (javax.servlet.UnavailableException)2 Handler (org.eclipse.jetty.server.Handler)2 ErrorHandler (org.eclipse.jetty.server.handler.ErrorHandler)2 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHandler (org.eclipse.jetty.servlet.ServletHandler)2 StacklessLogging (org.eclipse.jetty.util.log.StacklessLogging)2