Class RpcRequestBuilder
- java.lang.Object
-
- com.google.gwt.user.client.rpc.RpcRequestBuilder
-
public class RpcRequestBuilder extends java.lang.Object
This class encapsulates the logic necessary to configure a RequestBuilder for use with an RPC proxy object. Users who wish to alter the specifics of the HTTP requests issued by RPC proxy objects may override the protecteddoXyz
methods and pass an instance of the subclass toServiceDefTarget.setRpcRequestBuilder(com.google.gwt.user.client.rpc.RpcRequestBuilder)
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTENT_TYPE_HEADER
static java.lang.String
MODULE_BASE_HEADER
static java.lang.String
STRONG_NAME_HEADER
-
Constructor Summary
Constructors Constructor Description RpcRequestBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RpcRequestBuilder
create(java.lang.String serviceEntryPoint)
Initialize the RpcRequestBuilder.protected RequestBuilder
doCreate(java.lang.String serviceEntryPoint)
Called bycreate(java.lang.String)
to instantiate the RequestBuilder object.protected void
doFinish(RequestBuilder rb)
Called byfinish()
prior to returning the RequestBuilder to the caller.protected void
doSetCallback(RequestBuilder rb, RequestCallback callback)
protected void
doSetContentType(RequestBuilder rb, java.lang.String contentType)
Called bysetContentType(java.lang.String)
.protected void
doSetRequestData(RequestBuilder rb, java.lang.String data)
Called bysetRequestData(java.lang.String)
.protected void
doSetRequestId(RequestBuilder rb, int id)
Called bysetRequestId(int)
.RequestBuilder
finish()
This method must be called to return the RequestBuilder that the RPC request will be made with.RpcRequestBuilder
setCallback(RequestCallback callback)
Sets the RequestCallback to be used by the RequestBuilder.RpcRequestBuilder
setContentType(java.lang.String contentType)
Sets the MIME content type to be used by the RequestBuilder.RpcRequestBuilder
setRequestData(java.lang.String data)
Sets the request data to be sent in the request.RpcRequestBuilder
setRequestId(int id)
Sets the request id of the request.
-
-
-
Field Detail
-
CONTENT_TYPE_HEADER
public static final java.lang.String CONTENT_TYPE_HEADER
- See Also:
- Constant Field Values
-
MODULE_BASE_HEADER
public static final java.lang.String MODULE_BASE_HEADER
- See Also:
- Constant Field Values
-
STRONG_NAME_HEADER
public static final java.lang.String STRONG_NAME_HEADER
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public final RpcRequestBuilder create(java.lang.String serviceEntryPoint)
Initialize the RpcRequestBuilder. This method must be called before any of the other methods in this class may be called. Callingcreate
before callingfinish()
will reset the state of the RpcRequestBuilder.This method delegates to
doCreate(java.lang.String)
to instantiate the RequestBuilder.- Parameters:
serviceEntryPoint
- The URL entry point- Returns:
this
- See Also:
ServiceDefTarget.setServiceEntryPoint(String)
-
finish
public final RequestBuilder finish()
This method must be called to return the RequestBuilder that the RPC request will be made with.This method will call
doFinish(com.google.gwt.http.client.RequestBuilder)
before returning the current RequestBuilder.
-
setCallback
public final RpcRequestBuilder setCallback(RequestCallback callback)
Sets the RequestCallback to be used by the RequestBuilder. Delegates todoSetCallback(com.google.gwt.http.client.RequestBuilder, com.google.gwt.http.client.RequestCallback)
.- Parameters:
callback
- the RequestCallback to be used by the RequestBuilder- Returns:
this
-
setContentType
public final RpcRequestBuilder setContentType(java.lang.String contentType)
Sets the MIME content type to be used by the RequestBuilder. Delegates todoSetContentType(com.google.gwt.http.client.RequestBuilder, java.lang.String)
.- Parameters:
contentType
- the MIME content type to be used in the request- Returns:
this
-
setRequestData
public final RpcRequestBuilder setRequestData(java.lang.String data)
Sets the request data to be sent in the request. Delegates todoSetRequestData(com.google.gwt.http.client.RequestBuilder, java.lang.String)
.- Parameters:
data
- the data to send- Returns:
this
-
setRequestId
public final RpcRequestBuilder setRequestId(int id)
Sets the request id of the request. Delegates todoSetRequestId(com.google.gwt.http.client.RequestBuilder, int)
.- Parameters:
id
- the issue number of the request- Returns:
this
-
doCreate
protected RequestBuilder doCreate(java.lang.String serviceEntryPoint)
Called bycreate(java.lang.String)
to instantiate the RequestBuilder object.The default implementation creates a
POST
RequestBuilder with the given entry point.- Parameters:
serviceEntryPoint
- the URL to which the request should be issued- Returns:
- the RequestBuilder that should be ultimately passed to the RpcRequestBuilder's caller.
-
doFinish
protected void doFinish(RequestBuilder rb)
Called byfinish()
prior to returning the RequestBuilder to the caller.The default implementation sets the "X-GWT-Permutation" header to the value returned by
GWT.getPermutationStrongName()
.- Parameters:
rb
- The RequestBuilder that is currently being configured
-
doSetCallback
protected void doSetCallback(RequestBuilder rb, RequestCallback callback)
Called bysetCallback(com.google.gwt.http.client.RequestCallback)
.The default implementation calls
RequestBuilder.setCallback(RequestCallback)
.- Parameters:
rb
- the RequestBuilder that is currently being configuredcallback
- the user-provided callback
-
doSetContentType
protected void doSetContentType(RequestBuilder rb, java.lang.String contentType)
Called bysetContentType(java.lang.String)
.The default implementation sets the "Content-Type" header to the value specified by
contentType
by callingRequestBuilder.setHeader(String, String)
.- Parameters:
rb
- the RequestBuilder that is currently being configuredcontentType
- the desired MIME type of the request's contents
-
doSetRequestData
protected void doSetRequestData(RequestBuilder rb, java.lang.String data)
Called bysetRequestData(java.lang.String)
.The default implementation invokes
RequestBuilder.setRequestData(String)
.- Parameters:
rb
- the RequestBuilder that is currently being configureddata
- the data to send
-
doSetRequestId
protected void doSetRequestId(RequestBuilder rb, int id)
Called bysetRequestId(int)
.The default implementation is a no-op.
- Parameters:
rb
- the RequestBuilder that is currently being configuredid
- the request's issue id
-
-