com.sun.comm
Class Portmapping

java.lang.Object
  extended bycom.sun.comm.Portmapping

public class Portmapping
extends java.lang.Object

This class is used to handle all portmapping for javax.comm. it maintains the active list of exposed CommPortIdentifier objects, and is used to build and refresh the PortmapDatabase all alias mappings according to the portmap.properties file, which it parses and maintains an internal database to reflect.

This class populates the list of CommPortIdentifiers that will be seen by the application. This view of the ports and their aliases is determined by the portmap.properties configuration, which Sun Rays are on line, which dongles they have connected, whether or not the user is running on a Sun Ray session, and if in a Sun Ray session, which DTU the user is on.

If no portmap.properties file exists, server ports are displayed according to the PathBundle passed into refreshPortDatabase(). Sun Ray dongle paths are detected automatically, so no list need be provided. By default, Sun Ray dongle ports are shown by the basename of their path in the Sun Ray device tree (see the manpage for basename(1)), but the default aliases can be overridden.

Logical name definitions in the portmap.properties file can be used to create CommPortIdentifier referring server ports using names other other than their physical paths, or to omit certain paths (for example, /dev/cua/a and /dev/cua/b are good candidates since they overlap with /dev/term/a and /dev/term/b, albeit with certain implications).

Since:
3.0.0
Author:
Paul Klissner
See Also:
Format of portmap.properties file

Field Summary
private static int DEFAULT_ALIASING
           
private static int DONGLE_ALIASING
           
private static CommDriver driver
           
private static int PARALLEL
           
private static int SERIAL
           
 
Constructor Summary
Portmapping()
           
 
Method Summary
static void add(CommPortIdentifier cpi)
          Get current list of CommPortIdentifiers
static java.util.Enumeration getCommPortIdentifiers()
          Get current list of CommPortIdentifiers
static java.util.Enumeration refreshPortDatabase(java.lang.String portMapFilename, CommDriver driver, PathBundle serverPorts)
          Parses portmap.properties, building new port database accordingly.
private static void registerCommPorts(PathBundle serverPorts)
          Scan ports on system, registering them according to portmapping rules.
static java.lang.String translatePortname(java.lang.String portName)
          Attempt to translate the portname.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driver

private static CommDriver driver

SERIAL

private static final int SERIAL
See Also:
Constant Field Values

PARALLEL

private static final int PARALLEL
See Also:
Constant Field Values

DEFAULT_ALIASING

private static final int DEFAULT_ALIASING
See Also:
Constant Field Values

DONGLE_ALIASING

private static final int DONGLE_ALIASING
See Also:
Constant Field Values
Constructor Detail

Portmapping

public Portmapping()
Method Detail

refreshPortDatabase

public static java.util.Enumeration refreshPortDatabase(java.lang.String portMapFilename,
                                                        CommDriver driver,
                                                        PathBundle serverPorts)
                                                 throws java.io.IOException
Parses portmap.properties, building new port database accordingly.

Parameters:
portMapFilename - full path to portmap.properties

driver - implementation of CommPort driver to use during CommPortIdentifier creation

serverPorts - list of server-side physical comm ports and/or directories containing them.
Returns:
Enumeration containing up-to-date list of commPortIdentifiers
Throws:
java.io.IOException
See Also:
loadPortmapFile, translatePortname

registerCommPorts

private static void registerCommPorts(PathBundle serverPorts)
Scan ports on system, registering them according to portmapping rules.

Creates a new CommPortIdentifier for each port on the system that meets the criteria laid out in the portmap.properties file. Behavior of this comm. port registration is different depending on whether javax.comm is running in a Sun Ray session or not.


getCommPortIdentifiers

public static java.util.Enumeration getCommPortIdentifiers()
Get current list of CommPortIdentifiers

Returns:
Enumeration containing list of CommPortIdentifiers

add

public static void add(CommPortIdentifier cpi)
Get current list of CommPortIdentifiers

Parameters:
cpi - CommPortIdentifier we're adding to the list.

translatePortname

public static java.lang.String translatePortname(java.lang.String portName)
                                          throws java.io.IOException
Attempt to translate the portname.

Returns:
portname translated or orignal string if translation fails.
Throws:
java.io.IOException