Skip to content

Commit

Permalink
[2.x] Upgrades OCI to version 3.x (helidon-io#7883)
Browse files Browse the repository at this point in the history
* Upgrades OCI to version 3.x

Signed-off-by: Laird Nelson <[email protected]>
  • Loading branch information
ljnelson authored Oct 24, 2023
1 parent ce50ca2 commit dfe2ac3
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 766 deletions.
740 changes: 1 addition & 739 deletions dependencies/pom.xml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions examples/integrations/cdi/oci-objectstorage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<artifactId>oci-java-sdk-objectstorage</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,10 +44,11 @@
import com.oracle.bmc.database.model.GenerateAutonomousDatabaseWalletDetails;
import com.oracle.bmc.database.requests.GenerateAutonomousDatabaseWalletRequest;
import com.oracle.bmc.database.responses.GenerateAutonomousDatabaseWalletResponse;
import com.oracle.bmc.http.internal.ResponseHelper;
import oracle.security.pki.OraclePKIProvider;
import oracle.ucp.jdbc.PoolDataSource;
import org.eclipse.microprofile.config.inject.ConfigProperty;

import static com.oracle.bmc.http.client.Options.shouldAutoCloseResponseInputStream;
/**
* JAX-RS resource - REST API for the atp example.
*/
Expand Down Expand Up @@ -82,7 +83,7 @@ public class AtpResource {
@GET
@Path("/wallet")
public Response generateWallet() {
ResponseHelper.shouldAutoCloseResponseInputStream(false);
shouldAutoCloseResponseInputStream(false);
GenerateAutonomousDatabaseWalletResponse walletResponse =
databaseClient.generateAutonomousDatabaseWallet(
GenerateAutonomousDatabaseWalletRequest.builder()
Expand Down
28 changes: 27 additions & 1 deletion integrations/oci/sdk/cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
<scope>compile</scope>
<exclusions>
<!-- For dependency convergence. Defer to versions from jersey-apache-connector -->
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>compile</scope>
</dependency>
<!-- For dependency convergence. To make sure we use Jersey version of org.apache.httpcomponents:httpclient and httpcore -->
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
Expand Down Expand Up @@ -149,5 +175,5 @@
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -69,7 +69,7 @@
import com.oracle.bmc.Service;
import com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider;
import com.oracle.bmc.common.ClientBuilderBase;
import com.oracle.bmc.http.ClientConfigurator;
import com.oracle.bmc.http.client.jersey.ClientBuilderDecorator;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;

Expand Down Expand Up @@ -1065,7 +1065,7 @@ private static Class<?> loadClassUnresolved(String name) throws ClassNotFoundExc
private static void customizeEndpointResolution(ClientBuilderBase<?, ?> clientBuilder) {
EndpointAdjuster ea = EndpointAdjuster.of(clientBuilder.getClass().getName());
if (ea != null) {
clientBuilder.additionalClientConfigurator(ea);
clientBuilder.clientConfigurator(b -> b.property(ClientBuilderDecorator.PROPERTY, ea));
}
}

Expand Down Expand Up @@ -1321,7 +1321,7 @@ public final boolean equals(Object other) {

}

private enum EndpointAdjuster implements ClientConfigurator, ClientRequestFilter, Predicate<ClientRequestContext> {
private enum EndpointAdjuster implements ClientBuilderDecorator, ClientRequestFilter, Predicate<ClientRequestContext> {


/*
Expand Down Expand Up @@ -1432,9 +1432,10 @@ private enum EndpointAdjuster implements ClientConfigurator, ClientRequestFilter
*/


@Override // ClientConfigurator
public void customizeBuilder(ClientBuilder builder) {
@Override // ClientBuilderDecorator
public Client finish(ClientBuilder builder) {
builder.register(this, Map.of(ClientRequestFilter.class, Integer.valueOf(Priorities.AUTHENTICATION - 500)));
return builder.build();
}

@Override // Predicate<ClientRequestContext>
Expand All @@ -1459,10 +1460,6 @@ private void adjust(ClientRequestContext crc, String hostname) {
crc.setUri(UriBuilder.fromUri(crc.getUri()).host(this.adjuster.apply(hostname)).build());
}

@Override // ClientConfigurator
public void customizeClient(Client client) {
}


/*
* Static methods.
Expand Down
5 changes: 3 additions & 2 deletions integrations/oci/sdk/cdi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,6 @@
@SuppressWarnings({ "requires-automatic", "requires-transitive-automatic" })
module io.helidon.integrations.oci.sdk.cdi {

requires com.google.common; // OCI dependency
requires java.annotation;
requires java.logging;
requires java.ws.rs;
Expand All @@ -35,6 +34,8 @@
requires jakarta.interceptor.api;
requires microprofile.config.api;
requires oci.java.sdk.common;
requires oci.java.sdk.common.httpclient;
requires oci.java.sdk.common.httpclient.jersey;

exports io.helidon.integrations.oci.sdk.cdi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -190,7 +190,7 @@ private ExampleBean(// The service* parameters below are
// isn't; see the comments in the
// constructor body below. It should be
// unsatisfied.
Instance<com.oracle.bmc.circuitbreaker.JaxRsCircuitBreaker> unresolvedJaxRsCircuitBreakerInstance,
Instance<com.oracle.bmc.circuitbreaker.OciCircuitBreaker> unresolvedOciCircuitBreakerInstance,
// Streaming turns out to be the only
// convention-violating service in the
// entire portfolio, and the violation is
Expand All @@ -217,26 +217,26 @@ private ExampleBean(// The service* parameters below are
StreamClient streamingServiceClient, // oddball
StreamClientBuilder streamingServiceClientBuilder) { // oddball
super();
// unresolvedJaxRsCircuitBreakerInstance
// (Instance<com.oracle.bmc.circuitbreaker.JaxRsCircuitBreaker>)
// unresolvedOciCircuitBreakerInstance
// (Instance<com.oracle.bmc.circuitbreaker.OciCircuitBreaker>)
// is an example of something that seems like it obeys the
// OCI client service pattern. But it deviates in a
// couple ways.
//
// First, JaxRsCircuitBreaker is part of the common
// First, OciCircuitBreaker is part of the common
// runtime (see
// https://docs.oracle.com/en-us/iaas/tools/java/latest/overview-summary.html#:~:text=Oracle%20Cloud%20Infrastructure%20Common%20Runtime),
// and hence is not a service itself.
//
// Second, there are no JaxRsCircuitBreakerAsync,
// JaxRsCircuitBreakerAsyncClient,
// JaxRsCircuitBreakerAsyncClient$Builder,
// JaxRsCircuitBreakerClient or
// JaxRsCircuitBreakerClient$Builder classes.
// Second, there are no OciCircuitBreakerAsync,
// OciCircuitBreakerAsyncClient,
// OciCircuitBreakerAsyncClient$Builder,
// OciCircuitBreakerClient or
// OciCircuitBreakerClient$Builder classes.
//
// For all these reasons it should be excluded from
// processing (and is, or this test would fail).
assertTrue(unresolvedJaxRsCircuitBreakerInstance.isUnsatisfied());
assertTrue(unresolvedOciCircuitBreakerInstance.isUnsatisfied());
}

private static void customizeAsyncBuilder(@Observes AIServiceLanguageAsyncClient.Builder asyncClientBuilder) {
Expand Down

0 comments on commit dfe2ac3

Please sign in to comment.