org.jboss.logging
Class Log4jSocketServer

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.jboss.logging.Log4jSocketServer
All Implemented Interfaces:
Log4jSocketServerMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class Log4jSocketServer
extends org.jboss.system.ServiceMBeanSupport
implements Log4jSocketServerMBean

A Log4j SocketServer service. Listens for client connections on the specified port and creates a new thread and SocketNode to process the incoming client log messages.

The LoggerRepository can be changed based on the clients address by using a custom LoggerRepositoryFactory. The default factory will simply return the current repository.

Version:
$Revision: 1.2.2.1 $
Author:
Jason Dillon

Nested Class Summary
static class Log4jSocketServer.DefaultLoggerRepositoryFactory
          A simple LoggerRepository factory which simply returns the current repository from the LogManager.
static interface Log4jSocketServer.LoggerRepositoryFactory
           
protected  class Log4jSocketServer.SocketListenerThread
           
 
Field Summary
protected  int backlog
          The listen backlog count.
protected  InetAddress bindAddress
          The address to bind to.
protected  boolean listenerEnabled
          True if the socket listener is enabled.
protected  Log4jSocketServer.SocketListenerThread listenerThread
          The socket listener thread.
protected  Log4jSocketServer.LoggerRepositoryFactory loggerRepositoryFactory
          The factory to create LoggerRepository's for client connections.
protected  int port
          The port number where the server listens.
protected  ServerSocket serverSocket
          The server socket which the listener listens on.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
Log4jSocketServer()
           
 
Method Summary
protected  void createService()
           
protected  void destroyService()
           
 int getBacklog()
           
 InetAddress getBindAddress()
           
 org.apache.log4j.spi.LoggerRepository getLoggerRepository(InetAddress addr)
           
 Class getLoggerRepositoryFactoryType()
           
 int getPort()
           
 void setBacklog(int backlog)
           
 void setBindAddress(InetAddress addr)
           
 boolean setListenerEnabled()
           
 void setListenerEnabled(boolean enabled)
           
 void setLoggerRepositoryFactoryType(Class type)
           
 void setPort(int port)
           
protected  void startService()
           
protected  void stopService()
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

port

protected int port
The port number where the server listens.


backlog

protected int backlog
The listen backlog count.


bindAddress

protected InetAddress bindAddress
The address to bind to.


listenerEnabled

protected boolean listenerEnabled
True if the socket listener is enabled.


listenerThread

protected Log4jSocketServer.SocketListenerThread listenerThread
The socket listener thread.


serverSocket

protected ServerSocket serverSocket
The server socket which the listener listens on.


loggerRepositoryFactory

protected Log4jSocketServer.LoggerRepositoryFactory loggerRepositoryFactory
The factory to create LoggerRepository's for client connections.

Constructor Detail

Log4jSocketServer

public Log4jSocketServer()
Method Detail

setPort

public void setPort(int port)
Specified by:
setPort in interface Log4jSocketServerMBean

getPort

public int getPort()
Specified by:
getPort in interface Log4jSocketServerMBean

setBacklog

public void setBacklog(int backlog)
Specified by:
setBacklog in interface Log4jSocketServerMBean

getBacklog

public int getBacklog()
Specified by:
getBacklog in interface Log4jSocketServerMBean

setBindAddress

public void setBindAddress(InetAddress addr)
Specified by:
setBindAddress in interface Log4jSocketServerMBean

getBindAddress

public InetAddress getBindAddress()
Specified by:
getBindAddress in interface Log4jSocketServerMBean

setListenerEnabled

public void setListenerEnabled(boolean enabled)
Specified by:
setListenerEnabled in interface Log4jSocketServerMBean

setListenerEnabled

public boolean setListenerEnabled()
Specified by:
setListenerEnabled in interface Log4jSocketServerMBean

setLoggerRepositoryFactoryType

public void setLoggerRepositoryFactoryType(Class type)
                                    throws InstantiationException,
                                           IllegalAccessException,
                                           ClassCastException
Specified by:
setLoggerRepositoryFactoryType in interface Log4jSocketServerMBean
Throws:
InstantiationException
IllegalAccessException
ClassCastException

getLoggerRepositoryFactoryType

public Class getLoggerRepositoryFactoryType()
Specified by:
getLoggerRepositoryFactoryType in interface Log4jSocketServerMBean

getLoggerRepository

public org.apache.log4j.spi.LoggerRepository getLoggerRepository(InetAddress addr)
Specified by:
getLoggerRepository in interface Log4jSocketServerMBean

createService

protected void createService()
                      throws Exception
Throws:
Exception

startService

protected void startService()
                     throws Exception
Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Throws:
Exception

destroyService

protected void destroyService()
                       throws Exception
Throws:
Exception


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.