org.springframework.beans.factory.DisposableBeanpublic class NatsServer extends Object implements org.springframework.beans.factory.DisposableBean
SystemUtil.OperatingSystem,
NatsServer| Modifier and Type | Field | Description |
|---|---|---|
static String |
BEAN_NAME |
simpleName from
NatsServer class |
| Constructor | Description |
|---|---|
NatsServer() |
Create
NatsServer without any start able configuration |
NatsServer(int port) |
Create
NatsServer with simplest start able configuration |
NatsServer(String... natsServerConfig) |
Create custom
NatsServer with simplest configuration setNatsServerConfig(String...) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
destroy() |
Simply stops the
NatsServer |
Map<String,String> |
getNatsServerConfig() |
GetNatServerConfig
|
int |
getPort() |
Gets the port out of the configuration not from the real PID
|
void |
setNatsServerConfig(String... natsServerConfigArray) |
Passes the original parameters to the server on startup
|
void |
setNatsServerConfig(Map<String,String> natsServerConfig) |
Passes the original parameters to the server on startup
|
void |
start() |
Starts the server in
ProcessBuilder with the given parameterConfig setNatsServerConfig(String...) |
void |
stop() |
Stops the
ProcessBuilder and kills the NatsServer
Only a log error will occur if the NatsServer were never started |
String |
toString() |
public static final String BEAN_NAME
NatsServer classpublic NatsServer()
NatsServer without any start able configurationpublic NatsServer(int port)
NatsServer with simplest start able configurationport - start port - common default port is 4222public NatsServer(String... natsServerConfig)
NatsServer with simplest configuration setNatsServerConfig(String...)natsServerConfig - passes the original parameters to the server. example: port:4222, user:admin, password:adminpublic Map<String,String> getNatsServerConfig()
NatsServer configuration but not the config of the real PIDpublic void setNatsServerConfig(Map<String,String> natsServerConfig)
natsServerConfig - passes the original parameters to the server.setNatsServerConfig(String...)public void setNatsServerConfig(String... natsServerConfigArray)
natsServerConfigArray - example: port:4222, user:admin, password:adminpublic void start()
throws IOException
ProcessBuilder with the given parameterConfig setNatsServerConfig(String...)IOException - if NatsServer is not found or unsupported on the SystemUtil.OperatingSystemBindException - if port is already takenRuntimeException - with ConnectException if NatsServer is not startingpublic void stop()
ProcessBuilder and kills the NatsServer
Only a log error will occur if the NatsServer were never startedRuntimeException - as InterruptedException if shutdown is interruptedpublic int getPort()
RuntimeException - with ServiceConfigurationError when there is no port configuredpublic void destroy()
NatsServerdestroy in interface org.springframework.beans.factory.DisposableBeanstop()Copyright © 2018. All rights reserved.