use of org.apache.felix.http.proxy.ProxyServlet in project sling by apache.
the class SlingServletDelegate method init.
/**
* Initializes this servlet by loading the framework configuration
* properties, starting the OSGi framework (Apache Felix) and exposing the
* system bundle context and the <code>Felix</code> instance as servlet
* context attributes.
*
* @throws ServletException if the framework cannot be initialized.
*/
@Override
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());
// 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();
}
}
}
Aggregations