|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jpeterson.x10.GatewayImpl
Base GatewayImpl. Must be subclassed to do something useful. By default, a NullGatewayQueue is registered as the GatewayQueue. If you require event handling synchronized with the AWT event queue, you can manually register an AWTGatewayQueue.
Field Summary | |
protected java.util.Vector |
gatewayListeners
|
protected GatewayQueue |
gatewayQueue
|
Fields inherited from interface com.jpeterson.x10.Gateway |
ALLOCATED,
ALLOCATING_RESOURCES,
DEALLOCATED,
DEALLOCATING_RESOURCES,
PAUSED,
RESUMED |
Constructor Summary | |
protected |
GatewayImpl()
|
Method Summary | |
void |
addGatewayListener(GatewayListener listener)
Add a gateway listener. |
void |
allocate()
Allocate a gateway. |
void |
deallocate()
Deallocate a gateway. |
void |
dispatchControlEvent(ControlEvent event)
Method to actually send a GatewayEvent to registered listeners. |
void |
fireControlEvent(ControlEvent event)
Queues ControlEvent on registered GatewayQueue for subsequent dispatch to registered gateway listeners. |
GatewayQueue |
getGatewayQueue()
Retrieve the gateway queue used to process ControlEvents sent by the method fireControlEvent . |
long |
getGatewayState()
Returns a or'ed set of flags indicating the current state of a Gateway. |
void |
pause()
Pause a gateway. |
void |
removeGatewayListener(GatewayListener listener)
Remove a gateway listener. |
void |
resume()
Resume a gateway. |
void |
setGatewayQueue(GatewayQueue gatewayQueue)
Set the gateway queue used to process ControlEvents sent by the method fireControlEvent . |
protected void |
setGatewayState(long state)
Assign a new gateway state. |
protected void |
stateTransition(long state)
Performs state transitions for Gateway.ALLOCATED, Gateway.ALLOCATING_RESOURCES, Gateway.DEALLOCATED, Gateway.DEALLOCATING_RESOURCES, Gateway.PAUSED, Gateway.RESUMED. |
boolean |
testGatewayState(long state)
Returns true if the current gateway state matches the specified state. |
void |
waitGatewayState(long state)
Blocks the calling thread until the Gateway is in a specified state. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected GatewayQueue gatewayQueue
protected java.util.Vector gatewayListeners
Constructor Detail |
protected GatewayImpl()
Method Detail |
public long getGatewayState()
A GatewayEvent is issued each time the Gateway changes state.
The getGatewayState method can be called successfully in any Gateway state.
getGatewayState
,
waitGatewayState
,
getNewGatewayState
,
getOldGatewayState
protected void setGatewayState(long state)
public void waitGatewayState(long state) throws java.lang.InterruptedException, java.lang.IllegalArgumentException
All state bits specified in the state parameter must be set in order for the method to return, as defined for the testGatewayState method. If the state parameter defines an unreachable state (e.g. ALLOCATED | DEALLOCATED) an exception is thrown.
The waitGatewayState method can be called successfully in any Gateway state.
protected void stateTransition(long state)
public boolean testGatewayState(long state) throws java.lang.IllegalArgumentException
The test performed is not an exact match to the current state. Only the specified states are tested. For example the following returns true only if the Transmitter queue is empty, irrespective of the pause/resume and allocation states.
if (transmitter.testGatewayState(Transmitter.QUEUE_EMPTY)) ...
The testGatewayState method is equivalent to:
if ((gateway.getGatewayState() & state) == state)
The testGatewayState method can be called successfully in any Gateway state.
public void allocate() throws GatewayException, GatewayStateError
DEALLOCATING_RESOURCES
stategetGatewayState
,
deallocate
,
ALLOCATED
,
GATEWAY_ALLOCATED
public void deallocate() throws GatewayException, GatewayStateError
ALLOCATING_RESOURCES
stateallocate
,
GATEWAY_DEALLOCATED
,
QUEUE_EMPTY
public void pause() throws GatewayStateError
DEALLOCATED
or
DEALLOCATING_RESOURCES
statesresume
,
getGatewayState
,
GATEWAY_PAUSED
public void resume() throws GatewayStateError
DEALLOCATED
or
DEALLOCATING_RESOURCES
states.pause
,
getGatewayState
,
GATEWAY_RESUMED
public void addGatewayListener(GatewayListener listener)
listener
- the listener that will reveive GatewayEvents
Receiver
,
ReceptionListener
,
Transmitter
,
TransmissionListener
public void removeGatewayListener(GatewayListener listener)
listener
- the listener to be removedpublic void setGatewayQueue(GatewayQueue gatewayQueue)
fireControlEvent
.gatewayQueue
- GatewayQueue assigned to handle ControlEvents.public GatewayQueue getGatewayQueue()
fireControlEvent
.public void fireControlEvent(ControlEvent event)
setGatewayQueue
public void dispatchControlEvent(ControlEvent event)
This method should be overridden by subclass implementations of Transmitter and Receiver to handle their specific events. However, this method must be called to handle any events that they do not.
This method handles plane GatewayEvent and GatewayErrorEvent X10Events.
event
- the ControlEvent to be propagated to the listenersfireControlEvent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |