Example usage for org.springframework.web.servlet.mvc.condition PatternsRequestCondition PatternsRequestCondition

List of usage examples for org.springframework.web.servlet.mvc.condition PatternsRequestCondition PatternsRequestCondition

Introduction

In this page you can find the example usage for org.springframework.web.servlet.mvc.condition PatternsRequestCondition PatternsRequestCondition.

Prototype

public PatternsRequestCondition(String[] patterns, @Nullable UrlPathHelper urlPathHelper,
        @Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch) 

Source Link

Document

Additional constructor with flags for using suffix pattern (.*) and trailing slash matches.

Usage

From source file:org.mitre.openid.connect.client.keypublisher.ClientKeyPublisherMapping.java

/**
 * Map the "jwkKeyPublish" method to our jwkPublishUrl.
 *//*from  ww  w. j a v  a 2s.  c o m*/
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {

    if (method.getName().equals("publishClientJwk") && getJwkPublishUrl() != null) {
        return new RequestMappingInfo(new PatternsRequestCondition(new String[] { getJwkPublishUrl() },
                getUrlPathHelper(), getPathMatcher(), false, false), null, null, null, null, null, null);
    } else {
        return null;
    }

}

From source file:org.cfr.capsicum.server.CayenneFilter.java

@Override
public void afterPropertiesSet() throws ServletException {
    super.afterPropertiesSet();
    if (includeFilterPatterns == null) {
        this.includeFilterPatterns = new String[] { "**/*" };
    }// www. j a v  a  2 s. c o m
    UrlPathHelper pathHelper = new UrlPathHelper();
    pathHelper.setAlwaysUseFullPath(alwaysUseFullPath);
    pathHelper.setUrlDecode(urlDecode);
    conditionIncluded = new PatternsRequestCondition(includeFilterPatterns, pathHelper, null, true, true);
    if (excludeFilterPatterns != null) {
        conditionExcluded = new PatternsRequestCondition(excludeFilterPatterns, pathHelper, null, true, true);
    }
}

From source file:net.sf.cocmvc.ConventionalHandlerMapping.java

private PatternsRequestCondition createPatternRequestCondition(String[] patterns) {
    return new PatternsRequestCondition(patterns, this.getUrlPathHelper(), this.getPathMatcher(),
            useSuffixPatternMatch(), useTrailingSlashMatch());
}

From source file:org.makersoft.mvc.method.annotation.RESTfulMappingHandlerMapping.java

/**
 * Created a RequestMappingInfo from a RequestMapping annotation.
 *//*  w w w. jav a2s.  co m*/
private RequestMappingInfo createRequestMappingInfo(Method method, RESTfull annotation,
        Class<?> controllerClass) {

    Mapping mapping = RESTfulHelper.matchMapping(method.getName());

    if (mapping != null) {
        PackageBasedUrlPathBuilder builder = new PackageBasedUrlPathBuilder(packageLocators, controllerPackages,
                controllerSuffix, root);

        String[] namespaceString = builder.buildUrlPath(controllerClass, mapping.getMethodName(),
                mapping.getValues());
        if (namespaceString != null) {
            return new RequestMappingInfo(
                    new PatternsRequestCondition(namespaceString, getUrlPathHelper(), getPathMatcher(),
                            this.useSuffixPatternMatch, this.useTrailingSlashMatch),
                    new RequestMethodsRequestCondition(mapping.getRequestMethods()),
                    new ParamsRequestCondition(mapping.getParams()),
                    new HeadersRequestCondition(mapping.getHeaders()),
                    new ConsumesRequestCondition(mapping.getConsumes(), mapping.getHeaders()),
                    new ProducesRequestCondition(mapping.getProduces(), mapping.getHeaders()),
                    getCustomMethodCondition(method));
        }

    }

    return null;
}

From source file:org.springbyexample.mvc.method.annotation.ServiceHandlerMapping.java

/**
 * Register handler.//from   w ww.  j  av  a2s  .  co m
 */
private void registerHandler(Class<?> marshallingServiceClass, Method method) {
    ApplicationContext ctx = getApplicationContext();

    RestResource restResource = AnnotationUtils.findAnnotation(marshallingServiceClass, RestResource.class);
    Class<?> serviceClass = restResource.service();

    RestRequestResource restRequestResource = AnnotationUtils.findAnnotation(method, RestRequestResource.class);
    boolean export = (restRequestResource != null ? restRequestResource.export() : true);
    boolean relative = (restRequestResource != null ? restRequestResource.relative() : true);

    if (export) {
        Class<?> handlerServiceClass = serviceClass;
        String methodName = method.getName();
        Class<?>[] paramTypes = method.getParameterTypes();

        if (restRequestResource != null) {
            // explicit service specified
            if (restRequestResource.service() != ServiceValueConstants.DEFAULT_SERVICE_CLASS) {
                handlerServiceClass = restRequestResource.service();
            }

            // explicit method name specified
            if (StringUtils.hasText(restRequestResource.methodName())) {
                methodName = restRequestResource.methodName();
            }
        }

        Object handler = ctx.getBean(handlerServiceClass);
        Method serviceMethod = ClassUtils.getMethod(handlerServiceClass, methodName, paramTypes);
        RequestMappingInfo mapping = getMappingForMethod(method, marshallingServiceClass);

        if (relative) {
            List<String> patterns = new ArrayList<String>();

            for (String pattern : mapping.getPatternsCondition().getPatterns()) {
                // add REST resource path prefix to URI,
                // if relative path is just '/' add an empty string
                patterns.add(restResource.path() + (!"/".equals(pattern) ? pattern : ""));
            }

            // create a new mapping based on the patterns (patterns are unmodifiable in existing RequestMappingInfo)
            mapping = new RequestMappingInfo(
                    new PatternsRequestCondition(patterns.toArray(ArrayUtils.EMPTY_STRING_ARRAY),
                            getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(),
                            useTrailingSlashMatch()),
                    mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(),
                    mapping.getConsumesCondition(), mapping.getProducesCondition(),
                    mapping.getCustomCondition());
        }

        // need to set param types to use in createHandlerMethod before calling registerHandlerMethod
        restBridgedMethod = BridgeMethodResolver.findBridgedMethod(method);

        // mapping is key, HandlerMethod is value
        registerHandlerMethod(handler, serviceMethod, mapping);

        processConverters(restRequestResource, mapping, serviceMethod);
    }
}