Search in sources :

Example 1 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class ListContainersCommand method execute.

public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    report.setActionDescription(localStrings.getLocalString("list.containers.command", "List of Containers"));
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ActionReport.MessagePart top = report.getTopMessagePart();
    top.setMessage(localStrings.getLocalString("list.containers.command", "List of Containers"));
    top.setChildrenType(localStrings.getLocalString("container", "Container"));
    Iterable<? extends Sniffer> sniffers = habitat.getAllServices(Sniffer.class);
    if (sniffers == null) {
        top.setMessage(localStrings.getLocalString("list.containers.nocontainer", "No container currently configured"));
    } else {
        for (Sniffer sniffer : sniffers) {
            ActionReport.MessagePart container = top.addChild();
            container.setMessage(sniffer.getModuleType());
            container.addProperty(localStrings.getLocalString("contractprovider", "ContractProvider"), sniffer.getModuleType());
            EngineInfo engineInfo = containerRegistry.getContainer(sniffer.getModuleType());
            if (engineInfo != null) {
                container.addProperty(localStrings.getLocalString("status", "Status"), localStrings.getLocalString("started", "Started"));
                Module connectorModule = modulesRegistry.find(engineInfo.getSniffer().getClass());
                container.addProperty(localStrings.getLocalString("connector", "Connector"), connectorModule.getModuleDefinition().getName() + ":" + connectorModule.getModuleDefinition().getVersion());
                container.addProperty(localStrings.getLocalString("implementation", "Implementation"), engineInfo.getContainer().getClass().toString());
                boolean atLeastOne = false;
                for (Application app : applications.getApplications()) {
                    for (com.sun.enterprise.config.serverbeans.Module module : app.getModule()) {
                        Engine engine = module.getEngine(engineInfo.getSniffer().getModuleType());
                        if (engine != null) {
                            if (!atLeastOne) {
                                atLeastOne = true;
                                container.setChildrenType(localStrings.getLocalString("list.containers.listapps", "Applications deployed"));
                            }
                            container.addChild().setMessage(app.getName());
                        }
                    }
                }
                if (!atLeastOne) {
                    container.addProperty("Status", "Not Started");
                }
            }
        }
    }
}
Also used : Sniffer(org.glassfish.api.container.Sniffer) ActionReport(org.glassfish.api.ActionReport) EngineInfo(org.glassfish.internal.data.EngineInfo) Module(com.sun.enterprise.module.Module) Application(com.sun.enterprise.config.serverbeans.Application) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 2 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class MonitoringBootstrap method loadXMLProviders.

private void loadXMLProviders(File xmlProvidersDir) {
    // Creates a filter which will return only xml files
    FilenameFilter filter = new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.endsWith(".xml");
        }
    };
    // Retrieves all the provider XML's
    File[] files = xmlProvidersDir.listFiles(filter);
    if (files == null)
        return;
    Map<String, File> providerMap = new HashMap();
    for (File file : files) {
        if (logger.isLoggable(Level.FINE))
            logger.fine("Found the provider xml - " + file.getAbsolutePath());
        int index = file.getName().indexOf("-:");
        if (index != -1) {
            String moduleName = file.getName().substring(0, index);
            providerMap.put(moduleName, file);
            if (logger.isLoggable(Level.FINE))
                logger.fine(" The provider xml belongs to - \"" + moduleName + "\"");
            if (!map.containsKey(moduleName)) {
                continue;
            }
            if (logger.isLoggable(Level.FINE))
                logger.fine(" Module found (containsKey)");
            Module module = map.get(moduleName);
            if (module == null) {
                logger.log(Level.SEVERE, monitoringMissingModuleFromXmlProbeProviders, new Object[] { moduleName });
            } else {
                ClassLoader mcl = module.getClassLoader();
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("ModuleClassLoader = " + mcl);
                    logger.fine("XML File path = " + file.getAbsolutePath());
                }
                processProbeProviderXML(mcl, file.getAbsolutePath(), false);
            }
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) Module(com.sun.enterprise.module.Module) File(java.io.File)

Example 3 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class JerseyMvcTldProvider method postConstruct.

public void postConstruct() {
    final Class jerseyIncludeClass = org.glassfish.jersey.server.mvc.jsp.Include.class;
    URI[] uris = null;
    Module m = null;
    if (jerseyIncludeClass != null) {
        m = registry.find(jerseyIncludeClass);
    }
    if (m != null) {
        uris = m.getModuleDefinition().getLocations();
    } else {
        ClassLoader classLoader = getClass().getClassLoader();
        if (classLoader instanceof URLClassLoader) {
            URL[] urls = ((URLClassLoader) classLoader).getURLs();
            if (urls != null && urls.length > 0) {
                uris = new URI[urls.length];
                for (int i = 0; i < urls.length; i++) {
                    try {
                        uris[i] = urls[i].toURI();
                    } catch (URISyntaxException e) {
                        String msg = rb.getString(LogFacade.TLD_PROVIDER_IGNORE_URL);
                        msg = MessageFormat.format(msg, urls[i]);
                        logger.log(Level.WARNING, msg, e);
                    }
                }
            }
        } else {
            logger.log(Level.WARNING, LogFacade.UNABLE_TO_DETERMINE_TLD_RESOURCES, new Object[] { JerseyMvcTldProvider.class.getSimpleName(), classLoader, JerseyMvcTldProvider.class.getName() });
        }
    }
    if (uris != null && uris.length > 0) {
        Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
        for (URI uri : uris) {
            List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
            if (entries != null && entries.size() > 0) {
                tldMap.put(uri, entries);
            }
        }
    }
}
Also used : JarURIPattern(com.sun.enterprise.util.net.JarURIPattern) Pattern(java.util.regex.Pattern) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) Module(com.sun.enterprise.module.Module)

Example 4 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class GlassFishTldProvider method postConstruct.

public void postConstruct() {
    /*
         * Check whether JSP caching has been enabled
         */
    Config cfg = serverContext.getDefaultServices().getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
    WebContainer webContainer = cfg.getExtensionByType(WebContainer.class);
    if (webContainer == null) {
        return;
    }
    if (!Boolean.valueOf(webContainer.getJspCachingEnabled())) {
        return;
    }
    /*
         * JSP caching has been enabled
         */
    Class jspCachingImplClass = CacheTag.class;
    URI[] uris = null;
    Module m = null;
    if (jspCachingImplClass != null) {
        m = registry.find(jspCachingImplClass);
    }
    if (m != null) {
        uris = m.getModuleDefinition().getLocations();
    } else {
        ClassLoader classLoader = getClass().getClassLoader();
        if (classLoader instanceof URLClassLoader) {
            URL[] urls = ((URLClassLoader) classLoader).getURLs();
            if (urls != null && urls.length > 0) {
                uris = new URI[urls.length];
                for (int i = 0; i < urls.length; i++) {
                    try {
                        uris[i] = urls[i].toURI();
                    } catch (URISyntaxException e) {
                        String msg = rb.getString(LogFacade.TLD_PROVIDER_IGNORE_URL);
                        msg = MessageFormat.format(msg, urls[i]);
                        logger.log(Level.WARNING, msg, e);
                    }
                }
            }
        } else {
            logger.log(Level.WARNING, LogFacade.UNABLE_TO_DETERMINE_TLD_RESOURCES, new Object[] { "JSP Caching", classLoader, GlassFishTldProvider.class.getName() });
        }
    }
    if (uris != null && uris.length > 0) {
        Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
        for (URI uri : uris) {
            List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
            if (entries != null && entries.size() > 0) {
                tldMap.put(uri, entries);
            }
        }
    }
}
Also used : JarURIPattern(com.sun.enterprise.util.net.JarURIPattern) Pattern(java.util.regex.Pattern) Config(com.sun.enterprise.config.serverbeans.Config) WebContainer(org.glassfish.web.config.serverbeans.WebContainer) CacheTag(com.sun.appserv.web.taglibs.cache.CacheTag) Module(com.sun.enterprise.module.Module)

Example 5 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class GenericSniffer method setup.

/**
 * Sets up the container libraries so that any imported bundle from the
 * connector jar file will now be known to the module subsystem
 *
 * This method returns a {@link ModuleDefinition} for the module containing
 * the core implementation of the container. That means that this module
 * will be locked as long as there is at least one module loaded in the
 * associated container.
 *
 * @param containerHome is where the container implementation resides (Not used anymore)
 * @param logger the logger to use
 * @return the module definition of the core container implementation.
 *
 * @throws java.io.IOException exception if something goes sour
 */
@Override
public synchronized Module[] setup(String containerHome, Logger logger) throws IOException {
    // TODO(Sahoo): Change signature to not accept containerHome or logger
    if (modules != null) {
        if (logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, "GenericSniffer", "setup", "{0} has already setup {1} container, so just returning.", new Object[] { this, containerName });
        }
        return modules;
    }
    List<Module> tmp = new ArrayList<Module>();
    for (String moduleName : getContainerModuleNames()) {
        Module m = modulesRegistry.makeModuleFor(moduleName, null);
        if (m != null) {
            tmp.add(m);
        } else {
            throw new RuntimeException("Unable to set up module " + moduleName);
        }
    }
    modules = tmp.toArray(new Module[tmp.size()]);
    return modules;
}
Also used : Module(com.sun.enterprise.module.Module)

Aggregations

Module (com.sun.enterprise.module.Module)16 JarURIPattern (com.sun.enterprise.util.net.JarURIPattern)4 URI (java.net.URI)4 Pattern (java.util.regex.Pattern)4 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)3 URISyntaxException (java.net.URISyntaxException)3 URL (java.net.URL)3 URLClassLoader (java.net.URLClassLoader)3 HashMap (java.util.HashMap)2 ActionReport (org.glassfish.api.ActionReport)2 EngineInfo (org.glassfish.internal.data.EngineInfo)2 CacheTag (com.sun.appserv.web.taglibs.cache.CacheTag)1 InitialGroupInfoService (com.sun.corba.ee.impl.folb.InitialGroupInfoService)1 Application (com.sun.enterprise.config.serverbeans.Application)1 Config (com.sun.enterprise.config.serverbeans.Config)1 Engine (com.sun.enterprise.config.serverbeans.Engine)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1