in src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java [189:254]
public final void init() throws ServletException {
// temporary holders control final setup and ensure proper
// disposal in case of setup errors
Sling tmpSling = null;
Servlet tmpDelegatee = null;
try {
log("Starting Apache Sling in " + slingHome);
// read the default parameters
Map<String, String> props = loadConfigProperties(slingHome);
Logger logger = new ServletContextLogger(getServletContext());
LaunchpadContentProvider rp = new ServletContextResourceProvider(
getServletContext());
tmpSling = SlingBridge.getSlingBridge(notifiable, logger, rp, props, getServletContext());
// set up the OSGi HttpService proxy servlet
tmpDelegatee = new ProxyServlet();
tmpDelegatee.init(getServletConfig());
// set the fields only if the SlingServletDelegate has no been destroyed
// while Sling has been starting up. Otherwise we do not set the
// fields and leave the temporary variables assigned to have
// them destroyed in the finally clause.
if (servletDestroyed) {
log("SlingServletDelegate destroyed while starting Apache Sling, shutting Apache Sling down");
} else {
// set the fields now
sling = tmpSling;
delegatee = tmpDelegatee;
// reset temporary holders to prevent destroyal
tmpSling = null;
tmpDelegatee = null;
log("Apache Sling successfully started in " + slingHome);
}
} catch (BundleException be) {
throw new ServletException("Failed to start Apache Sling in " + slingHome, be);
} catch (ServletException se) {
throw new ServletException("Failed to start bridge servlet for Apache Sling", se);
} catch (Throwable t) {
throw new ServletException("Uncaught Failure starting Apache Sling", t);
} finally {
// clean up temporary fields
if (tmpDelegatee != null) {
tmpDelegatee.destroy();
}
if (tmpSling != null) {
tmpSling.destroy();
}
}
}