///////////////////////////////////////////////////////////////////////////////

    Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= CDI extension for OCI Object storage
:description: Helidon CDI extension for HikariCP
:keywords: helidon, java, microservices, microprofile, extensions, cdi, oci, object storage
:cdi-extension-api-url: https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#spi
:oci-objstore-url: https://docs.cloud.oracle.com/iaas/Content/Object/Concepts/objectstorageoverview.htm
:oci-javasdk-url: https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/javasdk.htm

This link:{cdi-extension-api-url}[CDI portable extension] provides support for
 injecting an link:{oci-objstore-url}[Oracle Cloud Infrastructure Object Storage client]
 in your Helidon MicroProfile applications.

== Prerequisites

To install the extension for Oracle Cloud Infrastructure Object Storage clients,
 you must first clone and install the Oracle Cloud Infrastructure Java SDK because
 it is not available, currently, in Maven Central.

Clone the SDK:

[source,bash]
----
git clone --depth 1 --branch v1.2.44 https://github.com/oracle/oci-java-sdk.git
----

Install the SDK:

[source,bash]
----
cd oci-java-sdk && mvn -B -U -f oci-java-sdk/pom.xml \
        -Dmaven.test.skip=true \
        -Dmaven.source.skip=true \
        -Dmaven.javadoc.skip=true \
        -Dlombok.delombok.skip=true \
        -pl bmc-objectstorage \
        -am \
        install
----

Declare the following dependency in your project:

[source,xml]
----
<dependency>
     <groupId>io.helidon.integrations.cdi</groupId>
     <artifactId>helidon-integrations-cdi-oci-objectstorage</artifactId>
</dependency>
----

== Injecting an Object Storage client

[source,java]
.Field-injection example
----
 @Inject
 private ObjectStorage client;
----

[source,java]
.Constructor-injection example
----
 private final ObjectStorage client;
 @Inject
 public YourConstructor(@Named("orders") ObjectStorage client) {
   super();
   this.client = client;
 }
----

The extension implements this injection point by creating an Object Storage client
 object in the link:{cdi-applicationscoped-api-url}[application scope].

You can configure the object using
 <<microprofile/02_server-configuration.adoc, MicroProfile config>>. For example,
 the Object Storage client created above can be configured as follows:

[source, properties]
.META-INF/microprofile-config.properties
----
oci.auth.fingerprint=
oci.auth.keyFile=
oci.auth.passphraseCharacters=
oci.auth.user=
oci.auth.tenancy=
oci.objectstorage.region=
oci.objectstorage.namespace=
----

These properties are described in the
 link:{oci-javasdk-url}[Oracle Cloud Infrastructure Object Storage Java SDK documentation].
