com.sun.comm
Class PortmapDatabase

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

class PortmapDatabase
extends java.lang.Object

Manages storage and look up of portmapping elements.

This is the Database stores CommPortIdentiers and the portmapping information used to manage their selection and naming.

A method is provided to parse the portmap.properties file, converting it into internal database format. Numerous methods are provided for cross-referencing and locating portmapping information that has been assimilated from portmap properties.

See Also:
Format of portmap.properties file.

Field Summary
private static java.util.Vector commPortIdentifiers
           
private static java.util.Vector portMapEntries
           
 
Constructor Summary
(package private) PortmapDatabase()
           
 
Method Summary
static void add(CommPortIdentifier cpi)
          Add a new CommPortIdentifier to the database
static void add(PortmapEntry pme)
          Add portmapping vector entry to database.
static java.lang.String DTUnameToTerminalId(java.lang.String dtuName)
          Find the terminalID a given DTUname maps to.
static void dump()
          Dump each portmapping entry in database as a string to stdout
static java.util.Enumeration elements()
          Return contents of port map database.
static java.util.Enumeration findByALNpath(java.lang.String alnPath)
          Locate all the port map entries that refer to a particular ALN path.
static java.util.Enumeration findByEquivName(java.lang.String equatedName)
          Locate all the port map entries that refer to a particular target name.
static PortmapEntry findByLogicalName(Alias alias)
          Locate a portmap entry via an aliased value.
static PortmapEntry findByLogicalName(java.lang.String aliasName)
          Locate a port map entry by it's logical name alias
static java.util.Enumeration findDTUnameRefs(java.lang.String dtuname)
          Locate all the port map entries that refer to a particular DTU name.
static java.util.Enumeration findDTUspecificALNs()
          Locate all session-local ALN aliases
static java.util.Enumeration findSessionLocalALNs()
          Locate all session-local ALN aliases
static java.util.Enumeration getCommPortIdentifiers()
          Get current list of CommPortIdentifiers
static void loadPortmapFile(java.lang.String portMapFilename)
          Builds portmapping database based on contents of portmap.properties file.
static java.lang.String terminalIdToDTUname(java.lang.String terminalId)
          Find the DTU name a given terminal ID maps to.
static java.lang.String translatePortname(java.lang.String portName)
          Translate a port specification as an alias.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

portMapEntries

private static java.util.Vector portMapEntries

commPortIdentifiers

private static java.util.Vector commPortIdentifiers
Constructor Detail

PortmapDatabase

PortmapDatabase()
Method Detail

loadPortmapFile

public static void loadPortmapFile(java.lang.String portMapFilename)
                            throws java.io.IOException
Builds portmapping database based on contents of portmap.properties file.

File format:

  • DTU alias

    Assigns a logical name to a DTU terminal ID. All other references to a specific DTU in the portmap.properties
    file must refer to a DTU alias to make it easier to identify and replace DTUs. These must be defined in the portmap.properties somewhere in the file previous to where DTUs are refreenced. Direct reference of DTU terminal ID's is not allowed except for DTU aliases to enforce clarity and make it easier to rename or replace DTUs.
    DTU Alias   =   Sun Ray DTU terminal ID

    Examples:
    Teller1_DTU = 02:5f:39:93:ab:92
    Kiosk_DTU = IEEE802.5abc2309fc29
  • DTU Specific

    Logical name only appears in CommPortIdentifier port list if javax.comm is running in a session on specified DTU (terminal id)
    logical name   =   DTU Alias   :   path to comm. port

    Examples:
    Hallway_Printer = Hallway_DTU:utprt2
    retina_scanner = entrance:utcom1
  • Session independent

    Logical name only appears in port list if not running in a Sun Ray session. The logical name replaces the physical path name in the CommPortIdentifier list.
    logical name   =   path to comm. port

    Examples:

    central_printer = /dev/printers/0
    Big_LED_display = /dev/term/a
  • Hidden (Session independent)

    Physical port name is hidden (for non-Sun Ray sessions)
    [hide]   path to comm. port

    Examples:      

    [hide] /dev/cua/a
    [hide] /dev/cua/b
  • Session local ALN     

    ALNs are "Automatic Logical Names" which are used to map to ports on Sun Ray dongles without having to know the device path

    Each ALN corresponds to RS-232 ports on attached USB dongle of DTU hosting local session. If the session moves to a new DTU, (javax.comm throws and exception on previous connection), when the comm. ports are re-enumerated, that session will see the corresponding ports on the dongle of the new DTU. This also faciliates DTU swapping.

    utcom1,    utcom2, ...    utprt1,    utprt2, ...

    Examples:

    local_printer = utprt1
    cashdrawer = utcom1
  • DTU Specific ALN     

    ALNs are "Automatic Logical Names" which are used to map to ports on Sun Ray dongles without having to know the device path

    Each ALN corresponds to RS-232 ports on attached USB dongle on the specified DTU. This allows devices on DTUS to be shared but requires root privilege, and implies a privileged daemon to manage the port for the local applications.

    dtu_alias.utcom1,    dtu_alias.utcom2, ...    dtu_alias.utprt1,    dtu_alias.utprt2, ...

    Examples:
    Charlies_printer = Charlies_DTU:utprt1
    teller1_cashdrawer = teller1:utcom4

Parameters:
portMapFilename - Path to portmap.properties file
Throws:
java.io.IOException
See Also:
com.sun.comm

translatePortname

public static java.lang.String translatePortname(java.lang.String portName)
                                          throws java.io.IOException
Translate a port specification as an alias.

This method is called during the CommPort.open() routine to attempt translating the device name path passed to open via the portmapping
database (based on portmap.properties). If the translation fails for any reason, the original untranslated name is passed back to
CommPort.open() which will then attempt to do a native OS open of whichever was returned, the callers original argument, or the
translated argument, and will throw an exception if the final argument is invalid.

Parameters:
portName - Original port name specified by the caller translation is attempted on.
Throws:
java.io.IOException

add

public static void add(CommPortIdentifier cpi)
Add a new CommPortIdentifier to the database

Parameters:
cpi - - the CommPortIdentifier to add.

add

public static void add(PortmapEntry pme)
Add portmapping vector entry to database.

Parameters:
pme - PortmapEntry to add to database

getCommPortIdentifiers

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

Returns:
Enumeration containing list of CommPortIdentifiers

elements

public static java.util.Enumeration elements()
Return contents of port map database.

Returns:
Enumeration of port map database entries.

dump

public static void dump()
Dump each portmapping entry in database as a string to stdout


DTUnameToTerminalId

public static java.lang.String DTUnameToTerminalId(java.lang.String dtuName)
Find the terminalID a given DTUname maps to.

Parameters:
dtuName - to match on.
Returns:
terminal ID if found otherwise null.

terminalIdToDTUname

public static java.lang.String terminalIdToDTUname(java.lang.String terminalId)
Find the DTU name a given terminal ID maps to.

Parameters:
terminalId - to match on.
Returns:
DTU name, if found otherwise null.

findByLogicalName

public static PortmapEntry findByLogicalName(Alias alias)
Locate a portmap entry via an aliased value.

(implicitly handles wildcard matching).

Parameters:
alias - Alias The alias to search for

findByLogicalName

public static PortmapEntry findByLogicalName(java.lang.String aliasName)
Locate a port map entry by it's logical name alias

Parameters:
aliasName - String The logical name alias to search for.
Returns:
PortmapEntry The port map entry corresponding to the alias or null if not found.

findByEquivName

public static java.util.Enumeration findByEquivName(java.lang.String equatedName)
Locate all the port map entries that refer to a particular target name.

Parameters:
equatedName - String Target name to match on.
Returns:
Enumeration List of port map entries that match the target.

findByALNpath

public static java.util.Enumeration findByALNpath(java.lang.String alnPath)
Locate all the port map entries that refer to a particular ALN path.

Parameters:
alnPath - String ALN path to match on.
Returns:
Enumeration List of port map entries that match the target.

findDTUnameRefs

public static java.util.Enumeration findDTUnameRefs(java.lang.String dtuname)
Locate all the port map entries that refer to a particular DTU name. Also supports a wild card match for any portmap entries flagged as 'globally visible'.

Parameters:
dtuname - String Target DTU name to match on.
Returns:
Enumeration List of port map entries that match the the DTU alias name.

findSessionLocalALNs

public static java.util.Enumeration findSessionLocalALNs()
Locate all session-local ALN aliases

Returns:
Enumeration List of port map entries that are ALN aliases.

findDTUspecificALNs

public static java.util.Enumeration findDTUspecificALNs()
Locate all session-local ALN aliases

Returns:
Enumeration List of port map entries that are ALN aliases.