You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RequestHandler.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server;
  17. import java.io.IOException;
  18. import java.io.Serializable;
  19. import com.vaadin.ui.UI;
  20. /**
  21. * Handler for producing a response to HTTP requests. Handlers can be either
  22. * added on a {@link VaadinService service} level, common for all users, or on a
  23. * {@link VaadinSession session} level for only a single user.
  24. */
  25. @FunctionalInterface
  26. public interface RequestHandler extends Serializable {
  27. /**
  28. * Called when a request needs to be handled. If a response is written, this
  29. * method should return <code>true</code> to indicate that no more request
  30. * handlers should be invoked for the request.
  31. * <p>
  32. * Note that request handlers by default do not lock the session. If you are
  33. * using VaadinSession or anything inside the VaadinSession you must ensure
  34. * the session is locked. This can be done by extending
  35. * {@link SynchronizedRequestHandler} or by using
  36. * {@link VaadinSession#accessSynchronously(Runnable)} or
  37. * {@link UI#accessSynchronously(Runnable)}.
  38. * </p>
  39. *
  40. * @param session
  41. * The session for the request
  42. * @param request
  43. * The request to handle
  44. * @param response
  45. * The response object to which a response can be written.
  46. * @return true if a response has been written and no further request
  47. * handlers should be called, otherwise false
  48. * @throws IOException
  49. * If an IO error occurred
  50. */
  51. boolean handleRequest(VaadinSession session, VaadinRequest request,
  52. VaadinResponse response) throws IOException;
  53. }