}
String jvmVersion = System.getProperty("java.runtime.version");
if ("1.6".compareTo(jvmVersion) > 0) {
throw new ConfigException(L().l("Resin requires Java 1.6 or later but was started with {0}",
jvmVersion));
}
// required for license check
System.setProperty("resin.home", resinHome.getNativePath());
// watchdog/0210
// Vfs.setPwd(_rootDirectory);
if (! _args.getResinConf().canRead()) {
throw new ConfigException(L().l("Resin/{0} can't open configuration file '{1}'",
VersionFactory.getVersion(),
_args.getResinConf().getNativePath()));
}
Path rootDirectory = _args.getRootDirectory();
Path dataDirectory = rootDirectory.lookup("watchdog-data");
ResinSystem system = new ResinSystem("watchdog",
rootDirectory,
dataDirectory);
Thread thread = Thread.currentThread();
thread.setContextClassLoader(system.getClassLoader());
LibraryLoader libLoader = new LibraryLoader();
libLoader.setPath(rootDirectory.lookup("lib"));
libLoader.init();
Config config = new Config();
BootResinConfig bootManager = new BootResinConfig(system, _args);
ResinELContext elContext = _args.getELContext();
/**
* XXX: the following setVar calls should not be necessary, but the
* EL.setEnviornment() call above is not effective:
*/
InjectManager beanManager = InjectManager.create();
Config.setProperty("resinHome", elContext.getResinHome());
Config.setProperty("java", elContext.getJavaVar());
Config.setProperty("resin", elContext.getResinVar());
Config.setProperty("server", elContext.getServerVar());
Config.setProperty("system", System.getProperties());
Config.setProperty("getenv", System.getenv());
ResinConfigLibrary.configure(beanManager);
config.configure(bootManager, _args.getResinConf(),
"com/caucho/server/resin/resin.rnc");
if (_args.isDynamicServer()) {
_client = bootManager.addDynamicClient(_args);
}
else {
_client = bootManager.findClient(_args.getServerId());
}
if (_client == null && _args.isShutdown()) {
_client = bootManager.findShutdownClient();
}
if (_client == null && ! (_args.isStart() || _args.isConsole())) {
_client = bootManager.findShutdownClient();
}
if (_client == null) {
throw new ConfigException(L().l("Resin/{0}: -server '{1}' does not match any defined <server>\nin {2}.",
VersionFactory.getVersion(), _args.getServerId(), _args.getResinConf()));
}
}