2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.io.neeo.internal.servletservices;
15 import java.io.IOException;
17 import javax.servlet.http.HttpServletRequest;
18 import javax.servlet.http.HttpServletResponse;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.events.Event;
23 import org.openhab.core.events.EventFilter;
26 * The interface definition for a servlet service. This interface describes the contract for any implemenation wanting
27 * to be a service for a servlet - which includes determining whether a route is valid for it, handling get/post and
30 * @author Tim Roberts - Initial Contribution
33 public interface ServletService extends AutoCloseable {
36 * Determines if the service can handle a route
38 * @param paths the non-null, possibly empty route paths
39 * @return true if it can handle the route, false otherwise
41 boolean canHandleRoute(String[] paths);
44 * Handles the get request. Will only be called if {@link #canHandleRoute(String[])} returns true
46 * @param req the non-null {@link HttpServletRequest}
47 * @param paths the non-null, possibly empty route paths
48 * @param resp the non-null {@link HttpServletResponse}
49 * @throws IOException Signals that an I/O exception has occurred.
51 void handleGet(HttpServletRequest req, String[] paths, HttpServletResponse resp) throws IOException;
54 * Handles the post request. Will only be called if {@link #canHandleRoute(String[])} returns true
56 * @param req the non-null {@link HttpServletRequest}
57 * @param paths the non-null, possibly empty route paths
58 * @param resp the non-null {@link HttpServletResponse}
59 * @throws IOException Signals that an I/O exception has occurred.
61 void handlePost(HttpServletRequest req, String[] paths, HttpServletResponse resp) throws IOException;
64 * Handles the event request and should return true if handled (false if not)
66 * @param event the non-null event
67 * @return true if handled, false otherwise
69 boolean handleEvent(Event event);
72 * Returns the {@link EventFilter} to use to filter events
74 * @return the possibly null event filter;
77 EventFilter getEventFilter();