Skip to content

Commit

Permalink
Synthetic CDI beans should have a beanClass attribute of the CDI exte…
Browse files Browse the repository at this point in the history
…nsion
  • Loading branch information
Skyllarr committed Oct 24, 2022
1 parent aa5933f commit 4537b9c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions impl/src/main/java/org/glassfish/soteria/cdi/CdiExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

identityStoreBeans.add(new CdiProducer<IdentityStore>()
.scope(ApplicationScoped.class)
.beanClass(IdentityStore.class)
.types(Object.class, IdentityStore.class, EmbeddedIdentityStore.class)
.addToId(EmbeddedIdentityStoreDefinition.class)
.create(e -> new EmbeddedIdentityStore(embeddedIdentityStoreDefinition))
Expand All @@ -139,7 +138,6 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

identityStoreBeans.add(new CdiProducer<IdentityStore>()
.scope(ApplicationScoped.class)
.beanClass(IdentityStore.class)
.types(Object.class, IdentityStore.class, DatabaseIdentityStore.class)
.addToId(DatabaseIdentityStoreDefinition.class)
.create(e -> new DatabaseIdentityStore(
Expand All @@ -154,7 +152,6 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

identityStoreBeans.add(new CdiProducer<IdentityStore>()
.scope(ApplicationScoped.class)
.beanClass(IdentityStore.class)
.types(Object.class, IdentityStore.class, LdapIdentityStore.class)
.addToId(LdapIdentityStoreDefinition.class)
.create(e -> new LdapIdentityStore(
Expand All @@ -169,7 +166,6 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

authenticationMechanismBean = new CdiProducer<HttpAuthenticationMechanism>()
.scope(ApplicationScoped.class)
.beanClass(BasicAuthenticationMechanism.class)
.types(Object.class, HttpAuthenticationMechanism.class, BasicAuthenticationMechanism.class)
.addToId(BasicAuthenticationMechanismDefinition.class)
.create(e -> new BasicAuthenticationMechanism(
Expand All @@ -183,7 +179,6 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

authenticationMechanismBean = new CdiProducer<HttpAuthenticationMechanism>()
.scope(ApplicationScoped.class)
.beanClass(HttpAuthenticationMechanism.class)
.types(Object.class, HttpAuthenticationMechanism.class)
.addToId(FormAuthenticationMechanismDefinition.class)
.create(e -> {
Expand All @@ -202,7 +197,6 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

authenticationMechanismBean = new CdiProducer<HttpAuthenticationMechanism>()
.scope(ApplicationScoped.class)
.beanClass(HttpAuthenticationMechanism.class)
.types(Object.class, HttpAuthenticationMechanism.class)
.addToId(CustomFormAuthenticationMechanismDefinition.class)
.create(e -> {
Expand All @@ -223,22 +217,19 @@ public <T> void processBean(@Observes ProcessBean<T> eventIn, BeanManager beanMa

authenticationMechanismBean = new CdiProducer<HttpAuthenticationMechanism>()
.scope(ApplicationScoped.class)
.beanClass(HttpAuthenticationMechanism.class)
.types(HttpAuthenticationMechanism.class)
.addToId(OpenIdAuthenticationMechanism.class)
.create(e -> getBeanReference(OpenIdAuthenticationMechanism.class));

identityStoreBeans.add(new CdiProducer<IdentityStore>()
.scope(ApplicationScoped.class)
.beanClass(IdentityStore.class)
.types(IdentityStore.class)
.addToId(OpenIdIdentityStore.class)
.create(e -> getBeanReference(OpenIdIdentityStore.class))
);

extraBeans.add(new CdiProducer<OpenIdAuthenticationMechanismDefinition>()
.scope(ApplicationScoped.class)
.beanClass(OpenIdAuthenticationMechanismDefinition.class)
.types(OpenIdAuthenticationMechanismDefinition.class)
.addToId("OpenId Definition")
.create(e -> definition)
Expand Down Expand Up @@ -272,7 +263,6 @@ public void afterBean(final @Observes AfterBeanDiscovery afterBeanDiscovery, Bea
if ("basic".equalsIgnoreCase(loginConfig.getAuthMethod())) {
authenticationMechanismBean = new CdiProducer<HttpAuthenticationMechanism>()
.scope(ApplicationScoped.class)
.beanClass(BasicAuthenticationMechanism.class)
.types(Object.class, HttpAuthenticationMechanism.class, BasicAuthenticationMechanism.class)
.addToId(BasicAuthenticationMechanismDefinition.class)
.create(e ->
Expand All @@ -283,7 +273,6 @@ public void afterBean(final @Observes AfterBeanDiscovery afterBeanDiscovery, Bea
} else if ("form".equalsIgnoreCase(loginConfig.getAuthMethod())) {
authenticationMechanismBean = new CdiProducer<HttpAuthenticationMechanism>()
.scope(ApplicationScoped.class)
.beanClass(HttpAuthenticationMechanism.class)
.types(Object.class, HttpAuthenticationMechanism.class)
.addToId(FormAuthenticationMechanismDefinition.class)
.create(e -> {
Expand Down Expand Up @@ -319,7 +308,6 @@ public void afterBean(final @Observes AfterBeanDiscovery afterBeanDiscovery, Bea
// Probably can circumvent this using programmatic lookup or Instance injection
afterBeanDiscovery.addBean()
.scope(Dependent.class)
.beanClass(OpenIdAuthenticationMechanismDefinition.class)
.types(OpenIdAuthenticationMechanismDefinition.class)
.id("Null OpenId Definition")
.createWith(cc -> null);
Expand All @@ -329,7 +317,6 @@ public void afterBean(final @Observes AfterBeanDiscovery afterBeanDiscovery, Bea
decorator.decorateBean(
new CdiProducer<IdentityStoreHandler>()
.scope(ApplicationScoped.class)
.beanClass(IdentityStoreHandler.class)
.types(Object.class, IdentityStoreHandler.class)
.addToId(IdentityStoreHandler.class)
.create(e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CdiProducer<T> implements Bean<T>, PassivationCapable {

private String id = this.getClass().getName();
private String name;
private Class<?> beanClass = Object.class;
private Class<?> beanClass = CdiExtension.class;
private Set<Type> types = singleton(Object.class);
private Set<Annotation> qualifiers = unmodifiableSet(asSet(new DefaultAnnotationLiteral(), new AnyAnnotationLiteral()));
private Class<? extends Annotation> scope = Dependent.class;
Expand Down

0 comments on commit 4537b9c

Please sign in to comment.