|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.jdesktop.beans.AbstractBean
org.jdesktop.ws.BaseService
public abstract class BaseService extends org.jdesktop.beans.AbstractBean
An abstact class useful as a base for asynchronous data service classes. For example, HttpService is a useful subclass for executing REST like webservice calls at a low level. WebService is a useful class which embodies one or more Operations (which are instances of BaseService) and which is useful for executing SOAP requests.
One could also imagine the creation of FtpService, SshService, SftpService, DatabaseService, and other such non http-based services.
BaseService serves as a base class for creating asynchronous Swing-friendly web service APIs. All events fired from BaseService are fired on the EDT, and it is assumed that all methods invoked on BaseService are likewise invoked on the Event Dispatching Thread (EDT).
| Nested Class Summary | |
|---|---|
private static class |
BaseService.Event
BaseService uses a smart implementation of publishing property change events onto the EDT to avoid EDT flooding, which most certainly would occur when transfering large files with all the progress notification updates. |
| Field Summary | |
|---|---|
private AtomicBoolean |
eventInProgress
Indicates that an event is in progress, and that there should therefore not be another SwingUtilities.invokeLater call. |
private LinkedBlockingQueue |
events
This LinkedBlockingQueue holds PropertyChangeListener/PropertyChangeEvent pairs which have not yet been fired on the EDT. |
private EventListenerList |
listeners
A list of listeners which are notified whenever the BaseService finishes, aborts, or fails. |
private float |
progress
The progress of the state. |
private State |
state
The state that this BaseService is in |
| Constructor Summary | |
protected BaseService()
Creates a new BaseService. |
|
| Method Summary | |
|---|---|
void
|
abort()
Aborts the current request. |
void
|
addAbortListener(AbortListener listener)
Adds a FailureListener |
void
|
addDoneListener(DoneListener listener)
Adds a DoneListener. |
void
|
addFailureListener(FailureListener listener)
|
protected void
|
doAbort()
|
protected void
|
doSend()
Invoked by this AbstractHttpService, this method performs the actual send operation. |
protected void
|
done()
|
void
|
fail(Throwable th)
Invoke this method from subclasses to force the connection to fail. |
private void
|
fireAbort()
Fires the aborted event, but does not change the state. |
private void
|
fireDone()
|
private void
|
fireFailure(Throwable th)
Fires the failure event, but does not change the state. |
protected void
|
fireOnEDT(String prop, Object oldv, Object newv)
Fires the given property change event on the EDT in a manner that avoids calling invokeLater for every property change event. |
float
|
getProgress()
Property indicating the upload or download progress. |
State
|
getState()
Property indicating the state of the service. |
void
|
removeAbortListener(AbortListener listener)
Removes a FailureListener |
void
|
removeDoneListener(DoneListener listener)
Removes an AbortListener |
void
|
removeFailureListener(FailureListener listener)
|
void
|
send()
Initiates the request/response cycle by sending a request to the remote service. |
protected void
|
setProgress(float p)
Sets the progress. |
protected void
|
setState(State s)
Sets the local state property, firing a property change event on the EventDispatchThread if necessary. |
| Methods inherited from class org.jdesktop.beans.AbstractBean | |
|---|---|
| org.jdesktop.beans.AbstractBean#clone(), org.jdesktop.beans.AbstractBean#addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), org.jdesktop.beans.AbstractBean#addPropertyChangeListener(java.beans.PropertyChangeListener), org.jdesktop.beans.AbstractBean#removePropertyChangeListener(java.beans.PropertyChangeListener), org.jdesktop.beans.AbstractBean#removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), org.jdesktop.beans.AbstractBean#getPropertyChangeListeners(java.lang.String), org.jdesktop.beans.AbstractBean#getPropertyChangeListeners(), org.jdesktop.beans.AbstractBean#addVetoableChangeListener(java.lang.String, java.beans.VetoableChangeListener), org.jdesktop.beans.AbstractBean#addVetoableChangeListener(java.beans.VetoableChangeListener), org.jdesktop.beans.AbstractBean#removeVetoableChangeListener(java.lang.String, java.beans.VetoableChangeListener), org.jdesktop.beans.AbstractBean#removeVetoableChangeListener(java.beans.VetoableChangeListener), org.jdesktop.beans.AbstractBean#getVetoableChangeListeners(java.lang.String), org.jdesktop.beans.AbstractBean#getVetoableChangeListeners(), org.jdesktop.beans.AbstractBean#wait(), org.jdesktop.beans.AbstractBean#wait(long), org.jdesktop.beans.AbstractBean#wait(long, int), org.jdesktop.beans.AbstractBean#equals(java.lang.Object), org.jdesktop.beans.AbstractBean#toString(), org.jdesktop.beans.AbstractBean#hashCode(), org.jdesktop.beans.AbstractBean#getClass(), org.jdesktop.beans.AbstractBean#notify(), org.jdesktop.beans.AbstractBean#notifyAll() |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private AtomicBoolean eventInProgress
private LinkedBlockingQueue events
private EventListenerList listeners
private float progress
private State state
| Constructor Detail |
|---|
protected BaseService()
| Method Detail |
|---|
public final void abort()
public void addAbortListener(AbortListener listener)
public final void addDoneListener(DoneListener listener)
public void addFailureListener(FailureListener listener)
protected void doAbort()
protected void doSend()
protected final void done()
public void fail(Throwable th)
private void fireAbort()
private void fireDone()
private void fireFailure(Throwable th)
protected final void fireOnEDT(String prop, Object oldv, Object newv)
public final float getProgress()
public final State getState()
public void removeAbortListener(AbortListener listener)
public final void removeDoneListener(DoneListener listener)
public void removeFailureListener(FailureListener listener)
public final void send()
state property or add one or more of
DoneListener, FailureListener, AbortListener.
protected void setProgress(float p)
protected void setState(State s)
Groovy Documentation