Search in sources :

Example 1 with ClientNamingConfigurator

use of org.glassfish.api.naming.ClientNamingConfigurator 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)

Aggregations

ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)1 StartupContext (com.sun.enterprise.module.bootstrap.StartupContext)1 StaticModulesRegistry (com.sun.enterprise.module.single.StaticModulesRegistry)1 ClientNamingConfiguratorImpl (com.sun.enterprise.naming.impl.ClientNamingConfiguratorImpl)1 Logger (java.util.logging.Logger)1 ProcessEnvironment (org.glassfish.api.admin.ProcessEnvironment)1 ClientNamingConfigurator (org.glassfish.api.naming.ClientNamingConfigurator)1 DynamicConfiguration (org.glassfish.hk2.api.DynamicConfiguration)1 DynamicConfigurationService (org.glassfish.hk2.api.DynamicConfigurationService)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1