Package org.acplt.oncrpc.apps.jportmap

# Class OncRpcEmbeddedPortmap

java.lang.Object
org.acplt.oncrpc.apps.jportmap.OncRpcEmbeddedPortmap

public class OncRpcEmbeddedPortmap extends Object
The class `OncRpcEmbeddedPortmap` provides an embeddable portmap service, which is automatically started in its own thread if the (operating) system does not already provide the portmap service. If an embedded portmap service is started it will stop only after the last ONC/RPC program has been deregistered.

Version:
  $Revision: 1.2 $ $Date: 2003/08/14 08:00:08 $ $State: Exp $ $Locker: $
Author:
  Harald Albrecht

## Field Summary

Fields
Modifier and Type
Field
Description
`protected org.acplt.oncrpc.apps.jportmap.OncRpcEmbeddedPortmap.embeddedjportmap`
`embeddedPortmap`
Portmap object acting as embedded portmap service or `null` if no embedded portmap service is necessary because the operating system already supplies one or another portmapper is already running.
`protected Thread`
`embeddedPortmapThread`
References thread object running the embedded portmap service.

## Constructor Summary

Constructors
Constructor
Description
`OncRpcEmbeddedPortmap()`
Constructs an embeddable portmap service of class `OncRpcEmbeddedPortmap` and starts the service if no other (external) portmap service is available.
`OncRpcEmbeddedPortmap(int checkTimeout)`
Constructs an embeddable portmap service of class `OncRpcEmbeddedPortmap` and starts the service if no other (external) portmap service is available.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`embeddedPortmapInUse()`
Indicates whether the embedded portmap service is in use.
`jportmap`
`getEmbeddedPortmap()`
Returns object implementing the embedded portmap service.
`Thread`
`getEmbeddedPortmapServiceThread()`
Returns the thread object running the embedded portmap service.
`static boolean`
`isPortmapRunning()`
Indicates whether a portmap service (regardless whether it's supplied by the operating system or an embedded portmap service) is currently running.
`static boolean`
`isPortmapRunning(int checkTimeout)`
Indicates whether a portmap service (regardless whether it's supplied by the operating system or an embedded portmap service) is currently running.
`void`
`shutdown()`
Stop the embedded portmap service if it is running.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### embeddedPortmap

protected org.acplt.oncrpc.apps.jportmap.OncRpcEmbeddedPortmap.embeddedjportmap embeddedPortmap
Portmap object acting as embedded portmap service or `null` if no embedded portmap service is necessary because the operating system already supplies one or another portmapper is already running.

### embeddedPortmapThread

protected Thread embeddedPortmapThread
References thread object running the embedded portmap service.

## Constructor Details

### OncRpcEmbeddedPortmap

public OncRpcEmbeddedPortmap() throws OncRpcException, IOException
Constructs an embeddable portmap service of class `OncRpcEmbeddedPortmap` and starts the service if no other (external) portmap service is available. This constructor is the same as `OncRpcEmbeddedPortmap` calling with a timeout of 3 seconds.

The constructor starts the portmap service in its own thread and then returns.

Throws:
  `OncRpcException` - in case of an RPC error.
  `IOException` - in case of an IO error.
See Also:
  - `embeddedPortmapInUse()`

### OncRpcEmbeddedPortmap

public OncRpcEmbeddedPortmap(int checkTimeout) throws OncRpcException, IOException
Constructs an embeddable portmap service of class `OncRpcEmbeddedPortmap` and starts the service if no other (external) portmap service is available.

The constructor starts the portmap service in its own thread and then returns.

Parameters:
  `checkTimeout` - timeout in milliseconds to wait before assuming that no portmap service is currently available.
Throws:
  `OncRpcException` - in case of an RPC error.
  `IOException` - in cas of an IO error.
See Also:
  - `embeddedPortmapInUse()`

## Method Details

### isPortmapRunning

public static boolean isPortmapRunning()
Indicates whether a portmap service (regardless whether it's supplied by the operating system or an embedded portmap service) is currently running. This method will check for 3 seconds for an answer from a portmap before assuming that no one exists.

Returns:
  `true`, if a portmap service (either external or embedded) is running and can be contacted.

### isPortmapRunning

public static boolean isPortmapRunning(int checkTimeout)
Indicates whether a portmap service (regardless whether it's supplied by the operating system or an embedded portmap service) is currently running.

Parameters:
  `checkTimeout` - timeout in milliseconds to wait before assuming that no portmap service is currently available.
Returns:
  `true`, if a portmap service (either external or embedded) is running and can be contacted.

### embeddedPortmapInUse

public boolean embeddedPortmapInUse()
Indicates whether the embedded portmap service is in use.

Returns:
  `true`, if embedded portmap service is currently used.

### getEmbeddedPortmapServiceThread

public Thread getEmbeddedPortmapServiceThread()
Returns the thread object running the embedded portmap service.

Returns:
  Thread object or `null` if no embedded portmap service has been started.

### getEmbeddedPortmap

public jportmap getEmbeddedPortmap()
Returns object implementing the embedded portmap service.

Returns:
  Embedded portmap object or `null` if no embedded portmap service has been started.

### shutdown

public void shutdown()
Stop the embedded portmap service if it is running. Normaly you should not use this method except you need to force the embedded portmap service to terminate. Under normal conditions the thread responsible for the embedded portmap service will terminate automatically after the last ONC/RPC program has been deregistered.

This method just signals the portmap thread to stop processing ONC/RPC portmap calls and to terminate itself after it has cleaned up after itself.