Just a second...

Using the Server API for configuration

Server API documentation

Server API documentation for full details of the API.

General use

The Server API only affects server-side configuration.

From within server-side code, the server configuration root can be obtained using ConfigManager.getServerConfig() which exposes all of the server side configuration also.

From the configuration root you can navigate to any subordinate configuration objects to view them or set their properties.

Most properties cannot be changed after the server has started and they become locked so any attempt to change them results in an exception. Certain properties (such as conflation and connection policies) can be changed at runtime. The API documentation makes it clear which properties can be changed at runtime.

For configuration objects which are optional but there can be many (multiplicity 0..n), there are appropriate add methods to add new objects.

In these cases there are also methods to obtain the full list or to obtain a specific one by name. In many cases there are also methods to remove an object.

Note: When there must be at least one object (multiplicity 1..n), you must configure at least one. However, if a server is started with missing configuration of this kind, suitable defaults are normally created and a warning logged.

Single instance configuration objects (multiplicity 1..1) subordinate to the root can be obtained so that their properties can be changed (or read). So, for example the Queues object (an instance of QueuesConfig) can be obtained using the getQueues() method.

When a single configuration object is optional (multiplicity 0..1), the get method can return null if it has not been defined. In this case to set it the set method (as opposed to add) returns the object created. An example of this is the file service (FileServiceConfig) on a web server (WebServerConfig) as shown in the following example code:

ServerConfig config = ConfigManager.getServerConfig(); 
WebServerConfig webServer = config.addWebServer("MyWebServer"); 
FileServiceConfig fileService = webServer.setFileService("File Service");

Configuring a server

After instantiating a Diffusion™ server in Java™ the root of the server configuration tree can be obtained from the server object itself and configuration objects can be navigated to and changed as required before starting the server.

For example, the following code shows how to add a connector that accepts client connections on port 9090:

DiffusionServer server = new DiffusionServer(); 
ServerConfig config = server.getConfig(); 
ConnectorConfig connector = config.addConnector("Client Connector"); 
connector.setPort(9090); 
connector.setType(Type.CLIENT); 
server.start();

In reality, it is best to configure far more values. However, if any essential objects are omitted (such as queues), suitable defaults are created when the server starts and a warning is logged.