Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
puts all the providers registered by the @RegisterProvider annotation in a
* map using the {@link AnnotationRegisteredProviders#addProviders(String, Map)} method
*
registers all the provider implementations annotated with @Provider using
* {@link AnnotationRegisteredProviders#addGlobalProvider(Class, int)}
*
*
*
* @param indexBuildItem index
* @param generatedBeans build producer for generated beans
*/
@BuildStep
void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem,
List registerProviderAnnotationInstances,
List annotationsToRegisterIntoClientContext,
BuildProducer generatedBeans,
BuildProducer generatedClasses,
BuildProducer unremovableBeans,
BuildProducer reflectiveClasses,
RestClientReactiveConfig clientConfig) {
String annotationRegisteredProvidersImpl = AnnotationRegisteredProviders.class.getName() + "Implementation";
IndexView index = indexBuildItem.getIndex();
Map> annotationsByClassName = new HashMap<>();
for (RegisterProviderAnnotationInstanceBuildItem bi : registerProviderAnnotationInstances) {
annotationsByClassName.computeIfAbsent(bi.getTargetClass(), key -> new ArrayList<>())
.add(bi.getAnnotationInstance());
}
try (ClassCreator classCreator = ClassCreator.builder()
.className(annotationRegisteredProvidersImpl)
.classOutput(new GeneratedBeanGizmoAdaptor(generatedBeans))
.superClass(AnnotationRegisteredProviders.class)
.build()) {
classCreator.addAnnotation(Singleton.class.getName());
MethodCreator constructor = classCreator
.getMethodCreator(MethodDescriptor.ofConstructor(annotationRegisteredProvidersImpl));
constructor.invokeSpecialMethod(MethodDescriptor.ofConstructor(AnnotationRegisteredProviders.class),
constructor.getThis());
if (clientConfig.providerAutodiscovery) {
for (AnnotationInstance instance : index.getAnnotations(ResteasyReactiveDotNames.PROVIDER)) {
ClassInfo providerClass = instance.target().asClass();
// ignore providers annotated with `@ConstrainedTo(SERVER)`
AnnotationInstance constrainedToInstance = providerClass
.declaredAnnotation(ResteasyReactiveDotNames.CONSTRAINED_TO);
if (constrainedToInstance != null) {
if (RuntimeType.valueOf(constrainedToInstance.value().asEnum()) == RuntimeType.SERVER) {
continue;
}
}
if (skipAutoDiscoveredProvider(providerClass.interfaceNames())) {
continue;
}
DotName providerDotName = providerClass.name();
int priority = getAnnotatedPriority(index, providerDotName.toString(), Priorities.USER);
constructor.invokeVirtualMethod(
MethodDescriptor.ofMethod(AnnotationRegisteredProviders.class, "addGlobalProvider",
void.class, Class.class,
int.class),
constructor.getThis(), constructor.loadClassFromTCCL(providerDotName.toString()),
constructor.load(priority));
}
}
MultivaluedMap generatedProviders = new QuarkusMultivaluedHashMap<>();
populateClientExceptionMapperFromAnnotations(generatedClasses, reflectiveClasses, index)
.forEach(generatedProviders::add);
populateClientRedirectHandlerFromAnnotations(generatedClasses, reflectiveClasses, index)
.forEach(generatedProviders::add);
for (AnnotationToRegisterIntoClientContextBuildItem annotation : annotationsToRegisterIntoClientContext) {
populateClientProviderFromAnnotations(annotation, generatedClasses, reflectiveClasses, index)
.forEach(generatedProviders::add);
}
addGeneratedProviders(index, constructor, annotationsByClassName, generatedProviders);
constructor.returnValue(null);
}
unremovableBeans.produce(UnremovableBeanBuildItem.beanClassNames(annotationRegisteredProvidersImpl));
}
@BuildStep
AdditionalBeanBuildItem registerProviderBeans(CombinedIndexBuildItem combinedIndex) {
IndexView index = combinedIndex.getIndex();
List allInstances = new ArrayList<>(index.getAnnotations(REGISTER_PROVIDER));
for (AnnotationInstance annotation : index.getAnnotations(REGISTER_PROVIDERS)) {
allInstances.addAll(asList(annotation.value().asNestedArray()));
}
allInstances.addAll(index.getAnnotations(REGISTER_CLIENT_HEADERS));
AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder().setUnremovable();
for (AnnotationInstance annotationInstance : allInstances) {
// Make sure all providers not annotated with @Provider but used in @RegisterProvider are registered as beans
AnnotationValue value = annotationInstance.value();
if (value != null) {
builder.addBeanClass(value.asClass().toString());
}
}
return builder.build();
}
@BuildStep
void registerCompressionInterceptors(BuildProducer reflectiveClasses) {
Boolean enableCompression = ConfigProvider.getConfig()
.getOptionalValue(ENABLE_COMPRESSION, Boolean.class)
.orElse(false);
if (enableCompression) {
reflectiveClasses.produce(ReflectiveClassBuildItem
.builder(ClientGZIPDecodingInterceptor.class)
.serialization(false)
.build());
}
}
@BuildStep
void handleSseEventFilter(BuildProducer reflectiveClasses,
BeanArchiveIndexBuildItem beanArchiveIndexBuildItem) {
var index = beanArchiveIndexBuildItem.getIndex();
Collection instances = index.getAnnotations(DotNames.SSE_EVENT_FILTER);
if (instances.isEmpty()) {
return;
}
List filterClassNames = new ArrayList<>(instances.size());
for (AnnotationInstance instance : instances) {
if (instance.target().kind() != AnnotationTarget.Kind.METHOD) {
continue;
}
if (instance.value() == null) {
continue; // can't happen
}
Type filterType = instance.value().asClass();
DotName filterClassName = filterType.name();
ClassInfo filterClassInfo = index.getClassByName(filterClassName.toString());
if (filterClassInfo == null) {
log.warn("Unable to find class '" + filterType.name() + "' in index");
} else if (!filterClassInfo.hasNoArgsConstructor()) {
throw new RestClientDefinitionException(
"Classes used in @SseEventFilter must have a no-args constructor. Offending class is '"
+ filterClassName + "'");
} else {
filterClassNames.add(filterClassName.toString());
}
}
reflectiveClasses.produce(ReflectiveClassBuildItem
.builder(filterClassNames.toArray(new String[0]))
.constructors(true)
.build());
}
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void addRestClientBeans(Capabilities capabilities,
CombinedIndexBuildItem combinedIndexBuildItem,
CustomScopeAnnotationsBuildItem scopes,
List restClientAnnotationsTransformerBuildItem,
BuildProducer generatedBeans,
RestClientReactiveConfig clientConfig,
RestClientsBuildTimeConfig clientsBuildConfig,
RestClientRecorder recorder) {
CompositeIndex index = CompositeIndex.create(combinedIndexBuildItem.getIndex());
Set registerRestClientAnnos = determineRegisterRestClientInstances(clientsBuildConfig, index);
Map configKeys = new HashMap<>();
var annotationsStore = new AnnotationStore(restClientAnnotationsTransformerBuildItem.stream()
.map(RestClientAnnotationsTransformerBuildItem::getAnnotationsTransformer).collect(toList()));
for (AnnotationInstance registerRestClient : registerRestClientAnnos) {
ClassInfo jaxrsInterface = registerRestClient.target().asClass();
// for each interface annotated with @RegisterRestClient, generate a $$CDIWrapper CDI bean that can be injected
if (Modifier.isAbstract(jaxrsInterface.flags())) {
validateKotlinDefaultMethods(jaxrsInterface, index);
List methodsToImplement = new ArrayList<>();
// search this interface and its super interfaces for jaxrs methods
searchForJaxRsMethods(methodsToImplement, jaxrsInterface, index);
// search this interface for default methods
// we could search for default methods in super interfaces too,
// but emitting the correct invokespecial instruction would become convoluted
// (as invokespecial may only reference a method from a _direct_ super interface)
for (MethodInfo method : jaxrsInterface.methods()) {
boolean isDefault = !Modifier.isAbstract(method.flags()) && !Modifier.isStatic(method.flags());
if (isDefault) {
methodsToImplement.add(method);
}
}
if (methodsToImplement.isEmpty()) {
continue;
}
String wrapperClassName = jaxrsInterface.name().toString() + CDI_WRAPPER_SUFFIX;
try (ClassCreator classCreator = ClassCreator.builder()
.className(wrapperClassName)
.classOutput(new GeneratedBeanGizmoAdaptor(generatedBeans))
.interfaces(jaxrsInterface.name().toString())
.superClass(RestClientReactiveCDIWrapperBase.class)
.build()) {
// CLASS LEVEL
final Optional configKey = getConfigKey(registerRestClient);
configKey.ifPresent(
key -> configKeys.put(jaxrsInterface.name().toString(), key));
final ScopeInfo scope = computeDefaultScope(capabilities, ConfigProvider.getConfig(), jaxrsInterface,
configKey, clientConfig);
// add a scope annotation, e.g. @Singleton
classCreator.addAnnotation(scope.getDotName().toString());
classCreator.addAnnotation(RestClient.class);
// e.g. @Typed({InterfaceClass.class})
// needed for CDI to inject the proper wrapper in case of
// subinterfaces
org.objectweb.asm.Type asmType = org.objectweb.asm.Type
.getObjectType(jaxrsInterface.name().toString().replace('.', '/'));
classCreator.addAnnotation(Typed.class.getName(), RetentionPolicy.RUNTIME)
.addValue("value", new org.objectweb.asm.Type[] { asmType });
for (AnnotationInstance annotation : annotationsStore.getAnnotations(jaxrsInterface)) {
if (SKIP_COPYING_ANNOTATIONS_TO_GENERATED_CLASS.contains(annotation.name())) {
continue;
}
// scope annotation is added to the generated class already, see above
if (scopes.isScopeIn(Set.of(annotation))) {
continue;
}
classCreator.addAnnotation(annotation);
}
// CONSTRUCTOR:
MethodCreator constructor = classCreator
.getMethodCreator(MethodDescriptor.ofConstructor(classCreator.getClassName()));
AnnotationValue baseUri = registerRestClient.value("baseUri");
ResultHandle baseUriHandle = constructor.load(baseUri != null ? baseUri.asString() : "");
constructor.invokeSpecialMethod(
MethodDescriptor.ofConstructor(RestClientReactiveCDIWrapperBase.class, Class.class, String.class,
String.class, boolean.class),
constructor.getThis(),
constructor.loadClassFromTCCL(jaxrsInterface.toString()),
baseUriHandle,
configKey.isPresent() ? constructor.load(configKey.get()) : constructor.loadNull(),
constructor.load(scope.getDotName().equals(REQUEST_SCOPED)));
constructor.returnValue(null);
// METHODS:
for (MethodInfo method : methodsToImplement) {
// for each method that corresponds to making a rest call, create a method like:
// public JsonArray get() {
// return ((InterfaceClass)this.getDelegate()).get();
// }
//
// for each default method, create a method like:
// public JsonArray get() {
// return InterfaceClass.super.get();
// }
MethodCreator methodCreator = classCreator.getMethodCreator(MethodDescriptor.of(method));
methodCreator.setSignature(method.genericSignatureIfRequired());
// copy method annotations, there can be interceptors bound to them:
for (AnnotationInstance annotation : annotationsStore.getAnnotations(method)) {
if (annotation.target().kind() == AnnotationTarget.Kind.METHOD
&& !BUILTIN_HTTP_ANNOTATIONS_TO_METHOD.containsKey(annotation.name())
&& !ResteasyReactiveDotNames.PATH.equals(annotation.name())) {
methodCreator.addAnnotation(annotation);
}
if (annotation.target().kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
// TODO should skip annotations like `@PathParam` / `@RestPath`, probably (?)
short position = annotation.target().asMethodParameter().position();
methodCreator.getParameterAnnotations(position).addAnnotation(annotation);
}
}
ResultHandle result;
int parameterCount = method.parameterTypes().size();
ResultHandle[] params = new ResultHandle[parameterCount];
for (int i = 0; i < parameterCount; i++) {
params[i] = methodCreator.getMethodParam(i);
}
if (Modifier.isAbstract(method.flags())) { // RestClient method
ResultHandle delegate = methodCreator.invokeVirtualMethod(
MethodDescriptor.ofMethod(RestClientReactiveCDIWrapperBase.class, "getDelegate",
Object.class),
methodCreator.getThis());
result = methodCreator.invokeInterfaceMethod(method, delegate, params);
} else { // default method
result = methodCreator.invokeSpecialInterfaceMethod(method, methodCreator.getThis(), params);
}
methodCreator.returnValue(result);
}
}
}
}
Set blockingClassNames = new HashSet<>();
Set registerBlockingClasses = new HashSet<>(index.getAnnotations(BLOCKING));
for (AnnotationInstance registerBlockingClass : registerBlockingClasses) {
AnnotationTarget target = registerBlockingClass.target();
if (target.kind() == AnnotationTarget.Kind.CLASS
&& isImplementorOf(index, target.asClass(), RESPONSE_EXCEPTION_MAPPER, Set.of(APPLICATION))) {
// Watch for @Blocking annotations in classes that implements ResponseExceptionMapper:
blockingClassNames.add(target.asClass().toString());
} else if (target.kind() == AnnotationTarget.Kind.METHOD
&& target.asMethod().annotation(CLIENT_EXCEPTION_MAPPER) != null) {
// Watch for @Blocking annotations in methods that are also annotated with @ClientExceptionMapper:
blockingClassNames.add(ClientExceptionMapperHandler.getGeneratedClassName(target.asMethod()));
}
}
recorder.setBlockingClassNames(blockingClassNames);
if (LaunchMode.current() == LaunchMode.DEVELOPMENT) {
recorder.setConfigKeys(configKeys);
}
}
private Set determineRegisterRestClientInstances(RestClientsBuildTimeConfig clientsConfig,
CompositeIndex index) {
// these are the actual instances
Set registerRestClientAnnos = new HashSet<>(index.getAnnotations(REGISTER_REST_CLIENT));
// a set of the original target class
Set registerRestClientTargets = registerRestClientAnnos.stream().map(ai -> ai.target().asClass()).collect(
Collectors.toSet());
// now we go through the keys and if any of them correspond to classes that don't have a @RegisterRestClient annotation, we fake that annotation
Set configKeyNames = clientsConfig.configs.keySet();
for (String configKeyName : configKeyNames) {
ClassInfo classInfo = index.getClassByName(configKeyName);
if (classInfo == null) {
continue;
}
if (registerRestClientTargets.contains(classInfo)) {
continue;
}
Optional cdiScope = clientsConfig.configs.get(configKeyName).scope;
if (cdiScope.isEmpty()) {
continue;
}
registerRestClientAnnos.add(AnnotationInstance.builder(REGISTER_REST_CLIENT).add("configKey", configKeyName)
.buildWithTarget(classInfo));
}
return registerRestClientAnnos;
}
/**
* Based on a list of interfaces implemented by @Provider class, determine if registration
* should be skipped or not. Server-specific types should be omitted unless implementation
* of a ClientRequestFilter exists on the same class explicitly.
* Features should always be omitted.
*/
private boolean skipAutoDiscoveredProvider(List providerInterfaceNames) {
if (providerInterfaceNames.contains(ResteasyReactiveDotNames.FEATURE)) {
return true;
}
if (providerInterfaceNames.contains(ResteasyReactiveDotNames.CONTAINER_REQUEST_FILTER)
|| providerInterfaceNames.contains(ResteasyReactiveDotNames.CONTAINER_RESPONSE_FILTER)
|| providerInterfaceNames.contains(ResteasyReactiveDotNames.EXCEPTION_MAPPER)) {
if (providerInterfaceNames.contains(CLIENT_REQUEST_FILTER)
|| providerInterfaceNames.contains(CLIENT_RESPONSE_FILTER)) {
return false;
} else {
return true;
}
}
return false;
}
private Map populateClientExceptionMapperFromAnnotations(
BuildProducer generatedClasses,
BuildProducer reflectiveClasses, IndexView index) {
var result = new HashMap();
ClientExceptionMapperHandler clientExceptionMapperHandler = new ClientExceptionMapperHandler(
new GeneratedClassGizmoAdaptor(generatedClasses, true));
for (AnnotationInstance instance : index.getAnnotations(CLIENT_EXCEPTION_MAPPER)) {
GeneratedClassResult classResult = clientExceptionMapperHandler.generateResponseExceptionMapper(instance);
if (classResult == null) {
continue;
}
if (result.containsKey(classResult.interfaceName)) {
throw new IllegalStateException("Only a single instance of '" + CLIENT_EXCEPTION_MAPPER
+ "' is allowed per REST Client interface. Offending class is '" + classResult.interfaceName + "'");
}
result.put(classResult.interfaceName, classResult);
reflectiveClasses.produce(ReflectiveClassBuildItem.builder(classResult.generatedClassName)
.serialization(false).build());
}
return result;
}
private Map populateClientRedirectHandlerFromAnnotations(
BuildProducer generatedClasses,
BuildProducer reflectiveClasses, IndexView index) {
var result = new HashMap();
ClientRedirectHandler clientHandler = new ClientRedirectHandler(new GeneratedClassGizmoAdaptor(generatedClasses, true));
for (AnnotationInstance instance : index.getAnnotations(CLIENT_REDIRECT_HANDLER)) {
GeneratedClassResult classResult = clientHandler.generateResponseExceptionMapper(instance);
if (classResult == null) {
continue;
}
GeneratedClassResult existing = result.get(classResult.interfaceName);
if (existing != null && existing.priority == classResult.priority) {
throw new IllegalStateException("Only a single instance of '" + CLIENT_REDIRECT_HANDLER
+ "' with the same priority is allowed per REST Client interface. "
+ "Offending class is '" + classResult.interfaceName + "'");
} else if (existing == null || existing.priority < classResult.priority) {
result.put(classResult.interfaceName, classResult);
reflectiveClasses.produce(ReflectiveClassBuildItem.builder(classResult.generatedClassName)
.serialization(false).build());
}
}
return result;
}
private Map populateClientProviderFromAnnotations(
AnnotationToRegisterIntoClientContextBuildItem annotationBuildItem,
BuildProducer generatedClasses,
BuildProducer reflectiveClasses, IndexView index) {
var result = new HashMap();
ClientContextResolverHandler handler = new ClientContextResolverHandler(annotationBuildItem.getAnnotation(),
annotationBuildItem.getExpectedReturnType(),
new GeneratedClassGizmoAdaptor(generatedClasses, true));
for (AnnotationInstance instance : index.getAnnotations(annotationBuildItem.getAnnotation())) {
GeneratedClassResult classResult = handler.generateContextResolver(instance);
if (classResult == null) {
continue;
}
if (result.containsKey(classResult.interfaceName)) {
throw new IllegalStateException("Only a single instance of '" + annotationBuildItem.getAnnotation()
+ "' is allowed per REST Client interface. Offending class is '" + classResult.interfaceName + "'");
}
result.put(classResult.interfaceName, classResult);
reflectiveClasses.produce(ReflectiveClassBuildItem.builder(classResult.generatedClassName)
.serialization(false).build());
}
return result;
}
private void addGeneratedProviders(IndexView index, MethodCreator constructor,
Map> annotationsByClassName,
Map> generatedProviders) {
for (Map.Entry> annotationsForClass : annotationsByClassName.entrySet()) {
ResultHandle map = constructor.newInstance(MethodDescriptor.ofConstructor(HashMap.class));
for (AnnotationInstance value : annotationsForClass.getValue()) {
String className = value.value().asString();
AnnotationValue priorityAnnotationValue = value.value("priority");
int priority;
if (priorityAnnotationValue == null) {
priority = getAnnotatedPriority(index, className, Priorities.USER);
} else {
priority = priorityAnnotationValue.asInt();
}
constructor.invokeInterfaceMethod(MAP_PUT, map, constructor.loadClassFromTCCL(className),
constructor.load(priority));
}
String ifaceName = annotationsForClass.getKey();
if (generatedProviders.containsKey(ifaceName)) {
// remove the interface from the generated provider since it's going to be handled now
// the remaining entries will be handled later
List providers = generatedProviders.remove(ifaceName);
for (GeneratedClassResult classResult : providers) {
constructor.invokeInterfaceMethod(MAP_PUT, map, constructor.loadClass(classResult.generatedClassName),
constructor.load(classResult.priority));
}
}
addProviders(constructor, ifaceName, map);
}
for (Map.Entry> entry : generatedProviders.entrySet()) {
ResultHandle map = constructor.newInstance(MethodDescriptor.ofConstructor(HashMap.class));
for (GeneratedClassResult classResult : entry.getValue()) {
constructor.invokeInterfaceMethod(MAP_PUT, map, constructor.loadClass(classResult.generatedClassName),
constructor.load(classResult.priority));
addProviders(constructor, entry.getKey(), map);
}
}
}
private void addProviders(MethodCreator constructor, String providerClass, ResultHandle map) {
constructor.invokeVirtualMethod(
MethodDescriptor.ofMethod(AnnotationRegisteredProviders.class, "addProviders", void.class, String.class,
Map.class),
constructor.getThis(), constructor.load(providerClass), map);
}
private int getAnnotatedPriority(IndexView index, String className, int defaultPriority) {
ClassInfo providerClass = index.getClassByName(DotName.createSimple(className));
int priority = defaultPriority;
if (providerClass == null) {
log.warnv("Unindexed provider class {0}. The priority of the provider will be set to {1}. ", className,
defaultPriority);
} else {
AnnotationInstance priorityAnnoOnProvider = providerClass.declaredAnnotation(ResteasyReactiveDotNames.PRIORITY);
if (priorityAnnoOnProvider != null) {
priority = priorityAnnoOnProvider.value().asInt();
}
}
return priority;
}
// By default, Kotlin does not use Java interface default methods, but generates a helper class that contains the implementation.
// In order to avoid the extra complexity of having to deal with this mode, we simply fail the build when this situation is encountered
// and provide an actionable error message on how to remedy the situation.
private void validateKotlinDefaultMethods(ClassInfo jaxrsInterface, IndexView index) {
if (jaxrsInterface.declaredAnnotation(KOTLIN_METADATA_ANNOTATION) != null) {
var potentialDefaultImplClass = DotName
.createSimple(jaxrsInterface.name().toString() + KOTLIN_INTERFACE_DEFAULT_IMPL_SUFFIX);
if (index.getClassByName(potentialDefaultImplClass) != null) {
throw new RestClientDefinitionException(String.format(
"Using Kotlin default methods on interfaces that are not backed by Java 8 default interface methods is not supported. See %s for more details. Offending interface is '%s'.",
"https://kotlinlang.org/docs/java-to-kotlin-interop.html#default-methods-in-interfaces",
jaxrsInterface.name().toString()));
}
}
}
private boolean isRestMethod(MethodInfo method) {
if (!Modifier.isAbstract(method.flags())) {
return false;
}
for (AnnotationInstance annotation : method.annotations()) {
if (annotation.target().kind() == AnnotationTarget.Kind.METHOD
&& BUILTIN_HTTP_ANNOTATIONS_TO_METHOD.containsKey(annotation.name())) {
return true;
} else if (annotation.name().equals(ResteasyReactiveDotNames.PATH)) {
return true;
}
}
return false;
}
private Optional getConfigKey(AnnotationInstance registerRestClientAnnotation) {
AnnotationValue configKeyValue = registerRestClientAnnotation.value("configKey");
return configKeyValue != null
? Optional.of(configKeyValue.asString())
: Optional.empty();
}
private ScopeInfo computeDefaultScope(Capabilities capabilities, Config config,
ClassInfo restClientInterface,
Optional configKey,
RestClientReactiveConfig mpClientConfig) {
ScopeInfo scopeToUse = null;
Optional scopeConfig = RestClientConfigUtils.findConfiguredScope(config, restClientInterface, configKey);
BuiltinScope globalDefaultScope = BuiltinScope.from(DotName.createSimple(mpClientConfig.scope));
if (globalDefaultScope == null) {
log.warnv("Unable to map the global rest client scope: '{0}' to a scope. Using @ApplicationScoped",
mpClientConfig.scope);
globalDefaultScope = BuiltinScope.APPLICATION;
}
if (scopeConfig.isPresent()) {
final DotName scope = DotName.createSimple(scopeConfig.get());
final BuiltinScope builtinScope = builtinScopeFromName(scope);
if (builtinScope != null) { // override default @Dependent scope with user defined one.
scopeToUse = builtinScope.getInfo();
} else if (capabilities.isPresent(Capability.SERVLET)) {
if (scope.equals(SESSION_SCOPED) || scope.toString().equalsIgnoreCase(SESSION_SCOPED.withoutPackagePrefix())) {
scopeToUse = new ScopeInfo(SESSION_SCOPED, true);
}
}
if (scopeToUse == null) {
log.warnf("Unsupported default scope {} provided for rest client {}. Defaulting to {}",
scope, restClientInterface.name(), globalDefaultScope.getName());
scopeToUse = globalDefaultScope.getInfo();
}
} else {
final Set annotations = restClientInterface.annotationsMap().keySet();
for (final DotName annotationName : annotations) {
final BuiltinScope builtinScope = BuiltinScope.from(annotationName);
if (builtinScope != null) {
scopeToUse = builtinScope.getInfo();
break;
}
if (annotationName.equals(SESSION_SCOPED)) {
scopeToUse = new ScopeInfo(SESSION_SCOPED, true);
break;
}
}
}
// Initialize a default @Dependent scope as per the spec
return scopeToUse != null ? scopeToUse : globalDefaultScope.getInfo();
}
private BuiltinScope builtinScopeFromName(DotName scopeName) {
BuiltinScope scope = BuiltinScope.from(scopeName);
if (scope == null) {
for (BuiltinScope builtinScope : BuiltinScope.values()) {
if (builtinScope.getName().withoutPackagePrefix().equalsIgnoreCase(scopeName.toString())) {
scope = builtinScope;
}
}
}
return scope;
}
}