Search in sources :

Example 11 with ModulesRegistry

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

the class ASClassLoaderUtil method getModulesClasspath.

private static synchronized String getModulesClasspath(ServiceLocator habitat) {
    synchronized (ASClassLoaderUtil.class) {
        if (modulesClassPath == null) {
            final StringBuilder tmpString = new StringBuilder();
            ModulesRegistry mr = habitat.getService(ModulesRegistry.class);
            if (mr != null) {
                for (Module module : mr.getModules()) {
                    for (URI uri : module.getModuleDefinition().getLocations()) {
                        tmpString.append(uri.getPath());
                        tmpString.append(File.pathSeparator);
                    }
                }
            }
            // set shared classpath for module so that it doesn't need to be
            // recomputed for every other invocation
            modulesClassPath = tmpString.toString();
        }
    }
    return modulesClassPath;
}
Also used : ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) Module(com.sun.enterprise.module.Module) URI(java.net.URI)

Example 12 with ModulesRegistry

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

the class RemoteCLICommand method getManHabitat.

/**
 * Return a ServiceLocator used just for reading man pages from the modules
 * in the modules directory.
 */
private static synchronized ServiceLocator getManHabitat() {
    if (manServiceLocator != null)
        return manServiceLocator;
    ModulesRegistry registry = new StaticModulesRegistry(getModuleClassLoader());
    manServiceLocator = registry.createServiceLocator("default");
    return manServiceLocator;
}
Also used : ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry)

Example 13 with ModulesRegistry

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

the class VerifyDomainXmlCommand method executeCommand.

/**
 */
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
    File domainXMLFile = getDomainXml();
    logger.log(Level.FINER, "Domain XML file = {0}", domainXMLFile);
    try {
        // get the list of JAR files from the modules directory
        ArrayList<URL> urls = new ArrayList<URL>();
        File idir = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
        File mdir = new File(idir, "modules");
        for (File f : mdir.listFiles()) {
            if (f.toString().endsWith(".jar")) {
                urls.add(f.toURI().toURL());
            }
        }
        final URL[] urlsA = urls.toArray(new URL[urls.size()]);
        ClassLoader cl = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {

            @Override
            public Object run() {
                return new URLClassLoader(urlsA, Globals.class.getClassLoader());
            }
        });
        ModulesRegistry registry = new StaticModulesRegistry(cl);
        ServiceLocator serviceLocator = registry.createServiceLocator("default");
        ConfigParser parser = new ConfigParser(serviceLocator);
        URL domainURL = domainXMLFile.toURI().toURL();
        DomDocument doc = parser.parse(domainURL);
        Dom domDomain = doc.getRoot();
        Domain domain = domDomain.createProxy(Domain.class);
        DomainXmlVerifier validator = new DomainXmlVerifier(domain);
        if (validator.invokeConfigValidator())
            return 1;
    } catch (Exception e) {
        throw new CommandException(e);
    }
    return 0;
}
Also used : Dom(org.jvnet.hk2.config.Dom) ArrayList(java.util.ArrayList) ConfigParser(org.jvnet.hk2.config.ConfigParser) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) URL(java.net.URL) IOException(java.io.IOException) DomDocument(org.jvnet.hk2.config.DomDocument) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) PrivilegedAction(java.security.PrivilegedAction) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) Domain(com.sun.enterprise.config.serverbeans.Domain) File(java.io.File)

Example 14 with ModulesRegistry

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

the class RuntimeRootImpl method stopDomain.

public void stopDomain() {
    final ModulesRegistry registry = InjectedValues.getInstance().getModulesRegistry();
    final Collection<Module> modules = registry.getModules("com.sun.enterprise.osgi-adapter");
    if (modules.size() == 1) {
        final Module mgmtAgentModule = modules.iterator().next();
        mgmtAgentModule.stop();
    } else {
        AMXLoggerInfo.getLogger().warning(AMXLoggerInfo.cantFindOSGIAdapter);
    }
    AMXLoggerInfo.getLogger().warning(AMXLoggerInfo.stoppingServerForcibly);
    System.exit(0);
}
Also used : ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) Module(com.sun.enterprise.module.Module)

Example 15 with ModulesRegistry

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

the class Globals method getStaticHabitat.

/**
 * Returns the default service locator. If it does not exist, one will be created.
 * @return
 */
public static ServiceLocator getStaticHabitat() {
    if (defaultHabitat == null) {
        synchronized (staticLock) {
            if (defaultHabitat == null) {
                ModulesRegistry modulesRegistry = new StaticModulesRegistry(Globals.class.getClassLoader());
                defaultHabitat = modulesRegistry.createServiceLocator("default");
            }
        }
    }
    return defaultHabitat;
}
Also used : StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry)

Aggregations

ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)15 StaticModulesRegistry (com.sun.enterprise.module.single.StaticModulesRegistry)8 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)6 StartupContext (com.sun.enterprise.module.bootstrap.StartupContext)5 Module (com.sun.enterprise.module.Module)3 File (java.io.File)3 URLClassLoader (java.net.URLClassLoader)3 Main (com.sun.enterprise.module.bootstrap.Main)2 ModuleStartup (com.sun.enterprise.module.bootstrap.ModuleStartup)2 IOException (java.io.IOException)2 URL (java.net.URL)2 PrivilegedAction (java.security.PrivilegedAction)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ProcessEnvironment (org.glassfish.api.admin.ProcessEnvironment)2 GlassFishException (org.glassfish.embeddable.GlassFishException)2 InitialGroupInfoService (com.sun.corba.ee.impl.folb.InitialGroupInfoService)1 Domain (com.sun.enterprise.config.serverbeans.Domain)1 BootException (com.sun.enterprise.module.bootstrap.BootException)1 ContextDuplicatePostProcessor (com.sun.enterprise.module.bootstrap.ContextDuplicatePostProcessor)1