Search in sources :

Example 1 with V3Mapper

use of org.glassfish.internal.grizzly.V3Mapper in project Payara by payara.

the class GlassfishNetworkListener method configureHttpProtocol.

@Override
protected void configureHttpProtocol(final ServiceLocator habitat, final NetworkListener networkListener, final Http http, final FilterChainBuilder filterChainBuilder, boolean securityEnabled) {
    if (httpAdapter == null) {
        registerMonitoringStatsProviders();
        final V3Mapper mapper = new V3Mapper(logger);
        mapper.setPort(port);
        mapper.setId(name);
        final ContainerMapper containerMapper = new ContainerMapper(grizzlyService, this);
        containerMapper.setMapper(mapper);
        containerMapper.setDefaultHost(http.getDefaultVirtualServer());
        containerMapper.setRequestURIEncoding(http.getUriEncoding());
        containerMapper.configureMapper();
        VirtualServer vs = null;
        String webAppRootPath = null;
        final Collection<VirtualServer> list = grizzlyService.getHabitat().getAllServices(VirtualServer.class);
        final String vsName = http.getDefaultVirtualServer();
        for (final VirtualServer virtualServer : list) {
            if (virtualServer.getId().equals(vsName)) {
                vs = virtualServer;
                webAppRootPath = vs.getDocroot();
                if (!grizzlyService.hasMapperUpdateListener() && vs.getProperty() != null && !vs.getProperty().isEmpty()) {
                    for (final Property p : vs.getProperty()) {
                        final String propertyName = p.getName();
                        if (propertyName.startsWith("alternatedocroot")) {
                            String value = p.getValue();
                            String[] mapping = value.split(" ");
                            if (mapping.length != 2) {
                                logger.log(Level.WARNING, "Invalid alternate_docroot {0}", value);
                                continue;
                            }
                            String docBase = mapping[1].substring("dir=".length());
                            String urlPattern = mapping[0].substring("from=".length());
                            containerMapper.addAlternateDocBase(urlPattern, docBase);
                        }
                    }
                }
                break;
            }
        }
        httpAdapter = new HttpAdapterImpl(vs, containerMapper, webAppRootPath);
        containerMapper.addDocRoot(webAppRootPath);
        AbstractActiveDescriptor<V3Mapper> aad = BuilderHelper.createConstantDescriptor(mapper);
        aad.addContractType(Mapper.class);
        aad.setName(address.toString() + port);
        ServiceLocatorUtilities.addOneDescriptor(grizzlyService.getHabitat(), aad);
        super.configureHttpProtocol(habitat, networkListener, http, filterChainBuilder, securityEnabled);
        final Protocol protocol = http.getParent();
        for (NetworkListener listener : protocol.findNetworkListeners()) {
            grizzlyService.notifyMapperUpdateListeners(listener, mapper);
        }
    } else {
        super.configureHttpProtocol(habitat, networkListener, http, filterChainBuilder, securityEnabled);
    }
}
Also used : Protocol(org.glassfish.grizzly.config.dom.Protocol) V3Mapper(org.glassfish.internal.grizzly.V3Mapper) Property(org.jvnet.hk2.config.types.Property) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 2 with V3Mapper

use of org.glassfish.internal.grizzly.V3Mapper in project Payara by payara.

the class WebConnector method initialize.

@Override
public void initialize() throws LifecycleException {
    V3Mapper v3Mapper = null;
    if (mapper == null) {
        v3Mapper = new V3Mapper();
        mapper = v3Mapper;
    }
    super.initialize();
    if (v3Mapper != null) {
        v3Mapper.setHttpHandler(getHandler());
    } else if (mapper instanceof V3Mapper) {
        ((V3Mapper) mapper).setHttpHandler(getHandler());
    }
}
Also used : V3Mapper(org.glassfish.internal.grizzly.V3Mapper)

Aggregations

V3Mapper (org.glassfish.internal.grizzly.V3Mapper)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)1 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)1 Protocol (org.glassfish.grizzly.config.dom.Protocol)1 Property (org.jvnet.hk2.config.types.Property)1