Package de.bwaldvogel.mongo
Class MongoServer
- java.lang.Object
-
- de.bwaldvogel.mongo.MongoServer
-
public class MongoServer extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MongoServer(MongoBackend backend)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.InetSocketAddressbind()starts and binds the server on a local random portvoidbind(java.lang.String hostname, int port)voidbind(java.net.SocketAddress socketAddress)voidenableSsl(java.security.PrivateKey key, java.lang.String keyPassword, java.security.cert.X509Certificate... keyCertChain)java.net.InetSocketAddressgetLocalAddress()voidshutdown()Stop accepting new clients.voidshutdownNow()Stops accepting new clients, closes all clients and finally shuts down the server In contrast toshutdown(), this method should not block.voidstopListenting()Closes the server socket.java.lang.StringtoString()
-
-
-
Constructor Detail
-
MongoServer
public MongoServer(MongoBackend backend)
-
-
Method Detail
-
enableSsl
public void enableSsl(java.security.PrivateKey key, java.lang.String keyPassword, java.security.cert.X509Certificate... keyCertChain)
-
bind
public void bind(java.lang.String hostname, int port)
-
bind
public void bind(java.net.SocketAddress socketAddress)
-
bind
public java.net.InetSocketAddress bind()
starts and binds the server on a local random port- Returns:
- the random local address the server was bound to
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
- Returns:
- the local address the server was bound or null if the server is not listening
-
shutdown
public void shutdown()
Stop accepting new clients. Wait until all resources (such as client connection) are closed and then shutdown. This method blocks until all clients are finished. UseshutdownNow()if the shutdown should be forced.
-
stopListenting
public void stopListenting()
Closes the server socket. No new clients are accepted afterwards.
-
shutdownNow
public void shutdownNow()
Stops accepting new clients, closes all clients and finally shuts down the server In contrast toshutdown(), this method should not block.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-