isc.util
Class ServerAdmin

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by isc.util.ServerAdmin
All Implemented Interfaces:
ServerAdminIF, java.io.Serializable, java.lang.Runnable, java.rmi.Remote
Direct Known Subclasses:
ServerAdminLDAP

public class ServerAdmin
extends java.rmi.server.UnicastRemoteObject
implements ServerAdminIF, java.lang.Runnable

ServerAdmin is a utility class for managing administration and communication for the daemon.

The client/server communication mechanism is controlled in the config file. Refer to the appropriate communciation documentation for specific details. The rmi class and registered name is specified with the following properties.

Setting local only will block exporting all remote interfaces. Note. in this mode, the server should be shutdown by a ^c or a kill.
Admin.LOCAL_ONLY=true

Admin.JNDIClass=
Admin.NAMING_ADMIN_NAME=
Uncomment the appropriate lines in the config file to use that mechanism.
!=====================================================================
! Define the Admin External JNDI interface
!=====================================================================
! LDAP Directory based interface
!----------------------------------------------------------------
Admin.JNDIClass=isc.util.ServerAdminLDAP
Admin.NAMING_PROVIDER_URL=ldap://localhost:389/o=jndiObjects
Admin.NAMING_INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
Admin.NAMING_URL_PKG_PREFIXES=com.sun.jndi.ldap
Admin.NAMING_USER=cn=Manager,o=jndiObjects
Admin.NAMING_PW=secret
Admin.NAMING_ADMIN_NAME=cn=sensor ! Non-LDAP interfaces
!----------------------------------------------------------------
!Admin.JNDIClass=isc.util.ServerAdmin
!Admin.NAMING_ADMIN_NAME=sensor ! RMI Naming
!----------------------------------------------------------------
!Admin.NAMING_CONTEXT_CLASS=Context
!Admin.NAMING_PROVIDER_URL=rmi://localhost:1090
!Admin.NAMING_INITIAL_CONTEXT_FACTORY=com.sun.jndi.rmi.registry.RegistryContextFactory
!Admin.NAMING_URL_PKG_PREFIXES=com.sun.jndi.ldap ! JBoss Naming
!----------------------------------------------------------------
!Admin.NAMING_CONTEXT_CLASS=Context
!Admin.NAMING_PROVIDER_URL=jnp://localhost:1099
!Admin.NAMING_INITIAL_CONTEXT_FACTORY=org.jnp.interfaces.NamingContextFactory
!Admin.NAMING_URL_PKG_PREFIXES=org.jboss.naming:org.jnp.interfaces

Author:
John Casey
  • DNA_sensor - Aug 12, 2005
  • See Also:
    Serialized Form

    Field Summary
    protected  javax.naming.Context ctx
               
    protected static org.apache.log4j.Logger log
              log4j
    protected static java.lang.String PROP_ADMIN_LOCALONLY
               
    protected static java.lang.String PROP_NAMING_ADMIN_NAME
               
    protected static java.lang.String PROP_NAMING_CONTEXT_FACTORY
               
    protected static java.lang.String PROP_NAMING_URL
               
    protected static java.lang.String PROP_NAMING_URL_PKG_PREFIXES
               
    protected  AppProperties props
               
    protected  boolean running
               
    protected static long serialVersionUID
               
     
    Fields inherited from class java.rmi.server.RemoteObject
    ref
     
    Constructor Summary
    ServerAdmin()
              Create a ServerAdmin service for server.
    ServerAdmin(int port)
              Create a serverAdmin service using a specific port.
    ServerAdmin(int port, java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf)
               
     
    Method Summary
    protected  void init()
              Initialize this service.
     void run()
               
     boolean ServerRunning()
              detect if the server is running
     boolean setlogging(java.lang.String property)
              set a log4j property and reset the logging to use the new properties.
     int shutdown(long time)
              Shutdown the server
    protected  boolean useLocalOnly()
               
     
    Methods inherited from class java.rmi.server.UnicastRemoteObject
    clone, exportObject, exportObject, exportObject, unexportObject
     
    Methods inherited from class java.rmi.server.RemoteServer
    getClientHost, getLog, setLog
     
    Methods inherited from class java.rmi.server.RemoteObject
    equals, getRef, hashCode, toString, toStub
     
    Methods inherited from class java.lang.Object
    finalize, getClass, notify, notifyAll, wait, wait, wait
     

    Field Detail

    serialVersionUID

    protected static final long serialVersionUID
    See Also:
    Constant Field Values

    running

    protected volatile boolean running

    props

    protected AppProperties props

    log

    protected static org.apache.log4j.Logger log
    log4j


    PROP_NAMING_URL

    protected static final java.lang.String PROP_NAMING_URL
    See Also:
    Constant Field Values

    PROP_NAMING_CONTEXT_FACTORY

    protected static final java.lang.String PROP_NAMING_CONTEXT_FACTORY
    See Also:
    Constant Field Values

    PROP_NAMING_URL_PKG_PREFIXES

    protected static final java.lang.String PROP_NAMING_URL_PKG_PREFIXES
    See Also:
    Constant Field Values

    PROP_NAMING_ADMIN_NAME

    protected static final java.lang.String PROP_NAMING_ADMIN_NAME
    See Also:
    Constant Field Values

    PROP_ADMIN_LOCALONLY

    protected static final java.lang.String PROP_ADMIN_LOCALONLY
    See Also:
    Constant Field Values

    ctx

    protected javax.naming.Context ctx
    Constructor Detail

    ServerAdmin

    public ServerAdmin()
                throws java.rmi.RemoteException
    Create a ServerAdmin service for server. There should be only one per process.

    Throws:
    java.rmi.RemoteException - if the remote communications setup failed

    ServerAdmin

    public ServerAdmin(int port)
                throws java.rmi.RemoteException
    Create a serverAdmin service using a specific port.

    Parameters:
    port - Port to listen on
    Throws:
    java.rmi.RemoteException - if the communications setup fails

    ServerAdmin

    public ServerAdmin(int port,
                       java.rmi.server.RMIClientSocketFactory csf,
                       java.rmi.server.RMIServerSocketFactory ssf)
                throws java.rmi.RemoteException
    Throws:
    java.rmi.RemoteException
    Method Detail

    init

    protected void init()
    Initialize this service. Read client/server attributes from the properties.


    shutdown

    public int shutdown(long time)
                 throws java.rmi.RemoteException
    Description copied from interface: ServerAdminIF
    Shutdown the server

    Specified by:
    shutdown in interface ServerAdminIF
    Parameters:
    time - specified in milliseconds. -1 will force an immediate exit in the process
    Returns:
    return status of the call
    Throws:
    java.rmi.RemoteException - if the communications failed

    setlogging

    public boolean setlogging(java.lang.String property)
                       throws java.rmi.RemoteException
    Description copied from interface: ServerAdminIF
    set a log4j property and reset the logging to use the new properties.

    Specified by:
    setlogging in interface ServerAdminIF
    Parameters:
    property - The log4j property in the form of key=value
    Returns:
    True if the values were set
    Throws:
    java.rmi.RemoteException - if the communications failed
    See Also:
    Log4j, AppProperties

    run

    public void run()
    Specified by:
    run in interface java.lang.Runnable

    ServerRunning

    public boolean ServerRunning()
    detect if the server is running

    Returns:
    True if the server is running

    useLocalOnly

    protected boolean useLocalOnly()