
artoria.ai.support.AiHandlerAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artoria-extend Show documentation
Show all versions of artoria-extend Show documentation
Artoria is a java technology framework based on the facade pattern.
The newest version!
package artoria.ai.support;
import artoria.ai.AiUtils;
import artoria.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import java.util.Map;
/**
* The ai handler auto configuration.
* @author Kahle
*/
@Configuration
public class AiHandlerAutoConfiguration {
private static final Logger log = LoggerFactory.getLogger(AiHandlerAutoConfiguration.class);
public AiHandlerAutoConfiguration(ApplicationContext appContext) {
// If not have beans, handlerMap is empty map, not is null.
Map handlerMap = appContext.getBeansOfType(AutoAiHandler.class);
for (AutoAiHandler aiHandler : handlerMap.values()) {
if (aiHandler == null) { continue; }
String handlerName = aiHandler.getName();
if (StringUtils.isBlank(handlerName)) {
log.warn("The ai handler \"{}\"'s name is blank, it will be ignored. "
, aiHandler.getClass());
continue;
}
AiUtils.registerHandler(handlerName, aiHandler);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy