use of org.eclipse.scout.rt.shared.servicetunnel.ServiceUtility in project scout.rt by eclipse.
the class MockServiceTunnel method mockServiceCall.
/**
* @return the service response You may call callTargetService() to simply call a service for test purpose (without a
* transaction!)
*/
protected ServiceTunnelResponse mockServiceCall(ServiceTunnelRequest req) throws Exception {
try {
ServiceUtility serviceUtility = BEANS.get(ServiceUtility.class);
Class<?> serviceInterface = Class.forName(req.getServiceInterfaceClassName());
Method serviceOperation = serviceUtility.getServiceOperation(serviceInterface, req.getOperation(), req.getParameterTypes());
Object service = null;
for (Object t : BEANS.all(serviceInterface)) {
if (Proxy.isProxyClass(t.getClass())) {
continue;
}
service = t;
break;
}
Object result = serviceUtility.invoke(service, serviceOperation, req.getArgs());
return new ServiceTunnelResponse(result, null, null);
} catch (Throwable t) {
return new ServiceTunnelResponse(null, null, t);
}
}
use of org.eclipse.scout.rt.shared.servicetunnel.ServiceUtility in project scout.rt by eclipse.
the class ServiceOperationInvoker method invokeInternal.
protected ServiceTunnelResponse invokeInternal(ServiceTunnelRequest serviceReq) throws ClassNotFoundException {
IServerSession serverSession = ServerSessionProvider.currentSession();
if (LOG.isDebugEnabled()) {
String userId = serverSession != null ? serverSession.getUserId() : "";
LOG.debug("started {}.{} by {} at {}", serviceReq.getServiceInterfaceClassName(), serviceReq.getOperation(), userId, new Date());
}
CallInspector callInspector = getCallInspector(serviceReq, serverSession);
ServiceTunnelResponse serviceRes = null;
try {
ServiceUtility serviceUtility = BEANS.get(ServiceUtility.class);
Class<?> serviceInterfaceClass = SerializationUtility.getClassLoader().loadClass(serviceReq.getServiceInterfaceClassName());
Method serviceOp = serviceUtility.getServiceOperation(serviceInterfaceClass, serviceReq.getOperation(), serviceReq.getParameterTypes());
Object[] args = serviceReq.getArgs();
Object service = getValidatedServiceAccess(serviceInterfaceClass, serviceOp, args);
Object data = serviceUtility.invoke(service, serviceOp, args);
Object[] outParameters = serviceUtility.extractHolderArguments(args);
serviceRes = new ServiceTunnelResponse(data, outParameters);
return serviceRes;
} finally {
updateInspector(callInspector, serviceRes);
}
}
Aggregations