qflib 0.98.1

de.qfs.lib.logrmi
Class RemoteLogFilter

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--de.qfs.lib.logrmi.LogClientImplBase
                          |
                          +--de.qfs.lib.logrmi.RemoteLogFilter
All Implemented Interfaces:
LogClient, LogFilter, LogUser, java.rmi.Remote, java.io.Serializable

Deprecated. Since qflib version 0.98.0 this class is superceded by RemoteLogWriter.

public class RemoteLogFilter
extends LogClientImplBase
implements LogUser

The RemoteLogFilter class takes care of all the necessary details to connect to a LogServer and pass the log messages created by a program to it. The convenience methods logRemote and stopLogging handle all the details.

There are two possible modes of operation: Contact a server as soon as the RemoteLogFilter is created or register with the RMI registry to get contacted later by a LogServer. The most useful mode of operation is to combine these two, since then the user doesn't need to concern himself with the order in which server and clients are started.

If the RemoteLogFilter is to register itself with the RMI registry, a few additional things have to be decided:
- Which registry port to use
- Whether to create a registry, if the rmiregistry tool hasn't been started. This can be useful when a long-running server program is using its own registry port anyway, but should be used with care, as the termination of the program that created the registry will destroy all other registrations.
- Whether LogServers from different machines are allowed to connect. This can be very useful but is also a great security hole. The decision depends on your kind of program and whether your machine is safe behind a firewall.

To handle the log messages, the RemoteLogFilter must be added to the Log filter chain with Log.addFilter. It implements the LogUser interface to enable configuration of which messages to pass on through the filter chain. Its default filter mode is FILTER_NONE.

Version:
$Revision: 1.2 $
Author:
Gregor Schmid
See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface de.qfs.lib.log.LogUser
FILTER_ALL, FILTER_NONE, FILTER_UNUSED, FILTER_USED
 
Fields inherited from interface de.qfs.lib.logrmi.LogClient
REGISTRY_BASE_NAME
 
Constructor Summary
RemoteLogFilter(java.lang.String name)
          Deprecated. Create a new RemoteLogFilter and connect to a LogServer.
 
Method Summary
 void connect(LogServer logServer)
          Deprecated. Tell the LogClient that it should disengage from the registry and connect itself to a LogServer.
 void connect(java.lang.String server)
          Deprecated. Connect to a LogServer.
 void disconnect()
          Deprecated. Disconnect from the LogServer.
 boolean filter(LogEntry logEntry)
          Deprecated. Take a LogEntry and pass it to the LogServer.
 LogEntry[] filter(LogEntry[] entries)
          Deprecated. Send all messages from the list to the remote listener.
static RemoteLogFilter getInstance()
          Deprecated. No replacement.
static void logRemote(java.lang.String name, int port, boolean createRegistry, boolean localOnly)
          Deprecated. Please use RemoteLogWriter.logRemote instead.
static void logRemote(java.lang.String server, java.lang.String name)
          Deprecated. Please use RemoteLogWriter.logRemote instead.
static void logRemote(java.lang.String server, java.lang.String name, int port, boolean createRegistry, boolean localOnly)
          Deprecated. Please use RemoteLogWriter.logRemote instead.
 void register(int port, boolean createRegistry, boolean localOnly)
          Deprecated. Register the RemoteLogFilter with the RMI registry.
 void setFilterMode(int mode)
          Deprecated. Configure the RemoteLogFilter's filter mode.
static void stopLogging()
          Deprecated. Please use RemoteLogWriter.stopLogging instead.
 
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
 

Constructor Detail

RemoteLogFilter

public RemoteLogFilter(java.lang.String name)
                throws java.rmi.RemoteException
Deprecated. 
Create a new RemoteLogFilter and connect to a LogServer.
Parameters:
name - The name to connect under.
Throws:
java.rmi.RemoteException - If something RMI specific goes wrong.
Method Detail

logRemote

public static void logRemote(java.lang.String server,
                             java.lang.String name)
                      throws java.net.MalformedURLException,
                             java.rmi.NotBoundException,
                             java.rmi.RemoteException
Deprecated. Please use RemoteLogWriter.logRemote instead.

Create a new RemoteLogFilter and connect it to a LogServer and put it into the Log filter chain unless the connection to the LogServer fails.
Parameters:
server - The servername to connect to in the format used by java.rmi.Naming.lookup.
name - The name to connect under.
Throws:
java.net.MalformedURLException - If the server URL is bad.
java.rmi.NotBoundException - If the server is not bound under that name.
java.rmi.RemoteException - If something RMI specific goes wrong.

logRemote

public static void logRemote(java.lang.String name,
                             int port,
                             boolean createRegistry,
                             boolean localOnly)
                      throws java.rmi.RemoteException
Deprecated. Please use RemoteLogWriter.logRemote instead.

Create a new RemoteLogFilter, register it with the RMI registry and put it into the Log filter chain unless the registration fails.
Parameters:
name - The name to use when connecting to a LogServer.
port - The registry port to use. The value -1 means use the standard RMI registry port.
createRegistry - Whether to create a new Registry if none is available.
localOnly - If true, only LogServers from the same network address as the RemoteLogFilter are allowed to connect.
Throws:
java.rmi.RemoteException - If something RMI specific goes wrong.

logRemote

public static void logRemote(java.lang.String server,
                             java.lang.String name,
                             int port,
                             boolean createRegistry,
                             boolean localOnly)
                      throws java.net.MalformedURLException,
                             java.rmi.NotBoundException,
                             java.rmi.RemoteException
Deprecated. Please use RemoteLogWriter.logRemote instead.

Create a new RemoteLogFilter and connect it to a LogServer, register it with the RMI registry and put it into the Log filter chain unless both the connection to the LogServer and the registration fail.
Parameters:
server - The servername to connect to in the format used by java.rmi.Naming.lookup.
name - The name to connect under.
port - The registry port to use. The value -1 means use the standard RMI registry port.
createRegistry - Whether to create a new Registry if none is available.
localOnly - If true, only LogServers from the same network address as the RemoteLogFilter are allowed to connect.
Throws:
java.net.MalformedURLException - If the server URL is bad.
java.rmi.NotBoundException - If the server is not bound under that name.
java.rmi.RemoteException - If something RMI specific goes wrong.

stopLogging

public static void stopLogging()
Deprecated. Please use RemoteLogWriter.stopLogging instead.

Remove the RemoteLogFilter instance from the Log filter chain, disconnect from the LogServer and remove the instance from the RMI registry.

getInstance

public static RemoteLogFilter getInstance()
Deprecated. No replacement.

Get the RemoteLogFilter instance created last through one of the logRemote methods.
Returns:
The previously created RemoteLogFilter.

connect

public void connect(java.lang.String server)
             throws java.net.MalformedURLException,
                    java.rmi.NotBoundException,
                    java.rmi.RemoteException
Deprecated. 
Connect to a LogServer.
Parameters:
server - The servername to connect to in the format used by java.rmi.Naming.lookup.
Throws:
java.net.MalformedURLException - If the server URL is bad.
java.rmi.NotBoundException - If the server is not bound under that name.
java.rmi.RemoteException - If something RMI specific goes wrong.

register

public void register(int port,
                     boolean createRegistry,
                     boolean localOnly)
              throws java.rmi.RemoteException
Deprecated. 
Register the RemoteLogFilter with the RMI registry.
Parameters:
port - The registry port to use, -1 for default.
createRegistry - Whether to create the registry if none exists.
localOnly - If true, only LogServers from the same network address as the RemoteLogFilter are allowed to connect.
Throws:
java.rmi.RemoteException - If no working Registry can be found or created.

disconnect

public void disconnect()
Deprecated. 
Disconnect from the LogServer.

filter

public boolean filter(LogEntry logEntry)
Deprecated. 
Take a LogEntry and pass it to the LogServer.
Specified by:
filter in interface LogFilter
Parameters:
logEntry - The entry to pass on.
Returns:
True if the entry should be passed on to the next filter.

filter

public LogEntry[] filter(LogEntry[] entries)
Deprecated. 
Send all messages from the list to the remote listener.
Specified by:
filter in interface LogFilter
Parameters:
entries - The list of LogEntries.

setFilterMode

public void setFilterMode(int mode)
Deprecated. 
Configure the RemoteLogFilter's filter mode.
Specified by:
setFilterMode in interface LogUser
Parameters:
mode - The mode to set.

connect

public void connect(LogServer logServer)
             throws java.rmi.RemoteException
Deprecated. 
Tell the LogClient that it should disengage from the registry and connect itself to a LogServer.
Overrides:
connect in class LogClientImplBase
Parameters:
logServer - The LogServer to connect to.
Throws:
java.rmi.RemoteException - If something RMI specific goes wrong.

qflib 0.98.1