use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class ConfigTest method before.
@BeforeClass
public static void before() {
DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
new ConfigModule(habitat).configure(config);
config.commit();
}
use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class ConfigDisposalTest method before.
@Before
public void before() {
String testName = TEST_NAME + RANDOM.nextInt();
habitat = ServiceLocatorFactory.getInstance().create(testName);
DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
new ConfigModule(habitat).configure(config);
config.commit();
parseDomainXml();
}
use of org.glassfish.hk2.api.DynamicConfigurationService 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();
}
}
use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class MicroGlassFishRuntime method newGlassFish.
@Override
public GlassFish newGlassFish(GlassFishProperties glassfishProperties) throws GlassFishException {
System.setProperty("com.sun.aas.installRoot", System.getProperty("com.sun.aas.instanceRoot"));
System.setProperty("com.sun.aas.installRootURI", System.getProperty("com.sun.aas.instanceRootURI"));
glassfishProperties.setProperty("com.sun.aas.installRoot", System.getProperty("com.sun.aas.instanceRoot"));
glassfishProperties.setProperty("com.sun.aas.installRootURI", System.getProperty("com.sun.aas.instanceRootURI"));
StartupContext context = new StartupContext(glassfishProperties.getProperties());
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
if (tccl instanceof OpenURLClassLoader) {
// Only our runtime classloaders list individual runtime jars.
SingleHK2Factory.initialize(tccl);
} else {
// Otherwise we assume we're in rootdir classloader and runtime jars are listed in boot jar's Class-Path
// manifest attribute
initializeWithJarManifest(tccl);
}
ModulesRegistry registry = AbstractFactory.getInstance().createModulesRegistry();
ServiceLocator habitat = registry.newServiceLocator();
DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(context));
config.commit();
registry.populateServiceLocator("default", habitat, Arrays.asList(new PayaraMicroInhabitantsParser(), new EmbeddedInhabitantsParser(), new DuplicatePostProcessor()));
registry.populateConfig(habitat);
ModuleStartup kernel = habitat.getService(ModuleStartup.class);
gf = new MicroGlassFish(kernel, habitat, glassfishProperties.getProperties());
return gf;
}
use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class LocalOSGiShellCommand method atomicReplace.
private static void atomicReplace(ServiceLocator locator, ProgramOptions options) {
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addUnbindFilter(BuilderHelper.createContractFilter(ProgramOptions.class.getName()));
ActiveDescriptor<ProgramOptions> desc = BuilderHelper.createConstantDescriptor(options, null, ProgramOptions.class);
config.addActiveDescriptor(desc);
config.commit();
}
Aggregations