use of lucee.runtime.cache.tag.webservice.WebserviceCacheItem in project Lucee by lucee.
the class Axis1Client method _callCachedWithin.
private Object _callCachedWithin(PageContext pc, Config secondChanceConfig, String methodName, Struct namedArguments, Object[] arguments) throws PageException, RemoteException, ServiceException {
// no pc no cache!
if (pc == null)
return _call(pc, secondChanceConfig, methodName, namedArguments, arguments);
Object cachedWithin = getCachedWithin(pc);
String cacheId = CacheHandlerCollectionImpl.createId(wsdlUrl, username, password, proxyData, methodName, arguments, namedArguments);
CacheHandler cacheHandler = pc.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_WEBSERVICE, null).getInstanceMatchingObject(cachedWithin, null);
if (cacheHandler instanceof CacheHandlerPro) {
CacheItem cacheItem = ((CacheHandlerPro) cacheHandler).get(pc, cacheId, cachedWithin);
if (cacheItem instanceof WebserviceCacheItem) {
WebserviceCacheItem entry = (WebserviceCacheItem) cacheItem;
return entry.getData();
}
} else if (cacheHandler != null) {
// TODO this else block can be removed when all cache handlers implement CacheHandlerPro
CacheItem cacheItem = cacheHandler.get(pc, cacheId);
if (cacheItem instanceof WebserviceCacheItem) {
WebserviceCacheItem entry = (WebserviceCacheItem) cacheItem;
return entry.getData();
}
}
// cached item not found, process and cache result if needed
long start = System.nanoTime();
Object rtn = _call(pc, secondChanceConfig, methodName, namedArguments, arguments);
if (cacheHandler != null)
cacheHandler.set(pc, cacheId, cachedWithin, new WebserviceCacheItem(rtn, wsdlUrl, methodName, System.nanoTime() - start));
return rtn;
}
Aggregations