org.opcfoundation.ua.application
Class Server

java.lang.Object
  extended by org.opcfoundation.ua.application.Server

public class Server
extends Object

This object represents a service server. It is an application that responds to ServiceRequests queries.

Server is assigned with at least one application instance certificate.

The initial server contains EndpointDiscoveryService by default.

See Also:
Application, service handler

Field Summary
protected  Application application
          The application
protected  List<EndpointServer.EndpointHandle> boundHandles
          Bound handles
protected  EndpointBindingCollection endpointBindings
          Endpoints
protected  EndpointDiscoveryService endpointDiscoveryService
          Endpoint discovery service
static String HTTPS_BINARY_TRANSPORT_PROFILE_URI
          Constant HTTPS_BINARY_TRANSPORT_PROFILE_URI="http://opcfoundation.org/UA-Profile/Tra"{trunked}
protected  ServiceHandlerComposition serviceHandlers
          Service Handler
static String SOAP_XML_TRANSPORT_PROFILE_URI
          Constant SOAP_XML_TRANSPORT_PROFILE_URI="http://opcfoundation.org/UA-Profile/Tra"{trunked}
static String UATCP_BINARY_TRANSPORT_PROFILE_URI
          Constant UATCP_BINARY_TRANSPORT_PROFILE_URI="http://opcfoundation.org/UA-Profile/Tra"{trunked}
protected  List<UserTokenPolicy> userTokenPolicies
          User Token Policies
 
Constructor Summary
Server(Application application)
          Constructor for Server.
 
Method Summary
 void addServiceHandler(Object serviceHandler)
          Add Service Handler.
 void addUserTokenPolicy(UserTokenPolicy policy)
          addUserTokenPolicy.
 List<EndpointServer.EndpointHandle> bind(String bindAddress, Endpoint endpointAddress)
          Bind an endpoint to the server.
 List<EndpointServer.EndpointHandle> bind(String bindAddress, String endpointUri, SecurityMode... modes)
          bind.
 void close()
          Close the server.
 ApplicationDescription createApplicationDescription()
          createApplicationDescription.
static Server createServerApplication()
          createServerApplication.
 Application getApplication()
          Getter for the field application.
 EndpointServer[] getBindings()
          getBindings.
 EncoderContext getEncoderContext()
          getEncoderContext.
 EndpointBindingCollection getEndpointBindings()
          Getter for the field endpointBindings.
 Endpoint getEndpointByUri(String uri)
          getEndpointByUri.
 EndpointDescription[] getEndpointDescriptions()
          getEndpointDescriptions.
 EndpointDescription[] getEndpointDescriptions(SocketAddress requestAddress)
          getEndpointDescriptions.
 Endpoint[] getEndpoints()
          getEndpoints.
<T> T
getServiceHandlerByService(Class<? extends ServiceRequest> requestClass)
          Get Service Handler object by service.
 ServiceHandlerComposition getServiceHandlerComposition()
          getServiceHandlerComposition.
 ServiceHandler[] getServiceHandlers()
          Getter for the field serviceHandlers.
 UserTokenPolicy[] getUserTokenPolicies()
          Getter for the field userTokenPolicies.
 boolean handlesService(Class<? extends IEncodeable> requestClass)
          Query whether the server can handle a service.
 boolean hasEndpoint(String uri)
          hasEndpoint.
 void removeUserTokenPolicy(UserTokenPolicy policy)
          removeUserTokenPolicy.
 void setEndpointBindings(EndpointBindingCollection newBindings)
          Setter for the field endpointBindings.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOAP_XML_TRANSPORT_PROFILE_URI

public static final String SOAP_XML_TRANSPORT_PROFILE_URI
Constant SOAP_XML_TRANSPORT_PROFILE_URI="http://opcfoundation.org/UA-Profile/Tra"{trunked}

See Also:
Constant Field Values

UATCP_BINARY_TRANSPORT_PROFILE_URI

public static final String UATCP_BINARY_TRANSPORT_PROFILE_URI
Constant UATCP_BINARY_TRANSPORT_PROFILE_URI="http://opcfoundation.org/UA-Profile/Tra"{trunked}

See Also:
Constant Field Values

HTTPS_BINARY_TRANSPORT_PROFILE_URI

public static final String HTTPS_BINARY_TRANSPORT_PROFILE_URI
Constant HTTPS_BINARY_TRANSPORT_PROFILE_URI="http://opcfoundation.org/UA-Profile/Tra"{trunked}

See Also:
Constant Field Values

serviceHandlers

protected ServiceHandlerComposition serviceHandlers
Service Handler


userTokenPolicies

protected List<UserTokenPolicy> userTokenPolicies
User Token Policies


endpointBindings

protected EndpointBindingCollection endpointBindings
Endpoints


endpointDiscoveryService

protected EndpointDiscoveryService endpointDiscoveryService
Endpoint discovery service


application

protected Application application
The application


boundHandles

protected List<EndpointServer.EndpointHandle> boundHandles
Bound handles

Constructor Detail

Server

public Server(Application application)

Constructor for Server.

Parameters:
application - a Application object.
Method Detail

createServerApplication

public static Server createServerApplication()

createServerApplication.

Returns:
a Server object.

getApplication

public Application getApplication()

Getter for the field application.

Returns:
a Application object.

createApplicationDescription

public ApplicationDescription createApplicationDescription()

createApplicationDescription.

Returns:
a ApplicationDescription object.

setEndpointBindings

public void setEndpointBindings(EndpointBindingCollection newBindings)

Setter for the field endpointBindings.

Parameters:
newBindings - a EndpointBindingCollection object.

getEndpointBindings

public EndpointBindingCollection getEndpointBindings()

Getter for the field endpointBindings.

Returns:
a EndpointBindingCollection object.

getEncoderContext

public EncoderContext getEncoderContext()

getEncoderContext.

Returns:
a EncoderContext object.

addServiceHandler

public void addServiceHandler(Object serviceHandler)
Add Service Handler. Service handler handles one or more service methods. Note, the server may not have more than one service handler for each method.

The serviceHandler is either: (a) an implementation of ServiceHandler (b) an object that contains methods that implement service requests. These methods are discovered using Java Reflection.

The following list contains service methods grouped by service sets:

Parameters:
serviceHandler - instanceof ServiceHandler or Object implementing service requests
See Also:
AttributeServiceSetHandler, DiscoveryServiceSetHandler, MethodServiceSetHandler, MonitoredItemServiceSetHandler, NodeManagementServiceSetHandler, SessionServiceSetHandler, SubscriptionServiceSetHandler,

The serviceHandler may implement one or more methods. In typical case service handler implements one service set, e.g. {@link org.opcfoundation.ua.core.SessionServiceSetHandler}.

A {@link org.opcfoundation.ua.core.ServiceFault} is returned to the client in case the server doesn't the requested service method.

Example: addServiceHandler( new TestServiceSetHandler() { void onTestStack(EndpointServiceRequest<TestStackRequest, TestStackResponse> req) { req.sendResponse( new ServiceFault() ); } void onTestStackEx(EndpointServiceRequest<TestStackExRequest, TestStackExResponse> req) { req.sendFault(new ServiceFault()); } } );


getServiceHandlers

public ServiceHandler[] getServiceHandlers()

Getter for the field serviceHandlers.

Returns:
an array of ServiceHandler objects.

getServiceHandlerByService

public <T> T getServiceHandlerByService(Class<? extends ServiceRequest> requestClass)
Get Service Handler object by service.

For example, to acquire session manager: SessionManager sessionManager = x.getServiceHandlerByService( CreateSessionRequest.class );

Type Parameters:
T - service handler type
Parameters:
requestClass - Service request class
Returns:
Service handler that serves the given request class in this server

handlesService

public boolean handlesService(Class<? extends IEncodeable> requestClass)
Query whether the server can handle a service.

Parameters:
requestClass - request class of the service, e.g. ReadRequest
Returns:
true if server can handle the service

getServiceHandlerComposition

public ServiceHandlerComposition getServiceHandlerComposition()

getServiceHandlerComposition.

Returns:
a ServiceHandlerComposition object.

addUserTokenPolicy

public void addUserTokenPolicy(UserTokenPolicy policy)

addUserTokenPolicy.

Parameters:
policy - a UserTokenPolicy object.

removeUserTokenPolicy

public void removeUserTokenPolicy(UserTokenPolicy policy)

removeUserTokenPolicy.

Parameters:
policy - a UserTokenPolicy object.

getUserTokenPolicies

public UserTokenPolicy[] getUserTokenPolicies()

Getter for the field userTokenPolicies.

Returns:
an array of UserTokenPolicy objects.

bind

public List<EndpointServer.EndpointHandle> bind(String bindAddress,
                                                Endpoint endpointAddress)
                                         throws ServiceResultException
Bind an endpoint to the server. bindAddress is resolved into ip-addresses. For instance, if "localhost" is used, then all local interface ips are bound. If port is not explicitly specified, the default port for the protocol is used. There must be protocol: "opc.tcp", "http", or "https". EndpointUri is the identifier of the endpoint.

Parameters:
bindAddress - bind address for the endpoint
endpointAddress - endpoint to bind
Returns:
list of handles
Throws:
ServiceResultException - if error

bind

public List<EndpointServer.EndpointHandle> bind(String bindAddress,
                                                String endpointUri,
                                                SecurityMode... modes)
                                         throws ServiceResultException

bind.

Parameters:
bindAddress - a String object.
endpointUri - a String object.
modes - a SecurityMode object.
Returns:
a List object.
Throws:
ServiceResultException - if any.

close

public void close()
Close the server.


getEndpoints

public Endpoint[] getEndpoints()

getEndpoints.

Returns:
an array of Endpoint objects.

hasEndpoint

public boolean hasEndpoint(String uri)

hasEndpoint.

Parameters:
uri - a String object.
Returns:
a boolean.

getEndpointByUri

public Endpoint getEndpointByUri(String uri)

getEndpointByUri.

Parameters:
uri - a String object.
Returns:
a Endpoint object.

getEndpointDescriptions

public EndpointDescription[] getEndpointDescriptions()

getEndpointDescriptions.

Returns:
an array of EndpointDescription objects.

getEndpointDescriptions

public EndpointDescription[] getEndpointDescriptions(SocketAddress requestAddress)

getEndpointDescriptions.

Parameters:
requestAddress - a SocketAddress object.
Returns:
an array of EndpointDescription objects.

getBindings

public EndpointServer[] getBindings()

getBindings.

Returns:
an array of EndpointServer objects.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2018. All rights reserved.