use of com.sun.enterprise.module.bootstrap.ContextDuplicatePostProcessor 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 com.sun.enterprise.module.bootstrap.ContextDuplicatePostProcessor in project Payara by payara.
the class StaticGlassFishRuntime method newGlassFish.
/**
* Creates a new GlassFish instance and add it to a Map of instances
* created by this runtime.
*
* @param glassFishProperties
* @return
* @throws Exception
*/
@Override
public synchronized GlassFish newGlassFish(GlassFishProperties glassFishProperties) throws GlassFishException {
// some code to be executed which may be depending on the environment variable values.
try {
// Don't set temporarily created instanceroot in the user supplied
// GlassFishProperties, hence clone it.
Properties cloned = new Properties();
cloned.putAll(glassFishProperties.getProperties());
final GlassFishProperties gfProps = new GlassFishProperties(cloned);
setEnv(gfProps);
final StartupContext startupContext = new StartupContext(gfProps.getProperties());
ModulesRegistry modulesRegistry = SingleHK2Factory.getInstance().createModulesRegistry();
ServiceLocator serviceLocator = main.createServiceLocator(modulesRegistry, startupContext, Arrays.asList((PopulatorPostProcessor) new EmbeddedInhabitantsParser(), new ContextDuplicatePostProcessor()), null);
final ModuleStartup gfKernel = main.findStartupService(modulesRegistry, serviceLocator, null, startupContext);
// create a new GlassFish instance
GlassFishImpl gfImpl = new GlassFishImpl(gfKernel, serviceLocator, gfProps.getProperties()) {
@Override
public void dispose() throws GlassFishException {
try {
super.dispose();
} finally {
gfMap.remove(gfProps.getInstanceRoot());
if ("true".equalsIgnoreCase(gfProps.getProperties().getProperty(autoDelete)) && gfProps.getInstanceRoot() != null) {
File instanceRoot = new File(gfProps.getInstanceRoot());
if (instanceRoot.exists()) {
// might have been deleted already.
Util.deleteRecursive(instanceRoot);
}
}
}
}
};
// Add this newly created instance to a Map
gfMap.put(gfProps.getInstanceRoot(), gfImpl);
return gfImpl;
} catch (GlassFishException e) {
throw e;
} catch (Exception e) {
throw new GlassFishException(e);
}
}
Aggregations