Skip to content

Commit

Permalink
Merge pull request #687 from smahieu87/feature/jakarta
Browse files Browse the repository at this point in the history
jakarta upgrade
  • Loading branch information
aaron-kumar authored Nov 16, 2024
2 parents dcd7f26 + 1f56170 commit 56a3896
Show file tree
Hide file tree
Showing 111 changed files with 869 additions and 824 deletions.
14 changes: 9 additions & 5 deletions oxalis-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@
<artifactId>peppol-common</artifactId>
</dependency>

<!-- Zipkin -->
<!-- Tracing -->
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-api</artifactId>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>

<!-- Testing -->
Expand All @@ -90,8 +94,8 @@

<!-- DI -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package network.oxalis.api.inject;

import javax.inject.Named;
import jakarta.inject.Named;
import java.lang.annotation.Annotation;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package network.oxalis.api.lookup;

import io.opentracing.Span;
import network.oxalis.api.lang.OxalisTransmissionException;
import network.oxalis.vefa.peppol.common.model.Endpoint;
import network.oxalis.vefa.peppol.common.model.Header;
Expand All @@ -45,15 +44,4 @@ public interface LookupService {
*/
Endpoint lookup(Header header) throws OxalisTransmissionException;

/**
* Performs lookup using metadata from content to be sent.
*
* @param header Metadata from content.
* @param root Current trace.
* @return Endpoint information to be used when transmitting content.
* @throws OxalisTransmissionException Thrown if no endpoint metadata were detected using metadata.
*/
default Endpoint lookup(Header header, Span root) throws OxalisTransmissionException {
return lookup(header);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package network.oxalis.api.outbound;

import io.opentracing.Span;
import network.oxalis.api.lang.OxalisTransmissionException;

/**
Expand All @@ -45,18 +44,4 @@ public interface MessageSender {
*/
TransmissionResponse send(TransmissionRequest transmissionRequest) throws OxalisTransmissionException;

/**
* Protocol specific transmission of transmission requested. (With tracing.)
*
* @param transmissionRequest Requested transmission to take place.
* @param root Current trace.
* @return Response content of a successful transmission.
* @throws OxalisTransmissionException Thrown when transmission was not sent according to protocol specific rules or
* because something went wrong during transmission.
*/
default TransmissionResponse send(TransmissionRequest transmissionRequest, Span root)
throws OxalisTransmissionException {
return send(transmissionRequest);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

package network.oxalis.api.outbound;

import io.opentracing.Span;
import network.oxalis.api.lang.OxalisTransmissionException;
import network.oxalis.api.lang.OxalisContentException;
import network.oxalis.api.lang.OxalisTransmissionException;
import network.oxalis.api.tag.Tag;

import java.io.IOException;
Expand Down Expand Up @@ -79,33 +78,5 @@ default TransmissionResponse send(InputStream inputStream)
TransmissionResponse send(InputStream inputStream, Tag tag)
throws IOException, OxalisTransmissionException, OxalisContentException;

/**
* Sends content found in the InputStream.
*
* @param inputStream InputStream containing content to be sent.
* @param root Current trace.
* @return Transmission response containing information from the performed transmission.
* @throws IOException Thrown on any IO exception.
* @throws OxalisTransmissionException Thrown if there were any problems making Oxalis unable to send the content.
*/
default TransmissionResponse send(InputStream inputStream, Span root)
throws IOException, OxalisTransmissionException, OxalisContentException {
return send(inputStream, Tag.NONE);
}

/**
* Sends content found in the InputStream.
*
* @param inputStream InputStream containing content to be sent.
* @param tag Tag defined by client.
* @param root Current trace.
* @return Transmission response containing information from the performed transmission.
* @throws IOException Thrown on any IO exception.
* @throws OxalisTransmissionException Thrown if there were any problems making Oxalis unable to send the content.
*/
default TransmissionResponse send(InputStream inputStream, Tag tag, Span root)
throws IOException, OxalisTransmissionException, OxalisContentException {
return send(inputStream, tag);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package network.oxalis.api.outbound;

import io.opentracing.Span;
import network.oxalis.api.lang.OxalisTransmissionException;

/**
Expand All @@ -47,16 +46,4 @@ public interface Transmitter {
*/
TransmissionResponse transmit(TransmissionMessage transmissionMessage) throws OxalisTransmissionException;

/**
* Transmit content of transmission request. (With tracing.)
*
* @param transmissionMessage Content to be transmitted.
* @param root Current trace.
* @return Result of transmission.
* @throws OxalisTransmissionException Thrown when transmission fails.
*/
default TransmissionResponse transmit(TransmissionMessage transmissionMessage, Span root)
throws OxalisTransmissionException {
return transmit(transmissionMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import network.oxalis.api.inject.NamedImpl;

import javax.inject.Named;
import jakarta.inject.Named;
import java.nio.file.Path;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@

package network.oxalis.api.statistics;

import io.opentracing.Span;
import network.oxalis.api.inbound.InboundMetadata;
import network.oxalis.api.outbound.TransmissionRequest;
import network.oxalis.api.outbound.TransmissionResponse;
import network.oxalis.api.inbound.InboundMetadata;

/**
* @author erlend
* @since 4.0.0
*/
public interface StatisticsService {

void persist(TransmissionRequest transmissionRequest, TransmissionResponse transmissionResponse, Span root);
void persist(TransmissionRequest transmissionRequest, TransmissionResponse transmissionResponse);

void persist(InboundMetadata inboundMetadata);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package network.oxalis.api.timestamp;

import io.opentracing.Span;
import network.oxalis.api.lang.TimestampException;
import network.oxalis.api.model.Direction;

Expand All @@ -35,7 +34,4 @@ public interface TimestampProvider {

Timestamp generate(byte[] content, Direction direction) throws TimestampException;

default Timestamp generate(byte[] content, Direction direction, Span span) throws TimestampException {
return generate(content, direction);
}
}
2 changes: 1 addition & 1 deletion oxalis-api/src/main/java/network/oxalis/api/util/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.lang.annotation.Target;

/**
* This annotation works as a replacement of {@link javax.inject.Named} to allow for multiple
* This annotation works as a replacement of {@link jakarta.inject.Named} to allow for multiple
* names for a given implementation. Used in combination with OxalisModule.
*
* @author erlend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.testng.Assert;
import org.testng.annotations.Test;

import javax.inject.Named;
import jakarta.inject.Named;

/**
* @author erlend
Expand Down
38 changes: 14 additions & 24 deletions oxalis-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
</organization>

<dependencies>

<!-- Oxalis -->
<dependency>
<groupId>network.oxalis</groupId>
Expand All @@ -61,6 +60,13 @@
<scope>test</scope>
</dependency>

<!-- Servlet -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -96,36 +102,20 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<!-- Zipkin -->
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-sender-urlconnection</artifactId>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-apache-httpclient-4.3</artifactId>
</dependency>


<!-- OpenTracing -->
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-noop</artifactId>
</dependency>
<!-- Tracing -->
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-apache-httpclient</artifactId>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spanmanager</artifactId>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.brave</groupId>
<artifactId>brave-opentracing</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import network.oxalis.api.model.Direction;
import network.oxalis.api.util.Type;

import javax.inject.Singleton;
import jakarta.inject.Singleton;
import java.util.UUID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import network.oxalis.api.model.Direction;
import network.oxalis.api.util.Type;

import javax.inject.Singleton;
import jakarta.inject.Singleton;
import java.util.UUID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import network.oxalis.api.model.Direction;
import network.oxalis.api.util.Type;

import javax.inject.Singleton;
import jakarta.inject.Singleton;
import java.util.UUID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class OxalisModule extends AbstractModule {

/**
* Binds an implementation to an interface using the {@link Type} annotation as replacement
* for {@link javax.inject.Named}.
* for {@link jakarta.inject.Named}.
*
* @param cls Interface used for binding.
* @param impl Implementation with {@link Type} annotation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import com.google.inject.Provides;
import com.google.inject.Singleton;
import io.opentracing.Tracer;
import io.opentracing.contrib.apache.http.client.TracingHttpClientBuilder;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetry;
import network.oxalis.api.settings.Settings;
import network.oxalis.commons.guice.OxalisModule;
import network.oxalis.commons.util.OxalisVersion;
Expand Down Expand Up @@ -72,8 +72,10 @@ protected RequestConfig getRequestConfig(Settings<HttpConf> settings) {

@Provides
protected CloseableHttpClient getHttpClient(PoolingHttpClientConnectionManager connectionManager,
RequestConfig requestConfig, Tracer tracer) {
HttpClientBuilder httpClientBuilder = new TracingHttpClientBuilder().withTracer(tracer);
RequestConfig requestConfig, OpenTelemetry openTelemetry) {
HttpClientBuilder httpClientBuilder = ApacheHttpClientTelemetry.builder(openTelemetry)
.build()
.newHttpClientBuilder();

httpClientBuilder.setUserAgent(USER_AGENT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import network.oxalis.vefa.peppol.security.api.CertificateValidator;
import org.apache.http.client.config.RequestConfig;

import javax.inject.Named;
import jakarta.inject.Named;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.typesafe.config.Config;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.contrib.spanmanager.DefaultSpanManager;
import network.oxalis.pkix.ocsp.api.OcspFetcher;
import network.oxalis.commons.certvalidator.api.CrlFetcher;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import network.oxalis.api.lang.OxalisLoadingException;
import network.oxalis.commons.certvalidator.api.CrlFetcher;
import network.oxalis.pkix.ocsp.api.OcspFetcher;
import network.oxalis.vefa.peppol.common.lang.PeppolLoadingException;
import network.oxalis.vefa.peppol.mode.Mode;
import network.oxalis.vefa.peppol.security.ModeDetector;
Expand Down Expand Up @@ -65,8 +64,7 @@ public class ModeProvider implements Provider<Mode> {

@Override
public Mode get() {
Span span = tracer.buildSpan("Mode detection").start();
DefaultSpanManager.getInstance().activate(span);
Span span = tracer.spanBuilder("Mode detection").startSpan();
try {
Map<String, Object> objectStorage = new HashMap<>();
objectStorage.put("ocsp_fetcher", ocspFetcher);
Expand All @@ -76,7 +74,7 @@ public Mode get() {
} catch (PeppolLoadingException e) {
throw new OxalisLoadingException("Unable to detect mode.", e);
} finally {
span.finish();
span.end();
}
}
}
Loading

0 comments on commit 56a3896

Please sign in to comment.