org.zodiac.autoconfigure.web.remote.WebRemoteApiVersionMappingRegistrar Maven / Gradle / Ivy
package org.zodiac.autoconfigure.web.remote;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.zodiac.commons.util.ClassLoaders;
import org.zodiac.commons.util.spring.Springs;
import org.zodiac.core.remote.annotation.RemoteApiVersionMappingRegistrar;
public class WebRemoteApiVersionMappingRegistrar extends RemoteApiVersionMappingRegistrar {
public WebRemoteApiVersionMappingRegistrar() {
}
@Override
protected boolean isSupported(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
return true;
}
@Override
protected void doRegister(AnnotationMetadata metadata, BeanDefinitionRegistry registry,
BeanNameGenerator beanNameGenerator, AnnotationAttributes attrs) {
super.doRegister(metadata, registry, beanNameGenerator, attrs);
/*Register rqeust handler mapping.*/
if (Springs.isReactiveWeb(getClass().getClassLoader(), getEnvironment(), getResourceLoader())) {
registerRequestHandlerMapping(metadata, attrs, registry, ClassLoaders.loadClass("org.zodiac.core.web.remote.reactive.versions.RemoteApiVersionRequestHandlerMapping"),
beanNameGenerator);
} else {
registerRequestHandlerMapping(metadata, attrs, registry,
ClassLoaders.loadClass("org.zodiac.core.web.remote.servlet.versions.RemoteApiVersionRequestHandlerMapping"), beanNameGenerator);
}
}
}