T
- the concrete RuntimePlatform
subclass type containing the providerH
- the RestHandler
type processing incoming Rest requestspublic abstract class WebhookEventProvider<T extends RuntimePlatform,H extends RestHandler> extends RuntimeEventProvider<T>
RuntimeEventProvider
that handles Rest requests sent by the XatkitServer
.
Concrete subclasses must implement the getEndpointURI()
that sets the URI to register the provider
to, and createRestHandler()
that creates the concrete RestHandler
instance handling incoming Rest
requests.
RestHandler
,
RestHandlerFactory
runtimePlatform, xatkitCore
Constructor and Description |
---|
WebhookEventProvider(T runtimePlatform)
Constructs a new
WebhookEventProvider with the provided runtimePlatform . |
WebhookEventProvider(T runtimePlatform,
Configuration configuration)
|
Modifier and Type | Method and Description |
---|---|
protected abstract H |
createRestHandler()
Returns the concrete
RestHandler instance that handles incoming Rest requests. |
HttpMethod |
getEndpointMethod()
Returns the
HttpMethod of the REST endpoint to register the provided to. |
abstract String |
getEndpointURI()
Returns the URI of the REST endpoint to register the provider to.
|
H |
getRestHandler()
Returns the
RestHandler embedded in this provider. |
void |
run()
Runs the provider.
|
broadcastEventInstance, close, getRuntimePlatform, sendEventInstance
public WebhookEventProvider(T runtimePlatform)
WebhookEventProvider
with the provided runtimePlatform
.
Note: this constructor should be used by WebhookEventProvider
s that do not require additional
parameters to be initialized. In that case see WebhookEventProvider(RuntimePlatform, Configuration)
.
runtimePlatform
- the RuntimePlatform
containing this WebhookEventProvider
NullPointerException
- if the provided runtimePlatform
is null
public WebhookEventProvider(T runtimePlatform, Configuration configuration)
WebhookEventProvider
from the provided runtimePlatform
and
configuration
.
Note: this constructor will be called by xatkit internal engine when initializing the
XatkitCore
component. Subclasses implementing this constructor typically
need additional parameters to be initialized, that can be provided in the configuration
.
runtimePlatform
- the RuntimePlatform
containing this WebhookEventProvider
configuration
- the Configuration
used to initialize the WebhookEventProvider
NullPointerException
- if the provided runtimePlatform
is null
public abstract String getEndpointURI()
The returned String
must be prefixed by a '/'
.
XatkitServer.registerWebhookEventProvider(WebhookEventProvider)
public HttpMethod getEndpointMethod()
HttpMethod
of the REST endpoint to register the provided to.
This method returns HttpMethod.POST
by default, subclasses can override this method to return custom
HttpMethod
.
HttpMethod
of the REST endpoint to register the provider toprotected abstract H createRestHandler()
RestHandler
instance that handles incoming Rest requests.
This handler can be defined with the utility methods provided in
RestHandlerFactory
.
RestHandler
instance that handles incoming Rest requestsRestHandlerFactory
public final H getRestHandler()
RestHandler
embedded in this provider.RestHandler
embedded in this providerpublic void run()
Copyright © 2020 SOM Research Lab. All rights reserved.