/** * Returns the resource attached under given {@code name}, or {@code null} if no such resource is * available. * * @param name The name under which the resource was attached * @param <R> The type of resource * @return The resource mapped to the given {@code name}, or {@code null} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getResource(String name) { return (R) resources().get(name); }
/** * Returns the resource attached under given {@code name}. If there is no resource mapped to the given key yet * the {@code mappingFunction} is invoked to provide the mapping. * * @param key The name under which the resource was attached * @param mappingFunction The function that provides the mapping if there is no mapped resource yet * @param <R> The type of resource * @return The resource mapped to the given {@code key}, or the resource returned by the * {@code mappingFunction} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getOrComputeResource(String key, Function<? super String, R> mappingFunction) { return (R) resources().computeIfAbsent(key, mappingFunction); }
/** * Returns the resource attached under given {@code name}. If there is no resource mapped to the given key, * the {@code defaultValue} is returned. * * @param key The name under which the resource was attached * @param defaultValue The value to return if no mapping is available * @param <R> The type of resource * @return The resource mapped to the given {@code key}, or the resource returned by the * {@code mappingFunction} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getOrDefaultResource(String key, R defaultValue) { return (R) resources().getOrDefault(key, defaultValue); }
/** * Initializes current unit of work with interceptor chain. * * @param interceptorChain the interceptor chain */ public static void initialize(InterceptorChain interceptorChain) { Assert.state(CurrentUnitOfWork.isStarted(), () -> "An active Unit of Work is required for injecting interceptor chain"); CurrentUnitOfWork.get().resources().put(INTERCEPTOR_CHAIN_EMITTER_KEY, interceptorChain); }
unitOfWork.onCleanup(u -> u.resources().remove(eventsKey)); return eventQueue; });
new UoWAttachedConnectionImpl(delegateConnection), new ConnectionWrapperFactory.NoOpCloseHandler()); uow.root().resources().put(CONNECTION_RESOURCE_NAME, connection); uow.onCommit(u -> { Connection cx = u.root().getResource(CONNECTION_RESOURCE_NAME);
/** * Returns the resource attached under given {@code name}, or {@code null} if no such resource is * available. * * @param name The name under which the resource was attached * @param <R> The type of resource * @return The resource mapped to the given {@code name}, or {@code null} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getResource(String name) { return (R) resources().get(name); }
/** * Returns the resource attached under given {@code name}, or {@code null} if no such resource is * available. * * @param name The name under which the resource was attached * @param <R> The type of resource * @return The resource mapped to the given {@code name}, or {@code null} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getResource(String name) { return (R) resources().get(name); }
/** * Returns the resource attached under given {@code name}. If there is no resource mapped to the given key yet * the {@code mappingFunction} is invoked to provide the mapping. * * @param key The name under which the resource was attached * @param mappingFunction The function that provides the mapping if there is no mapped resource yet * @param <R> The type of resource * @return The resource mapped to the given {@code key}, or the resource returned by the * {@code mappingFunction} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getOrComputeResource(String key, Function<? super String, R> mappingFunction) { return (R) resources().computeIfAbsent(key, mappingFunction); }
/** * Returns the resource attached under given {@code name}. If there is no resource mapped to the given key, * the {@code defaultValue} is returned. * * @param key The name under which the resource was attached * @param defaultValue The value to return if no mapping is available * @param <R> The type of resource * @return The resource mapped to the given {@code key}, or the resource returned by the * {@code mappingFunction} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getOrDefaultResource(String key, R defaultValue) { return (R) resources().getOrDefault(key, defaultValue); }
/** * Returns the resource attached under given {@code name}. If there is no resource mapped to the given key, * the {@code defaultValue} is returned. * * @param key The name under which the resource was attached * @param defaultValue The value to return if no mapping is available * @param <R> The type of resource * @return The resource mapped to the given {@code key}, or the resource returned by the * {@code mappingFunction} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getOrDefaultResource(String key, R defaultValue) { return (R) resources().getOrDefault(key, defaultValue); }
/** * Returns the resource attached under given {@code name}. If there is no resource mapped to the given key yet * the {@code mappingFunction} is invoked to provide the mapping. * * @param key The name under which the resource was attached * @param mappingFunction The function that provides the mapping if there is no mapped resource yet * @param <R> The type of resource * @return The resource mapped to the given {@code key}, or the resource returned by the * {@code mappingFunction} if no resource was found. */ @SuppressWarnings("unchecked") default <R> R getOrComputeResource(String key, Function<? super String, R> mappingFunction) { return (R) resources().computeIfAbsent(key, mappingFunction); }
/** * Initializes current unit of work with interceptor chain. * * @param interceptorChain the interceptor chain */ public static void initialize(InterceptorChain interceptorChain) { Assert.state(CurrentUnitOfWork.isStarted(), () -> "An active Unit of Work is required for injecting interceptor chain"); CurrentUnitOfWork.get().resources().put(INTERCEPTOR_CHAIN_EMITTER_KEY, interceptorChain); }
/** * Initializes current unit of work with interceptor chain. * * @param interceptorChain the interceptor chain */ public static void initialize(InterceptorChain interceptorChain) { Assert.state(CurrentUnitOfWork.isStarted(), () -> "An active Unit of Work is required for injecting interceptor chain"); CurrentUnitOfWork.get().resources().put(INTERCEPTOR_CHAIN_EMITTER_KEY, interceptorChain); }
unitOfWork.onCleanup(u -> u.resources().remove(eventsKey)); return eventQueue;
unitOfWork.onCleanup(u -> u.resources().remove(eventsKey)); return eventQueue; });
new UoWAttachedConnectionImpl(delegateConnection), new ConnectionWrapperFactory.NoOpCloseHandler()); uow.root().resources().put(CONNECTION_RESOURCE_NAME, connection); uow.onCommit(u -> { Connection cx = u.root().getResource(CONNECTION_RESOURCE_NAME);
new UoWAttachedConnectionImpl(delegateConnection), new ConnectionWrapperFactory.NoOpCloseHandler()); uow.root().resources().put(CONNECTION_RESOURCE_NAME, connection); uow.onCommit(u -> { Connection cx = u.root().getResource(CONNECTION_RESOURCE_NAME);