|
JSR-043: JTAPI-1.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.EventObject | +--javax.telephony.media.provider.EventObject | +--javax.telephony.media.provider.Base.Event
Implement a base class for Async.Event and MediaEvent. Includes in-package methods for provider use.
This class can be instantiated, but the resulting event has a no-op dispatch method; which means it goes through the EventQueue, but is not dispatched to any Listener. For most uses, a specialized class with a dispatch to Listener should be used.
This models the basic S.200 Event structure. The standard message/event fields are represented in this object, eventID, qualifier, error, suberr, payload, S.200 "status" is represented by the exception field in combination with the error:
statusOK: | error == Error_OK; | exception == null |
statusWarn: | error != Error_OK; | exception == null |
statusFail: | error != Error_OK; | exception != null |
Inner Class Summary | |
static class |
Base.Event.SyncInterruptedException
Thown when waitForEventDone() is interrupted by another Thread. |
Fields inherited from interface javax.telephony.media.MediaConstants |
e_OK, q_Duration, q_Standard, q_Stop |
Constructor Summary | |
Base.Event(java.lang.Object source,
Symbol eventID)
Construct specific completion or non-tranaction event. |
|
Base.Event(java.lang.Object source,
Symbol eventID,
java.lang.Exception exception)
Constructor for an event that is done. |
Method Summary | |
void |
dispatch(java.util.EventListener listener)
Invoke the appropriate callback method on the appropriate Listener. |
void |
done(java.lang.Exception exception)
Set the exception and mark as done. |
Symbol |
getError()
Identify the reason or cause of an error or failure. |
Symbol |
getEventID()
Get the Symbol that identifies this event. |
java.lang.Exception |
getException()
Simple waitForEventDone() and then return any Exception. |
MediaService |
getMediaService()
Deprecated. "use MediaServiceEvent.getMediaService()" |
java.util.Dictionary |
getPayload()
Get the Payload of this event. |
Symbol |
getQualifier()
Get the Qualifier of this event. |
int |
getSubError()
Get the suberror for this event. |
Symbol |
getWarning()
Return the error code, in the case where it was not a failure that generates an Exception. |
boolean |
isDone()
Indicates whether this Event has completed. |
void |
setError(Symbol error)
|
void |
setFields(java.util.Dictionary message)
extract common fields from an S.200 message Dictionary |
void |
setFields(Symbol qual,
Symbol error,
int suberror,
java.util.Dictionary payload)
Set extra info fields before done(Exception). |
void |
setPayload(java.util.Dictionary payload)
|
void |
setQualifier(Symbol qual)
|
void |
setSubError(int suberror)
|
void |
throwIfRuntimeException()
waitForEventDone() and then throw if event holds a RuntimeException. |
java.lang.String |
toString()
|
void |
waitForEventDone()
Waits for this event to complete. |
void |
waitForEventDone(long msecs)
Waits at most msecs for this event to complete. |
void |
waitForListenersDone()
waitForEventDone() and wait for Listener callbacks to return. |
Methods inherited from class java.util.EventObject |
getSource |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Base.Event(java.lang.Object source, Symbol eventID)
source
- the MPI$Owner which dispatches this Dispather.DispatchableEvent.eventID
- a Symbol that identifies this event.public Base.Event(java.lang.Object source, Symbol eventID, java.lang.Exception exception)
source
- the MediaService object that created this EventObject.eventID
- a Symbol that identifies the event.exception
- an Exception to be thrown in invoking thread.Method Detail |
public java.lang.String toString()
toString
in class java.util.EventObject
public MediaService getMediaService()
Defined in MediaEvent
public Symbol getEventID()
Implements MediaEvent
getEventID
in interface MediaEvent
public Symbol getQualifier()
getQualifier
in interface MediaEvent
public Symbol getError()
If this Event is not associated with an Exception,
then getError() returns ESymbol.Error_OK
.
In such a case, use getWarning()
getError
in interface MediaEvent
public Symbol getWarning()
getWarning
in interface MediaEvent
public int getSubError()
getSubError
in interface MediaEvent
public java.util.Dictionary getPayload()
getPayload
in interface MediaEvent
public java.lang.Exception getException()
Implements Async.Event.
getException
in interface MediaEvent
javax.telephony.media.MediaEvent
public void throwIfRuntimeException()
Implements Async.Event
All synchronous API methds come here to synchronize, and this method does special synchronization to wait until all the Listeners for an event have run an returned.
Note: We believe the synch APIs are the only users of this method. If this method comes to be used in a context where this 'Listener' synchronization is not desired, then we could use the regular waitForEventDone() here and change Base_MediaService.java to invoke waitForListenersDone() directly before calling throwIf...Exception().
Note: This method catches any InterruptedException and throws it as a RuntimeException. If an application needs to catch the InterruptedException directly, it should use waitForEventDone(long).
throwIfRuntimeException
in interface Async.Event
javax.telephony.media.async.Async.Event
java.lang.RuntimeException
- if the event holds a RuntimeException.public void waitForListenersDone()
Used by the synchronous API.
Note: This method catches any InterruptedException and throws it as a RuntimeException. If an application needs to catch the InterruptedException directly, it should use waitForEventDone(long).
waitForListenersDone
in interface Async.Event
javax.telephony.media.async.Async.Event
a
- RuntimeException
if another thread interrupts the current thread.
That is, any InterruptedException is wrapped in
a RuntimeException.public void waitForEventDone()
Implements Async.Event
Note: This method catches any InterruptedException and throws it as a RuntimeException. If an application needs to catch the InterruptedException directly, it should use waitForEventDone(long).
Note: Applications should be aware that Listener callbacks may run before, during, or after the thread that calls this method is continued. In contrast, the synchonous API methods use waitForListenersDone() which blocks until all Listeners have been notified.
waitForEventDone
in interface Async.Event
SyncInterruptedException,
- a RuntimeException
if another thread has interrupted the current thread.public final void waitForEventDone(long msecs) throws java.lang.InterruptedException
Implements Async.Event
waitForEventDone
in interface Async.Event
msecs
- the time to wait in milliseconds,
msecs = 0 means wait forever.Base.Event.SyncInterruptedException
- if another thread has interrupted
the current thread. The interrupted status of the
current thread is cleared when this exception is thrown.public final boolean isDone()
Implements Async.Event
isDone
in interface Async.Event
public void setFields(java.util.Dictionary message)
public void setFields(Symbol qual, Symbol error, int suberror, java.util.Dictionary payload)
Note: this is not synchronized, it should be called from the same thread that [later] calls done(Exception).
qual
- a Symbol that identifies the cause of completionerror
- a Symbol that identifies the cause of failuresuberror
- an int with more info about the errorpayload
- a Dictionary of additional information (non null).public void setQualifier(Symbol qual)
public void setError(Symbol error)
public void setSubError(int suberror)
public void setPayload(java.util.Dictionary payload)
public void done(java.lang.Exception exception)
Used by implementations of MPI.MediaGroup and MPI.GroupProvider.
Implements MPI.Event
public void dispatch(java.util.EventListener listener)
Implements Dispatcher.DispatchableEvent
Typically, Async.SomeEvent dispatches to like this:
public void dispatch(EventListener listener) {
if (listener instanceof Async.SomeListener)
((Async.SomeListener)listener).onSomeDone(this);
}
Invoked by Base_MediaService
dispatch
in interface Dispatcher.DispatchableEvent
listener
- an EventListener, some kind of MediaListener.
|
JSR-043: JTAPI-1.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |