All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.web.remote.smart.EnableSmartRequestMapping Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.web.remote.smart;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.function.Predicate;

import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Indexed;
import org.springframework.web.bind.annotation.RequestMapping;
import org.zodiac.core.remote.annotation.EnableRemoteRequestMapping;

/**
 * The intelligent request (webmvc/webflux) mapping processing component enhances
 * the following functions: Implement the interface of
 * {@code org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations} and {@code org.springframework.boot.autoconfigure.web.reactive.WebFluxRegistrations}, unify the
 * request mapping handler. 
* support:
* 1. allow the same mapping handler to register according to priority, * reference: {@code org.zodiac.core.web.servlet.SmartServletHandlerMapping#doRegisterMapping} and * {@code org.zodiac.core.web.reactive.SmartReactiveHandlerMapping#doRegisterMapping};
* 2. control the judgment condition of handler,reference: * {@code org.zodiac.core.web.servlet.ServletHandlerMappingSupport#isHandler} and * {@code org.zodiac.core.web.reactive.ReactiveHandlerMappingSupport#isHandler};
*/ @Retention(RUNTIME) @Target({ TYPE }) @Documented @Indexed //@EnableRemoteRequestMapping @Import({ SmartHandlerMappingRegistrar.class }) public @interface EnableSmartRequestMapping { @AliasFor(annotation = EnableRemoteRequestMapping.class) String[] value() default {}; @AliasFor(annotation = EnableRemoteRequestMapping.class) String[] packagePatterns() default {}; @AliasFor(annotation = EnableRemoteRequestMapping.class) boolean packagePatternsUseForInclude() default true; @AliasFor(annotation = EnableRemoteRequestMapping.class) Class>>[] filters() default { DefaultMappingHandlerFilter.class }; @AliasFor(annotation = EnableRemoteRequestMapping.class) boolean overrideAmbiguousByOrder() default false; /** * Refer: {@link #packagePatterns()} */ public static final String PACKAGE_PATTERNS = "packagePatterns"; /** * Refer: {@link #packagePatternsUseForInclude()} */ public static final String PACKAGE_PATTERNS_FOR_INCLUDE = "packagePatternsUseForInclude"; /** * Refer: {@link #packagePatterns()} */ public static final String FILTERS = "filters"; /** * Refer: {@link #overrideAmbiguousByOrder()} */ public static final String OVERRIDE_AMBIGUOUS = "overrideAmbiguousByOrder"; public static class DefaultMappingHandlerFilter implements Predicate> { @Override public boolean test(Class beanType) { return AnnotatedElementUtils.hasAnnotation(beanType, Controller.class) || AnnotatedElementUtils.hasAnnotation(beanType, RequestMapping.class); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy