Package org.glassfish.grizzly.http.server

Examples of org.glassfish.grizzly.http.server.HttpServer


            Map<String, String> initParams = new HashMap<String, String>();
            initParams.put(
                    ServerProperties.PROVIDER_PACKAGES,
                    HelloWorldResource.class.getPackage().getName());
            final HttpServer server = GrizzlyWebContainerFactory.create(BASE_URI, ServletContainer.class, initParams);

            System.out.println(String.format("Application started.%nTry out %s%s%nHit enter to stop it...",
                    BASE_URI, ROOT_PATH));
            System.in.read();
            server.shutdownNow();
        } catch (IOException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here


    public static final String WEB_ROOT = "/webroot/";
    public static final String APP_PATH = "/tonegen/";
    public static final int PORT = 9998;

    public static HttpServer startServer(String webRootPath) {
        final HttpServer server = new HttpServer();
        final NetworkListener listener = new NetworkListener("grizzly", "localhost", PORT);

        server.addListener(listener);

        final ServerConfiguration config = server.getServerConfiguration();
        // add handler for serving static content
        config.addHttpHandler(new CLStaticHttpHandler(Main.class.getClassLoader(), WEB_ROOT), APP_PATH);

        // add handler for serving JAX-RS resources
        config.addHttpHandler(RuntimeDelegate.getInstance().createEndpoint(createResourceConfig(), GrizzlyHttpContainer.class),
                APP_PATH);

        try {
            // Start the server.
            server.start();
        } catch (Exception ex) {
            throw new ProcessingException("Exception thrown when trying to start grizzly server", ex);
        }

        return server;
View Full Code Here


    public static void main(String[] args) {

        try {
            final HttpServer server = startServer(args.length >= 1 ? args[0] : null);
            System.out.println(String.format("Application started.\n" +
                    "Access it at %s\n" +
                    "Hit enter to stop it...",
                    getAppUri()));
            System.in.read();
            server.shutdownNow();
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here

     */
    public static void main(String[] args) {
        try {
            System.out.println("HTTP TRACE Support Jersey Example App");

            final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, create());

            System.out.println(String.format(
                    "Application started.\n"
                            + "To test TRACE with a programmatic resource, send HTTP TRACE request to:%n  %s%s%n"
                            + "To test TRACE with an annotated resource, send HTTP TRACE request to:%n  %s%s%n"
                            + "Hit enter to stop it...",
                    BASE_URI, ROOT_PATH_PROGRAMMATIC,
                    BASE_URI, ROOT_PATH_ANNOTATED));
            System.in.read();
            server.shutdownNow();
        } catch (IOException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here

    public static final String WEB_ROOT = "/webroot/";
    public static final String APP_PATH = "/sparklines/";
    public static final int PORT = 9998;

    public static HttpServer startServer(String webRootPath) {
        final HttpServer server = new HttpServer();
        final NetworkListener listener = new NetworkListener("grizzly", "localhost", PORT);

        server.addListener(listener);

        final ServerConfiguration config = server.getServerConfiguration();
        // add handler for serving static content
        config.addHttpHandler(new CLStaticHttpHandler(Main.class.getClassLoader(), WEB_ROOT), APP_PATH);

        // add handler for serving JAX-RS resources
        config.addHttpHandler(RuntimeDelegate.getInstance().createEndpoint(createResourceConfig(), GrizzlyHttpContainer.class),
                APP_PATH);

        try {
            // Start the server.
            server.start();
        } catch (Exception ex) {
            throw new ProcessingException("Exception thrown when trying to start grizzly server", ex);
        }

        return server;
View Full Code Here


    public static void main(String[] args) {

        try {
            final HttpServer server = startServer(args.length >= 1 ? args[0] : null);
            System.out.println(String.format("Application started.\n" +
                    "Access it at %s\n" +
                    "Hit enter to stop it...",
                    getAppUri()));
            System.in.read();
            server.shutdownNow();
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here

    public static void main(String[] args) {
        try {
            System.out.println("\"Exception Mapping\" Jersey Example App");

            final ResourceConfig resourceConfig = new ResourceConfig(ExceptionResource.class);
            final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig);

            System.out.println(String.format(
                    "Application started.%n"
                    + "Try out %s%s%n"
                    + "Hit enter to stop it...",
                    BASE_URI, ROOT_PATH));
            System.in.read();
            server.shutdownNow();
        } catch (IOException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
View Full Code Here

    private static final URI BASE_URI = URI.create("http://localhost:8080/");
    private static URI baseUri;

    public static void main(final String[] args) throws Exception {
        baseUri = args.length > 0 ? URI.create(args[0]) : BASE_URI;
        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, createApp());

        LOG.info("Jersey performance test data generation - application started.");

        try {
            // generate text files - 1kb, 5kb, 10kb, 1MB and optionally 1GB
            generateFile("simple/text", 1024, FILE_PATH + "custom-1kb.text");
            generateFile("simple/text", 5 * 1024, FILE_PATH + "custom-5kb.text");
            generateFile("simple/text", 10 * 1024, FILE_PATH + "custom-10kb.text");
            generateFile("simple/text", 1024 * 1024, FILE_PATH + "custom-1MB.text");
            if (GENERATE_ALSO_GIGABYTE_DATASETS) {
                generateFile("text", 1024 * 1024 * 1024, FILE_PATH + "custom-1GB.text");
            }

            // generate json files - 1kb, 5kb, 10kb, 1MB and optionally 1GB
            generateFile("simple/json", 1024, FILE_PATH + "custom-1kb.json");
            generateFile("simple/json", 5 * 1024, FILE_PATH + "custom-5kb.json");
            generateFile("simple/json", 10 * 1024, FILE_PATH + "custom-10kb.json");
            generateFile("simple/json", 1024 * 1024, FILE_PATH + "custom-1MB.json");
            if (GENERATE_ALSO_GIGABYTE_DATASETS) {
                generateFile("simple/json", 1024 * 1024 * 1024, FILE_PATH + "custom-1GB.json");
            }

            // generate xml files - 1kb, 5kb, 10kb, 1MB and optionally 1GB
            generateFile("simple/xml", 1024, FILE_PATH + "custom-1kb.xml");
            generateFile("simple/xml", 5 * 1024, FILE_PATH + "custom-5kb.xml");
            generateFile("simple/xml", 10 * 1024, FILE_PATH + "custom-10kb.xml");
            generateFile("simple/xml", 1024 * 1024, FILE_PATH + "custom-1MB.xml");
            if (GENERATE_ALSO_GIGABYTE_DATASETS) {
                generateFile("simple/xml", 1024 * 1024 * 1024, FILE_PATH + "custom-1GB.json");
            }
        } catch (final IOException e) {
            LOG.log(Level.SEVERE, "An error occurred during test data generation. ", e);
        }
        server.shutdown();
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
            System.out.println("Jersey performance test web service application");

            final ResourceConfig resourceConfig = new ResourceConfig(NameBoundFilterResource.class, NameBoundFilter.class);
            URI baseUri = args.length > 0 ? URI.create(args[0]) : BASE_URI;
            final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);

            System.out.println(String.format("Application started.\nTry out %s%s\nHit Ctrl-C to stop it...",
                    baseUri, ROOT_PATH));

            while (server.isStarted()) {
                Thread.sleep(600000);
            }
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
            System.out.println("Jersey performance test web service application");

            final ResourceConfig resourceConfig = new ResourceConfig(TextEntityResource.class, GlobalFilter.class);
            URI baseUri = args.length > 0 ? URI.create(args[0]) : BASE_URI;
            final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);

            System.out.println(String.format("Application started.\nTry out %s%s\nHit Ctrl-C to stop it...",
                    baseUri, ROOT_PATH));

            while (server.isStarted()) {
                Thread.sleep(600000);
            }
    }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.http.server.HttpServer

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.