Search in sources :

Example 16 with Sniffer

use of org.glassfish.api.container.Sniffer in project Payara by payara.

the class ApplicationLifecycle method getSniffersFromApp.

@Override
public List<Sniffer> getSniffersFromApp(Application app) {
    List<String> snifferTypes = new ArrayList<String>();
    for (com.sun.enterprise.config.serverbeans.Module module : app.getModule()) {
        for (Engine engine : module.getEngines()) {
            snifferTypes.add(engine.getSniffer());
        }
    }
    if (snifferTypes.isEmpty()) {
        // domain.xml, so we need to re-process it during deployment
        return null;
    }
    List<Sniffer> sniffers = new ArrayList<Sniffer>();
    if (app.isStandaloneModule()) {
        for (String snifferType : snifferTypes) {
            Sniffer sniffer = snifferManager.getSniffer(snifferType);
            if (sniffer != null) {
                sniffers.add(sniffer);
            } else {
                logger.log(Level.SEVERE, KernelLoggerInfo.cantFindSniffer, snifferType);
            }
        }
        if (sniffers.isEmpty()) {
            logger.log(Level.SEVERE, KernelLoggerInfo.cantFindSnifferForApp, app.getName());
            return null;
        }
    } else {
        // composite application.
        return null;
    }
    return sniffers;
}
Also used : Sniffer(org.glassfish.api.container.Sniffer) com.sun.enterprise.config.serverbeans(com.sun.enterprise.config.serverbeans)

Example 17 with Sniffer

use of org.glassfish.api.container.Sniffer in project Payara by payara.

the class ContainerMapper method initializeFileURLPattern.

private void initializeFileURLPattern(String ext) {
    for (Sniffer sniffer : grizzlyService.getHabitat().<Sniffer>getAllServices(Sniffer.class)) {
        boolean match = false;
        if (sniffer.getURLPatterns() != null) {
            for (String pattern : sniffer.getURLPatterns()) {
                if (pattern.equalsIgnoreCase(ext)) {
                    match = true;
                    break;
                }
            }
            HttpHandler httpHandler;
            if (match) {
                httpHandler = grizzlyService.getHabitat().getService(SnifferAdapter.class);
                ((SnifferAdapter) httpHandler).initialize(sniffer, this);
                ContextRootInfo c = new ContextRootInfo(httpHandler, null);
                mapperLock.readLock().unlock();
                mapperLock.writeLock().lock();
                try {
                    for (String pattern : sniffer.getURLPatterns()) {
                        for (String host : grizzlyService.hosts) {
                            mapper.addWrapper(host, ROOT, pattern, c, "*.jsp".equals(pattern) || "*.jspx".equals(pattern));
                        }
                    }
                } finally {
                    mapperLock.readLock().lock();
                    mapperLock.writeLock().unlock();
                }
                return;
            }
        }
    }
}
Also used : Sniffer(org.glassfish.api.container.Sniffer) ContextRootInfo(org.glassfish.grizzly.config.ContextRootInfo)

Aggregations

Sniffer (org.glassfish.api.container.Sniffer)17 IOException (java.io.IOException)5 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)4 ActionReport (org.glassfish.api.ActionReport)3 Test (org.junit.Test)3 PropertyVetoException (java.beans.PropertyVetoException)2 ArrayList (java.util.ArrayList)2 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)2 MultiException (org.glassfish.hk2.api.MultiException)2 Types (org.glassfish.hk2.classmodel.reflect.Types)2 DeploymentTracing (org.glassfish.internal.deployment.DeploymentTracing)2 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)2 RetryableException (org.jvnet.hk2.config.RetryableException)2 SAXParseException (org.xml.sax.SAXParseException)2 com.sun.enterprise.config.serverbeans (com.sun.enterprise.config.serverbeans)1 Application (com.sun.enterprise.config.serverbeans.Application)1 Engine (com.sun.enterprise.config.serverbeans.Engine)1 ArchiveFactory (com.sun.enterprise.deploy.shared.ArchiveFactory)1