use of org.apache.sling.launchpad.base.shared.Loader in project sling by apache.
the class SlingServlet method startSling.
/**
* Called from the startup thread initiated by a request or from
* {@link #init()} to install the launcher jar and actually start sling.
*/
private void startSling() {
try {
File launchpadHome = getLaunchpadHome(slingHome);
this.loader = new Loader(launchpadHome) {
@Override
protected void info(String msg) {
log(msg);
}
};
} catch (IllegalArgumentException iae) {
startupFailure(null, iae);
return;
}
try {
URL launcherJar = getServletContext().getResource(SharedConstants.DEFAULT_SLING_LAUNCHER_JAR);
if (launcherJar == null) {
launcherJar = getServletContext().getResource("/WEB-INF" + SharedConstants.DEFAULT_SLING_LAUNCHER_JAR);
}
startSling(launcherJar);
} catch (MalformedURLException mue) {
log("Cannot load Apache Sling Launcher JAR " + SharedConstants.DEFAULT_SLING_LAUNCHER_JAR, mue);
}
}
use of org.apache.sling.launchpad.base.shared.Loader in project sling by apache.
the class Main method doStart.
protected boolean doStart(final URL launcherJar) {
// prevent duplicate start
if (this.started) {
info("Apache Sling has already been started", null);
return true;
}
info("Starting Apache Sling in " + slingHome, null);
this.started = true;
Loader loaderTmp = null;
try {
final File launchpadHome = getLaunchpadHome(slingHome, commandLineArgs);
loaderTmp = new Loader(launchpadHome) {
@Override
protected void info(String msg) {
Main.info(msg, null);
}
};
} catch (IllegalArgumentException iae) {
error("Cannot launch: Launchpad folder cannot be used: " + iae.getMessage(), null);
return false;
}
this.loader = loaderTmp;
if (launcherJar != null) {
try {
loader.installLauncherJar(launcherJar);
} catch (IOException ioe) {
error("Cannot launch: Cannot install " + launcherJar + " for use", ioe);
return false;
}
} else {
info("No Launcher JAR to install", null);
}
Object object = null;
try {
object = loader.loadLauncher(SharedConstants.DEFAULT_SLING_MAIN);
} catch (IllegalArgumentException iae) {
error("Cannot launch: Failed loading Sling class " + SharedConstants.DEFAULT_SLING_MAIN, iae);
return false;
}
if (object instanceof Launcher) {
// configure the launcher
Launcher sling = (Launcher) object;
sling.setNotifiable(new Notified());
sling.setCommandLine(commandLineArgs);
sling.setSlingHome(slingHome);
// launch it
info("Starting launcher ...", null);
if (sling.start()) {
info("Startup completed", null);
this.sling = sling;
addShutdownHook();
return true;
}
error("Cannot launch: Launcher.start() returned false", null);
} else {
error("Cannot launch: Class " + SharedConstants.DEFAULT_SLING_MAIN + " is not a Launcher class", null);
}
return false;
}
Aggregations