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 Attributes:
AbstractHTTPServerAgent.DEPLOYMENT_PATH(required)AbstractHTTPServerAgent.ALLOWED_ORIGINSAbstractHTTPServerAgent.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.AlreadyGzippedWriterInterceptorprotected static org.openremote.container.web.ClientErrorExceptionHandlerprotected org.openremote.model.Containerstatic final HTTPMethod[]static final StringThis is the default path prefix for all deployments.protected static org.openremote.container.web.WebServiceExceptions.DefaultResteasyExceptionMapperprotected booleanprotected static org.openremote.container.web.WebServiceExceptions.ForbiddenResteasyExceptionMapperprotected org.openremote.container.security.IdentityServiceprotected static org.openremote.container.json.JacksonConfigstatic final PatternThe regex used to validate the deployment path.protected static org.openremote.container.web.WebServiceExceptions.ServletUndertowExceptionHandlerprotected org.openremote.container.web.WebServiceFields inherited from class org.openremote.agent.protocol.AbstractProtocol
agent, assetService, datapointService, dynamicAttributes, executorService, linkedAttributes, messageBrokerContext, predictedDatapointService, producerTemplate, timerServiceFields inherited from interface org.openremote.model.asset.agent.Protocol
ACTUATOR_TOPIC, ACTUATOR_TOPIC_TARGET_PROTOCOL, DYNAMIC_TIME_PLACEHOLDER_REGEXP, DYNAMIC_VALUE_PLACEHOLDER, DYNAMIC_VALUE_PLACEHOLDER_REGEXP, SENSOR_QUEUE, SENSOR_QUEUE_SOURCE_PROTOCOL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureDeploymentInfo(io.undertow.servlet.api.DeploymentInfo deploymentInfo) protected javax.ws.rs.core.Applicationprotected org.jboss.resteasy.spi.ResteasyDeploymentcreateDeployment(javax.ws.rs.core.Application application) protected io.undertow.servlet.api.DeploymentInfocreateDeploymentInfo(org.jboss.resteasy.spi.ResteasyDeployment resteasyDeployment) protected voiddeploy(io.undertow.servlet.api.DeploymentInfo deploymentInfo) voiddoStart(org.openremote.model.Container container) Start this protocol instanceprotected voiddoStop(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 StringGet a unique deployment name for this instance.protected StringDeployment path will always be prefixed withgetDeploymentPathPrefix(); default implementation combines the prefix with the value of {@link AbstractHTTPServerAgent# META_PROTOCOL_DEPLOYMENT_PATH}, for example: getDeploymentPathPrefix() = "/rest"AbstractHTTPServerAgent.DEPLOYMENT_PATH= "complaints"protected StringGet 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 voidundeploy()Methods inherited from class org.openremote.agent.protocol.AbstractProtocol
doLinkAttribute, doLinkedAttributeWrite, doUnlinkAttribute, getAgent, getLinkedAttributes, linkAttribute, processLinkedAttributeWrite, sendAttributeEvent, sendAttributeEvent, setConnectionStatus, start, stop, toString, unlinkAttribute, updateAgentAttribute, updateLinkedAttribute, updateLinkedAttributeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
-
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:AbstractProtocolStart this protocol instance- Specified by:
doStartin classAbstractProtocol<U extends AbstractHTTPServerAgent<U,T, V>, V extends org.openremote.model.asset.agent.AgentLink<?>> - Throws:
Exception
-
doStop
Description copied from class:AbstractProtocolStop this protocol instance- Specified by:
doStopin classAbstractProtocol<U extends AbstractHTTPServerAgent<U,T, V>, V extends org.openremote.model.asset.agent.AgentLink<?>> - Throws:
Exception
-
createApplication
protected javax.ws.rs.core.Application createApplication() -
createDeployment
protected org.jboss.resteasy.spi.ResteasyDeployment createDeployment(javax.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 of {@link AbstractHTTPServerAgent# META_PROTOCOL_DEPLOYMENT_PATH}, for example:- getDeploymentPathPrefix() = "/rest"
AbstractHTTPServerAgent.DEPLOYMENT_PATH= "complaints"
Full path to deployment = "/rest/complaints"
If the
AbstractHTTPServerAgent.DEPLOYMENT_PATHis missing or not a String or the generated path does not match thePATH_REGEXregex then anIllegalArgumentExceptionwill 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.ProtocolGet a URI that describes this specific protocol instance
-