use of fish.payara.micro.boot.loader.OpenURLClassLoader in project Payara by payara.
the class PayaraMicroImpl method addLibrary.
@Override
public PayaraMicroImpl addLibrary(File lib) {
OpenURLClassLoader loader = (OpenURLClassLoader) this.getClass().getClassLoader();
if (lib.exists() && lib.canRead() && lib.getName().endsWith(".jar")) {
try {
loader.addURL(lib.toURI().toURL());
LOGGER.log(Level.INFO, "Added " + lib.getAbsolutePath() + " to classpath");
} catch (MalformedURLException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
} else {
LOGGER.log(Level.SEVERE, "Unable to read jar " + lib.getName());
}
return this;
}
use of fish.payara.micro.boot.loader.OpenURLClassLoader 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;
}
Aggregations