Groovy Documentation

org.jdesktop.ws
[Java] Class HttpService

java.lang.Object
  org.jdesktop.beans.AbstractBean
      org.jdesktop.ws.BaseService
          org.jdesktop.ws.AbstractHttpService
              org.jdesktop.ws.HttpService

public class HttpService
extends AbstractHttpService

An HTTP based REST web service.

Authors:
Richard


Nested Class Summary
private static class HttpService.HttpWorker

Instances of this class actually perform the request/response cycle in the background.

 
Field Summary
private Request request

The request to use when sending.

private Response response

The response from the web server.

private SecurityLevel securityLevel

The security level to use.

 
Fields inherited from class AbstractHttpService
session, workerRef
 
Fields inherited from class BaseService
eventInProgress, events, listeners, progress, state
 
Constructor Summary
HttpService()

 
Method Summary
protected SwingWorker createWorker()

protected void doSend()

Request getRequest()

Gets the Request used by this service.

Response getResponse()

Gets the response, if there is one.

SecurityLevel getSecurityLevel()

Gets the security level used with this service.

void setRequest(Request r)

Sets the Request to use with this service.

private void setResponse(Response r)

Sets the Response.

void setSecurityLevel(SecurityLevel level)

Sets the security level.

 
Methods inherited from class AbstractHttpService
createWorker, doAbort, doSend, getSession, setState
 
Methods inherited from class BaseService
abort, addAbortListener, addDoneListener, addFailureListener, doAbort, doSend, done, fail, fireAbort, fireDone, fireFailure, fireOnEDT, getProgress, getState, removeAbortListener, removeDoneListener, removeFailureListener, send, setProgress, setState
 
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()
 

Field Detail

request

private Request request
The request to use when sending. By default this is a normal Request. If you want to use HTML Form parameters, then use a FormRequest by calling setRequest.


response

private Response response
The response from the web server. This is reset to null whenever an abort occurs, or at the beginning of a new request/response cycle. Also, when a failure occurs it is set to null. Note that if the request/response cycle succeeds, but the actual call failed (due to semantics or something on the server) "done" will be called and this will have a value.


securityLevel

private SecurityLevel securityLevel
The security level to use. If not set, medium level security is used.


 
Constructor Detail

HttpService

HttpService()


 
Method Detail

createWorker

protected SwingWorker createWorker()


doSend

@Override
protected void doSend()


getRequest

public final Request getRequest()
Gets the Request used by this service. This will never return null.
Returns:


getResponse

public final Response getResponse()
Gets the response, if there is one. This may return null if the state is anything other than DONE. It will not ever be null if the state is DONE.
Returns:


getSecurityLevel

public final SecurityLevel getSecurityLevel()
Gets the security level used with this service. There are three levels of security. The first is "high", which is the default in Java (though not in this class). High security requires that the web server have a certificate signed by a trusted certificate root, such as Verisign. The second level of security is "medium", and is the default for this class. Medium level security means that if a certificate is from a trusted root, then it is trusted. Otherwise, the user is prompted to accept the certificate. This is essentially the mode supported by web browsers. The third level of security is "low" in which case the user will never be prompted. Obviously this is only good for testing (if that) and should never be used when deployed. Note that changing the security level requires priviledges, and thus your app needs to be signed.
Returns:


setRequest

public void setRequest(Request r)
Sets the Request to use with this service. If null, then a new Request will be created, ensuring that it is never null. This will fire a property change event.
Parameters:
r


setResponse

private void setResponse(Response r)
Sets the Response. This simply sets the value and fires a property change event.
Parameters:
r


setSecurityLevel

public void setSecurityLevel(SecurityLevel level)
Sets the security level. This cannot be null.


 

Groovy Documentation