Package com.sun.grizzly.http.servlet

Examples of com.sun.grizzly.http.servlet.ServletAdapter


    public static SelectorThread create(URI u, Class<? extends Servlet> c,
            Map<String, String> initParams) throws IOException {
        if (u == null)
            throw new IllegalArgumentException("The URI must not be null");

        ServletAdapter adapter = new ServletAdapter();
        if (initParams == null) {
            adapter.addInitParameter(ClasspathResourceConfig.PROPERTY_CLASSPATH,
                     System.getProperty("java.class.path").replace(File.pathSeparatorChar, ';'));
        } else {
            for (Map.Entry<String, String> e : initParams.entrySet()) {
                adapter.addInitParameter(e.getKey(), e.getValue());
            }
        }
       
        adapter.setServletInstance(getInstance(c));
       
        String path = u.getPath();
        if (path == null)
            throw new IllegalArgumentException("The URI path, of the URI " + u +
                    ", must be non-null");
        else if (path.length() == 0)
            throw new IllegalArgumentException("The URI path, of the URI " + u +
                    ", must be present");
        else if (path.charAt(0) != '/')
            throw new IllegalArgumentException("The URI path, of the URI " + u +
                    ". must start with a '/'");
       
        if (path.length() > 1) {
            if (path.endsWith("/"))
                path = path.substring(0, path.length() - 1);
            adapter.setContextPath(path);
        }
       
        return GrizzlyServerFactory.create(u, adapter);
    }   
View Full Code Here

TOP

Related Classes of com.sun.grizzly.http.servlet.ServletAdapter

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.