ResinELContext elContext = _args.getELContext();
// XXX: needs to be config
InjectManager webBeans = InjectManager.create();
Config.setProperty("resinHome", elContext.getResinHome());
Config.setProperty("resin", elContext.getResinVar());
Config.setProperty("server", elContext.getServerVar());
Config.setProperty("java", elContext.getJavaVar());
Config.setProperty("system", System.getProperties());
Config.setProperty("getenv", System.getenv());
ResinConfigLibrary.configure(webBeans);
_watchdogPort = _args.getWatchdogPort();
readConfig(_args);
WatchdogChild server = null;
if (_args.isDynamicServer()) {
String serverId = _args.getDynamicAddress() + "-"
+ _args.getDynamicPort();
server = _watchdogMap.get(serverId);
}
else
server = _watchdogMap.get(_args.getServerId());
if (server == null)
throw new IllegalStateException(L().l("'{0}' is an unknown server",
_args.getServerId()));
JniBoot boot = new JniBoot();
Path logDirectory = getLogDirectory();
if (boot.isValid()) {
if (! isLogDirectoryExists) {
logDirectory.mkdirs();
boot.chown(logDirectory, server.getUserName(), server.getGroupName());
}
}
server.getConfig().logInit(logStream);
Resin resin = Resin.createWatchdog();
resin.preConfigureInit();
resin.setConfigFile(_args.getResinConf().getNativePath());
Thread thread = Thread.currentThread();
thread.setContextClassLoader(resin.getClassLoader());
Cluster cluster = resin.createCluster();
ClusterServer clusterServer = cluster.createServer();
// cluster.addServer(clusterServer);
clusterServer.setId("");
clusterServer.setPort(0);
// clusterServer.addHttp(http);
cluster.addServer(clusterServer);
resin.addCluster(cluster);
_server = resin.createServer();
thread.setContextClassLoader(_server.getClassLoader());
_httpPort = _server.createHttp();
if (_watchdogPort > 0)
_httpPort.setPort(_watchdogPort);
else
_httpPort.setPort(server.getWatchdogPort());
_httpPort.setAddress(server.getWatchdogAddress());
_httpPort.setAcceptThreadMin(1);
_httpPort.setAcceptThreadMax(2);
_httpPort.init();
_server.bindPorts();
ClassLoader oldLoader = thread.getContextClassLoader();
try {
thread.setContextClassLoader(_server.getClassLoader());
webBeans = InjectManager.create();
AdminAuthenticator auth = null;
if (_management != null)
auth = _management.getAdminAuthenticator();
if (auth != null) {
BeanFactory<Authenticator> factory = webBeans.createBeanFactory(Authenticator.class);
factory.type(Authenticator.class);
factory.type(AdminAuthenticator.class);
factory.binding(CurrentLiteral.CURRENT);
webBeans.addBean(factory.singleton(auth));
}
DependencyCheckInterval depend = new DependencyCheckInterval();
depend.setValue(new Period(-1));
depend.init();