Examples of AsyncResult


Examples of com.volantis.cache.AsyncResult

        final String cacheName = "cache";
        cpc.createCache(cacheName, "10", "0");

        final Cache cache = cpc.getCache("cache");

        AsyncResult async = cache.asyncQuery(cacheKey, Period.inSeconds(30));

        assertFalse(async.isReady());

        CacheEntry entry = async.getEntry();
        assertNotNull(entry);

        final SystemClock clock = SystemClock.getDefaultInstance();
        ProviderResult result = new ProviderResult(new Integer(1),
            cache.getRootGroup(), true,
            new PipelineCacheState(
                clock.getCurrentTime().addPeriod(Period.inSeconds(2))));
        async.update(result);

        CacheableObjectProvider cacheableObjectProvider =
            new ExpiredObjectsRemainExpiredCacheableObjectProvider(cache.getRootGroup());
        assertNotNull("Integer object is retrievable via the cache",
                cache.retrieve(cacheKey, cacheableObjectProvider));
View Full Code Here

Examples of com.volantis.cache.AsyncResult

     */
    private Object retrieveInternal(
            Object key, final CacheableObjectProvider provider) {

        Object value = null;
        AsyncResult async = asyncQuery(key, Period.INDEFINITELY);

        // Act on the state of the entry. It is possible that within this
        // window where the entry is not synchronized that the entry could
        // change, the only case were it cannot is if it was in the update
        // state as all other threads will see it as pending and wait.
        // Some of the things that can happen in this window are:
        // 1) Entries may have been removed, either implicitly, or explicitly.
        // 2) Entries may have expired on another thread.
        // 3) Entries may have moved groups.
        // 4) Entries may have new values.

        if (async.isReady()) {
            value = async.getValue();
        } else {
            ProviderResult result = null;
            Throwable throwable = null;
            boolean failed = true;
            try {
                // Get the entry, this will return null if the entry is marked
                // as being uncacheable.
                CacheEntry entry = async.getEntry();

                // Get the provider to retrieve the object. It is given the
                // whole entry so that it can perform revalidation of an
                // existing entry if it has expired.
                result = provider.retrieve(clock, key, entry);
                if (result == null) {
                    throw new IllegalStateException("Result from provider is null");
                }

                // Request to the provider did not fail.
                failed = false;

            } catch (RuntimeException e) {

                // Remember the exception so that it can be stored in the
                // entry to indicate the original cause.
                throwable = e;

                // Rethrow the exceptions.
                throw e;

            } catch (Error e) {

                // Remember the exception so that it can be stored in the
                // entry to indicate the original cause.
                throwable = e;

                // Rethrow the exceptions.
                throw e;

            } finally {
                if (failed) {
                    async.failed(throwable);
                } else {
                    // the cache must be updated even if the result has a
                    // non-null throwable
                                       
                    value = async.update(result);

                    // if the result has a throwable, thow it wrapped inside a
                    // runtime exception
                    Throwable cause = result.getThrowable();
                    if (cause != null) {
View Full Code Here

Examples of javax.ejb.AsyncResult

            // simulating a long running query
            Thread.sleep(AWAIT);
        } catch (InterruptedException ex) {
            Logger.getLogger(MyAsyncBeanMethodLevel.class.getName()).log(Level.SEVERE, null, ex);
        }
        return new AsyncResult(n1 + n2);
    }
View Full Code Here

Examples of javax.ejb.AsyncResult

            // simulating a long running query
            Thread.sleep(AWAIT);
        } catch (InterruptedException ex) {
            Logger.getLogger(MyAsyncBeanClassLevel.class.getName()).log(Level.SEVERE, null, ex);
        }
        return new AsyncResult(n1 + n2);
    }
View Full Code Here

Examples of org.apache.axis2.client.async.AsyncResult

                        } else {
                            callback.onError(new Exception(body.getFault()
                                    .getReason().getText()));
                        }
                    } else {
                        AsyncResult asyncResult = new AsyncResult(response);

                        callback.onComplete(asyncResult);
                    }
                }
View Full Code Here

Examples of org.apache.axis2.client.async.AsyncResult

        String messageID    = relatesTO.getValue();
        Callback callback   = (Callback) callbackStore.get(messageID);

        if (callback != null) {
            callbackStore.remove(messageID);
            callback.onComplete(new AsyncResult(messageCtx));
        }
    }
View Full Code Here

Examples of org.apache.axis2.client.async.AsyncResult

              } else {
                callback.onError(new Exception(body.getFault()
                    .getReason().getText()));
              }
            } else {
              AsyncResult asyncResult = new AsyncResult(response);

              callback.onComplete(asyncResult);
            }
          }
View Full Code Here

Examples of org.apache.axis2.client.async.AsyncResult

                            axisCallback.onError(fault);
                        }

                    } else {
                        if (callback != null) {
                            AsyncResult asyncResult = new AsyncResult(response);
                            callback.onComplete(asyncResult);
                        } else {
                            axisCallback.onMessage(response);
                        }
View Full Code Here

Examples of org.apache.axis2.client.async.AsyncResult

        // THIS NEXT PART WILL EVENTUALLY GO AWAY WHEN Callback DOES

        // OK, this must be an old-style Callback
        Callback callback = (Callback)callbackObj;
        AsyncResult result = new AsyncResult(msgContext);

        // check whether the result is a fault.
        try {
            SOAPEnvelope envelope = result.getResponseEnvelope();

            OperationContext opContext = msgContext.getOperationContext();
            if (opContext != null && !opContext.isComplete()) {
                opContext.addMessageContext(msgContext);
            }
View Full Code Here

Examples of org.apache.axis2.client.async.AsyncResult

    public void receive(MessageContext messageCtx) throws AxisFault {
        RelatesTo relatesTO = messageCtx.getOptions().getRelatesTo();
        String messageID = relatesTO.getValue();
        Callback callback = (Callback) callbackStore.get(messageID);
        AsyncResult result = new AsyncResult(messageCtx);

        if (callback != null) {
            callback.onComplete(result);
            callback.setComplete(true);
            //closing the tranport
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.