本文整理汇总了Java中com.google.gwt.user.server.rpc.RPC类的典型用法代码示例。如果您正苦于以下问题:Java RPC类的具体用法?Java RPC怎么用?Java RPC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RPC类属于com.google.gwt.user.server.rpc包,在下文中一共展示了RPC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSerializationPolicy
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@Override
public SerializationPolicy getSerializationPolicy(String moduleBaseURL,
String strongName) {
SerializationPolicy serializationPolicy = null;
synchronized (serializationPolicyCache) {
serializationPolicy = serializationPolicyCache.get(moduleBaseURL
+ strongName);
}
if (serializationPolicy != null) {
return serializationPolicy;
}
serializationPolicy = loadSerializationPolicy(moduleBaseURL, strongName);
if (serializationPolicy == null) {
serializationPolicy = RPC.getDefaultSerializationPolicy();
}
serializationPolicyCache.put(moduleBaseURL + strongName,
serializationPolicy);
return serializationPolicy;
}
示例2: processCall
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
/**
* This is taken from GWT 2.4 sources. The changed code was to, rather than
* call the actual XxxxServer method that would have handled the request,
* simply encode an AccessDeniedException as the failure response for the request.
*
* Revisions to newer GWT versions should verify that this code is still
* suitable for those newer GWT versions.
*/
@Override
public String processCall(String payload) throws SerializationException {
try {
RPCRequest rpcRequest = RPC.decodeRequest(payload);
onAfterRequestDeserialized(rpcRequest);
// ******* CHANGED GWT 2.4 CODE STARTS
LogFactory.getLog(GWTAccessDeniedHandlerImpl.class).warn("GWT Method: "
+ rpcRequest.getMethod().getName() + " Exception: " + e.getMessage());
return RPC
.encodeResponseForFailure(
rpcRequest.getMethod(),
new org.opendatakit.common.security.client.exception.AccessDeniedException(
e));
// ******** CHANGED GWT 2.4 CODE ENDS
} catch (IncompatibleRemoteServiceException ex) {
LogFactory.getLog(GWTAccessDeniedHandlerImpl.class).warn("An IncompatibleRemoteServiceException was thrown while processing this call.",
ex);
return RPC.encodeResponseForFailure(null, ex);
}
}
示例3: processPost
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@Override
protected void processPost(HttpServletRequest request, HttpServletResponse response) throws Throwable {
try {
String requestPayload = this.readContent(request);
RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, this.getClass(), this);
String responsePayload =
RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters(),
rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());
boolean gzipEncode =
RPCServletUtils.acceptsGzipEncoding(request)
&& RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);
RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode);
} catch (Exception e) {
this.logger.error("Request processing failed", e);
throw Throwables.propagate(e);
}
}
示例4: processPostRpc
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@RequestMapping(value = "/commandService", method = RequestMethod.POST)
public void processPostRpc(HttpServletRequest request, HttpServletResponse response)
throws Throwable {
try {
String requestPayload = RPCServletUtils.readContentAsGwtRpc(request);
RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, CommandService.class, this);
String responsePayload =
RPC.invokeAndEncodeResponse(commandService,
rpcRequest.getMethod(), rpcRequest.getParameters(),
rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());
boolean gzipEncode =
RPCServletUtils.acceptsGzipEncoding(request)
&& RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);
RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode);
} catch (Exception e) {
this.logger.error("Request processing failed", e);
throw Throwables.propagate(e);
}
}
示例5: processCall
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@Override
public String processCall(String payload) throws SerializationException {
try {
RPCRequest req = RPC.decodeRequest(payload, null, this);
RemoteService service = getServiceInstance(req.getMethod().getDeclaringClass());
return RPC.invokeAndEncodeResponse(service, req.getMethod(),
req.getParameters(), req.getSerializationPolicy());
} catch (IncompatibleRemoteServiceException ex) {
log("IncompatibleRemoteServiceException in the processCall(String) method.",
ex);
return RPC.encodeResponseForFailure(null, ex);
}
}
示例6: parseGWTRPC
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
private static String parseGWTRPC( HttpMessage message, Value value, String charset )
throws IOException
{
RPCRequest request = RPC.decodeRequest( new String( message.content(), charset ) );
String operationName = (String)request.getParameters()[0];
joliex.gwt.client.Value requestValue = (joliex.gwt.client.Value)request.getParameters()[1];
JolieGWTConverter.gwtToJolieValue( requestValue, value );
return operationName;
}
示例7: doUnexpectedFailure
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@Override
protected void doUnexpectedFailure(Throwable e) {
RPCRequest req = (RPCRequest) ServerContext.getRequestOwner().getAttribute("rpcRequest");
if (req == null) {
super.doUnexpectedFailure(e);
return;
}
try {
RPC.encodeResponseForFailure(req.getMethod(), e, req.getSerializationPolicy());
} catch (Exception ex) {
ex.printStackTrace();
super.doUnexpectedFailure(ex);
}
}
示例8: 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();
}
示例9: 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);
}
}
示例10: 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;
}
示例11: doFilter
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
if (request.getRequestURI().endsWith(".rpc")) {
String requestURI = request.getRequestURI();
String rpc = requestURI.substring(requestURI.lastIndexOf("/") + 1);
Object delegate =webApplicationContext.getBean(rpc);
if (delegate == null) {
throw new AssertionError("RPC实例为null");
}
String payload = RPCServletUtils.readContent(request,
"text/x-gwt-rpc", null);
RPCRequest rpcRequest = RPC.decodeRequest(payload,
delegate.getClass(), this);
Method rpcRequestMethod = rpcRequest.getMethod();
try {
String responsePayload = RPC4Monitor.invokeAndEncodeResponse(delegate,
rpcRequestMethod, rpcRequest.getParameters(),
rpcRequest.getSerializationPolicy(),
rpcRequest.getFlags());
RPCServletUtils.writeResponse(null, (HttpServletResponse) resp,
responsePayload, false);
} catch (SerializationException e) {
log.error(e);
throw new RuntimeException("RPC序列化异常", e);
}
} else {
chain.doFilter(req, resp);
}
}
示例12: processCall
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
public String processCall(String payload) throws SerializationException {
try {
RPCRequest rpcRequest = RPC.decodeRequest(payload, this.remoteServiceClass);
return RPC.invokeAndEncodeResponse(this.remoteService, rpcRequest.getMethod(),
rpcRequest.getParameters());
} catch (IncompatibleRemoteServiceException ex) {
LOGGER.warn("An IncompatibleRemoteServiceException was thrown while processing this call.",
ex);
return RPC.encodeResponseForFailure(null, ex);
}
}
示例13: processCall
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
@Override
public String processCall(String payload) {
// // ロギング
// RPCRequest rpcRequest = RPC.decodeRequest(payload, getClass(), this);
// if (!LOGGING_EXCLUDED_METHODS.contains(rpcRequest.getMethod().getName())) {
// logger.info(getRemoteAddress() + " " + rpcRequest.getMethod());
// }
// processCall()から送出される例外を捕捉してログに出力する
try {
return super.processCall(payload);
} catch (Throwable e) {
String message = "processCall()中にエラーが発生しました: "
+ MoreObjects.toStringHelper(this).add("remoteAddress", getRemoteAddress())
.add("rpcRequest", RPC.decodeRequest(payload, null, this)).add("payload", payload)
.toString();
logger.log(Level.WARNING, message, e);
try {
return RPC.encodeResponseForFailure(null,
new ServiceException(Throwables.getStackTraceAsString(e)));
} catch (SerializationException e1) {
logger.log(Level.WARNING, "エラー情報の返信に失敗しました", e1);
}
}
// フォールバック
return "";
}
示例14: deserialize
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
public static <T> T deserialize(Class<? super T> clazz, String serializedString, String moduleName) throws SerializationException {
if(clazz == null || serializedString == null){
return null;
}
SerializationPolicy policy;
synchronized (StorageUtilsHolder.SERIALIZATION_POLICY_CACHE) {
String _mn = (moduleName != null && !moduleName.trim().isEmpty()) ? moduleName.trim() : DEFAULT_POLICY_MODULE;
policy = StorageUtilsHolder.SERIALIZATION_POLICY_CACHE.get(_mn);
}
if (policy == null) policy = RPC.getDefaultSerializationPolicy();
return StorageUtilsHolder.SERIALIZER.deserialize(clazz, serializedString, policy);
}
示例15: serialize
import com.google.gwt.user.server.rpc.RPC; //导入依赖的package包/类
public static <T> String serialize(Class<? super T> clazz, T instance, String moduleName) throws SerializationException {
if(clazz == null || instance == null){
return null;
}
SerializationPolicy policy;
synchronized (StorageUtilsHolder.SERIALIZATION_POLICY_CACHE) {
String _mn = (moduleName != null && !moduleName.trim().isEmpty()) ? moduleName.trim() : DEFAULT_POLICY_MODULE;
policy = StorageUtilsHolder.SERIALIZATION_POLICY_CACHE.get(_mn);
}
if (policy == null) policy = RPC.getDefaultSerializationPolicy();
return serialize(clazz, instance, policy);
}