Skip to content

Commit

Permalink
Amazon Services - Unwrap Instance when inspecting injection points
Browse files Browse the repository at this point in the history
Fixes quarkusio#15213

(cherry picked from commit 34d8f4b)
  • Loading branch information
gsmet committed Jun 21, 2021
1 parent 7b3cf24 commit 216ed51
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.enterprise.context.ApplicationScoped;

import org.jboss.jandex.DotName;
import org.jboss.jandex.ParameterizedType;
import org.jboss.jandex.Type;

import io.quarkus.amazon.common.runtime.AmazonClientApacheTransportRecorder;
Expand All @@ -22,6 +23,7 @@
import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.processor.BuildExtension;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.arc.processor.InjectionPointInfo;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildProducer;
Expand Down Expand Up @@ -61,12 +63,12 @@ protected void setupExtension(BeanRegistrationPhaseBuildItem beanRegistrationPha

//Discover all clients injections in order to determine if async or sync client is required
for (InjectionPointInfo injectionPoint : beanRegistrationPhase.getContext().get(BuildExtension.Key.INJECTION_POINTS)) {
Type requiredType = injectionPoint.getRequiredType();
Type injectedType = getInjectedType(injectionPoint);

if (syncClientName().equals(requiredType.name())) {
if (syncClientName().equals(injectedType.name())) {
syncClassName = Optional.of(syncClientName());
}
if (asyncClientName().equals(requiredType.name())) {
if (asyncClientName().equals(injectedType.name())) {
asyncClassName = Optional.of(asyncClientName());
}
}
Expand Down Expand Up @@ -203,4 +205,15 @@ protected void createClientBuilders(
.done());
}
}

private Type getInjectedType(InjectionPointInfo injectionPoint) {
Type requiredType = injectionPoint.getRequiredType();
Type injectedType = requiredType;

if (DotNames.INSTANCE.equals(requiredType.name()) && requiredType instanceof ParameterizedType) {
injectedType = requiredType.asParameterizedType().arguments().get(0);
}

return injectedType;
}
}

0 comments on commit 216ed51

Please sign in to comment.