Skip to content

Commit

Permalink
Merge pull request #5911 from vietk/bugfix/spring-di-custom-scopes-on…
Browse files Browse the repository at this point in the history
…-configuration-bean-methods

Ensure that type of annotation is a Class when resolving custom stereotypes usage
  • Loading branch information
geoand authored Dec 3, 2019
2 parents 9153e1b + 8e00185 commit 8ec57ac
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ AnnotationsTransformerBuildItem beanTransformer(
for (final DotName name : stereotypeScopes.keySet()) {
instances.put(name, index.getAnnotations(name)
.stream()
.filter(it -> isAnnotation(it.target().asClass().flags()))
.filter(it -> it.target().kind() == AnnotationTarget.Kind.CLASS
&& isAnnotation(it.target().asClass().flags()))
.collect(Collectors.toSet()));
}
additionalStereotypeBuildItemBuildProducer.produce(new AdditionalStereotypeBuildItem(instances));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ public AnotherRequestBean requestBean() {
return new AnotherRequestBean();
}

@Bean
@CustomPrototype
public CustomPrototypeBean beanWithCustomPrototype() {
return new CustomPrototypeBean();
}

private static class SingletonBean {

}

private static class AnotherRequestBean {

}

public static class CustomPrototypeBean {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.quarkus.it.spring;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Scope("prototype")
public @interface CustomPrototype {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.it.spring;

import static io.quarkus.it.spring.AppConfiguration.CustomPrototypeBean;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
Expand All @@ -18,6 +20,8 @@ public class InjectedSpringBeansResource {
RequestBean requestBean;
@Inject
SessionBean sessionBean;
@Inject
CustomPrototypeBean anotherRequestBean;

@GET
@Produces(MediaType.TEXT_PLAIN)
Expand Down

0 comments on commit 8ec57ac

Please sign in to comment.