Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement some BeanManager methods #11077

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Stereotype;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedMember;
Expand Down Expand Up @@ -172,17 +173,22 @@ public boolean isInterceptorBinding(Class<? extends Annotation> annotationType)

@Override
public boolean isStereotype(Class<? extends Annotation> annotationType) {
throw new UnsupportedOperationException();
//best effort, in theory an extension could change this but this is an edge case
return annotationType.isAnnotationPresent(Stereotype.class);
}

@Override
public Set<Annotation> getInterceptorBindingDefinition(Class<? extends Annotation> bindingType) {
throw new UnsupportedOperationException();
//best effort, in theory an extension could change this its better than nothing
//it could also return annotations that aren't bindings
return new HashSet<>(Arrays.asList(bindingType.getAnnotations()));
}

@Override
public Set<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype) {
throw new UnsupportedOperationException();
//best effort, in theory an extension could change this its better than nothing
//it could also return annotations that aren't metadata
return new HashSet<>(Arrays.asList(stereotype.getAnnotations()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.enterprise.inject.Stereotype;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -25,6 +28,14 @@ public void testStereotype() {
assertEquals("interceptedOK", Arc.container().instance(IamIntercepted.class).get().getId());
}

@Test
public void testStereotypeBeanManager() {
BeanManager beanManager = CDI.current().getBeanManager();
Assertions.assertTrue(beanManager.isStereotype(BeIntercepted.class));
Assertions.assertFalse(beanManager.isStereotype(SimpleBinding.class));

}

@SimpleBinding
@Documented
@Stereotype
Expand Down