com.prosysopc.ua.server
Class ServiceHandler

java.lang.Object
  extended by com.prosysopc.ua.server.ServiceHandler
Direct Known Subclasses:
AttributeServiceHandler, NodeManagementServiceHandler, SessionServiceHandler, SubscriptionServiceHandler

public abstract class ServiceHandler
extends Object

A base class for ServiceHandler implementations.


Field Summary
protected static String[] stringTable
           
 
Constructor Summary
protected ServiceHandler(SessionManager sessionManager)
           
  ServiceHandler(SessionManager sessionManager, NodeManagerTable nodeManagerTable)
          Create a new ServiceManager attached to a serviceContext manager
 
Method Summary
protected  void checkRequestLength(Object[] requestObjects, int maxOperations)
           
protected  ServiceContext createServiceContext(org.opcfoundation.ua.core.RequestHeader requestHeader)
          Create the serviceContext object used to identify the session and other parameters of a service call.
protected  void fireRequestResponse(org.opcfoundation.ua.builtintypes.ServiceRequest request, org.opcfoundation.ua.builtintypes.ServiceResponse response, ServiceContext serviceContext)
          This method should be called every time a response has been handled.
protected  org.opcfoundation.ua.encoding.EncoderContext getEncoderContext()
           
protected  org.slf4j.Logger getLogger()
           
static int getMaxOperationsPerRequest()
          The maximum number of operations allowed per service request.
 UaNode getNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
          Find the Node for nodeId.
 NodeManagerTable getNodeManagerTable()
           
protected  OperationLimitsTypeNode getOperationLimits()
           
 UaServer getServer()
           
 SessionManager getSessionManager()
           
protected  void handleServiceResultException(org.opcfoundation.ua.builtintypes.ServiceResponse response, ServiceException e)
          Handle the ServiceException by converting it to the ServiceResult in the response.
 boolean hasNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
           
static void setMaxOperationsPerRequest(int maxOperationsPerRequest)
          Define the maximum number of operations allowed per service request.
 void setRequestResponseListener(RequestResponseListener listener)
          Sets the Request-Response Listener.
protected static org.opcfoundation.ua.builtintypes.ExtensionObject toExtensionObject(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.Structure data, org.opcfoundation.ua.builtintypes.QualifiedName dataEncoding, org.opcfoundation.ua.encoding.EncoderContext encoderContext)
           
protected  void validateEncoding(org.opcfoundation.ua.core.ReadValueId v)
           
static org.opcfoundation.ua.builtintypes.DiagnosticInfo[] validateOperationalDiagnostics(org.opcfoundation.ua.builtintypes.ServiceRequest request, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
           
protected  ServiceContext validateRequest(org.opcfoundation.ua.builtintypes.ServiceRequest request, org.opcfoundation.ua.transport.ServerSecureChannel serverSecureChannel)
           
protected  void validateResponse(org.opcfoundation.ua.builtintypes.ServiceRequest request, org.opcfoundation.ua.builtintypes.ServiceResponse response, ServiceContext serviceContext)
          Validates the service response by setting the timestamp to current.
protected  org.opcfoundation.ua.builtintypes.DiagnosticInfo[] validateResponse(org.opcfoundation.ua.builtintypes.ServiceRequest request, org.opcfoundation.ua.builtintypes.ServiceResponse response, ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] operationalDiagnosticInfos)
           
protected  org.opcfoundation.ua.builtintypes.DiagnosticInfo validateServiceDiagnostics(org.opcfoundation.ua.builtintypes.ServiceRequest request, org.opcfoundation.ua.builtintypes.DiagnosticInfo diagnosticInfo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringTable

protected static final String[] stringTable
Constructor Detail

ServiceHandler

public ServiceHandler(SessionManager sessionManager,
                      NodeManagerTable nodeManagerTable)
Create a new ServiceManager attached to a serviceContext manager

Parameters:
sessionManager -
nodeManagerTable -

ServiceHandler

protected ServiceHandler(SessionManager sessionManager)
Method Detail

getMaxOperationsPerRequest

public static int getMaxOperationsPerRequest()
The maximum number of operations allowed per service request. This is a general safety limit for all service calls. If the client exceeds this limit, a ServiceException with StatusCodes.Bad_TooManyOperations is thrown.

Returns:
the maxOperationsPerRequest

setMaxOperationsPerRequest

public static void setMaxOperationsPerRequest(int maxOperationsPerRequest)
Define the maximum number of operations allowed per service request. This is a general safety limit for all service calls. If the client exceeds this limit, a ServiceException with StatusCodes.Bad_TooManyOperations is thrown.

Default: 10000

Parameters:
maxOperationsPerRequest - the maxOperationsPerRequest to set. If 0 or negative, no limit is used.

validateOperationalDiagnostics

public static org.opcfoundation.ua.builtintypes.DiagnosticInfo[] validateOperationalDiagnostics(org.opcfoundation.ua.builtintypes.ServiceRequest request,
                                                                                                org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
Parameters:
request -
diagnosticInfos -
Returns:

toExtensionObject

protected static org.opcfoundation.ua.builtintypes.ExtensionObject toExtensionObject(ServiceContext serviceContext,
                                                                                     org.opcfoundation.ua.builtintypes.Structure data,
                                                                                     org.opcfoundation.ua.builtintypes.QualifiedName dataEncoding,
                                                                                     org.opcfoundation.ua.encoding.EncoderContext encoderContext)
                                                                              throws ServiceException
Parameters:
data -
dataEncoding -
Returns:
Throws:
ServiceException

getNode

public final UaNode getNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
                     throws StatusException
Find the Node for nodeId. This is a final method. Override findNode, which is called by this method

Parameters:
nodeId - The ID of the node to look for.
Returns:
The node
Throws:
StatusException - Bad_NodeIdInvalid, if the nodeId is null. Bad_NodeIdUnknown, if the node is not found

getNodeManagerTable

public NodeManagerTable getNodeManagerTable()
Returns:
the nodeManagerTable

getServer

public UaServer getServer()

getSessionManager

public SessionManager getSessionManager()
Returns:
the sessionManager

hasNode

public boolean hasNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)

setRequestResponseListener

public void setRequestResponseListener(RequestResponseListener listener)
Sets the Request-Response Listener. Use this only in case you want to log every Request-Response pair which the server receives and responses. Usually used only for debugging purposes.

See RequestResponseListener for more info.

Parameters:
listener - The listener. If parameter is null, the old listener is removed, otherwise the old listener is replaced with the parameter.

checkRequestLength

protected void checkRequestLength(Object[] requestObjects,
                                  int maxOperations)
                           throws ServiceException
Throws:
ServiceException

createServiceContext

protected ServiceContext createServiceContext(org.opcfoundation.ua.core.RequestHeader requestHeader)
                                       throws ServiceException
Create the serviceContext object used to identify the session and other parameters of a service call.

Parameters:
requestHeader - The session token used to identity the session during communications
Returns:
The serviceContext
Throws:
ServiceException - If the serviceContext is not found, StatusCode = Bad_SessionIdInvalid

fireRequestResponse

protected void fireRequestResponse(org.opcfoundation.ua.builtintypes.ServiceRequest request,
                                   org.opcfoundation.ua.builtintypes.ServiceResponse response,
                                   ServiceContext serviceContext)
This method should be called every time a response has been handled.

Parameters:
request - The Request from client
response - The Response to the request from server
serviceContext -

getEncoderContext

protected org.opcfoundation.ua.encoding.EncoderContext getEncoderContext()

getLogger

protected org.slf4j.Logger getLogger()

getOperationLimits

protected OperationLimitsTypeNode getOperationLimits()
Returns:

handleServiceResultException

protected void handleServiceResultException(org.opcfoundation.ua.builtintypes.ServiceResponse response,
                                            ServiceException e)
Handle the ServiceException by converting it to the ServiceResult in the response. Also set ServiceDiagnostics from the exception.

Parameters:
response - The response message to set
e - The exception info

validateEncoding

protected void validateEncoding(org.opcfoundation.ua.core.ReadValueId v)
                         throws StatusException
Throws:
StatusException

validateRequest

protected ServiceContext validateRequest(org.opcfoundation.ua.builtintypes.ServiceRequest request,
                                         org.opcfoundation.ua.transport.ServerSecureChannel serverSecureChannel)
                                  throws ServiceException
Parameters:
request - the request message
serverSecureChannel -
Returns:
Throws:
ServiceException

validateResponse

protected void validateResponse(org.opcfoundation.ua.builtintypes.ServiceRequest request,
                                org.opcfoundation.ua.builtintypes.ServiceResponse response,
                                ServiceContext serviceContext)
Validates the service response by setting the timestamp to current.

Parameters:
response - the response to validate - it must not be null
serviceContext -

validateResponse

protected org.opcfoundation.ua.builtintypes.DiagnosticInfo[] validateResponse(org.opcfoundation.ua.builtintypes.ServiceRequest request,
                                                                              org.opcfoundation.ua.builtintypes.ServiceResponse response,
                                                                              ServiceContext serviceContext,
                                                                              org.opcfoundation.ua.builtintypes.DiagnosticInfo[] operationalDiagnosticInfos)
Parameters:
request -
response -
serviceContext -
operationalDiagnosticInfos -
Returns:

validateServiceDiagnostics

protected org.opcfoundation.ua.builtintypes.DiagnosticInfo validateServiceDiagnostics(org.opcfoundation.ua.builtintypes.ServiceRequest request,
                                                                                      org.opcfoundation.ua.builtintypes.DiagnosticInfo diagnosticInfo)
Parameters:
request -
diagnosticInfo -
Returns:


Copyright © 2018. All rights reserved.