Package org.glassfish.grizzly.http.server

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


    public static HttpServer createHttpServer(
            final URI u,
            final ResourceConfig rc,
            final IoCComponentProviderFactory factory)
            throws IOException, IllegalArgumentException, NullPointerException {
        final HttpHandler processor = ContainerFactory.createContainer(
                HttpHandler.class, rc, factory);
        return createHttpServer(u, processor);
    }
View Full Code Here


            // directly.
            // TODO: Not sure that will works with JRuby.
            if (!mapMultipleAdapter && mapper instanceof V3Mapper) {
                // Remove the MappingData as we might delegate the request
                // to be serviced directly by the WebContainer
                final HttpHandler httpHandler = ((V3Mapper) mapper).getHttpHandler();
                if (httpHandler != null) {
                    request.setNote(MAPPING_DATA, null);
//                    req.setNote(MAPPED_ADAPTER, a);
                    httpHandler.service(request, response);
                    return;
                }
            }

            final DataChunk decodedURI = request.getRequest()
                    .getRequestURIRef().getDecodedRequestURIBC(isAllowEncodedSlash());

            mappingData = request.getNote(MAPPING_DATA);
            if (mappingData == null) {
                mappingData = new MappingData();
                request.setNote(MAPPING_DATA, mappingData);
            } else {
                mappingData.recycle();
            }
            HttpHandler httpService;

            final CharChunk decodedURICC = decodedURI.getCharChunk();
            final int semicolon = decodedURICC.indexOf(';', 0);

            // Map the request without any trailling.
            httpService = mapUriWithSemicolon(request, decodedURI, semicolon, mappingData);
            if (httpService == null || httpService instanceof ContainerMapper) {
                String ext = decodedURI.toString();
                String type = "";
                if (ext.lastIndexOf(".") > 0) {
                    ext = "*" + ext.substring(ext.lastIndexOf("."));
                    type = ext.substring(ext.lastIndexOf(".") + 1);
                }

                if (!MimeType.contains(type) && !"/".equals(ext)) {
                    initializeFileURLPattern(ext);
                    mappingData.recycle();
                    httpService = mapUriWithSemicolon(request, decodedURI, semicolon, mappingData);
                } else {
                    super.service(request, response);
                    return;
                }
            }

            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Request: {0} was mapped to Adapter: {1}",
                        new Object[]{decodedURI.toString(), httpService});
            }

            // The Adapter used for servicing static pages doesn't decode the
            // request by default, hence do not pass the undecoded request.
            if (httpService == null || httpService instanceof ContainerMapper) {
                super.service(request, response);
            } else {
//                req.setNote(MAPPED_ADAPTER, adapter);

//                ContextRootInfo contextRootInfo = null;
//                if (mappingData.context != null && mappingData.context instanceof ContextRootInfo) {
//                    contextRootInfo = (ContextRootInfo) mappingData.context;
//                }

                //if (contextRootInfo == null) {
                    httpService.service(request, response);
//                } else {
//                    ClassLoader cl = null;
//                    if (contextRootInfo.getContainer() instanceof ApplicationContainer) {
//                        cl = ((ApplicationContainer) contextRootInfo.getContainer()).getClassLoader();
//                    }
View Full Code Here

                        match = true;
                        break;
                    }
                }

                HttpHandler adapter;
                if (match) {
                    adapter = grizzlyService.getHabitat().getService(SnifferAdapter.class);
                    ((SnifferAdapter) adapter).initialize(sniffer, this);
                    ContextRootInfo c = new ContextRootInfo(adapter, null);
View Full Code Here

            Thread.currentThread().setContextClassLoader(originalContextClassLoader);
        }
    }

    protected JerseyContainer getJerseyContainer(ResourceConfig rc) {
        final HttpHandler httpHandler = ContainerFactory.createContainer(HttpHandler.class, rc);
        return new JerseyContainer() {
            @Override
            public void service(Request request, Response response) throws Exception {
                httpHandler.service(request, response);
            }
        };
    }
View Full Code Here

//                serverConfig.getMonitoringConfig().getFileCacheConfig().getProbes());
        filterChainBuilder.add(fileCacheFilter);
        final HttpServerFilter webServerFilter = new HttpServerFilter(getHttpServerFilterConfiguration(http),
            delayedExecutor);

        final HttpHandler httpHandler = getHttpHandler();
        httpHandler.setAllowEncodedSlash(GrizzlyConfig.toBoolean(http.getEncodedSlashEnabled()));
        webServerFilter.setHttpHandler(httpHandler);
//        webServerFilter.getMonitoringConfig().addProbes(
//                serverConfig.getMonitoringConfig().getWebServerConfig().getProbes());
        filterChainBuilder.add(webServerFilter);
View Full Code Here

        try {
            // If we have only one Adapter deployed, invoke that Adapter directly.
            if (!mapMultipleAdapter) {
                // Remove the MappingData as we might delegate the request
                // to be serviced directly by the WebContainer
                final HttpHandler httpHandler = mapper.getHttpHandler();
                if (httpHandler != null) {
                    request.setNote(MAPPING_DATA, null);
//                    httpHandler.service(request, response);
//                    return;
                    return new HttpHandlerCallable(httpHandler,
                            request, response);
                }
            }

            final DataChunk decodedURI = request.getRequest()
                    .getRequestURIRef().getDecodedRequestURIBC(isAllowEncodedSlash());

            mappingData = request.getNote(MAPPING_DATA);
            if (mappingData == null) {
                mappingData = new MappingData();
                request.setNote(MAPPING_DATA, mappingData);
            } else {
                mappingData.recycle();
            }
            HttpHandler httpHandler;

            final CharChunk decodedURICC = decodedURI.getCharChunk();
            final int semicolon = decodedURICC.indexOf(';', 0);

            // Map the request without any trailling.
View Full Code Here

                        match = true;
                        break;
                    }
                }

                HttpHandler httpHandler;
                if (match) {
                    httpHandler = grizzlyService.getHabitat().getService(SnifferAdapter.class);
                    ((SnifferAdapter) httpHandler).initialize(sniffer, this);
                    ContextRootInfo c = new ContextRootInfo(httpHandler, null);
View Full Code Here

            // directly.
            // TODO: Not sure that will works with JRuby.
            if (!mapMultipleAdapter && mapper instanceof V3Mapper) {
                // Remove the MappingData as we might delegate the request
                // to be serviced directly by the WebContainer
                final HttpHandler httpHandler = ((V3Mapper) mapper).getHttpHandler();
                if (httpHandler != null) {
                    request.setNote(MAPPING_DATA, null);
//                    req.setNote(MAPPED_ADAPTER, a);
                    httpHandler.service(request, response);
                    return;
                }
            }

            final DataChunk decodedURI = request.getRequest()
                    .getRequestURIRef().getDecodedRequestURIBC(isAllowEncodedSlash());

            mappingData = request.getNote(MAPPING_DATA);
            if (mappingData == null) {
                mappingData = new MappingData();
                request.setNote(MAPPING_DATA, mappingData);
            } else {
                mappingData.recycle();
            }
            HttpHandler httpService;

            final CharChunk decodedURICC = decodedURI.getCharChunk();
            final int semicolon = decodedURICC.indexOf(';', 0);

            // Map the request without any trailling.
            httpService = mapUriWithSemicolon(request, decodedURI, semicolon, mappingData);
            if (httpService == null || httpService instanceof ContainerMapper) {
                String ext = decodedURI.toString();
                String type = "";
                if (ext.lastIndexOf(".") > 0) {
                    ext = "*" + ext.substring(ext.lastIndexOf("."));
                    type = ext.substring(ext.lastIndexOf(".") + 1);
                }

                if (!MimeType.contains(type) && !"/".equals(ext)) {
                    initializeFileURLPattern(ext);
                    mappingData.recycle();
                    httpService = mapUriWithSemicolon(request, decodedURI, semicolon, mappingData);
                } else {
                    super.service(request, response);
                    return;
                }
            }

            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Request: {0} was mapped to Adapter: {1}",
                        new Object[]{decodedURI.toString(), httpService});
            }

            // The Adapter used for servicing static pages doesn't decode the
            // request by default, hence do not pass the undecoded request.
            if (httpService == null || httpService instanceof ContainerMapper) {
                super.service(request, response);
            } else {
//                req.setNote(MAPPED_ADAPTER, adapter);

                ContextRootInfo contextRootInfo = null;
                if (mappingData.context != null && mappingData.context instanceof ContextRootInfo) {
                    contextRootInfo = (ContextRootInfo) mappingData.context;
                }

                if (contextRootInfo == null) {
                    httpService.service(request, response);
                } else {
                    ClassLoader cl = null;
                    if (contextRootInfo.getContainer() instanceof ApplicationContainer) {
                        cl = ((ApplicationContainer) contextRootInfo.getContainer()).getClassLoader();
                    }
View Full Code Here

                        match = true;
                        break;
                    }
                }

                HttpHandler adapter;
                if (match) {
                    adapter = grizzlyService.getHabitat().getService(SnifferAdapter.class);
                    ((SnifferAdapter) adapter).initialize(sniffer, this);
                    ContextRootInfo c = new ContextRootInfo(adapter, null);
View Full Code Here

            Thread.currentThread().setContextClassLoader(originalContextClassLoader);
        }
    }

    protected JerseyContainer getJerseyContainer(ResourceConfig rc) {
        final HttpHandler httpHandler = ContainerFactory.createContainer(HttpHandler.class, rc);
        return new JerseyContainer() {
            @Override
            public void service(Request request, Response response) throws Exception {
                httpHandler.service(request, response);
            }
        };
    }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.http.server.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.