org.garret.jipc
org.garret.jipc.client
org.garret.jipc.server
org.garret.jipc.protocol
JIPC supports local and remote sessions. Remote sessions
created by org.garret.jipc.client.JIPCClientFactory
class
establish connection with the server through TCP/IP stream socket.
Server process should be started before clients.
In this case primitives at local computer servers as stubs and redirect
requests to the server.
This mode is useful to provide synchronization and communication
between several Java processes at the same or different computers.
Local sessions are created by org.garret.jipc.server.JIPCServer
class. Them are useful to provide synchronization of threads within the same
process (if you want to use more sophisticated synchronization primitives than
standard synchronization facilities provided by Java language).
The single local session can be shared by all threads.
No server process should be started in this case.
jipc.jar
is located in lib
directory.
If you want to build it yourself, go to src
directory
and execute compile.bat
script.
Add jipc.jar
to your Java class path.
Server can be started by the following command:
java org.garret.jipc.server.JIPCServer PORTHere
PORT
is any free IP port at your system. Server is starts
interactive dialog, allowing you the inspect current state of the server
(info
command) or terminate the server (exit
command).The following system properties are used by server:
Property | Meaning | Default value |
---|---|---|
jipc.linger | Socket linger time | 10 seconds |
jipc.debug | Debug level:
| 1 |
start java org.garret.jipc.server.JIPCServer -d 6000will start server process in the background. To send commands to the server started in daemon mode you can use
org.garret.jipc.client.JIPCServerMonitor
:
Usage: java org.garret.jipc.client.JIPCServerMonitor HOSTNAME PORT [command] Commands: SHUTDOWN shutdown server INFO dump information about server statusIf command is not specified in command line, server monitor starts interactive dialog. In this dialog, except SHTDOWN and INFO commands it also supports EXIT and HELP commands. EXIT command is used to close dialog, HELP shows list of available commands. Now it is possible to start client processes using JIPC library. Client should create JIPC sessions using
org.garret.jipc.client.JIPCClientFactory.create(String address, int port)
method.
Here address
is address of the host where server is started and
port
is port listening by the server. Before exit client
should close session. Below is example of using JIPC library:
import org.garret.jipc.*; import org.garret.jipc.client.JIPCClientFactory; public class JIPCTest { public static void main(String args[]) throws Exception { String hostName = System.getProperty("host", "localhost"); int port = Integer.parseInt(System.getProperty("port", "6000")); JIPCFactory factory = org.garret.jipc.client.JIPCClientFactory.getInstance(); JIPCSession session = factory.create(host, port); JIPCMutex mutex = session.createMutex("my-mutex", false); mutex.lock(); // do something mutex.unlock(); session.close(); } }
I will provide e-mail support and help you with development of JIPC package.
Look for new version at my homepage | E-Mail me about bugs and problems