Search in sources :

Example 16 with ServletConfig

use of javax.servlet.ServletConfig in project opennms by OpenNMS.

the class ServletHandler method init.

@Override
public void init() throws ServletException {
    String name = "servlet_" + getId();
    ServletConfig config = new ServletConfigImpl(name, getContext(), getInitParams());
    this.servlet.init(config);
}
Also used : ServletConfig(javax.servlet.ServletConfig)

Example 17 with ServletConfig

use of javax.servlet.ServletConfig in project opennms by OpenNMS.

the class PollerConfigServlet method reloadFiles.

/**
     * <p>reloadFiles</p>
     *
     * @throws javax.servlet.ServletException if any.
     */
public void reloadFiles() throws ServletException {
    ServletConfig config = this.getServletConfig();
    try {
        PollerConfigFactory.init();
        pollerFactory = PollerConfigFactory.getInstance();
        pollerConfig = pollerFactory.getConfiguration();
        if (pollerConfig == null) {
            throw new ServletException("Poller Configuration file is empty");
        }
    } catch (Throwable e) {
        throw new ServletException(e.getMessage());
    }
    initPollerServices();
    this.redirectSuccess = config.getInitParameter("redirect.success");
    if (this.redirectSuccess == null) {
        throw new ServletException("Missing required init parameter: redirect.success");
    }
}
Also used : ServletException(javax.servlet.ServletException) ServletConfig(javax.servlet.ServletConfig)

Example 18 with ServletConfig

use of javax.servlet.ServletConfig in project opennms by OpenNMS.

the class ImportAssetsServlet method init.

/**
     * Looks up the <code>redirect.success</code> parameter in the servlet's
     * configuration. If not present, this servlet will throw an exception so it will
     * be marked unavailable.
     *
     * @throws javax.servlet.ServletException if any.
     */
@Override
public void init() throws ServletException {
    ServletConfig config = this.getServletConfig();
    this.redirectSuccess = config.getInitParameter("redirect.success");
    if (this.redirectSuccess == null) {
        throw new UnavailableException("Require a redirect.success init parameter.");
    }
    this.model = new AssetModel();
}
Also used : ServletConfig(javax.servlet.ServletConfig) UnavailableException(javax.servlet.UnavailableException)

Example 19 with ServletConfig

use of javax.servlet.ServletConfig in project opennms by OpenNMS.

the class MailerServlet method init.

/**
     * <p>init</p>
     *
     * @throws javax.servlet.ServletException if any.
     */
@Override
public void init() throws ServletException {
    ServletConfig config = this.getServletConfig();
    this.redirectSuccess = config.getInitParameter("redirect.success");
    this.mailProgram = config.getInitParameter("mail.program");
    if (this.redirectSuccess == null) {
        throw new ServletException("Missing required init parameter: redirect.success");
    }
    if (this.mailProgram == null) {
        throw new ServletException("Missing required init parameter: mail.program");
    }
}
Also used : ServletException(javax.servlet.ServletException) ServletConfig(javax.servlet.ServletConfig)

Example 20 with ServletConfig

use of javax.servlet.ServletConfig in project pratilipi by Pratilipi.

the class GenericService method service.

@Override
protected final void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String requestUri = request.getRequestURI();
    ServletConfig servletConfig = getServletConfig();
    String prefix = servletConfig.getInitParameter("Prefix");
    if (prefix != null && !prefix.isEmpty())
        requestUri = requestUri.substring(prefix.length());
    if (requestUri.isEmpty())
        requestUri = "/";
    String apiVer = request.getParameter(RequestParameter.API_VERSION.getName());
    GenericApi api = apiVer == null ? ApiRegistry.getApi(requestUri) : ApiRegistry.getApi(requestUri, apiVer);
    if (api == null)
        super.service(request, response);
    else
        api.service(request, response);
}
Also used : ServletConfig(javax.servlet.ServletConfig)

Aggregations

ServletConfig (javax.servlet.ServletConfig)69 ServletContext (javax.servlet.ServletContext)52 Enumeration (java.util.Enumeration)37 BeforeMethod (org.testng.annotations.BeforeMethod)21 ServletException (javax.servlet.ServletException)20 Test (org.junit.Test)15 IOException (java.io.IOException)12 BlockingIOCometSupport (org.atmosphere.container.BlockingIOCometSupport)9 MockServletConfig (org.springframework.mock.web.test.MockServletConfig)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 MockServletContext (org.springframework.mock.web.test.MockServletContext)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 AtmosphereFramework (org.atmosphere.runtime.AtmosphereFramework)6 ServletContextAwareProcessor (org.springframework.web.context.support.ServletContextAwareProcessor)6 HttpServlet (javax.servlet.http.HttpServlet)5 SimpleBroadcaster (org.atmosphere.util.SimpleBroadcaster)5 UnavailableException (javax.servlet.UnavailableException)4 PrintWriter (java.io.PrintWriter)3 AsynchronousProcessor (org.atmosphere.runtime.AsynchronousProcessor)3 AtmosphereRequest (org.atmosphere.runtime.AtmosphereRequest)3