use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class ASClassLoaderUtil method getModulesClasspath.
private static synchronized String getModulesClasspath(ServiceLocator habitat) {
synchronized (ASClassLoaderUtil.class) {
if (modulesClassPath == null) {
final StringBuilder tmpString = new StringBuilder();
ModulesRegistry mr = habitat.getService(ModulesRegistry.class);
if (mr != null) {
for (Module module : mr.getModules()) {
for (URI uri : module.getModuleDefinition().getLocations()) {
tmpString.append(uri.getPath());
tmpString.append(File.pathSeparator);
}
}
}
// set shared classpath for module so that it doesn't need to be
// recomputed for every other invocation
modulesClassPath = tmpString.toString();
}
}
return modulesClassPath;
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class RemoteCLICommand method getManHabitat.
/**
* Return a ServiceLocator used just for reading man pages from the modules
* in the modules directory.
*/
private static synchronized ServiceLocator getManHabitat() {
if (manServiceLocator != null)
return manServiceLocator;
ModulesRegistry registry = new StaticModulesRegistry(getModuleClassLoader());
manServiceLocator = registry.createServiceLocator("default");
return manServiceLocator;
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class VerifyDomainXmlCommand method executeCommand.
/**
*/
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
File domainXMLFile = getDomainXml();
logger.log(Level.FINER, "Domain XML file = {0}", domainXMLFile);
try {
// get the list of JAR files from the modules directory
ArrayList<URL> urls = new ArrayList<URL>();
File idir = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
File mdir = new File(idir, "modules");
for (File f : mdir.listFiles()) {
if (f.toString().endsWith(".jar")) {
urls.add(f.toURI().toURL());
}
}
final URL[] urlsA = urls.toArray(new URL[urls.size()]);
ClassLoader cl = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Object run() {
return new URLClassLoader(urlsA, Globals.class.getClassLoader());
}
});
ModulesRegistry registry = new StaticModulesRegistry(cl);
ServiceLocator serviceLocator = registry.createServiceLocator("default");
ConfigParser parser = new ConfigParser(serviceLocator);
URL domainURL = domainXMLFile.toURI().toURL();
DomDocument doc = parser.parse(domainURL);
Dom domDomain = doc.getRoot();
Domain domain = domDomain.createProxy(Domain.class);
DomainXmlVerifier validator = new DomainXmlVerifier(domain);
if (validator.invokeConfigValidator())
return 1;
} catch (Exception e) {
throw new CommandException(e);
}
return 0;
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class RuntimeRootImpl method stopDomain.
public void stopDomain() {
final ModulesRegistry registry = InjectedValues.getInstance().getModulesRegistry();
final Collection<Module> modules = registry.getModules("com.sun.enterprise.osgi-adapter");
if (modules.size() == 1) {
final Module mgmtAgentModule = modules.iterator().next();
mgmtAgentModule.stop();
} else {
AMXLoggerInfo.getLogger().warning(AMXLoggerInfo.cantFindOSGIAdapter);
}
AMXLoggerInfo.getLogger().warning(AMXLoggerInfo.stoppingServerForcibly);
System.exit(0);
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class Globals method getStaticHabitat.
/**
* Returns the default service locator. If it does not exist, one will be created.
* @return
*/
public static ServiceLocator getStaticHabitat() {
if (defaultHabitat == null) {
synchronized (staticLock) {
if (defaultHabitat == null) {
ModulesRegistry modulesRegistry = new StaticModulesRegistry(Globals.class.getClassLoader());
defaultHabitat = modulesRegistry.createServiceLocator("default");
}
}
}
return defaultHabitat;
}
Aggregations