/** * Lazily initialize {@link AsyncContext} for this * request processing context. * <p> * The {@code lazyContextValue} will be only invoked once during the first call to {@link #asyncContext()}. * As such, the asynchronous context for this request can be initialized lazily, on demand. * </p> * * @param lazyContextValue lazily initialized {@code AsyncContext} instance bound to this request processing context. */ // TODO figure out how to make this package-private. public void initAsyncContext(Value<AsyncContext> lazyContextValue) { asyncContextValueRef.set(Values.lazy(lazyContextValue)); }
/** * Get the asynchronous context associated with this request processing context. * * May return {@code null} if no asynchronous context has been initialized in this request processing context yet. * * @return asynchronous context associated with this request processing context, or {@code null} if the * asynchronous context has not been initialized yet * (see {@link #initAsyncContext(org.glassfish.jersey.internal.util.collection.Value)}). */ public AsyncContext asyncContext() { return asyncContextValueRef.get().get(); }
/** * Get the resource name. * <p/> * If the resource was constructed from a JAX-RS annotated resource class, * the resource name will be set to the {@link Class#getName() fully-qualified name} * of the resource class. * * @return reference JAX-RS resource handler class. */ public String getName() { return name.get(); }
/** * Get a new constant {@link Value value provider} whose {@link Value#get() get()} * method always returns the instance supplied to the {@code value} parameter. * <p/> * In case the supplied value constant is {@code null}, an {@link #empty() empty} value * provider is returned. * * @param <T> value type. * @param value value instance to be provided. * @return constant value provider. */ public static <T> Value<T> of(final T value) { return (value == null) ? Values.<T>empty() : new InstanceValue<T>(value); }
/** * Creates a new {@link Set} backed by a ConcurrentHashMapV8 * from the given type to {@code Boolean.TRUE}. * * @return the new set * @since 1.8 */ public static <K> KeySetView<K, Boolean> newKeySet() { return new KeySetView<K, Boolean> (new ConcurrentHashMapV8<K, Boolean>(), Boolean.TRUE); }
/** * Get a new constant {@link UnsafeValue value provider} whose {@link UnsafeValue#get() get()} * method always returns the instance supplied to the {@code value} parameter. * <p/> * In case the supplied value constant is {@code null}, an {@link #emptyUnsafe() empty} value * provider is returned. * * @param <T> value type. * @param value value instance to be provided. * @return constant value provider. */ public static <T, E extends Throwable> UnsafeValue<T, E> unsafe(final T value) { return (value == null) ? Values.<T, E>emptyUnsafe() : new InstanceUnsafeValue<T, E>(value); }
/** * Create new type-class pair for a non-generic class. * * @param rawClass (raw) class representing the non-generic type. * * @return new non-generic type-class pair. */ public static ClassTypePair of(Class<?> rawClass) { return new ClassTypePair(rawClass, rawClass); }
/** * Get the asynchronous context associated with this request processing context. * * May return {@code null} if no asynchronous context has been initialized in this request processing context yet. * * @return asynchronous context associated with this request processing context, or {@code null} if the * asynchronous context has not been initialized yet * (see {@link #initAsyncContext(org.glassfish.jersey.internal.util.collection.Value)}). */ public AsyncContext asyncContext() { return asyncContextValueRef.get().get(); }
/** * Get a new constant {@link Value value provider} whose {@link Value#get() get()} * method always returns the instance supplied to the {@code value} parameter. * <p/> * In case the supplied value constant is {@code null}, an {@link #empty() empty} value * provider is returned. * * @param <T> value type. * @param value value instance to be provided. * @return constant value provider. */ public static <T> Value<T> of(final T value) { return (value == null) ? Values.<T>empty() : new InstanceValue<T>(value); }
/** * Creates a new {@link Set} backed by a ConcurrentHashMapV8 * from the given type to {@code Boolean.TRUE}. * * @return the new set * @since 1.8 */ public static <K> KeySetView<K, Boolean> newKeySet() { return new KeySetView<K, Boolean> (new ConcurrentHashMapV8<K, Boolean>(), Boolean.TRUE); }