org.garret.jipc
Interface JIPCSession


public interface JIPCSession

JIPC session. Session can be remote and local. Remote sessions establish conntection with the server through TCP/IP stream socket. In this case primitives at local computer servers as stubs and redirect requests to the server. This mode is useful to provide sycnhronization and communication between several Java processes at the same or different computers. Local sessions are useful to provide synhcronization of threads within the same process. The single local session can be shared by all threads.
Session interface provides methods for creating sycnhronization objects. Name of the object is unique with objects of the same type (events, semaphores,...). It is possible that, for example mutex and event has the same name.


Method Summary
 void close()
          Close session.
 org.garret.jipc.JIPCBarrier createBarrier(java.lang.String name, int nSessions)
          Create or return existed barrier synchronization object.
 org.garret.jipc.JIPCEvent createEvent(java.lang.String name, boolean signaled, boolean manualReset)
          Create or return existed event synchronization object.
 org.garret.jipc.JIPCLock createLock(java.lang.String name)
          Create or return existed lock synchronization object.
 org.garret.jipc.JIPCMutex createMutex(java.lang.String name, boolean locked)
          Create or return existed mutex synchronization object.
 org.garret.jipc.JIPCQueue createQueue(java.lang.String name)
          Create or return existed queue bject.
 org.garret.jipc.JIPCSemaphore createSemaphore(java.lang.String name, int initCount)
          Create or return existed semaphore synchronization object.
 org.garret.jipc.JIPCSharedMemory createSharedMemory(java.lang.String name, java.io.Serializable obj)
          Create or return existed shared memory object.
 boolean isLocal()
          Checks whether it is local session
 org.garret.jipc.JIPCBarrier openBarrier(java.lang.String name)
          Open existed barrier.
 org.garret.jipc.JIPCEvent openEvent(java.lang.String name)
          Open existed event.
 org.garret.jipc.JIPCLock openLock(java.lang.String name)
          Open existed lock.
 org.garret.jipc.JIPCMutex openMutex(java.lang.String name)
          Open existed mutex.
 org.garret.jipc.JIPCQueue openQueue(java.lang.String name)
          Open existed queue.
 org.garret.jipc.JIPCSemaphore openSemaphore(java.lang.String name)
          Open existed semaphore.
 org.garret.jipc.JIPCSharedMemory openSharedMemory(java.lang.String name)
          Create or return existed shared memory object.
 void showServerInfo(java.io.PrintStream stream)
          Get information about server state.
 void shutdownServer()
          Terminate server.
 

Method Detail

close

public void close()
           throws JIPCException,
                  java.io.IOException
Close session. This method disconnects client from server, release all locks hold by this session and close all primitives opened by this session.
Attention!You should no call this method for local sessions if it is shared by multiple threads

JIPCException
java.io.IOException

createBarrier

public org.garret.jipc.JIPCBarrier createBarrier(java.lang.String name,
                                                 int nSessions)
                                          throws JIPCException,
                                                 java.io.IOException
Create or return existed barrier synchronization object.

Parameters:
name - unique barrier name.
nSessions - positive number of sessions to be synchronized on barrier
Returns:
created or existed barrier, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

createEvent

public org.garret.jipc.JIPCEvent createEvent(java.lang.String name,
                                             boolean signaled,
                                             boolean manualReset)
                                      throws JIPCException,
                                             java.io.IOException
Create or return existed event synchronization object.

Parameters:
name - unique event name.
signaled - initial state of the event, ignored if mutex already exists
manualReset - mode of the event, ignored if mutex already exists
Returns:
created or existed event, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

createLock

public org.garret.jipc.JIPCLock createLock(java.lang.String name)
                                    throws JIPCException,
                                           java.io.IOException
Create or return existed lock synchronization object.

Parameters:
name - unique lock name.
Returns:
created or existed lock, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

createMutex

public org.garret.jipc.JIPCMutex createMutex(java.lang.String name,
                                             boolean locked)
                                      throws JIPCException,
                                             java.io.IOException
Create or return existed mutex synchronization object.

Parameters:
name - unique mutex name.
locked - initial state of the mutex, if true then it is owned by session created this mutex, ignored if mutex already exists
Returns:
created or existed mutex, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

createQueue

public org.garret.jipc.JIPCQueue createQueue(java.lang.String name)
                                      throws JIPCException,
                                             java.io.IOException
Create or return existed queue bject.

Parameters:
name - unique queue name.
Returns:
created or existed queue, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

createSemaphore

public org.garret.jipc.JIPCSemaphore createSemaphore(java.lang.String name,
                                                     int initCount)
                                              throws JIPCException,
                                                     java.io.IOException
Create or return existed semaphore synchronization object.

Parameters:
name - unique semaphore name.
initCount - non-negative initial value of semaphore counter, ignored if mutex already exists
Returns:
created or existed semaphore, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

createSharedMemory

public org.garret.jipc.JIPCSharedMemory createSharedMemory(java.lang.String name,
                                                           java.io.Serializable obj)
                                                    throws JIPCException,
                                                           java.io.IOException
Create or return existed shared memory object.

Parameters:
name - unique shared memory name.
obj - non-null initial value of shared memory object
Returns:
created or existed shared memory, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

isLocal

public boolean isLocal()
Checks whether it is local session

Returns:
true is session was created by means of org.garret.jipc.server.JIPCServer factory, false - if session eas created by org.garret.jipc.client.JIPCClientFactory.

openBarrier

public org.garret.jipc.JIPCBarrier openBarrier(java.lang.String name)
                                        throws JIPCException,
                                               java.io.IOException
Open existed barrier.

Parameters:
name - barrier name
Returns:
barrier or null if barrier with such name doesn't exists
JIPCException
java.io.IOException

openEvent

public org.garret.jipc.JIPCEvent openEvent(java.lang.String name)
                                    throws JIPCException,
                                           java.io.IOException
Open existed event.

Parameters:
name - event name
Returns:
event or null if event with such name doesn't exists
JIPCException
java.io.IOException

openLock

public org.garret.jipc.JIPCLock openLock(java.lang.String name)
                                  throws JIPCException,
                                         java.io.IOException
Open existed lock.

Parameters:
name - lock name
Returns:
lock or null if lock with such name doesn't exists
JIPCException
java.io.IOException

openMutex

public org.garret.jipc.JIPCMutex openMutex(java.lang.String name)
                                    throws JIPCException,
                                           java.io.IOException
Open existed mutex.

Parameters:
name - mutex name
Returns:
mutex or null if mutex with such name doesn't exists
JIPCException
java.io.IOException

openQueue

public org.garret.jipc.JIPCQueue openQueue(java.lang.String name)
                                    throws JIPCException,
                                           java.io.IOException
Open existed queue.

Parameters:
name - queue name
Returns:
queue or null if queue with such name doesn't exists
JIPCException
java.io.IOException

openSemaphore

public org.garret.jipc.JIPCSemaphore openSemaphore(java.lang.String name)
                                            throws JIPCException,
                                                   java.io.IOException
Open existed semaphore.

Parameters:
name - semaphore name
Returns:
semaphore or null if semaphore with such name doesn't exists
JIPCException
java.io.IOException

openSharedMemory

public org.garret.jipc.JIPCSharedMemory openSharedMemory(java.lang.String name)
                                                  throws JIPCException,
                                                         java.io.IOException
Create or return existed shared memory object.

Parameters:
name - unique shared memory name.
Returns:
created or existed shared memory, use alreadExists method to check if new object is created
JIPCException
java.io.IOException

showServerInfo

public void showServerInfo(java.io.PrintStream stream)
                    throws JIPCException,
                           java.io.IOException
Get information about server state. This method is used by JIPCServerMonitor and should not be used by normal client unless it wants to monitor server itself.

JIPCException
java.io.IOException

shutdownServer

public void shutdownServer()
                    throws JIPCException,
                           java.io.IOException
Terminate server. This method is used by JIPCServerMonitor and should not be used by normal client unless it wants to monitor server itself. This method do nothing for local sessions. You should not execute any other session method after this this method.

JIPCException
java.io.IOException