@ThreadSafe public interface RESTService
Singleton to bind a resource to a singleton
context instead of a per-request context.
The REST Service implementation is guaranteed to be thread safe.
| Modifier and Type | Method and Description |
|---|---|
void |
addContextResolver(Class<? extends javax.ws.rs.ext.ContextResolver> contextResolver)
Adds an
ContextResolver to all available listeners. |
void |
addContextResolver(Class<? extends javax.ws.rs.ext.ContextResolver> contextResolver,
Collection<String> listenerIdentifier)
Adds an
ContextResolver to all specified listeners. |
void |
addExceptionMapper(Class<? extends javax.ws.rs.ext.ExceptionMapper<? extends Throwable>> exceptionMapper)
Adds an
ExceptionMapper to all available listeners. |
void |
addExceptionMapper(Class<? extends javax.ws.rs.ext.ExceptionMapper<? extends Throwable>> exceptionMapper,
Collection<String> listenerIdentifier)
Adds an
ExceptionMapper to all specified listeners. |
void |
addExceptionMapper(javax.ws.rs.ext.ExceptionMapper<? extends Throwable> exceptionMapper)
Adds an
ExceptionMapper to all available listeners. |
void |
addExceptionMapper(javax.ws.rs.ext.ExceptionMapper<? extends Throwable> exceptionMapper,
Collection<String> listenerIdentifier)
Adds an
ExceptionMapper to all specified listeners. |
<T extends javax.servlet.Filter> |
addFilter(ServletFilter<T> filter,
String path)
Adds a specific
ServletFilter with a given path to the RESTService on all available listeners. |
<T extends javax.servlet.Filter> |
addFilter(ServletFilter<T> filter,
String path,
Collection<String> listeners)
Adds a specific
ServletFilter with a given path to the RESTService on specific listeners. |
void |
addJaxRsApplication(javax.ws.rs.core.Application application)
Adds a
Application to the RESTService. |
void |
addJaxRsApplication(javax.ws.rs.core.Application application,
Collection<String> listenerIdentifiers)
Adds a
Application to the RESTService. |
void |
addJaxRsResources(Class<?>... resources)
Adds an arbitrary number of JAX-RS resources to all available listeners.
|
void |
addJaxRsResources(Collection<Class<?>> resources,
Collection<String> listenerIdentifiers)
Adds an arbitrary number of JAX-RS resources to all specified listeners.
|
void |
addJaxRsSingletons(Collection<Object> singletons,
Collection<String> listenerIdentifiers)
Adds all given JAX-RS resources as singleton to all specified listeners.
|
void |
addJaxRsSingletons(Object... singletons)
Adds all given JAX-RS resources as singleton to all available listeners.
|
void |
addListener(Listener listener)
Adds a new listener to the REST Service programmatically.
|
void |
addMessageBodyReader(Class<? extends javax.ws.rs.ext.MessageBodyReader> messageBodyReader)
Adds a
MessageBodyReader to all listeners. |
void |
addMessageBodyReader(Class<? extends javax.ws.rs.ext.MessageBodyReader> messageBodyReader,
Collection<String> listenerIdentifier)
Adds a
MessageBodyReader to all specified listeners. |
void |
addMessageBodyWriter(Class<? extends javax.ws.rs.ext.MessageBodyWriter> messageBodyWriter)
Adds a
MessageBodyWriter to all listeners. |
void |
addMessageBodyWriter(Class<? extends javax.ws.rs.ext.MessageBodyWriter> messageBodyWriter,
Collection<String> listenerIdentifier)
Adds a
MessageBodyWriter to all specified listeners. |
<T extends javax.servlet.http.HttpServlet> |
addServlet(Class<T> servlet,
String path)
Adds a servlet to a specific path and adds the servlet to all available listeners.
|
<T extends javax.servlet.http.HttpServlet> |
addServlet(Class<T> servlet,
String path,
Collection<String> listenerIdentifiers)
Adds a servlet to a specific path and adds the servlet to all specified listeners.
|
void |
addServlet(javax.servlet.http.HttpServlet servlet,
String path)
Adds a servlet instance to a specific path and adds the servlet to all available listeners.
|
void |
addServlet(javax.servlet.http.HttpServlet servlet,
String path,
Collection<String> listenerIdentifiers)
Adds a servlet instance to a specific path and adds the servlet to all specified listeners.
|
<T extends javax.servlet.http.HttpServlet> |
addServletWithFilters(Class<T> servlet,
String path,
Collection<String> listenerIdentifiers,
ServletFilter<? extends javax.servlet.Filter>... filters)
Adds a servlet to a specific path and adds the servlet to all specified listeners.
|
<T extends javax.servlet.http.HttpServlet> |
addServletWithFilters(Class<T> servlet,
String path,
ServletFilter<? extends javax.servlet.Filter>... filters)
Adds a servlet to a specific path and adds the servlet to all available listeners.
|
void |
addServletWithFilters(javax.servlet.http.HttpServlet servlet,
String path,
Collection<String> listenerIdentifiers,
ServletFilter<? extends javax.servlet.Filter>... filters)
Adds a servlet instance to a specific path and adds the servlet to all specific listeners.
|
void |
addServletWithFilters(javax.servlet.http.HttpServlet servlet,
String path,
ServletFilter<? extends javax.servlet.Filter>... filters)
Adds a servlet instance to a specific path and adds the servlet to all available listeners.
|
Collection<Listener> |
getListeners()
Returns an immutable view of all listeners.
|
void addListener(@NotNull Listener listener)
listener - the Listener implementationNullPointerException - if the passed listener is nullIllegalArgumentException - if the passed listener is not a valid listener type (like HttpListener@ReadOnly Collection<Listener> getListeners()
if (listener instanceof HttpListener) {
HttpListener httpListener = (HttpListener) listener;
}
void addServlet(@NotNull javax.servlet.http.HttpServlet servlet, @NotNull String path)
servlet - the servlet to addpath - the path to bind the servlet toNullPointerException - if the servlet or the path is nullvoid addServlet(@NotNull javax.servlet.http.HttpServlet servlet, @NotNull String path, @NotNull Collection<String> listenerIdentifiers)
servlet - the servlet to addpath - the path to bind the servlet tolistenerIdentifiers - a collection with identifiers of listenersNullPointerException - if the servlet, the path or the listener identifiers collection is null<T extends javax.servlet.http.HttpServlet> T addServlet(@NotNull Class<T> servlet, @NotNull String path)
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addServlet(HttpServlet, String) instead.
servlet - the servlet to addpath - the path to bind the servlet toNullPointerException - if the servlet or the path is null<T extends javax.servlet.http.HttpServlet> T addServlet(@NotNull Class<T> servlet, @NotNull String path, @NotNull Collection<String> listenerIdentifiers)
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addServlet(HttpServlet, String, Collection) instead.
servlet - the servlet to addpath - the path to bind the servlet tolistenerIdentifiers - a collection with identifiers of listenersNullPointerException - if the servlet or the path is null<T extends javax.servlet.Filter> T addFilter(@NotNull ServletFilter<T> filter, @NotNull String path)
ServletFilter with a given path to the RESTService on all available listeners.T - the Filter which is contained in the ServletFilterfilter - the ServletFilterpath - the PathFilter instanceNullPointerException - if the ServletFilter or path is null<T extends javax.servlet.Filter> T addFilter(@NotNull ServletFilter<T> filter, @NotNull String path, @NotNull Collection<String> listeners)
ServletFilter with a given path to the RESTService on specific listeners.T - the Filter which is contained in the ServletFilterfilter - the ServletFilterpath - the Pathlisteners - a collection of listenersFilter instanceNullPointerException - if the ServletFilter, path or listener collection is nullvoid addServletWithFilters(@NotNull javax.servlet.http.HttpServlet servlet, @NotNull String path, @NotNull ServletFilter<? extends javax.servlet.Filter>... filters)
servlet - the servlet to addpath - the path to bind the servlet tofilters - an arbitrary amount of filters for this specific servletNullPointerException - if the servlet, the path or the filter array is nullvoid addServletWithFilters(@NotNull javax.servlet.http.HttpServlet servlet, @NotNull String path, @NotNull Collection<String> listenerIdentifiers, @NotNull ServletFilter<? extends javax.servlet.Filter>... filters)
servlet - the servlet to addpath - the path to bind the servlet tolistenerIdentifiers - a collection of listener identifierdfilters - an arbitrary amount of filters for this specific servletNullPointerException - if the servlet, the path, the listener collection or the filter array is null<T extends javax.servlet.http.HttpServlet> T addServletWithFilters(@NotNull Class<T> servlet, @NotNull String path, @NotNull ServletFilter<? extends javax.servlet.Filter>... filters)
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addServletWithFilters(HttpServlet, String, ServletFilter[]) instead.
servlet - the servlet to addpath - the path to bind the servlet tofilters - an arbitrary amount of filters for this specific servletNullPointerException - if the servlet, the path or the filter array is null<T extends javax.servlet.http.HttpServlet> T addServletWithFilters(@NotNull Class<T> servlet, @NotNull String path, @NotNull Collection<String> listenerIdentifiers, @NotNull ServletFilter<? extends javax.servlet.Filter>... filters)
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addServletWithFilters(HttpServlet, String, Collection, ServletFilter[]) instead.
servlet - the servlet to addpath - the path to bind the servlet tolistenerIdentifiers - the collection of listenersfilters - an arbitrary amount of filters for this specific servletNullPointerException - if the servlet, the path or the filter array is nullvoid addJaxRsApplication(@NotNull javax.ws.rs.core.Application application)
Application to the RESTService.
Please be aware that when using this method, only all properties, classes and singletons are
added to the RESTService, the Application and all annotations on the Application
are ignored. So essentially this is a convenient method which allows you to add a lot of resources at once
Important: ApplicationPath annotations are ignored.
All resources defined in the Application will be added to all available listeners.application - the ApplicationNullPointerException - if the passed Application is nullvoid addJaxRsApplication(@NotNull javax.ws.rs.core.Application application, @NotNull Collection<String> listenerIdentifiers)
Application to the RESTService.
Please be aware that when using this method, only all properties, classes and singletons are
added to the RESTService, the Application and all annotations on the Application
are ignored. So essentially this is a convenient method which allows you to add a lot of resources at once
Important: ApplicationPath annotations are ignored.
All resources defined in the Application will be added to all specified listeners.application - the ApplicationlistenerIdentifiers - a collection of listenersNullPointerException - if the passed Application or the collection of listeners is nullvoid addJaxRsSingletons(@NotNull Object... singletons)
Singletonsingletons - an arbitrary number of singleton resourcesNullPointerException - if the singleton array is nullvoid addJaxRsSingletons(@NotNull Collection<Object> singletons, @NotNull Collection<String> listenerIdentifiers)
Singletonsingletons - an collection of singleton resourceslistenerIdentifiers - a collection of listenersNullPointerException - if the singleton array is nullvoid addJaxRsResources(@NotNull Class<?>... resources)
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addJaxRsResources(Collection, Collection) instead.
resources - a arbitrary number of JAX-RS resource classesNullPointerException - if the resources array is nullvoid addJaxRsResources(@NotNull Collection<Class<?>> resources, @NotNull Collection<String> listenerIdentifiers)
Dependency injection during a constructor or an PostConstruct method is limited.
resources - a collection of JAX-RS resource classeslistenerIdentifiers - a collection of listenersNullPointerException - if the resources array or the listener collection is nullvoid addExceptionMapper(@NotNull javax.ws.rs.ext.ExceptionMapper<? extends Throwable> exceptionMapper)
ExceptionMapper to all available listeners.
Since you have to instantiate the ExceptionMapper objects on your own,
it can't use dependency injection by HiveMQ and you have to pass your dependencies on your own
to the objects.
ExceptionMappers which use dependency injection,
consider using another method of the RESTService which accepts classes instead of objects.exceptionMapper - the JAX-RS ExceptionMapper instance that should be added to all listenersNullPointerException - if the ExceptionMapper is nullvoid addExceptionMapper(@NotNull javax.ws.rs.ext.ExceptionMapper<? extends Throwable> exceptionMapper, @NotNull Collection<String> listenerIdentifier)
ExceptionMapper to all specified listeners.
Since you have to instantiate the ExceptionMapper objects on your own,
it can't use dependency injection by HiveMQ and you have to pass your dependencies on your own
to the objects.
ExceptionMappers which use dependency injection,
consider using another method of the RESTService which accepts classes instead of objects.exceptionMapper - the JAX-RS ExceptionMapper instance that should be added to all specified listenerslistenerIdentifier - a collection of listenersNullPointerException - if the ExceptionMapper or the listener collection is nullvoid addExceptionMapper(@NotNull Class<? extends javax.ws.rs.ext.ExceptionMapper<? extends Throwable>> exceptionMapper)
ExceptionMapper to all available listeners.
The ExceptionMapper can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addExceptionMapper(ExceptionMapper) instead.
exceptionMapper - the JAX-RS ExceptionMapper class that should be added to all listenersNullPointerException - if the ExceptionMapper is nullvoid addExceptionMapper(@NotNull Class<? extends javax.ws.rs.ext.ExceptionMapper<? extends Throwable>> exceptionMapper, @NotNull Collection<String> listenerIdentifier)
ExceptionMapper to all specified listeners.
The ExceptionMapper can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods or addExceptionMapper(ExceptionMapper, Collection) instead.
exceptionMapper - the JAX-RS ExceptionMapper class that should be added to all specified listenerslistenerIdentifier - a collection of listenersNullPointerException - if the ExceptionMapper or the listener collection is nullvoid addContextResolver(@NotNull Class<? extends javax.ws.rs.ext.ContextResolver> contextResolver)
ContextResolver to all available listeners.
The ContextResolver can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods instead.
contextResolver - the JAX-RS ContextResolver class that should be added to all listenersNullPointerException - if the ContextResolver is nullvoid addContextResolver(@NotNull Class<? extends javax.ws.rs.ext.ContextResolver> contextResolver, @NotNull Collection<String> listenerIdentifier)
ContextResolver to all specified listeners.
The ContextResolver can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods instead.
contextResolver - the JAX-RS ContextResolver class that should be added to all specified listenerslistenerIdentifier - the collection of listenersNullPointerException - if the ContextResolver or the listener collection is nullvoid addMessageBodyWriter(@NotNull Class<? extends javax.ws.rs.ext.MessageBodyWriter> messageBodyWriter)
MessageBodyWriter to all listeners.
The MessageBodyWriter can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods instead.
messageBodyWriter - the JAX-RS MessageBodyWriter class that should be added to all listenersNullPointerException - if the MessageBodyWriter is nullvoid addMessageBodyWriter(@NotNull Class<? extends javax.ws.rs.ext.MessageBodyWriter> messageBodyWriter, @NotNull Collection<String> listenerIdentifier)
MessageBodyWriter to all specified listeners.
The MessageBodyWriter can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods instead.
messageBodyWriter - the JAX-RS MessageBodyWriter class that should be added to all specified listenerslistenerIdentifier - the collection of listenersNullPointerException - if the MessageBodyWriter or the listener collection is nullvoid addMessageBodyReader(@NotNull Class<? extends javax.ws.rs.ext.MessageBodyReader> messageBodyReader)
MessageBodyReader to all listeners.
The MessageBodyReader can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods instead.
messageBodyReader - the JAX-RS MessageBodyReader class that should be added to all listenersNullPointerException - if the MessageBodyReader is nullvoid addMessageBodyReader(@NotNull Class<? extends javax.ws.rs.ext.MessageBodyReader> messageBodyReader, @NotNull Collection<String> listenerIdentifier)
MessageBodyReader to all specified listeners.
The MessageBodyReader can use dependency injection and HiveMQ will instantiate it for you at runtime
Dependency injection during a constructor is limited to com.hivemq.spi and JDK classes. You can use PostConstruct methods instead.
messageBodyReader - the JAX-RS MessageBodyReader class that should be added to all specified listenerslistenerIdentifier - the collection of listenersNullPointerException - if the MessageBodyReader or the listener collection is nullCopyright © 2013-2018 dc-square GmbH. All Rights Reserved.