use of cn.cerc.jbean.core.ServiceStatus in project summer-bean by cn-cerc.
the class LocalService method execute.
// 不带缓存调用服务
public IStatus execute(Object... args) {
if (args.length > 0) {
Record headIn = getDataIn().getHead();
if (args.length % 2 != 0)
return new ServiceStatus(false, "传入的参数数量必须为偶数!");
for (int i = 0; i < args.length; i = i + 2) headIn.setField(args[i].toString(), args[i + 1]);
}
if (handle == null)
return new ServiceStatus(false, "handle is null.");
if (serviceCode == null)
return new ServiceStatus(false, "service is null.");
IService bean = Application.getService(handle, serviceCode);
if (bean == null)
return new ServiceStatus(false, String.format("bean %s not find", serviceCode));
if ((bean instanceof Microservice) && ((Microservice) bean).getService() == null)
((Microservice) bean).setService(serviceCode);
try {
log.info(this.serviceCode);
IStatus status = bean.execute(dataIn, dataOut);
message = status.getMessage();
return status;
} catch (Exception e) {
Throwable err = e;
if (e.getCause() != null)
err = e.getCause();
log.error(err.getMessage(), err);
message = err.getMessage();
return new ServiceStatus(false, message);
}
}
use of cn.cerc.jbean.core.ServiceStatus in project summer-bean by cn-cerc.
the class Microservice method execute.
@Override
public IStatus execute(DataSet dataIn, DataSet dataOut) {
if (dataIn != null)
this.dataIn = dataIn;
if (dataOut != null)
this.dataOut = dataOut;
String host = Application.getServerConfig().getProperty("microservice." + location, "127.0.0.1");
String token = (String) this.getHandle().getProperty(Application.token);
RemoteService app = new RemoteService();
app.setService(this.service);
app.setHost(host);
app.setToken(token);
app.setDataIn(this.getDataIn());
app.setDataOut(this.getDataOut());
ServiceStatus status = new ServiceStatus(true);
try {
boolean rst = app.exec();
status.setMessage(app.getMessage());
status.setResult(rst);
} catch (Exception e) {
status.setMessage(e.getMessage());
status.setResult(true);
}
return status;
}
Aggregations