Search in sources :

Example 1 with RequestHandler

use of com.vaadin.flow.server.RequestHandler in project flow by vaadin.

the class PwaHandler method handleRequest.

@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException {
    PwaRegistry pwaRegistry = pwaRegistryGetter.get();
    boolean hasPwa = pwaRegistry != null && pwaRegistry.getPwaConfiguration().isEnabled();
    RequestHandler handler = null;
    session.lock();
    try {
        if (isInitialized && !hasPwa) {
            requestHandlerMap.clear();
        } else if (!isInitialized && hasPwa) {
            init(pwaRegistry);
        }
        if (hasPwa) {
            handler = requestHandlerMap.get(request.getPathInfo());
        }
    } finally {
        session.unlock();
    }
    if (handler == null) {
        return false;
    } else {
        return handler.handleRequest(session, request, response);
    }
}
Also used : RequestHandler(com.vaadin.flow.server.RequestHandler) PwaRegistry(com.vaadin.flow.server.PwaRegistry)

Example 2 with RequestHandler

use of com.vaadin.flow.server.RequestHandler in project flow by vaadin.

the class SessionRequestHandler method handleRequest.

@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException {
    // Use a copy to avoid ConcurrentModificationException
    session.lock();
    List<RequestHandler> requestHandlers;
    try {
        requestHandlers = new ArrayList<>(session.getRequestHandlers());
    } finally {
        session.unlock();
    }
    for (RequestHandler handler : requestHandlers) {
        if (handler.handleRequest(session, request, response)) {
            return true;
        }
    }
    // If not handled
    return false;
}
Also used : RequestHandler(com.vaadin.flow.server.RequestHandler)

Aggregations

RequestHandler (com.vaadin.flow.server.RequestHandler)2 PwaRegistry (com.vaadin.flow.server.PwaRegistry)1