|
| 1 | +# helidon-integrations-oci-sdk |
| 2 | + |
| 3 | +There are two different approaches for [OCI SDK](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/javasdk.htm) integration from Helidon depending upon which type of application you are developing. |
| 4 | +* **Helidon MP** (using _CDI_). For this refer to the [cdi](./cdi) module. |
| 5 | +* **Helidon SE** (not using _CDI_). For this refer to the information below. |
| 6 | + |
| 7 | + |
| 8 | +## Helidon Injection Framework and OCI SDK Integration |
| 9 | +This section only applies for **Helidon SE** type applications. If you are using **Helidon MP** then this section does not apply to you, and you should instead refer to the [cdi](./cdi) module. |
| 10 | + |
| 11 | +The **Helidon Injection Framework** offers a few different ways to integrate to 3rd party libraries. The **OCI SDK** library, however, is a little different in that a special type/style of fluent builder is needed when using the **OCI SDK**. This means that you can't simply use the _new_ operator when creating instances; you instead need to use the imperative fluent builder style. Fortunately, though, most of the **OCI SDK** follows the same pattern for accessing the API via this fluent builder style. Since the **Helidon Injection Framework** leverages compile-time DI code generation, this arrangement makes it very convenient to generate the correct underpinnings that leverages a template following this fluent builder style. |
| 12 | + |
| 13 | +The net of all of this is that there are two modules that you will need to integrate DI into your **Helidon SE** application. |
| 14 | + |
| 15 | +1. The [processor](./processor) module is required to be on your compiler / APT classpath. It will observe cases where you are _@Inject_ services from the **OCI SDK** and then code-generate the appropriate [Activator](../api/src/main/java/io/helidon/pico/api/Activator.java)s for those injected services. Remember, the _processor_ module only needs APT classpath during compilation - it is not needed at runtime. |
| 16 | + |
| 17 | +2. The [runtime](./runtime) module is required to be on your runtime classpath. This module supplies the default implementation for OCI authentication providers, and OCI extensibility into Helidon. |
| 18 | + |
| 19 | + |
| 20 | +### MP Modules |
| 21 | +* [cdi](./cdi) - required to be added as a normal dependency in your final application. |
| 22 | + |
| 23 | + |
| 24 | +### Non-MP Modules |
| 25 | +* [processor](./processor) - required to be in the APT classpath. |
| 26 | +* [runtime](./runtime) - required to be added as a normal dependency in your final application. |
| 27 | +* [tests](./tests) - tests for OCI SDK integration. |
| 28 | + |
| 29 | + |
| 30 | +### Usage |
| 31 | + |
| 32 | +In your pom.xml, add this plugin to be run as part of the compilation phase: |
| 33 | +```pom.xml |
| 34 | + <plugin> |
| 35 | + <groupId>org.apache.maven.plugins</groupId> |
| 36 | + <artifactId>maven-compiler-plugin</artifactId> |
| 37 | + <configuration> |
| 38 | + <forceJavacCompilerUse>true</forceJavacCompilerUse> |
| 39 | + <annotationProcessorPaths> |
| 40 | + <path> |
| 41 | + <groupId>io.helidon.integrations.oci.sdk</groupId> |
| 42 | + <artifactId>helidon-integrations-oci-sdk-processor</artifactId> |
| 43 | + <version>${helidon.version}</version> |
| 44 | + </path> |
| 45 | + </annotationProcessorPaths> |
| 46 | + </configuration> |
| 47 | + </plugin> |
| 48 | +``` |
| 49 | + |
| 50 | +Add the runtime dependency to your pom.xml, along with any other OCI SDK library that is required by your application: |
| 51 | +```pom.xml |
| 52 | + <dependency> |
| 53 | + <groupId>io.helidon.integrations.oci.sdk</groupId> |
| 54 | + <artifactId>helidon-integrations-oci-sdk-runtime</artifactId> |
| 55 | + </dependency> |
| 56 | + |
| 57 | + ... |
| 58 | + <!-- arbitrarily selected OCI libraries - use the libraries appropriate for your application --> |
| 59 | + <dependency> |
| 60 | + <groupId>com.oracle.oci.sdk</groupId> |
| 61 | + <artifactId>oci-java-sdk-ailanguage</artifactId> |
| 62 | + </dependency> |
| 63 | + <dependency> |
| 64 | + <groupId>com.oracle.oci.sdk</groupId> |
| 65 | + <artifactId>oci-java-sdk-objectstorage</artifactId> |
| 66 | + </dependency> |
| 67 | +``` |
| 68 | + |
| 69 | +Note that if you are using JPMS (i.e., _module-info.java_), then you will also need to be sure to export the _io.helidon.integrations.generated_ derivative package names from your module(s). |
| 70 | + |
| 71 | +### How it works |
| 72 | +See the [InjectionProcessorObserverForOci javadoc](processor/src/main/java/io/helidon/integrations/oci/sdk/processor/InjectionProcessorObserverForOCI.java) for a description. In summary, this processor will observe **OCI SDK** injection points and then code generate **Activators** enabling injection of SDK services in conjuction with the [runtime](./runtime) module on the classpath. |
0 commit comments