本文整理汇总了Java中com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java RPC.encodeResponseForSuccess方法的具体用法?Java RPC.encodeResponseForSuccess怎么用?Java RPC.encodeResponseForSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.server.rpc.RPC
的用法示例。
在下文中一共展示了RPC.encodeResponseForSuccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCall
import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
private void processCall(final HttpServletResponse response,
final byte[] bytes, final Map<String, String> parameters) throws Exception {
Object presentationService = applicationContext.getBean(serviceName
.get());
if (!(presentationService instanceof IFileUploadPresentationService)) {
throw new IllegalArgumentException(
"Requested Spring Bean is not a File Upload Presentation Service: ("
+ presentationService + ")");
}
String encodedResult = null;
if (parameters.get(MAX_FILE_SIZE_PARAM_NAME) != null) {
long maxFileSize = Long.parseLong(parameters
.get(MAX_FILE_SIZE_PARAM_NAME));
if (bytes.length > maxFileSize) {
encodedResult = RPC.encodeResponseForFailure(
((IFileUploadPresentationService) presentationService)
.getClass().getDeclaredMethod("uploadFile",
bytes.getClass(), Map.class),
new GWTMaxFileSizeExceedException());
}
}
try {
String result = ((IFileUploadPresentationService) presentationService)
.uploadFile(bytes, parameters);
encodedResult = RPC.encodeResponseForSuccess(
((IFileUploadPresentationService) presentationService)
.getClass().getDeclaredMethod("uploadFile",
bytes.getClass(), Map.class), result);
} catch (PresentationException e) {
GWTPresentationException pex = new GWTPresentationException(e);
encodedResult = RPC.encodeResponseForFailure(
((IFileUploadPresentationService) presentationService)
.getClass().getDeclaredMethod("uploadFile",
bytes.getClass(), Map.class), pex);
}
response.getOutputStream().write(encodedResult.getBytes());
response.getOutputStream().flush();
}
示例2: processCall
import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
@Override
public String processCall(final String payload)
throws SerializationException {
try {
Object presentationService = applicationContext.getBean(serviceName
.get());
if (!(presentationService instanceof RemoteService)) {
throw new IllegalArgumentException(
"Requested Spring Bean is not a GWT RemoteService Presentation Service: "
+ payload + " (" + presentationService + ")");
}
RPCRequest rpcRequest = RPC.decodeRequest(payload,
presentationService.getClass(), this);
if (presentationService instanceof AuthenticationServiceFacade
&& rpcRequest.getMethod().equals(
AuthenticationServiceFacade.class
.getMethod("getXSRFSessionToken"))) {
return RPC.encodeResponseForSuccess(rpcRequest.getMethod(),
SecurityHelper.createXSRFToken(getThreadLocalRequest()));
}
return RPC.invokeAndEncodeResponse(presentationService,
rpcRequest.getMethod(), rpcRequest.getParameters(),
rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());
} catch (Exception e) {
GWTPresentationException pex = new GWTPresentationException(
e.getMessage());
return RPC.encodeResponseForFailure(null, pex);
}
}
示例3: toClient
import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
* serialize PresenceRoom to send to client.
* @param p_room
* @return null if any error occur.
*/
public static String toClient(PresenceRoom p_room)
{
String response = null;
try
{
response = RPC.encodeResponseForSuccess( s_getRoom, p_room,
FmgSerializationPolicy.getPolicy() );
} catch( SerializationException e )
{
log.error( e );
}
return response;
}
示例4: gwtSerialize
import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
* Server-side deserialize does not match server-side serialize, so we can't test a round trip.
*/
public static <T> void gwtSerialize(T object) throws SerializationException {
RPC.encodeResponseForSuccess(arbitraryVoidReturningMethod(), object);
}
示例5: invokeMethodOnService
import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
* Handles method invocation on a service and is invoked by
* {@link #processCall(String)}.
*
* @param service
* Service to invoke method on
* @param targetMethod
* Method to invoke.
* @param targetParameters
* Parameters to pass to method. Can be null for no arguments.
* @param rpcRequest
* RPCRequest instance for this request
* @return Return RPC encoded result.
* @throws Exception Any exception caused in serialization
*/
protected String invokeMethodOnService(Object service, Method targetMethod, Object[] targetParameters,
RPCRequest rpcRequest) throws Exception {
Object result = targetMethod.invoke(service, targetParameters);
SerializationPolicy serializationPolicy = getSerializationPolicyProvider().getSerializationPolicyForSuccess(rpcRequest, service, targetMethod, targetParameters, result);
String encodedResult = RPC.encodeResponseForSuccess(rpcRequest.getMethod(), result, serializationPolicy, serializationFlags);
return encodedResult;
}