Package org.glassfish.grizzly.http.server

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


//        System.out.println("Starting grizzly...");
        return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
    }

    public static void main(String[] args) throws IOException {
        HttpServer httpServer = startServer();
        System.out.println(String.format("Jersey app started with WADL at %sapplication.wadl", BASE_URI));
        System.out.println("Hit return to stop...");
        System.in.read();
        httpServer.stop();
    }
View Full Code Here


//                    System.getProperty("java.class.path").replace(File.pathSeparatorChar, ';'));
        } else {
            registration.setInitParameters(initParams);
        }

        HttpServer server = GrizzlyHttpServerFactory.createHttpServer(u);
        context.deploy(server);
        return server;
    }
View Full Code Here

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

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

            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.stop();
        } catch (IOException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
View Full Code Here

  public static void main(String[] argv) throws Exception {
    if (argv.length > 0) {
      String cmd = argv[0];
      String[] args = Arrays.copyOfRange(argv, 1, argv.length);
      if (cmd.equals("standalone")) {
        HttpServer ws = createWebServer(args);
        ws.start();
        Thread.currentThread().join(0);
        return;
      } else if (cmd.equals("uploadcode")) {
        uploadCode(args);
        return;
View Full Code Here

    }
    if (System.getProperty(ALLOW_ENCODED_SLASH) == null) {
      System.setProperty(ALLOW_ENCODED_SLASH, "true");
    }

    HttpServer ws = new HttpServer();
    ws.getHttpHandler().setAllowEncodedSlash(true);
    ws.addListener(new NetworkListener("web",listenInterface,port));
    DovetaildbServlet ddbServlet = new DovetaildbServlet();
   
    WebappContext webappContext = new WebappContext("webapp", "/");
    ServletRegistration reg = webappContext.addServlet("dovetaildb", ddbServlet);
    reg.setInitParameter("headerFile", headerFile.getAbsolutePath());
View Full Code Here

  public void testMain() throws Exception {
    File tempFile = File.createTempFile("MainTest", "ser");
    assertTrue(tempFile.delete());
    File bagDir = Util.createTempDirectory("MainTest_bag");
    try {
      HttpServer ws = Main.createWebServer(new String[]{"--port=10801", "--createmode=OPEN", "-m", tempFile.getAbsolutePath()});
      ws.start();
      Thread.currentThread().sleep(1000);
      try {
        baseUrl = "http://localhost:10801";
        Object ret;
        ret = call("_meta","execute",Util.literalSMap().p("code","repo.getDbNames()"));
        //System.out.println(ret.toString());
        String pathStr = bagDir.getAbsolutePath().replace('\\', '/');
        ret = call("_meta","execute",Util.literalSMap().p("code","repo.setDb(\"testdb\",Packages.dovetaildb.StdLib.makeFsDb(\""+pathStr+"\",false))"));
        //System.out.println(ret.toString());
        checkDocExamples();
        Random random = new Random(43534454);
        long jsonSize=0;
        ArrayList<Map<String,Object>> allRecs = new ArrayList<Map<String,Object>>();
        int NUM_ENTRIES = 25;
        for(int i=0; i<NUM_ENTRIES; i++) {
          Map<String,Object> entry = makeEntry(i, random);
          allRecs.add(entry);
          String encodedEntry = Util.jsonEncode(entry);
          jsonSize += encodedEntry.length() + 1;
          ret = call("testdb","put",Util.literalSMap().p("bag","people").p("entry", encodedEntry));
          //System.out.println(ret.toString());
        }
        System.out.println("load complete");
        size(bagDir);
        //long preRebuildSize = Util.sizeDir(bagDir);
       
        forceRebuild();
        size(bagDir);
       
        //long postRebuildSize = Util.sizeDir(bagDir);
        System.out.println("json raw: "+jsonSize);

        // test behavior
        List<Map<String,Object>> rets;
        rets = callQuery("testdb","people","{\"id\":\"0\"}","{}");
        System.out.println("WHO? "+rets);
        assertEquals(1, rets.size());
        rets = callQuery("testdb","people","{}","{}");
        System.out.println("WHO? "+rets);
        assertEquals(NUM_ENTRIES, rets.size());
        List<Map<String,Object>> recs;
        Map<String,Object> rec;
        recs = callQuery("testdb","people","{}","{}");
        assertEquals(NUM_ENTRIES, recs.size());
        double midNum =((Number)recs.get(0).get("score")).doubleValue();
        recs = callQuery("testdb","people","{}","{\"score\":{\"score\":[\"NumericScore\"]}}");
        System.out.println("WHO? "+recs);
        double hiNum = ((Number)recs.get(0).get("score")).doubleValue();
        assertEquals(NUM_ENTRIES, recs.size());
        recs = callQuery("testdb","people","{}","{\"score\":{\"score\":[\"ReverseScore\",[\"NumericScore\"]]}}");
        assertEquals(NUM_ENTRIES, recs.size());
        rec = recs.get(0);
        assertTrue(((String)rec.get("name")).length() > 0);
        double loNum = ((Number)rec.get("score")).doubleValue();
        assertTrue(loNum < hiNum);
        assertTrue(loNum <= midNum);
        assertTrue(midNum <= hiNum);
      } finally {
        ws.stop();
      }
    } finally {
      tempFile.delete();
      Util.deleteDirectory(bagDir);
    }
View Full Code Here

        bind(UserRepository.class).toInstance(userRepository);
      }
    });

    // start server with guice injector
    HttpServer server = createHttpServer("http://localhost:8080", rc,
        new GuiceComponentProviderFactory(rc, injector));

    // wait for shutdown ...
    System.out.println("Hit <return> to stop server...");
    System.in.read();
    server.stop();

    // save state
    freeze(userRepository);
  }
View Full Code Here

    @SuppressWarnings({"ResultOfMethodCallIgnored"})
    public static void main(String[] args) {
        try {
            System.out.println("XML with MOXy Jersey Example App");

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

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

        ResourceConfig rc = new PackagesResourceConfig("com.sun.jersey.samples.helloworld.resources");
        return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
    }
   
    public static void main(String[] args) throws IOException {
        HttpServer httpServer = startServer();
        System.out.println(String.format("Jersey app started with WADL available at "
                + "%sapplication.wadl\nTry out %shelloworld\nHit enter to stop it...",
                BASE_URI, BASE_URI));
        System.in.read();
        httpServer.stop();
    }
View Full Code Here

    @SuppressWarnings("ResultOfMethodCallIgnored")
    public static void main(String[] args) {
        try {
            System.out.println("\"Custom Executor Managed Async Resources\" Jersey Example App");

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

            System.out.println(String.format("Application started.\n" +
                    "To test long-running asynchronous operation resource, try %s%s\n" +
                    "To test async chat resource, try %s%s\n" +
                    "Hit enter to stop it...", BASE_URI, ASYNC_LONG_RUNNING_MANAGED_OP_PATH, BASE_URI, "chat"));

            System.in.read();

            server.stop();
        } catch (IOException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
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.