Search in sources :

Example 1 with WebserviceCacheItem

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;
}
Also used : WebserviceCacheItem(lucee.runtime.cache.tag.webservice.WebserviceCacheItem) CacheHandlerPro(lucee.runtime.cache.tag.CacheHandlerPro) WebserviceCacheItem(lucee.runtime.cache.tag.webservice.WebserviceCacheItem) CacheItem(lucee.runtime.cache.tag.CacheItem) CacheHandler(lucee.runtime.cache.tag.CacheHandler)

Aggregations

CacheHandler (lucee.runtime.cache.tag.CacheHandler)1 CacheHandlerPro (lucee.runtime.cache.tag.CacheHandlerPro)1 CacheItem (lucee.runtime.cache.tag.CacheItem)1 WebserviceCacheItem (lucee.runtime.cache.tag.webservice.WebserviceCacheItem)1