Search in sources :

Example 1 with ServletMatch

use of com.ibm.designer.runtime.domino.adapter.ServletMatch in project org.openntf.xsp.jakartaee by OpenNTF.

the class ServletServletFactory method getServletMatch.

@Override
public final ServletMatch getServletMatch(String contextPath, String path) throws javax.servlet.ServletException {
    try {
        if (LibraryUtil.usesLibrary(ServletLibrary.LIBRARY_ID, module)) {
            for (Map.Entry<WebServlet, Class<? extends Servlet>> entry : getModuleServlets().entrySet()) {
                String match = matches(entry.getKey(), path);
                if (match != null) {
                    javax.servlet.Servlet servlet = getExecutorServlet(entry.getKey(), entry.getValue());
                    String pathInfo = findPathInfo(path, match);
                    int pathInfoLen = pathInfo == null ? 0 : pathInfo.length();
                    return new ServletMatch(servlet, path.substring(0, path.length() - pathInfoLen), pathInfo);
                }
            }
        }
    } catch (UncheckedIOException e) {
        throw new javax.servlet.ServletException(e);
    }
    return null;
}
Also used : ServletMatch(com.ibm.designer.runtime.domino.adapter.ServletMatch) WebServlet(jakarta.servlet.annotation.WebServlet) ServletException(javax.servlet.ServletException) Servlet(jakarta.servlet.Servlet) WebServlet(jakarta.servlet.annotation.WebServlet) UncheckedIOException(java.io.UncheckedIOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ServletMatch

use of com.ibm.designer.runtime.domino.adapter.ServletMatch in project org.openntf.xsp.jakartaee by OpenNTF.

the class OldServletContextWrapper method getRequestDispatcher.

@Override
public RequestDispatcher getRequestDispatcher(String path) {
    // Unsupported on Domino, so try to replicate the behavior from the ComponentModule
    ServletMatch match = getServletFactories().stream().map(f -> {
        try {
            return f.getServletMatch(getContextPath(), path);
        } catch (javax.servlet.ServletException e) {
            throw new RuntimeException(e);
        }
    }).filter(Objects::nonNull).findFirst().orElse(null);
    if (match != null) {
        // TODO figure out if this behavior should change
        return new RequestDispatcher() {

            @Override
            public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
                Servlet servlet = ServletUtil.oldToNew(match.getServlet());
                servlet.service(request, response);
            }

            @Override
            public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
                Servlet servlet = ServletUtil.oldToNew(match.getServlet());
                servlet.service(request, response);
            }
        };
    }
    return null;
}
Also used : ComponentModule(com.ibm.designer.runtime.domino.adapter.ComponentModule) RequestDispatcher(jakarta.servlet.RequestDispatcher) ServletRegistration(jakarta.servlet.ServletRegistration) SessionCookieConfig(jakarta.servlet.SessionCookieConfig) Enumeration(java.util.Enumeration) URL(java.net.URL) Dynamic(jakarta.servlet.FilterRegistration.Dynamic) HashMap(java.util.HashMap) ServletContextAttributeListener(jakarta.servlet.ServletContextAttributeListener) IServletFactory(com.ibm.designer.runtime.domino.adapter.IServletFactory) ServletException(jakarta.servlet.ServletException) ArrayList(java.util.ArrayList) MappingBasedServletFactory(org.openntf.xsp.jakartaee.MappingBasedServletFactory) Filter(jakarta.servlet.Filter) JspPropertyGroupDescriptor(jakarta.servlet.descriptor.JspPropertyGroupDescriptor) Map(java.util.Map) ServletContextAttributeEvent(jakarta.servlet.ServletContextAttributeEvent) EnumSet(java.util.EnumSet) PrivilegedActionException(java.security.PrivilegedActionException) ServletMatch(com.ibm.designer.runtime.domino.adapter.ServletMatch) ServletRequest(jakarta.servlet.ServletRequest) MalformedURLException(java.net.MalformedURLException) Collection(java.util.Collection) Set(java.util.Set) SessionTrackingMode(jakarta.servlet.SessionTrackingMode) TaglibDescriptor(jakarta.servlet.descriptor.TaglibDescriptor) IOException(java.io.IOException) NSFComponentModule(com.ibm.domino.xsp.module.nsf.NSFComponentModule) Field(java.lang.reflect.Field) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) EventListener(java.util.EventListener) List(java.util.List) Stream(java.util.stream.Stream) JspConfigDescriptor(jakarta.servlet.descriptor.JspConfigDescriptor) FilterRegistration(jakarta.servlet.FilterRegistration) ServletResponse(jakarta.servlet.ServletResponse) NotesContext(com.ibm.domino.xsp.module.nsf.NotesContext) Servlet(jakarta.servlet.Servlet) ServletContext(jakarta.servlet.ServletContext) AccessController(java.security.AccessController) Collections(java.util.Collections) InputStream(java.io.InputStream) ServletException(jakarta.servlet.ServletException) ServletRequest(jakarta.servlet.ServletRequest) ServletResponse(jakarta.servlet.ServletResponse) ServletMatch(com.ibm.designer.runtime.domino.adapter.ServletMatch) Objects(java.util.Objects) Servlet(jakarta.servlet.Servlet) RequestDispatcher(jakarta.servlet.RequestDispatcher)

Example 3 with ServletMatch

use of com.ibm.designer.runtime.domino.adapter.ServletMatch in project org.openntf.xsp.jakartaee by OpenNTF.

the class MappingBasedServletFactory method getServletMatch.

@Override
public final ServletMatch getServletMatch(String contextPath, String path) throws ServletException {
    try {
        String lib = getLibraryId();
        if (StringUtil.isEmpty(lib) || LibraryUtil.usesLibrary(lib, module)) {
            for (String ext : getExtensions()) {
                int extIndex = StringUtil.toString(path).indexOf(ext);
                if (extIndex > -1) {
                    String servletPath = path.substring(0, extIndex + ext.length());
                    String pathInfo = path.substring(extIndex + ext.length());
                    return new ServletMatch(getExecutorServlet(), servletPath, pathInfo);
                }
            }
        }
    } catch (UncheckedIOException e) {
        throw new ServletException(e);
    }
    return null;
}
Also used : ServletException(javax.servlet.ServletException) ServletMatch(com.ibm.designer.runtime.domino.adapter.ServletMatch) UncheckedIOException(java.io.UncheckedIOException)

Aggregations

ServletMatch (com.ibm.designer.runtime.domino.adapter.ServletMatch)3 Servlet (jakarta.servlet.Servlet)2 UncheckedIOException (java.io.UncheckedIOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ServletException (javax.servlet.ServletException)2 ComponentModule (com.ibm.designer.runtime.domino.adapter.ComponentModule)1 IServletFactory (com.ibm.designer.runtime.domino.adapter.IServletFactory)1 NSFComponentModule (com.ibm.domino.xsp.module.nsf.NSFComponentModule)1 NotesContext (com.ibm.domino.xsp.module.nsf.NotesContext)1 Filter (jakarta.servlet.Filter)1 FilterRegistration (jakarta.servlet.FilterRegistration)1 Dynamic (jakarta.servlet.FilterRegistration.Dynamic)1 RequestDispatcher (jakarta.servlet.RequestDispatcher)1 ServletContext (jakarta.servlet.ServletContext)1 ServletContextAttributeEvent (jakarta.servlet.ServletContextAttributeEvent)1 ServletContextAttributeListener (jakarta.servlet.ServletContextAttributeListener)1 ServletException (jakarta.servlet.ServletException)1 ServletRegistration (jakarta.servlet.ServletRegistration)1 ServletRequest (jakarta.servlet.ServletRequest)1