use of org.glassfish.hk2.bootstrap.impl.ClasspathDescriptorFileFinder in project Payara by payara.
the class ACCModulesManager method prepareHabitat.
/**
* Sets up the HK2 habitat.
* <p>
* Must be invoked at least once before an AppClientContainerBuilder
* returns a new AppClientContainer to the caller.
* @param classLoader
* @param logger
* @throws com.sun.enterprise.module.bootstrap.BootException
* @throws java.net.URISyntaxException
*/
private static ServiceLocator prepareHabitat(final ClassLoader loader) {
ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create("default");
habitat = serviceLocator;
ContextDuplicatePostProcessor duplicateProcessor = new ContextDuplicatePostProcessor();
List<PopulatorPostProcessor> postProcessors = new LinkedList<PopulatorPostProcessor>();
postProcessors.add(duplicateProcessor);
try {
HK2Populator.populate(serviceLocator, new ClasspathDescriptorFileFinder(loader), postProcessors);
} catch (IOException e) {
e.printStackTrace();
}
return habitat;
}
use of org.glassfish.hk2.bootstrap.impl.ClasspathDescriptorFileFinder in project Payara by payara.
the class Utils method getNewServiceLocator.
public static ServiceLocator getNewServiceLocator(String name) {
ServiceLocator habitat = null;
if (ServiceLocatorFactory.getInstance().find(name) == null) {
ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create(name);
DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.commit();
habitat = ServiceLocatorFactory.getInstance().create(name);
try {
HK2Populator.populate(serviceLocator, new ClasspathDescriptorFileFinder(Utils.class.getClassLoader()), null);
} catch (IOException e) {
e.printStackTrace();
}
}
return (habitat != null) ? habitat : ServiceLocatorFactory.getInstance().create(name);
}
Aggregations