Skip to content

Commit

Permalink
[JBTM-3381] Enhance Quarkus compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: ruromero <rromerom@redhat.com>
  • Loading branch information
ruromero committed Oct 30, 2020
1 parent b3e22db commit 50f97bb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 60 deletions.
28 changes: 0 additions & 28 deletions rts/lra/client/pom.xml
Expand Up @@ -39,34 +39,6 @@
<artifactId>jboss-json-api_1.0_spec</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${version.jackson}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>${version.cdi-api}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-binding-provider</artifactId>
<version>${version.org.jboss.resteasy}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${version.commons-io}</version>
</dependency>
</dependencies>

<profiles>
Expand Down
Expand Up @@ -106,13 +106,13 @@ public class NarayanaLRAClient implements Closeable {
* Key for looking up the config property that specifies which port a
* coordinator is running on
*/
public static String LRA_COORDINATOR_PORT_KEY = "lra.http.port";
public static final String LRA_COORDINATOR_PORT_KEY = "lra.http.port";

/**
* Key for looking up the config property that specifies which JAX-RS path a
* coordinator is running on
*/
public static String LRA_COORDINATOR_PATH_KEY = "lra.coordinator.path";
public static final String LRA_COORDINATOR_PATH_KEY = "lra.coordinator.path";

public static final long DEFAULT_TIMEOUT_MILLIS = 0L;

Expand Down Expand Up @@ -179,7 +179,7 @@ public NarayanaLRAClient(String scheme, String host, int port) throws URISyntaxE
*
* @param coordinatorUri uri of the lra coordinator
*/
public NarayanaLRAClient(URI coordinatorUri) throws MalformedURLException, URISyntaxException {
public NarayanaLRAClient(URI coordinatorUri) {
init(coordinatorUri);
}

Expand Down Expand Up @@ -305,7 +305,7 @@ public URI startLRA(URI parentLRA, String clientID, Long timeout, ChronoUnit uni

response = client.target(base)
.path(START_PATH)
.queryParam(CLIENT_ID_PARAM_NAME, client)
.queryParam(CLIENT_ID_PARAM_NAME, clientID)
.queryParam(TIMELIMIT_PARAM_NAME, Duration.of(timeout, unit).toMillis())
.queryParam(PARENT_LRA_PARAM_NAME, encodedParentLRA)
.request()
Expand All @@ -320,13 +320,6 @@ public URI startLRA(URI parentLRA, String clientID, Long timeout, ChronoUnit uni
}

lra = URI.create(response.getHeaderString(HttpHeaders.LOCATION));

if (lra == null) {
LRALogger.i18NLogger.error_nullLraOnCreation(response.toString());
throwGenericLRAException(null, INTERNAL_SERVER_ERROR.getStatusCode(), "LRA creation is null");
return null;
}

lraTrace(lra, "startLRA returned");

Current.push(lra);
Expand Down Expand Up @@ -367,7 +360,7 @@ public void closeLRA(URI lraId) throws WebApplicationException {

/**
* @param lraId the URI of the LRA to join
* @param timelimit how long the participant is prepared to wait for LRA completion
* @param timeLimit how long the participant is prepared to wait for LRA completion
* @param compensateUri URI for compensation notifications
* @param completeUri URI for completion notifications
* @param forgetUri URI for forget callback
Expand All @@ -377,18 +370,18 @@ public void closeLRA(URI lraId) throws WebApplicationException {
* @return a recovery URL for this enlistment
* @throws WebApplicationException if the LRA coordinator failed to enlist the participant
*/
public URI joinLRA(URI lraId, Long timelimit,
public URI joinLRA(URI lraId, Long timeLimit,
URI compensateUri, URI completeUri, URI forgetUri, URI leaveUri, URI afterUri, URI statusUri,
String compensatorData) throws WebApplicationException {
return enlistCompensator(lraId, timelimit, "",
return enlistCompensator(lraId, timeLimit, "",
compensateUri, completeUri,
forgetUri, leaveUri, afterUri, statusUri,
compensatorData);
}

public void leaveLRA(URI lraId, String body) throws WebApplicationException {
Client client = null;
Response response = null;
Response response;

try {
client = getClient();
Expand Down Expand Up @@ -496,7 +489,7 @@ public static boolean isAsyncCompletion(Method method) {
if (method.isAnnotationPresent(Complete.class) || method.isAnnotationPresent(Compensate.class)) {
for (Annotation[] ann : method.getParameterAnnotations()) {
for (Annotation an : ann) {
if (Suspended.class.getName().equals(an.annotationType().getName())) {
if (Suspended.class.isAssignableFrom(an.annotationType())) {
LRALogger.logger.warn("JAX-RS @Suspended annotation is untested");
return true;
}
Expand Down Expand Up @@ -548,7 +541,7 @@ private static int checkMethod(Map<String, String> paths,

public LRAStatus getStatus(URI uri) throws WebApplicationException {
Client client = null;
Response response = null;
Response response;
URL lraId;

try {
Expand Down Expand Up @@ -641,7 +634,7 @@ private static StringBuilder makeLink(StringBuilder b, String uriPrefix, String
return b.append(link);
}

private URI enlistCompensator(URI lraUri, long timelimit, String uriPrefix,
private URI enlistCompensator(URI lraUri, Long timelimit, String uriPrefix,
URI compensateUri, URI completeUri,
URI forgetUri, URI leaveUri, URI afterUri, URI statusUri,
String compensatorData) {
Expand Down Expand Up @@ -670,7 +663,7 @@ private URI enlistCompensator(URI lraUri, long timelimit, String uriPrefix,
return enlistCompensator(lraUri, timelimit, linkHeaderValue.toString(), compensatorData);
}

private URI enlistCompensator(URI uri, long timelimit, String linkHeader, String compensatorData) {
private URI enlistCompensator(URI uri, Long timelimit, String linkHeader, String compensatorData) {
// register with the coordinator
// put the lra id in an http header
Client client = null;
Expand All @@ -687,7 +680,7 @@ private URI enlistCompensator(URI uri, long timelimit, String linkHeader, String
);
return null;
}
if (timelimit < 0) {
if (timelimit == null || timelimit < 0) {
timelimit = 0L;
}

Expand Down
@@ -1 +1 @@
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
org.jboss.resteasy.microprofile.client.impl.MpClientBuilderImpl
@@ -1 +1 @@
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
org.jboss.resteasy.microprofile.client.impl.MpClientBuilderImpl
6 changes: 0 additions & 6 deletions rts/lra/service-base/pom.xml
Expand Up @@ -19,12 +19,6 @@
<version>${version.microprofile.lra.api}</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${version.apache.httpclient}</version>
</dependency>

<!-- jboss logging -->
<dependency>
<groupId>org.jboss.logging</groupId>
Expand Down
Expand Up @@ -58,10 +58,6 @@ public interface lraI18NLogger {
@Message(id = 25002, value = "LRA created with an unexpected status code: %d, coordinator response '%s'")
void error_lraCreationUnexpectedStatus(int status, String response);

@LogMessage(level = ERROR)
@Message(id = 25003, value = "LRA is null on creation, coordinator response '%s'")
void error_nullLraOnCreation(String response);

@LogMessage(level = ERROR)
@Message(id = 25004, value = "Cannot create URL from coordinator response '%s'")
void error_cannotCreateUrlFromLCoordinatorResponse(String response, @Cause Throwable t);
Expand Down

0 comments on commit 50f97bb

Please sign in to comment.