Esempio n. 1
0
  /**
   * Remove a port mapping from the active list
   *
   * @param portMap PortMapping
   * @return boolean
   */
  private final boolean removePortMapping(PortMapping portMap) {

    //	Remove the port mapping from the active lists

    Integer key = new Integer(portMap.hashCode());
    Object removedObj = m_mappings.remove(key);

    key =
        new Integer(PortMapping.generateHashCode(portMap.getProgramId(), 0, portMap.getProtocol()));
    m_noVerMappings.remove(key);

    //	Return a status indicating if the mapping was removed

    return removedObj != null ? true : false;
  }
Esempio n. 2
0
  /**
   * Search for a port mapping
   *
   * @param progId int
   * @param verId int
   * @param proto int
   * @return PortMapping
   */
  private final PortMapping findPortMapping(int progId, int verId, int proto) {

    //	Create a key for the RPC service

    Integer key = new Integer(PortMapping.generateHashCode(progId, verId, proto));

    //	Search for the required port mapping, including the version id

    PortMapping portMap = m_mappings.get(key);
    if (portMap == null && verId == 0) {

      //	Search for the port mapping without the version id

      portMap = m_noVerMappings.get(key);
    }

    //	Return the port mapping, or null if not found

    return portMap;
  }
Esempio n. 3
0
  /**
   * Add a port mapping to the active list
   *
   * @param portMap PortMapping
   * @return boolean
   */
  private final boolean addPortMapping(PortMapping portMap) {

    //	Check if there is an existing port mapping that matches the new port

    Integer key = new Integer(portMap.hashCode());
    if (m_mappings.get(key) != null) return false;

    //	Add the port mapping

    m_mappings.put(key, portMap);

    //	Add a port mapping with a version id of zero

    key =
        new Integer(PortMapping.generateHashCode(portMap.getProgramId(), 0, portMap.getProtocol()));
    m_noVerMappings.put(key, portMap);

    //	Indicate that the mapping was added

    return true;
  }