public Object async()

in safeguard-impl/src/main/java/org/apache/safeguard/impl/asynchronous/AsynchronousInterceptor.java [52:69]


    public Object async(final InvocationContext context) throws Exception {
        final Map<Key, Boolean> models = cache.getEnabled();
        final Key cacheKey = new Key(context, cache.getUnwrappedCache().getUnwrappedCache());
        Boolean enabled = models.get(cacheKey);
        if (enabled == null) {
            enabled = cache.getMapper().isEnabled(context.getMethod(), Asynchronous.class);
            models.putIfAbsent(cacheKey, enabled);
        }
        if (!enabled) {
            return context.proceed();
        }
        final String key = Asynchronous.class.getName() + ".skip_" +
                context.getContextData().get(IdGeneratorInterceptor.class.getName());
        if (context.getContextData().putIfAbsent(key, Boolean.TRUE) != null) { // bulkhead or so handling threading
            return context.proceed();
        }
        return around(context);
    }