Search in sources :

Example 21 with ServletHandler

use of org.apache.felix.http.base.internal.handler.ServletHandler in project felix by apache.

the class SharedHttpServiceImpl method unregister.

/**
 * @see org.osgi.service.http.HttpService#unregister(java.lang.String)
 */
public Servlet unregister(final String alias) {
    synchronized (this.aliasMap) {
        final ServletHandler handler = this.aliasMap.remove(alias);
        if (handler == null) {
            throw new IllegalArgumentException("Nothing registered at " + alias);
        }
        final Servlet s = handler.getServlet();
        this.handlerRegistry.getRegistry(handler.getContextServiceId()).unregisterServlet(handler.getServletInfo(), true);
        return s;
    }
}
Also used : ServletHandler(org.apache.felix.http.base.internal.handler.ServletHandler) HttpServiceServletHandler(org.apache.felix.http.base.internal.handler.HttpServiceServletHandler) Servlet(javax.servlet.Servlet)

Example 22 with ServletHandler

use of org.apache.felix.http.base.internal.handler.ServletHandler in project felix by apache.

the class SharedServletContextImpl method getNamedDispatcher.

@Override
public RequestDispatcher getNamedDispatcher(final String name) {
    if (name == null) {
        return null;
    }
    final RequestDispatcher dispatcher;
    final ServletHandler servletHandler = this.registry.resolveServletByName(name);
    if (servletHandler != null) {
        final ServletResolution resolution = new ServletResolution();
        resolution.handler = servletHandler;
        resolution.handlerRegistry = this.registry;
        // TODO - what is the path of a named servlet?
        final RequestInfo requestInfo = new RequestInfo("", null, null, null);
        dispatcher = new RequestDispatcherImpl(resolution, requestInfo);
    } else {
        dispatcher = null;
    }
    return dispatcher;
}
Also used : ServletResolution(org.apache.felix.http.base.internal.registry.ServletResolution) ServletHandler(org.apache.felix.http.base.internal.handler.ServletHandler) RequestInfo(org.apache.felix.http.base.internal.dispatch.RequestInfo) RequestDispatcher(javax.servlet.RequestDispatcher) RequestDispatcherImpl(org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)

Aggregations

ServletHandler (org.apache.felix.http.base.internal.handler.ServletHandler)22 HttpServiceServletHandler (org.apache.felix.http.base.internal.handler.HttpServiceServletHandler)12 Test (org.junit.Test)9 FailedDTOHolder (org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder)7 ServletContextDTO (org.osgi.service.http.runtime.dto.ServletContextDTO)7 Servlet (javax.servlet.Servlet)6 ServletConfig (javax.servlet.ServletConfig)5 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 ServletInfo (org.apache.felix.http.base.internal.runtime.ServletInfo)3 FileNotFoundException (java.io.FileNotFoundException)2 RequestDispatcher (javax.servlet.RequestDispatcher)2 ServletException (javax.servlet.ServletException)2 RequestDispatcherImpl (org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)2 RequestInfo (org.apache.felix.http.base.internal.dispatch.RequestInfo)2 FilterHandler (org.apache.felix.http.base.internal.handler.FilterHandler)2 ServletResolution (org.apache.felix.http.base.internal.registry.ServletResolution)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1