= Helidon Jedis CDI Integration

The Helidon Jedis CDI Integration project supplies a
http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#spi[CDI portable
extension] that lets the end user inject various
https://github.com/xetorthio/jedis#jedis[Jedis] objects into her
CDI-based application.

== Installation

Ensure that the Helidon Jedis CDI Integration project and its runtime
dependencies are present on your application's runtime classpath.

For Maven users, your `<dependency>` stanza should look like this:

[source,xml]
----
<dependency>
  <groupId>io.helidon.integrations.cdi</groupId>
  <artifactId>helidon-integrations-cdi-jedis</artifactId>
  <version>1.0.0</version>
  <scope>runtime</scope>
</dependency>
----

== Usage

If you want to use a
https://static.javadoc.io/redis.clients/jedis/2.9.0/redis/clients/jedis/JedisPool.html[`JedisPool`]
named `orders` in your application code, simply inject it in the
http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#injection_and_resolution[usual,
idiomatic CDI way].  Here is a field injection example:

[source,java]
----
@Inject
@Named("orders")
private JedisPool ordersPool;
----

And here is a constructor injection example:

[source,java]
----
private final JedisPool ordersPool;

@Inject
public YourConstructor(@Named("orders") JedisPool pool) {
  super();
  this.ordersPool = pool;
}
----

The Helidon Jedis CDI Integration project will satisfy this injection
point with a
https://static.javadoc.io/redis.clients/jedis/2.9.0/redis/clients/jedis/JedisPool.html[`JedisPool`]
in
http://docs.jboss.org/cdi/api/2.0/javax/enterprise/context/ApplicationScoped.html[application
scope].

To create it, the Helidon Jedis CDI Integration project will use
https://static.javadoc.io/org.eclipse.microprofile.config/microprofile-config-api/1.3/index.html?overview-summary.html[MicroProfile
Config] to locate its configuration.
https://static.javadoc.io/org.eclipse.microprofile.config/microprofile-config-api/1.3/org/eclipse/microprofile/config/Config.html#getPropertyNames--[Property
names] that start with `redis.clients.jedis.JedisPool.`_dataSourceName_`.` will
be parsed, and the remaining portion of each such name will be treated
as a Java bean property of `JedisPool`.

So, for example, a System property with a name like this:

----
redis.clients.jedis.JedisPool.orders.port
----

...set to a value of:

----
6379
----

...together with other similarly-named properties will result
ultimately in a `JedisPool` object injectable under the name `orders`
with a `port` property set to `6379` like so:

[source,java]
----
@Inject
@Named("orders")
private JedisPool pool;
----
