Search in sources :

Example 6 with Module

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

the class AppServerStartup method printModuleStatus.

public static void printModuleStatus(ModulesRegistry registry, Level level) {
    if (!logger.isLoggable(level) || registry == null) {
        return;
    }
    StringBuilder sb = new StringBuilder("Module Status Report Begins\n");
    for (Module m : registry.getModules()) {
        if (m.getState() == ModuleState.READY) {
            sb.append(m).append("\n");
        }
    }
    sb.append("\n");
    // then resolved
    for (Module m : registry.getModules()) {
        if (m.getState() == ModuleState.RESOLVED) {
            sb.append(m).append("\n");
        }
    }
    sb.append("\n");
    // finally installed
    for (Module m : registry.getModules()) {
        if (m.getState() != ModuleState.READY && m.getState() != ModuleState.RESOLVED) {
            sb.append(m).append("\n");
        }
    }
    sb.append("Module Status Report Ends");
    logger.log(level, sb.toString());
}
Also used : Module(com.sun.enterprise.module.Module)

Example 7 with Module

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

the class ContainerStarter method startContainer.

public Collection<EngineInfo> startContainer(Sniffer sniffer) {
    assert sniffer != null;
    String containerName = sniffer.getModuleType();
    assert containerName != null;
    // repositories which would allow access to the container module.
    try {
        Module[] modules = sniffer.setup(null, logger);
        logger.logp(Level.FINE, "ContainerStarter", "startContainer", "Sniffer {0} set up following modules: {1}", new Object[] { sniffer, modules != null ? Arrays.toString(modules) : "" });
    } catch (FileNotFoundException fnf) {
        logger.log(Level.SEVERE, fnf.getMessage());
        return null;
    } catch (IOException ioe) {
        logger.log(Level.SEVERE, ioe.getMessage(), ioe);
        return null;
    }
    // first the right container from that module.
    Map<String, EngineInfo> containers = new HashMap<String, EngineInfo>();
    for (String name : sniffer.getContainersNames()) {
        ServiceHandle<Container> provider = serviceLocator.getServiceHandle(Container.class, name);
        if (provider == null) {
            logger.severe("Cannot find Container named " + name + ", so unable to start " + sniffer.getModuleType() + " container");
            return null;
        }
        EngineInfo info = new EngineInfo(provider, sniffer, null);
        containers.put(name, info);
    }
    // Now that we have successfully created all containers, let's register them as well.
    for (Map.Entry<String, EngineInfo> entry : containers.entrySet()) {
        registry.addContainer(entry.getKey(), entry.getValue());
    }
    return containers.values();
}
Also used : EngineInfo(org.glassfish.internal.data.EngineInfo) Container(org.glassfish.api.container.Container) HashMap(java.util.HashMap) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Module(com.sun.enterprise.module.Module) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 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 9 with Module

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

the class ActiveModules method generateModuleStatus.

/*
     * For all modules in the READY state map the module to a location
     * in a bit field.   The location is determined by the mapping defined
     * in the ModuleMap.   The bit to set is in one of six long values.  
     * This method calculates which bit in which long value should be set.
     * We use network-byte order.
     */
public String generateModuleStatus() {
    long[] loadedModules = { 0, 0, 0, 0, 0, 0 };
    StringBuilder str = new StringBuilder(128);
    for (Module m : registry.getModules()) {
        if (m.getState() == ModuleState.READY) {
            Integer bit = ModuleMap.getMap().get(m.getName());
            /* 
                 * If the module name is not in the map set the high bit
                 * so we know we have unmapped modules in use.
                 */
            if (bit == null) {
                bit = UNMAPPED_MODULE;
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("ActiveModules: Unmapped module: " + m.getName());
                }
            }
            int group = (bit - 1) / 64;
            if (group > 5) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("ActiveModules: id out of range: " + m.getName() + " " + bit);
                }
                // Ignore if the module map id is out of range.
                continue;
            }
            bit -= 64 * group;
            if (bit != null) {
                loadedModules[group] |= ((long) 1 << (bit.intValue() - 1));
            }
        }
    }
    // We are using the standard network byte order (big-endian)
    for (int i = NLONGS - 1; i >= 0; i--) {
        str.append(Long.toHexString(loadedModules[i]));
        if (i != 0)
            str.append(" ");
    }
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("ActiveModules: loadModules[0]: " + Long.toBinaryString(loadedModules[0]));
        logger.fine("ActiveModules: loadModules[1]: " + Long.toBinaryString(loadedModules[1]));
        logger.fine("ActiveModules: loadModules[2]: " + Long.toBinaryString(loadedModules[2]));
        logger.fine("ActiveModules: loadModules[3]: " + Long.toBinaryString(loadedModules[3]));
        logger.fine("ActiveModules: loadModules[4]: " + Long.toBinaryString(loadedModules[4]));
        logger.fine("ActiveModules: loadModules[5]: " + Long.toBinaryString(loadedModules[5]));
    }
    return (str.toString());
}
Also used : Module(com.sun.enterprise.module.Module)

Example 10 with Module

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

the class GlassFishTldProvider method postConstruct.

public void postConstruct() {
    Class jsfImplClass = null;
    try {
        jsfImplClass = getClass().getClassLoader().loadClass("com.sun.faces.spi.InjectionProvider");
    } catch (ClassNotFoundException ignored) {
    }
    URI[] uris = null;
    Module m = null;
    if (jsfImplClass != null) {
        m = registry.find(jsfImplClass);
    }
    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[] { "JSF", 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) 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)

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