Skip to content

Commit

Permalink
Delay initialization AuthenticationProvider in Global Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
kse-music committed Nov 8, 2024
1 parent b9d5493 commit aad371f
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -94,25 +95,26 @@ private <T> List<BeanWithName<T>> getBeansWithName(Class<T> type) {
String[] beanNames = InitializeAuthenticationProviderBeanManagerConfigurer.this.context
.getBeanNamesForType(type);
for (String beanName : beanNames) {
T bean = InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanName, type);
beanWithNames.add(new BeanWithName<T>(bean, beanName));
Supplier<T> bean = () -> InitializeAuthenticationProviderBeanManagerConfigurer.this.context
.getBean(beanName, type);
beanWithNames.add(new BeanWithName<>(bean, beanName));
}
return beanWithNames;
}

static class BeanWithName<T> {

private final T bean;
private final Supplier<T> bean;

private final String name;

BeanWithName(T bean, String name) {
BeanWithName(Supplier<T> bean, String name) {
this.bean = bean;
this.name = name;
}

T getBean() {
return this.bean;
return this.bean.get();
}

String getName() {
Expand Down

0 comments on commit aad371f

Please sign in to comment.