dev.alangomes.springspigot.picocli.SpringCommandFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spigot-spring-boot-starter Show documentation
Show all versions of spigot-spring-boot-starter Show documentation
Spring support for spigot plugins
package dev.alangomes.springspigot.picocli;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import picocli.CommandLine;
@Component
class SpringCommandFactory implements CommandLine.IFactory {
@Autowired
private BeanFactory beanFactory;
@Override
public K create(Class cls) throws Exception {
K bean = beanFactory.getBean(cls);
if (!(bean instanceof Iterable) && AopUtils.isAopProxy(bean)) {
return (K) ((Advised) bean).getTargetSource().getTarget();
}
return bean;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy