Class AbstractHTTPServerProtocol<T extends AbstractHTTPServerProtocol<T,U,V>,U extends AbstractHTTPServerAgent<U,T,V>,V extends org.openremote.model.asset.agent.AgentLink<?>>
java.lang.Object
org.openremote.agent.protocol.AbstractProtocol<U,V>
org.openremote.agent.protocol.http.AbstractHTTPServerProtocol<T,U,V>
- All Implemented Interfaces:
org.openremote.model.asset.agent.Protocol<U>
public abstract class AbstractHTTPServerProtocol<T extends AbstractHTTPServerProtocol<T,U,V>,U extends AbstractHTTPServerAgent<U,T,V>,V extends org.openremote.model.asset.agent.AgentLink<?>>
extends AbstractProtocol<U,V>
This is an abstract protocol for creating JAX-RS deployments; a concrete implementation should be created for each
required JAX-RS deployment. Multiple instances of the same deployment can be created by creating multiple protocol
instances for the desired concrete implementation.
The deployment is deployed by creating an instance of a concrete AbstractHTTPServerAgent
implementation with
the following Attribute
s:
AbstractHTTPServerAgent.DEPLOYMENT_PATH
(required)AbstractHTTPServerAgent.ALLOWED_ORIGINS
AbstractHTTPServerAgent.ALLOWED_HTTP_METHODS
getDeploymentPath()
. The realm that the Agent
belongs to will be used implicitly for all incoming requests to any deployments
that this protocol creates and therefore only users of that realm will be able to make calls to the deployment when
AbstractHTTPServerAgent.ROLE_BASED_SECURITY
is true.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static org.openremote.container.web.AlreadyGzippedWriterInterceptor
protected static org.openremote.container.web.ClientErrorExceptionHandler
protected org.openremote.model.Container
static final org.openremote.model.http.HTTPMethod[]
static final String
This is the default path prefix for all deployments.protected static org.openremote.container.web.WebServiceExceptions.DefaultResteasyExceptionMapper
protected boolean
protected static org.openremote.container.web.WebServiceExceptions.ForbiddenResteasyExceptionMapper
protected org.openremote.container.security.IdentityService
protected static org.openremote.container.json.JacksonConfig
static final Pattern
The regex used to validate the deployment path.protected static org.openremote.container.web.WebServiceExceptions.ServletUndertowExceptionHandler
protected org.openremote.container.web.WebService
Fields inherited from class org.openremote.agent.protocol.AbstractProtocol
agent, assetService, datapointService, dynamicAttributes, executorService, linkedAttributes, messageBrokerContext, predictedDatapointService, processorLock, producerTemplate, scheduledExecutorService, timerService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureDeploymentInfo
(io.undertow.servlet.api.DeploymentInfo deploymentInfo) protected jakarta.ws.rs.core.Application
protected org.jboss.resteasy.spi.ResteasyDeployment
createDeployment
(jakarta.ws.rs.core.Application application) protected io.undertow.servlet.api.DeploymentInfo
createDeploymentInfo
(org.jboss.resteasy.spi.ResteasyDeployment resteasyDeployment) protected void
deploy
(io.undertow.servlet.api.DeploymentInfo deploymentInfo) void
doStart
(org.openremote.model.Container container) Start this protocol instanceprotected void
doStop
(org.openremote.model.Container container) Stop this protocol instanceShould return instances of all JAX-RS interface implementations that make up this protocol's deployment.protected String
Get a unique deployment name for this instance.protected String
Deployment path will always be prefixed withgetDeploymentPathPrefix()
; default implementation combines the prefix with the value ofAbstractHTTPServerAgent.DEPLOYMENT_PATH
, for example: getDeploymentPathPrefix() = "/rest"AbstractHTTPServerAgent.DEPLOYMENT_PATH
= "complaints"protected String
Get the path prefix to use for this protocol instance; should use "/rest" unless there is a good reason to override this.Get a URI that describes this specific protocol instanceGet standard JAX-RS providers that are used in the deployment.protected void
undeploy()
Methods inherited from class org.openremote.agent.protocol.AbstractProtocol
doLinkAttribute, doLinkedAttributeWrite, doUnlinkAttribute, getAgent, getLinkedAttributes, linkAttribute, onAgentAttributeChanged, processLinkedAttributeWrite, sendAttributeEvent, sendAttributeEvent, setAssetService, setConnectionStatus, start, stop, toString, unlinkAttribute, updateLinkedAttribute, updateLinkedAttribute
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.openremote.model.asset.agent.Protocol
getProtocolName, prefixLogMessage
-
Field Details
-
DEFAULT_DEPLOYMENT_PATH_PREFIX
This is the default path prefix for all deployments. Should not be overridden unless you know what you are doing and there is a good reason to override.- See Also:
-
PATH_REGEX
The regex used to validate the deployment path. -
DEFAULT_ALLOWED_METHODS
public static final org.openremote.model.http.HTTPMethod[] DEFAULT_ALLOWED_METHODS -
deployment
-
defaultResteasyExceptionMapper
protected static org.openremote.container.web.WebServiceExceptions.DefaultResteasyExceptionMapper defaultResteasyExceptionMapper -
forbiddenResteasyExceptionMapper
protected static org.openremote.container.web.WebServiceExceptions.ForbiddenResteasyExceptionMapper forbiddenResteasyExceptionMapper -
jacksonConfig
protected static org.openremote.container.json.JacksonConfig jacksonConfig -
alreadyGzippedWriterInterceptor
protected static org.openremote.container.web.AlreadyGzippedWriterInterceptor alreadyGzippedWriterInterceptor -
clientErrorExceptionHandler
protected static org.openremote.container.web.ClientErrorExceptionHandler clientErrorExceptionHandler -
undertowExceptionHandler
protected static org.openremote.container.web.WebServiceExceptions.ServletUndertowExceptionHandler undertowExceptionHandler -
container
protected org.openremote.model.Container container -
devMode
protected boolean devMode -
identityService
protected org.openremote.container.security.IdentityService identityService -
webService
protected org.openremote.container.web.WebService webService
-
-
Constructor Details
-
AbstractHTTPServerProtocol
-
-
Method Details
-
doStart
Description copied from class:AbstractProtocol
Start this protocol instance- Specified by:
doStart
in classAbstractProtocol<U extends AbstractHTTPServerAgent<U,
T, V>, V extends org.openremote.model.asset.agent.AgentLink<?>> - Throws:
Exception
-
doStop
Description copied from class:AbstractProtocol
Stop this protocol instance- Specified by:
doStop
in classAbstractProtocol<U extends AbstractHTTPServerAgent<U,
T, V>, V extends org.openremote.model.asset.agent.AgentLink<?>> - Throws:
Exception
-
createApplication
protected jakarta.ws.rs.core.Application createApplication() -
createDeployment
protected org.jboss.resteasy.spi.ResteasyDeployment createDeployment(jakarta.ws.rs.core.Application application) -
createDeploymentInfo
protected io.undertow.servlet.api.DeploymentInfo createDeploymentInfo(org.jboss.resteasy.spi.ResteasyDeployment resteasyDeployment) -
getApiSingletons
Should return instances of all JAX-RS interface implementations that make up this protocol's deployment. -
getDeploymentPathPrefix
Get the path prefix to use for this protocol instance; should use "/rest" unless there is a good reason to override this. -
getDeploymentPath
Deployment path will always be prefixed withgetDeploymentPathPrefix()
; default implementation combines the prefix with the value ofAbstractHTTPServerAgent.DEPLOYMENT_PATH
, for example:- getDeploymentPathPrefix() = "/rest"
AbstractHTTPServerAgent.DEPLOYMENT_PATH
= "complaints"
Full path to deployment = "/rest/complaints"
If the
AbstractHTTPServerAgent.DEPLOYMENT_PATH
is missing or not a String or the generated path does not match thePATH_REGEX
regex then anIllegalArgumentException
will is thrown.- Throws:
IllegalArgumentException
-
getStandardProviders
Get standard JAX-RS providers that are used in the deployment. -
configureDeploymentInfo
protected void configureDeploymentInfo(io.undertow.servlet.api.DeploymentInfo deploymentInfo) -
getDeploymentName
Get a unique deployment name for this instance. -
deploy
protected void deploy(io.undertow.servlet.api.DeploymentInfo deploymentInfo) -
undeploy
protected void undeploy() -
getProtocolInstanceUri
Description copied from interface:org.openremote.model.asset.agent.Protocol
Get a URI that describes this specific protocol instance
-