Package org.openmuc.jdlms
Class ServerBuilder<T extends ServerBuilder<T>>
- java.lang.Object
-
- org.openmuc.jdlms.ServerBuilder<T>
-
- Type Parameters:
T
- the concrete server builder.
- Direct Known Subclasses:
DlmsServer.TcpServerBuilder
public abstract class ServerBuilder<T extends ServerBuilder<T>> extends java.lang.Object
Builder class to build a DLMS Server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ServerBuilder.ServerSettingsImpl
-
Constructor Summary
Constructors Constructor Description ServerBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract DlmsServer
build()
Builds a new server and starts it, with the provided settings.protected DlmsServer
newServer(ServerTransportLayer serverTransportLayer)
protected DataDirectory
parseLogicalDevices()
T
registerLogicalDevice(java.util.List<LogicalDevice> newlogicalDevices)
Register list of logical devices to the server.T
registerLogicalDevice(LogicalDevice... logicalDevice)
Register one or more logical devices to the server.T
setConnectionListener(ServerConnectionListener connectionListener)
T
setInactivityTimeout(int inactivityTimeout)
Sets the inactivity timeout.T
setMaxClients(int maxClients)
Restrict the maximum number of connected clients.protected void
setPropertiesTo(ServerBuilder.ServerSettingsImpl settings)
T
setReferencingMethod(ReferencingMethod referencingMethod)
Set the Referencing Method.T
setResponseTimeout(int responseTimeout)
The max time a server waits for a response from the client, after sending a request to the client.
-
-
-
Method Detail
-
build
public abstract DlmsServer build() throws java.io.IOException
Builds a new server and starts it, with the provided settings.- Returns:
- the new Server.
- Throws:
java.io.IOException
- if an I/O exception occurs while starting the server.
-
registerLogicalDevice
public final T registerLogicalDevice(LogicalDevice... logicalDevice)
Register one or more logical devices to the server.- Parameters:
logicalDevice
- a logical device.- Returns:
- the self reference of the connection builder.
-
registerLogicalDevice
public T registerLogicalDevice(java.util.List<LogicalDevice> newlogicalDevices)
Register list of logical devices to the server.- Parameters:
newlogicalDevices
- a list of logical devices.- Returns:
- the self reference of the connection builder.
-
setMaxClients
public T setMaxClients(int maxClients)
Restrict the maximum number of connected clients.A value of zero imposes no restriction.
- Parameters:
maxClients
- positive integer, restricting the maximum number of connected clients.- Returns:
- the self reference of the connection builder.
- Throws:
java.lang.IllegalArgumentException
- if themaxClients < 0
.
-
setInactivityTimeout
public T setInactivityTimeout(int inactivityTimeout)
Sets the inactivity timeout. If a client doesn't send a request within that time, the server closes the connection.The timeout must be greater than 0. A timeout of values 0 implies that the option is disabled (i.e., timeout of infinity).
The default value is 0.
- Parameters:
inactivityTimeout
- the timeout value.- Returns:
- the self reference of the connection builder.
- Throws:
java.lang.IllegalArgumentException
- if theinactivityTimeout < 0
.
-
setReferencingMethod
public T setReferencingMethod(ReferencingMethod referencingMethod)
Set the Referencing Method. Default value isLOGICAL
.- Parameters:
referencingMethod
- the referencing method.- Returns:
- the self reference of the connection builder.
-
setResponseTimeout
public T setResponseTimeout(int responseTimeout)
The max time a server waits for a response from the client, after sending a request to the client.The timeout must be greater than 0. A timeout of values 0 implies that the option is disabled (i.e., timeout of infinity).
The default value is 0.
- Parameters:
responseTimeout
- the timeout value.- Returns:
- the self reference of the connection builder.
- Throws:
java.lang.IllegalArgumentException
- if theresponseTimeout < 0
.
-
setConnectionListener
public T setConnectionListener(ServerConnectionListener connectionListener)
-
setPropertiesTo
protected void setPropertiesTo(ServerBuilder.ServerSettingsImpl settings)
-
parseLogicalDevices
protected final DataDirectory parseLogicalDevices()
-
newServer
protected DlmsServer newServer(ServerTransportLayer serverTransportLayer) throws java.io.IOException
- Throws:
java.io.IOException
-
-