    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Interface javax.comm.CommPortOwnershipListener

public interface CommPortOwnershipListener
extends EventListener

Propagates various communications port ownership events. When a port is opened, a `CommPortOwnership` event of type `PORT_OWNED` will be propagated. When a port is closed, a `CommPortOwnership` event of type `PORT_UNOWNED` will be propagated.

Multiple applications that are seeking ownership of a communications port can resolve their differences as follows:

- ABCapp calls `open` and takes ownership of port.
- XYZapp calls `open` sometime later.
- While processing XYZapp's `open`, `CommPortIdentifier` will propagate a `CommPortOwnership` event with the event type `PORT_OWNERSHIP_REQUESTED`.
- If ABCapp is registered to listen to these events and if it is willing to give up ownership, it calls `close` from within the event callback.
- After the event has been fired, `CommPortIdentifier` checks to see if ownership was given up, and if so, turns over ownership of the port to XYZapp by returning success from `open`.

Note: When a `close` is called from within a `CommPortOwnership` event callback, a new `CommPortOwnership` event will not be generated.

See Also:
  CommPort, CommPortIdentifier, EventListener

##

PORT_OWNED
  The port just went from unowned to owned state, when an application successfully called `CommPortIdentifier.open`.
PORT_OWNERSHIP_REQUESTED
  Ownership contention.
PORT_UNOWNED
  The port just went from owned to unowned state, when the port's owner called `CommPort.close`.

##

ownershipChange(int)
  Propagates a `CommPortOwnership` event.

##

PORT_OWNED

     public static final int PORT_OWNED

  The port just went from unowned to owned state, when an application successfully called `CommPortIdentifier.open`.

PORT_UNOWNED

     public static final int PORT_UNOWNED

  The port just went from owned to unowned state, when the port's owner called `CommPort.close`.

PORT_OWNERSHIP_REQUESTED

     public static final int PORT_OWNERSHIP_REQUESTED

  Ownership contention. The port is owned by one application and another application wants ownership. If the owner of this port is listening to this event, it can call `CommPort.close` during the processing of this event and thereby give up ownership of the port.

##

ownershipChange

     public abstract void ownershipChange(int type)

  Propagates a `CommPortOwnership` event. This method will be called with the type set to one of the variables `PORT_OWNED`, `PORT_UNOWNED`, or `PORT_OWNERSHIP_REQUESTED`.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index