/** * 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); }
/** * 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); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Create new request processing context. * * @param injectionManager injection manager / injector. * @param request container request. * @param routingContext routing context. * @param monitoringEventBuilder request monitoring event builder. * @param monitoringEventListener registered request monitoring event listener. */ public RequestProcessingContext( final InjectionManager injectionManager, final ContainerRequest request, final UriRoutingContext routingContext, final RequestEventBuilder monitoringEventBuilder, final RequestEventListener monitoringEventListener) { this.injectionManager = injectionManager; this.request = request; this.routingContext = routingContext; this.respondingContext = new DefaultRespondingContext(); this.closeableService = new DefaultCloseableService(); this.monitoringEventBuilder = monitoringEventBuilder; this.monitoringEventListener = monitoringEventListener; this.asyncContextValueRef = Refs.threadSafe(Values.<AsyncContext>empty()); }
/** * Create new request processing context. * * @param injectionManager injection manager / injector. * @param request container request. * @param routingContext routing context. * @param monitoringEventBuilder request monitoring event builder. * @param monitoringEventListener registered request monitoring event listener. */ public RequestProcessingContext( final InjectionManager injectionManager, final ContainerRequest request, final UriRoutingContext routingContext, final RequestEventBuilder monitoringEventBuilder, final RequestEventListener monitoringEventListener) { this.injectionManager = injectionManager; this.request = request; this.routingContext = routingContext; this.respondingContext = new DefaultRespondingContext(); this.closeableService = new DefaultCloseableService(); this.monitoringEventBuilder = monitoringEventBuilder; this.monitoringEventListener = monitoringEventListener; this.asyncContextValueRef = Refs.threadSafe(Values.<AsyncContext>empty()); }
/** * Create an instance of this processor with injected {@link javax.ws.rs.core.Configuration config} and * (optional) {@link javax.servlet.ServletContext servlet context}. * * @param config config to configure this processor from. * @param injectionManager injection manager. */ @Inject public FreemarkerViewProcessor(javax.ws.rs.core.Configuration config, InjectionManager injectionManager) { super(config, injectionManager.getInstance(ServletContext.class), "freemarker", "ftl"); this.factory = getTemplateObjectFactory(injectionManager::createAndInitialize, FreemarkerConfigurationFactory.class, () -> { Configuration configuration = getTemplateObjectFactory(injectionManager::createAndInitialize, Configuration.class, Values.empty()); if (configuration == null) { return new FreemarkerDefaultConfigurationFactory(injectionManager.getInstance(ServletContext.class)); } else { return new FreemarkerSuppliedConfigurationFactory(configuration); } }); }
/** * Create new request processing context. * * @param injectionManager injection manager / injector. * @param request container request. * @param routingContext routing context. * @param monitoringEventBuilder request monitoring event builder. * @param monitoringEventListener registered request monitoring event listener. */ public RequestProcessingContext( final InjectionManager injectionManager, final ContainerRequest request, final UriRoutingContext routingContext, final RequestEventBuilder monitoringEventBuilder, final RequestEventListener monitoringEventListener) { this.injectionManager = injectionManager; this.request = request; this.routingContext = routingContext; this.respondingContext = new DefaultRespondingContext(); this.closeableService = new DefaultCloseableService(); this.monitoringEventBuilder = monitoringEventBuilder; this.monitoringEventListener = monitoringEventListener; this.asyncContextValueRef = Refs.threadSafe(Values.<AsyncContext>empty()); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Get a new eagerly initialized {@link Value value provider}. * <p/> * The value returned by its {@link Value#get() get()} method is eagerly computed from the supplied * {@code delegate} value provider and is then stored in a final field for a subsequent retrieval. * <p> * The implementation of the returned eager value provider is thread-safe and is guaranteed to * invoke the {@code get()} method on the supplied {@code delegate} value provider instance once * and only once. * </p> * <p> * If the supplied value provider is {@code null}, an {@link #empty() empty} value * provider is returned. * </p> * * @param <T> value type. * @param delegate value provider delegate that will be used to eagerly initialize the value provider. * @return eagerly initialized, constant value provider. */ public static <T> Value<T> eager(final Value<T> delegate) { return (delegate == null) ? Values.<T>empty() : new EagerValue<T>(delegate); }
/** * Create new request processing context. * * @param serviceLocator service locator / injector. * @param request container request. * @param routingContext routing context. * @param monitoringEventBuilder request monitoring event builder. * @param monitoringEventListener registered request monitoring event listener. */ public RequestProcessingContext( final ServiceLocator serviceLocator, final ContainerRequest request, final UriRoutingContext routingContext, final RequestEventBuilder monitoringEventBuilder, final RequestEventListener monitoringEventListener) { this.serviceLocator = serviceLocator; this.request = request; this.routingContext = routingContext; this.respondingContext = new DefaultRespondingContext(); this.closeableService = new DefaultCloseableService(); this.monitoringEventBuilder = monitoringEventBuilder; this.monitoringEventListener = monitoringEventListener; this.asyncContextValueRef = Refs.threadSafe(Values.<AsyncContext>empty()); }
/** * Create an instance of this processor with injected {@link javax.ws.rs.core.Configuration config} and * (optional) {@link javax.servlet.ServletContext servlet context}. * * @param config config to configure this processor from. * @param injectionManager injection manager. */ @Inject public FreemarkerViewProcessor(javax.ws.rs.core.Configuration config, InjectionManager injectionManager) { super(config, injectionManager.getInstance(ServletContext.class), "freemarker", "ftl"); this.factory = getTemplateObjectFactory(injectionManager::createAndInitialize, FreemarkerConfigurationFactory.class, () -> { Configuration configuration = getTemplateObjectFactory(injectionManager::createAndInitialize, Configuration.class, Values.empty()); if (configuration == null) { return new FreemarkerDefaultConfigurationFactory(injectionManager.getInstance(ServletContext.class)); } else { return new FreemarkerSuppliedConfigurationFactory(configuration); } }); }