Limit the Number of Objects a Thread Touches
The next tip in using threads is almost an emergent tip. If you use containers to mediate thread communication, use background threads to perform resource allocation and cleanup tasks, and carefully limit the number of objects that serialization will visit, you'll notice something else happening. Each thread will only ever visit a small number of objects. There's a slight exception to this. Since RMI reuses the same thread across multiple client requests, that thread may eventually wind up...
Methods Across the Wire
Though convenient, automatically generating marshalling and demarshalling code is mostly a side effect produced in the service of a much more important goal. In a nutshell RMI is designed to make communication between two Java programs, running in separate JVMs, as much like making a method call inside a single process as possible. This is an ambitious goal. How does RMI achieve it Recall that in order to communicate with the printer server, we wrote an object, ClientNetworkWrapper, which did...
Java.rmi.dgc.lease Dirty Java.rmi.server.objid Long Java.rmi.dgc.lease
The standard log is easy to use. You turn it on and off using the java.rmi.server.logCalls system property. This is a boolean system property. Note that this property can either be set at the command line or in code. There is no functional difference between the command line invocation java -Djava.rmi.server.logCalls true other stuff and using to invoke a program that contains the line System.getProperties true Actually, this isn't quite true. At the command line, you always have permission to...
rmic The RMI Compiler
Stubs and skeletons are generated from server class files by a command-line application called rmic. This application ships with Sun s version of the Java Development Kit JDK . The simplest invocation of rmic uses the following format rmic full class name including packages For example rmic Assuming the class is on your classpath, this will generate two additional class files in the same directory as the original class file. The names of the generated classes will be the original class name,...
Streams Reusability and Testing
InputStream and OutputStream are abstract classes. FileInputStream and File-OutputStream are concrete subclasses. One of the issues that provokes endless discussions in software design circles centers around method signatures. For example, consider the following four method signatures parseObjectsFromFile String filename parseObjectsFromFile File file parseObjectsFromFile FileInputStream fileInputStream parseObjectsFromStream InputStream inputStream The first three signatures are better...
