Skip to content

Commit

Permalink
vip
Browse files Browse the repository at this point in the history
  • Loading branch information
th-schwarz committed Jul 7, 2024
1 parent e4a2d06 commit 45b735c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/main/java/codes/thischwa/dyndrest/config/PostProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,29 @@ public Object postProcessBeforeInitialization(Object bean, String beanName)
@Nullable
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
Collection<Class<?>> toBeRemoved = new HashSet<>();
for (Class<?> wantedBean : wanted) {
if (wantedBean.isInstance(bean) && !initialized.contains(bean)) {
initialized.add(bean);
toBeRemoved.add(wantedBean);
}
}
wanted.removeAll(toBeRemoved);
processBean(bean);
if (!processed && wanted.isEmpty()) {
log.info("*** Relevant beans found!");
log.info("*** Wanted beans found!");
try {
process(initialized);
} catch (Exception e) {
throw new BeanInitializationException(
"Error while processing " + this.getClass().getName());
"Error while processing " + this.getClass().getName(), e);
}
processed = true;
}

return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
}

private void processBean(Object bean) {
Collection<Class<?>> toBeRemoved = new HashSet<>();
for (Class<?> wantedBean : wanted) {
if (wantedBean.isInstance(bean) && !initialized.contains(bean)) {
initialized.add(bean);
toBeRemoved.add(wantedBean);
}
}
wanted.removeAll(toBeRemoved);
}
}

0 comments on commit 45b735c

Please sign in to comment.