@Override
public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) {
final DefinedExecutable de = registry.get(key);
if (de == null) {
logger.log(Level.FINE, "Not request logging request to URI: %s as no operation was found", key.toString());
observer.onResult(new ExecutionResult(new CougarServiceException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString())));
} else {
long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime;
long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime();
long expiryTime = Math.min(clientExpiryTime, serverExpiryTime);
if (expiryTime == Long.MAX_VALUE) {
expiryTime = 0;
}
if (!(observer instanceof ExpiringObserver)) {
final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime);
if (expiringObserver.expires()) {
registerExpiringObserver(expiringObserver);
}
observer = expiringObserver;
}
observer = new ExecutionObserverWrapper(observer, de.recorder, key);
try {
ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx);
de.exec.execute(contextToUse, key, args, observer, this, timeConstraints);
} catch (CougarException e) {
observer.onResult(new ExecutionResult(e));
} catch (Exception e) {
observer.onResult(new ExecutionResult(
new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
"Exception thrown by service method",
e)));
}
}
if (observer instanceof ExpiringObserver) {