Search in sources :

Example 1 with StaticModulesRegistry

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

the class ACCModulesManager method initialize.

public static synchronized void initialize(final ClassLoader loader) throws URISyntaxException {
    /*
         * The habitat might have been initialized earlier.  Currently
         * we use a single habitat for the JVM.  
         */
    if (habitat == null) {
        habitat = prepareHabitat(loader);
        /*
             * Set up the default habitat in Globals as soon as we know
             * which habitat we'll use.
             */
        Globals.setDefaultHabitat(habitat);
        ServiceLocator locator = habitat;
        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();
        /*
             * Remove any already-loaded startup context so we can replace it
             * with the ACC one.
             */
        config.addUnbindFilter(BuilderHelper.createContractFilter(StartupContext.class.getName()));
        /*
             * Following the example from AppServerStartup, remove any
             * pre-loaded lazy inhabitant for ProcessEnvironment that exists
             * from HK2's scan for services.  Then add in
             * an ACC ProcessEnvironment.
             */
        config.addUnbindFilter(BuilderHelper.createContractFilter(ProcessEnvironment.class.getName()));
        config.commit();
        config = dcs.createDynamicConfiguration();
        StartupContext startupContext = new ACCStartupContext();
        AbstractActiveDescriptor<?> startupContextDescriptor = BuilderHelper.createConstantDescriptor(startupContext);
        startupContextDescriptor.addContractType(StartupContext.class);
        config.addActiveDescriptor(startupContextDescriptor);
        ModulesRegistry modulesRegistry = new StaticModulesRegistry(ACCModulesManager.class.getClassLoader());
        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(modulesRegistry));
        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new ProcessEnvironment(ProcessEnvironment.ProcessType.ACC)));
        /*
             * Create the ClientNamingConfigurator used by naming.
             */
        ClientNamingConfigurator cnc = new ClientNamingConfiguratorImpl();
        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(cnc));
        Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        AbstractActiveDescriptor<Logger> di = BuilderHelper.createConstantDescriptor(logger);
        di.addContractType(Logger.class);
        config.addActiveDescriptor(di);
        config.commit();
    }
}
Also used : DynamicConfigurationService(org.glassfish.hk2.api.DynamicConfigurationService) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) Logger(java.util.logging.Logger) ProcessEnvironment(org.glassfish.api.admin.ProcessEnvironment) ClientNamingConfigurator(org.glassfish.api.naming.ClientNamingConfigurator) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ClientNamingConfiguratorImpl(com.sun.enterprise.naming.impl.ClientNamingConfiguratorImpl) DynamicConfiguration(org.glassfish.hk2.api.DynamicConfiguration) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry)

Example 2 with StaticModulesRegistry

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

the class CLIContainer method getServiceLocator.

public ServiceLocator getServiceLocator() {
    if (serviceLocator == null) {
        Metrix.event("Init hk2 - start");
        ModulesRegistry registry = new StaticModulesRegistry(this.classLoader);
        serviceLocator = registry.createServiceLocator("default");
        if (programOptions != null) {
            ServiceLocatorUtilities.addOneConstant(serviceLocator, programOptions);
        }
        if (environment != null) {
            ServiceLocatorUtilities.addOneConstant(serviceLocator, environment);
        }
        ServiceLocatorUtilities.addOneConstant(serviceLocator, this);
        Metrix.event("Init hk2 - done");
    }
    return serviceLocator;
}
Also used : ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry)

Example 3 with StaticModulesRegistry

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

the class CustomizationTokensProvider method initializeLocator.

protected void initializeLocator() {
    final ClassLoader ecl = CustomizationTokensProvider.class.getClassLoader();
    File inst = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
    final File ext = new File(inst, "modules");
    LOG.log(Level.FINE, "asadmin modules directory: {0}", ext);
    if (ext.isDirectory()) {
        AccessController.doPrivileged(new PrivilegedAction() {

            @Override
            public Object run() {
                try {
                    URLClassLoader pl = new URLClassLoader(getJars(ext));
                    ModulesRegistry registry = new StaticModulesRegistry(pl);
                    locator = registry.createServiceLocator("default");
                    return pl;
                } catch (IOException ex) {
                    // any failure here is fatal
                    LOG.log(Level.SEVERE, ConfigApiLoggerInfo.MODULES_CL_FAILED, ex);
                }
                return ecl;
            }
        });
    } else {
        LOG.log(Level.FINER, "Modules directory does not exist");
    }
}
Also used : 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) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) IOException(java.io.IOException) File(java.io.File)

Example 4 with StaticModulesRegistry

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

the class Utils method getNewHabitat.

public static ServiceLocator getNewHabitat(String root) {
    Properties p = new Properties();
    p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTALL_ROOT_PROP_NAME, root);
    p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTANCE_ROOT_PROP_NAME, root);
    ModulesRegistry registry = new StaticModulesRegistry(Utils.class.getClassLoader(), new StartupContext(p));
    ServiceLocator defaultSL = registry.createServiceLocator("default");
    return defaultSL;
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) Properties(java.util.Properties)

Example 5 with StaticModulesRegistry

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

the class SunDeploymentManager method prepareHabitat.

private void prepareHabitat() {
    ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader());
    ServiceLocator serviceLocator = registry.createServiceLocator("default");
    habitat = serviceLocator.getService(ServiceLocator.class);
    StartupContext startupContext = new StartupContext();
    ServiceLocatorUtilities.addOneConstant(habitat, startupContext);
    ServiceLocatorUtilities.addOneConstant(habitat, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other));
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) ProcessEnvironment(org.glassfish.api.admin.ProcessEnvironment)

Aggregations

StaticModulesRegistry (com.sun.enterprise.module.single.StaticModulesRegistry)9 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)8 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)5 StartupContext (com.sun.enterprise.module.bootstrap.StartupContext)3 File (java.io.File)2 IOException (java.io.IOException)2 URLClassLoader (java.net.URLClassLoader)2 PrivilegedAction (java.security.PrivilegedAction)2 ProcessEnvironment (org.glassfish.api.admin.ProcessEnvironment)2 Domain (com.sun.enterprise.config.serverbeans.Domain)1 ClientNamingConfiguratorImpl (com.sun.enterprise.naming.impl.ClientNamingConfiguratorImpl)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Logger (java.util.logging.Logger)1 ClientNamingConfigurator (org.glassfish.api.naming.ClientNamingConfigurator)1 DynamicConfiguration (org.glassfish.hk2.api.DynamicConfiguration)1 DynamicConfigurationService (org.glassfish.hk2.api.DynamicConfigurationService)1 ConfigParser (org.jvnet.hk2.config.ConfigParser)1 Dom (org.jvnet.hk2.config.Dom)1