Search in sources :

Example 11 with Sniffer

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

the class InplantedTest method Test.

@Test
public void Test() {
    ServiceLocator habitat = server.getHabitat();
    System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
    for (Sniffer s : habitat.<Sniffer>getAllServices(Sniffer.class)) {
        System.out.println("Got sniffer " + s.getModuleType());
    }
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) Sniffer(org.glassfish.api.container.Sniffer) Test(org.junit.Test)

Example 12 with Sniffer

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

the class DOLUtils method setExtensionArchivistForSubArchivist.

/**
 * Sets the class for processing an archive on a subarchive
 * <p>
 * If there an exception occurs in this method it will be caught and logged as a warning
 * @param habitat
 * @param archive
 * @param md
 * @param app
 * @param subArchivist
 */
public static void setExtensionArchivistForSubArchivist(ServiceLocator habitat, ReadableArchive archive, ModuleDescriptor md, Application app, Archivist subArchivist) {
    try {
        Collection<Sniffer> sniffers = getSniffersForModule(habitat, archive, md, app);
        ArchivistFactory archivistFactory = habitat.getService(ArchivistFactory.class);
        subArchivist.setExtensionArchivists(archivistFactory.getExtensionsArchivists(sniffers, subArchivist.getModuleType()));
    } catch (Exception e) {
        deplLogger.log(Level.WARNING, EXCEPTION_CAUGHT, new Object[] { e.getMessage(), e });
    }
}
Also used : Sniffer(org.glassfish.api.container.Sniffer) ArchivistFactory(com.sun.enterprise.deployment.archivist.ArchivistFactory) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException)

Example 13 with Sniffer

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

the class DolProvider method processDOL.

private Application processDOL(DeploymentContext dc) throws IOException {
    ReadableArchive sourceArchive = dc.getSource();
    sourceArchive.setExtraData(Types.class, dc.getTransientAppMetaData(Types.class.getName(), Types.class));
    sourceArchive.setExtraData(Parser.class, dc.getTransientAppMetaData(Parser.class.getName(), Parser.class));
    ClassLoader cl = dc.getClassLoader();
    DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
    sourceArchive.addArchiveMetaData(DeploymentProperties.APP_PROPS, dc.getAppProps());
    sourceArchive.addArchiveMetaData(DeploymentProperties.COMMAND_PARAMS, params);
    String name = params.name();
    String archiveType = dc.getArchiveHandler().getArchiveType();
    Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
    if (archivist == null) {
        // an empty Application object
        return Application.createApplication();
    }
    archivist.setAnnotationProcessingRequested(true);
    String xmlValidationLevel = dasConfig.getDeployXmlValidation();
    archivist.setXMLValidationLevel(xmlValidationLevel);
    if (xmlValidationLevel.equals("none")) {
        archivist.setXMLValidation(false);
    }
    archivist.setRuntimeXMLValidationLevel(xmlValidationLevel);
    if (xmlValidationLevel.equals("none")) {
        archivist.setRuntimeXMLValidation(false);
    }
    Collection<Sniffer> sniffers = dc.getTransientAppMetaData(DeploymentProperties.SNIFFERS, Collection.class);
    archivist.setExtensionArchivists(archivistFactory.getExtensionsArchivists(sniffers, archivist.getModuleType()));
    ApplicationHolder holder = dc.getModuleMetaData(ApplicationHolder.class);
    File deploymentPlan = params.deploymentplan;
    handleDeploymentPlan(deploymentPlan, archivist, sourceArchive, holder);
    long start = System.currentTimeMillis();
    Application application = null;
    if (holder != null) {
        application = holder.app;
        application.setAppName(name);
        application.setClassLoader(cl);
        application.setRoleMapper(null);
        if (application.isVirtual()) {
            ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
            md.setModuleName(name);
        }
        try {
            applicationFactory.openWith(application, sourceArchive, archivist);
        } catch (SAXParseException e) {
            throw new IOException(e);
        }
    } else {
        // and it's a standalone module
        try {
            application = applicationFactory.openArchive(name, archivist, sourceArchive, true);
            application.setAppName(name);
            ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
            md.setModuleName(name);
        } catch (SAXParseException e) {
            throw new IOException(e);
        }
    }
    application.setRegistrationName(name);
    sourceArchive.removeExtraData(Types.class);
    sourceArchive.removeExtraData(Parser.class);
    Logger.getAnonymousLogger().log(Level.FINE, "DOL Loading time" + (System.currentTimeMillis() - start));
    return application;
}
Also used : Types(org.glassfish.hk2.classmodel.reflect.Types) Sniffer(org.glassfish.api.container.Sniffer) IOException(java.io.IOException) Parser(org.glassfish.hk2.classmodel.reflect.Parser) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) SAXParseException(org.xml.sax.SAXParseException) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) File(java.io.File) Application(com.sun.enterprise.deployment.Application)

Example 14 with Sniffer

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

the class GetDeploymentConfigurationsCommand method execute.

/**
 * Entry point from the framework into the command execution
 * @param context context for the command.
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    ActionReport.MessagePart part = report.getTopMessagePart();
    final ApplicationInfo appInfo = appRegistry.get(appname);
    if (appInfo == null) {
        return;
    }
    try {
        if (appInfo.getEngineRefs().size() > 0) {
            // composite archive case, i.e. ear
            for (EngineRef ref : appInfo.getEngineRefs()) {
                Sniffer appSniffer = ref.getContainerInfo().getSniffer();
                addToResultDDList("", appSniffer.getDeploymentConfigurations(appInfo.getSource()), part);
            }
            for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) {
                for (Sniffer moduleSniffer : moduleInfo.getSniffers()) {
                    ReadableArchive moduleArchive = appInfo.getSource().getSubArchive(moduleInfo.getName());
                    addToResultDDList(moduleInfo.getName(), moduleSniffer.getDeploymentConfigurations(moduleArchive), part);
                }
            }
        } else {
            // standalone module
            for (Sniffer sniffer : appInfo.getSniffers()) {
                addToResultDDList(appname, sniffer.getDeploymentConfigurations(appInfo.getSource()), part);
            }
        }
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ModuleInfo(org.glassfish.internal.data.ModuleInfo) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Sniffer(org.glassfish.api.container.Sniffer) IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) EngineRef(org.glassfish.internal.data.EngineRef)

Example 15 with Sniffer

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

the class IsSnifferUserVisibleCommand method execute.

public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    ActionReport.MessagePart part = report.getTopMessagePart();
    Sniffer sniffer = snifferManager.getSniffer(sniffername);
    if (sniffer != null) {
        String isVisible = String.valueOf(sniffer.isUserVisible());
        part.addProperty(DeploymentProperties.IS_SNIFFER_USER_VISIBLE, isVisible);
        part.setMessage(isVisible);
    }
}
Also used : Sniffer(org.glassfish.api.container.Sniffer) ActionReport(org.glassfish.api.ActionReport)

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