Package com.sun.net.httpserver

Examples of com.sun.net.httpserver.HttpHandler


            }
        });
    }

    public void mapping(final String context, final File file) {
        httpServer.createContext(context, new HttpHandler() {
            @Override
            public void handle(HttpExchange httpExchange) throws IOException {
                ByteSource byteSource = Files.asByteSource(file);
                httpExchange.sendResponseHeaders(200, byteSource.size());
                BufferedOutputStream os = new BufferedOutputStream(httpExchange.getResponseBody());
View Full Code Here


    }

    @Test
    public void testFetch() throws Exception {
        final HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
        final HttpHandler handler = RuntimeDelegate.getInstance().createEndpoint(new Application() {

            @Override
            public Set<Class<?>> getClasses() {
                return Collections.<Class<?>>singleton(Resource.class);
            }
View Full Code Here

  static HttpServer startServer() throws IOException {
    // create a new server listening at port 8080
    HttpServer server = HttpServer.create(new InetSocketAddress(getBaseURI().getPort()), 0);

    // create a handler wrapping the JAX-RS application
    HttpHandler handler = RuntimeDelegate.getInstance().createEndpoint(new JaxRsApplication(), HttpHandler.class);

    // map JAX-RS handler to the server root
    server.createContext(getBaseURI().getPath(), handler);

    // start the server
View Full Code Here

      String deploymentName = archive.getName();
     
      Exception failure = null;
      try
      {
         httpFileServer.createContext("/" + deploymentName, new HttpHandler()
         {
            public void handle(HttpExchange exchange) throws IOException
            {
               InputStream zip = archive.as(ZipExporter.class).exportZip();
               ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
View Full Code Here

   private HttpHandler httpHandler;

   public LoginTestTemplate(final String expectedUserName, final String expectedPassword, final int responseCode, final String sessionId) {

      httpHandler = new HttpHandler() {
         @Override
         public void handle(HttpExchange httpExchange) throws IOException {
            Headers headers = httpExchange.getRequestHeaders();

            Assert.assertEquals("application/x-www-form-urlencoded; charset=UTF-8", headers.getFirst("Content-Type"));
View Full Code Here

    }
   
    @Test
    public void externalLinksToRemoteRepoWithoutModuleNamePattern() throws Exception {
        HttpServer stubServer = HttpServer.create(new InetSocketAddress(0), 1);
        stubServer.createContext("/repo", new HttpHandler() {
            @Override
            public void handle(HttpExchange httpExchange) throws IOException {
                if (httpExchange.getRequestMethod().equals("HEAD")) {
                    httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, -1);
                } else {
View Full Code Here

      String deploymentName = archive.getName();
     
      Exception failure = null;
      try
      {
         httpFileServer.createContext("/" + deploymentName, new HttpHandler()
         {
            @Override
            public void handle(HttpExchange exchange) throws IOException
            {
               InputStream zip = archive.as(ZipExporter.class).exportZip();
View Full Code Here

    static HttpServer startServer() throws IOException {
        // create a new server listening at port 8080
        HttpServer server = HttpServer.create(new InetSocketAddress(getBaseURI().getPort()), 0);

        // create a handler wrapping the JAX-RS application
        HttpHandler handler = RuntimeDelegate.getInstance().createEndpoint(new JaxRsApplication(), HttpHandler.class);

        // map JAX-RS handler to the server root
        server.createContext(getBaseURI().getPath(), handler);

        // start the server
View Full Code Here

      String deploymentName = archive.getName();
     
      Exception failure = null;
      try
      {
         httpFileServer.createContext("/" + deploymentName, new HttpHandler()
         {
            public void handle(HttpExchange exchange) throws IOException
            {
               InputStream zip = archive.as(ZipExporter.class).exportZip();
               ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
View Full Code Here

      String deploymentName = archive.getName();
     
      Exception failure = null;
      try
      {
         httpFileServer.createContext("/" + deploymentName, new HttpHandler()
         {
            public void handle(HttpExchange exchange) throws IOException
            {
               InputStream zip = archive.as(ZipExporter.class).exportZip();
               ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of com.sun.net.httpserver.HttpHandler

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.