org.apache.log4j.examples
Class NumberCruncherServer
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--org.apache.log4j.examples.NumberCruncherServer
- All Implemented Interfaces:
- NumberCruncher, Remote, Serializable
- public class NumberCruncherServer
- extends UnicastRemoteObject
- implements NumberCruncher
A simple NumberCruncher
implementation that logs its
progress when factoring numbers. The purpose of the whole exercise
is to show the use of nested diagnostic contexts in order to
distinguish the log output from different client requests.
Usage: java org.apache.log4j.examples.NumberCruncherServer configFile
where configFile is a log4j configuration file.
We supply a simple config file factor.lcf
for directing log output to the file factor.log
.
Try it yourself by starting a NumberCruncherServer
and make queries from multiple NumberCruncherClients
to factor numbers.
Sample output shows the log
output when two clients connect to the server near simultaneously.
See source code
of NumberCruncherServer
for more details.
Note that class files for the example code is not included in
any of the distributed log4j jar files. You will have to add the
directory /dir-where-you-unpacked-log4j/classes
to
your classpath before trying out the examples.
- See Also:
- Serialized Form
Method Summary |
static void |
delay(int millis)
|
int[] |
factor(int number)
Factor a positive integer number and return its
distinct factor's as an integer array. |
static void |
main(String[] args)
|
NumberCruncherServer
public NumberCruncherServer()
throws RemoteException
factor
public int[] factor(int number)
throws RemoteException
- Description copied from interface:
NumberCruncher
- Factor a positive integer
number
and return its
distinct factor's as an integer array.
- Specified by:
factor
in interface NumberCruncher
delay
public static void delay(int millis)
main
public static void main(String[] args)
Please notify me about new log4j releases.