Package ch.qos.logback.classic.net
Class SimpleSocketServer
- java.lang.Object
-
- java.lang.Thread
-
- ch.qos.logback.classic.net.SimpleSocketServer
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
SimpleSSLSocketServer
public class SimpleSocketServer extends java.lang.ThreadA simpleSocketNodebased server.<b>Usage:</b> java ch.qos.logback.classic.net.SimpleSocketServer port configFilewhere port is a port number where the server listens and configFile is an xml configuration file fed toJoranConfigurator.- Since:
- 0.8.4
-
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedprivate java.util.concurrent.CountDownLatchlatchprivate LoggerContextlc(package private) org.slf4j.Loggerloggerprivate intportprivate java.net.ServerSocketserverSocketprivate java.util.List<SocketNode>socketNodeList
-
Constructor Summary
Constructors Constructor Description SimpleSocketServer(LoggerContext lc, int port)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static voidconfigureLC(LoggerContext lc, java.lang.String configFile)protected static voiddoMain(java.lang.Class<? extends SimpleSocketServer> serverClass, java.lang.String[] argv)protected java.lang.StringgetClientThreadName(java.net.Socket socket)Returns a name to identify each client thread.java.util.concurrent.CountDownLatchgetLatch()Used for testing purposesprotected javax.net.ServerSocketFactorygetServerSocketFactory()Gets the platform defaultServerSocketFactory.protected java.lang.StringgetServerThreadName()Returns the name given to the server thread.booleanisClosed()static voidmain(java.lang.String[] argv)(package private) static intparsePortNumber(java.lang.String portStr)voidrun()(package private) voidsetLatch(java.util.concurrent.CountDownLatch latch)Used for testing purposes(package private) voidsignalAlmostReadiness()Signal another thread that we have established a connection This is useful for testing purposes.voidsocketNodeClosing(SocketNode sn)(package private) static voidusage(java.lang.String msg)-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
logger
org.slf4j.Logger logger
-
port
private final int port
-
lc
private final LoggerContext lc
-
closed
private boolean closed
-
serverSocket
private java.net.ServerSocket serverSocket
-
socketNodeList
private java.util.List<SocketNode> socketNodeList
-
latch
private java.util.concurrent.CountDownLatch latch
-
-
Constructor Detail
-
SimpleSocketServer
public SimpleSocketServer(LoggerContext lc, int port)
-
-
Method Detail
-
main
public static void main(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
doMain
protected static void doMain(java.lang.Class<? extends SimpleSocketServer> serverClass, java.lang.String[] argv) throws java.lang.Exception
- Throws:
java.lang.Exception
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
getServerThreadName
protected java.lang.String getServerThreadName()
Returns the name given to the server thread.
-
getClientThreadName
protected java.lang.String getClientThreadName(java.net.Socket socket)
Returns a name to identify each client thread.
-
getServerSocketFactory
protected javax.net.ServerSocketFactory getServerSocketFactory()
Gets the platform defaultServerSocketFactory.Subclasses may override to provide a custom server socket factory.
-
signalAlmostReadiness
void signalAlmostReadiness()
Signal another thread that we have established a connection This is useful for testing purposes.
-
setLatch
void setLatch(java.util.concurrent.CountDownLatch latch)
Used for testing purposes- Parameters:
latch-
-
getLatch
public java.util.concurrent.CountDownLatch getLatch()
Used for testing purposes
-
isClosed
public boolean isClosed()
-
close
public void close()
-
socketNodeClosing
public void socketNodeClosing(SocketNode sn)
-
usage
static void usage(java.lang.String msg)
-
parsePortNumber
static int parsePortNumber(java.lang.String portStr)
-
configureLC
public static void configureLC(LoggerContext lc, java.lang.String configFile) throws JoranException
- Throws:
JoranException
-
-