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

ELYEE-30 Change bean class of produced beans #22

Merged
merged 1 commit into from
May 23, 2023
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 @@ -121,7 +121,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 @@ -134,7 +133,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 @@ -149,7 +147,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 @@ -164,7 +161,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 @@ -178,7 +174,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 @@ -197,7 +192,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 @@ -218,22 +212,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 @@ -267,7 +258,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 @@ -278,7 +268,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 @@ -314,7 +303,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 @@ -324,7 +312,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