当前位置: 首页>>代码示例>>Java>>正文


Java AntPathMatcher类代码示例

本文整理汇总了Java中org.springframework.util.AntPathMatcher的典型用法代码示例。如果您正苦于以下问题:Java AntPathMatcher类的具体用法?Java AntPathMatcher怎么用?Java AntPathMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AntPathMatcher类属于org.springframework.util包,在下文中一共展示了AntPathMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFile

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
@RequestMapping(value = "/{solution}/**", method = {RequestMethod.GET, RequestMethod.HEAD})
@ResponseBody
public ResponseEntity<FileSystemResource> getFile(@PathVariable("solution") String solution,
		HttpServletRequest request) {
	String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
	String bestMatchPattern = (String ) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
    AntPathMatcher apm = new AntPathMatcher();
    path = apm.extractPathWithinPattern(bestMatchPattern, path);
    File file = fileService.getFile(solution, path);
	if (file.exists() && file.isFile()) {
		try {
			String detect = tika.detect(file);
			MediaType mediaType = MediaType.parseMediaType(detect);
			return ResponseEntity.ok()
					.contentLength(file.length())
					.contentType(mediaType)
					.lastModified(file.lastModified())
					.body(new FileSystemResource(file));
		} catch (IOException e) {
			e.printStackTrace();
		}
	} else {
           throw new ResourceNotFoundException();
       }
	return null;
}
 
开发者ID:Itema-as,项目名称:dawn-marketplace-server,代码行数:27,代码来源:FileController.java

示例2: dotPathSeparator

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
@Test
public void dotPathSeparator() {
	DotPathSeparatorController controller = new DotPathSeparatorController();

	this.messageHandler.setPathMatcher(new AntPathMatcher("."));
	this.messageHandler.registerHandler(controller);
	this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));

	Message<?> message = createMessage("/app1/pre.foo");
	this.messageHandler.registerHandler(this.testController);
	this.messageHandler.handleMessage(message);

	assertEquals("handleFoo", controller.method);

	message = createMessage("/app2/pre.foo");
	this.messageHandler.handleMessage(message);

	assertEquals("handleFoo", controller.method);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:SimpAnnotationMethodMessageHandlerTests.java

示例3: PatternsRequestCondition

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Private constructor accepting a collection of patterns.
 */
private PatternsRequestCondition(Collection<String> patterns, UrlPathHelper urlPathHelper,
		PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch,
		List<String> fileExtensions) {

	this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
	this.pathHelper = (urlPathHelper != null ? urlPathHelper : new UrlPathHelper());
	this.pathMatcher = (pathMatcher != null ? pathMatcher : new AntPathMatcher());
	this.useSuffixPatternMatch = useSuffixPatternMatch;
	this.useTrailingSlashMatch = useTrailingSlashMatch;
	if (fileExtensions != null) {
		for (String fileExtension : fileExtensions) {
			if (fileExtension.charAt(0) != '.') {
				fileExtension = "." + fileExtension;
			}
			this.fileExtensions.add(fileExtension);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:PatternsRequestCondition.java

示例4: registerPathMatcher

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher}
 * under that well-known name, unless already registered.
 * @return a RuntimeBeanReference to this {@link PathMatcher} instance
 */
public static RuntimeBeanReference registerPathMatcher(RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {
	if (pathMatcherRef != null) {
		if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
			parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
		}
		parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
	}
	else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
			&& !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
		RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
		pathMatcherDef.setSource(source);
		pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef);
		parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME));
	}
	return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:MvcNamespaceUtils.java

示例5: getInterceptorsForPath

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
	PathMatcher pathMatcher = new AntPathMatcher();
	List<HandlerInterceptor> result = new ArrayList<HandlerInterceptor>();
	for (Object interceptor : this.registry.getInterceptors()) {
		if (interceptor instanceof MappedInterceptor) {
			MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor;
			if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
				result.add(mappedInterceptor.getInterceptor());
			}
		}
		else if (interceptor instanceof HandlerInterceptor) {
			result.add((HandlerInterceptor) interceptor);
		}
		else {
			fail("Unexpected interceptor type: " + interceptor.getClass().getName());
		}
	}
	return result;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:InterceptorRegistryTests.java

示例6: getLogs

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
@Override
public List<Log> getLogs() throws IOException {
	final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
	resolver.setPathMatcher(new AntPathMatcher());
	final Resource[] resources = resolver.getResources("file:" + getPattern());
	final ArrayList<Log> logs = new ArrayList<Log>(resources.length);
	// TODO Decouple direct file log association
	for (int i = 0; i < resources.length; i++) {
		if (resources[i].exists()) {
			if (resources[i].getFile().isFile()) {
				logs.add(new FileLog(resources[i].getFile()));
			}
		} else {
			logger.info("Ignore not existent file: {}", resources[i].getFile());
		}
	}
	return logs;
}
 
开发者ID:logsniffer,项目名称:logsniffer,代码行数:19,代码来源:WildcardLogsSource.java

示例7: configureMessageBroker

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
@Override
public void configureMessageBroker(final MessageBrokerRegistry config) {
  // to support stomp over websockets natively...
  logger.warn(" ~~> issue #24 - not using the spring stomp broker relay until it supports reactor 3");
  config.enableSimpleBroker("/topic");

  // to use the stomp support built into RabbitMQ...
  // NOTE: not using this due to https://github.com/the-james-burton/the-turbine/issues/24
  // config.enableStompBrokerRelay("/topic", "/queue")
  //     .setRelayHost("localhost")
  //     .setRelayPort(61613)
  //     .setSystemLogin("guest")
  //     .setSystemPasscode("guest");
  // // .setVirtualHost("/");

  config.setApplicationDestinationPrefixes("/app");
  config.setPathMatcher(new AntPathMatcher("."));
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:19,代码来源:WebSocketConfig.java

示例8: initCache

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
private void initCache(List<Object> controllers){
    if(null == mappingCache){
        mappingCache = new HashMap<String, Action>();
    }
    AntPathMatcher matcher = new AntPathMatcher();
    for(Object bean : controllers){
        Class<?> clazz = bean.getClass();
        List<Method> methods = ReflectUtil.getPublicMethods(clazz);
        String mapping = getMapping(clazz);
        log.info(clazz.getName());
        for(Method method : methods){
            String returnType = method.getReturnType().getName();
            if(!(void.class.getName().equals(returnType) || String.class.getName().equals(returnType))){
                continue;
            }
            String resource =  mapping + method.getName();
            String[] argNames = ReflectUtil.getMethodArgNames(clazz.getName(), method.getName());
            Action action = new Action(bean, method, method.getParameterTypes(), argNames, resource);
            action.setInterceptors(this.interceptorConfigBean.getInterceptors(resource, matcher));
            mappingCache.put(resource, action);
            log.info(resource);
        }
    }
}
 
开发者ID:nullcodeexecutor,项目名称:rural,代码行数:25,代码来源:RuralContext.java

示例9: setup

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
@Before
public void setup() {
	MockitoAnnotations.initMocks(this);
	when(this.clientOutboundChannel.send(any(WampMessage.class))).thenReturn(true);

	DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
	MethodParameterConverter paramConverter = new MethodParameterConverter(
			new ObjectMapper(), conversionService);
	this.messageHandler = new WampAnnotationMethodMessageHandler(
			this.clientInboundChannel, this.clientOutboundChannel,
			this.eventMessenger, conversionService, paramConverter,
			new AntPathMatcher(), WampMessageSelectors.ACCEPT_ALL,
			new GenericMessageConverter());

	@SuppressWarnings("resource")
	StaticApplicationContext applicationContext = new StaticApplicationContext();
	applicationContext.registerPrototype("annotatedTestService",
			AnnotatedTestService.class);
	applicationContext.refresh();
	this.messageHandler.setApplicationContext(applicationContext);
	this.messageHandler.afterPropertiesSet();

	this.messageHandler.start();
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:25,代码来源:WampAnnotationMethodMessageHandlerTest.java

示例10: PatternsRequestCondition

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Private constructor accepting a collection of patterns.
 */
private PatternsRequestCondition(Collection<String> patterns, UrlPathHelper urlPathHelper,
		PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch,
		List<String> fileExtensions) {

	this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
	this.pathHelper = urlPathHelper != null ? urlPathHelper : new UrlPathHelper();
	this.pathMatcher = pathMatcher != null ? pathMatcher : new AntPathMatcher();
	this.useSuffixPatternMatch = useSuffixPatternMatch;
	this.useTrailingSlashMatch = useTrailingSlashMatch;
	if (fileExtensions != null) {
		for (String fileExtension : fileExtensions) {
			if (fileExtension.charAt(0) != '.') {
				fileExtension = "." + fileExtension;
			}
			this.fileExtensions.add(fileExtension);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:PatternsRequestCondition.java

示例11: getInterceptorsForPath

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
	PathMatcher pathMatcher = new AntPathMatcher();
	List<HandlerInterceptor> result = new ArrayList<HandlerInterceptor>();
	for (Object i : registry.getInterceptors()) {
		if (i instanceof MappedInterceptor) {
			MappedInterceptor mappedInterceptor = (MappedInterceptor) i;
			if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
				result.add(mappedInterceptor.getInterceptor());
			}
		}
		else if (i instanceof HandlerInterceptor){
			result.add((HandlerInterceptor) i);
		}
		else {
			fail("Unexpected interceptor type: " + i.getClass().getName());
		}
	}
	return result;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:InterceptorRegistryTests.java

示例12: getBeanNameFromRequest

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Try to match a ant url pattern in url mapping and return the UI bean name
 * @param request vaadin request
 * @return the bean name for request, null if none.
 */
protected String getBeanNameFromRequest(VaadinRequest request) {
	String beanName = null;
	String pathInfo = request.getPathInfo();
	
	if (this.pathMatcher == null)
		this.pathMatcher = new AntPathMatcher();
	
	for (String pattern : this.urlMap.keySet())  {
		if (log.isDebugEnabled())
			log.debug("Matching pattern [" + pattern + "] over path info [" + pathInfo + "]");
		
		if (this.pathMatcher.match(pattern, request.getPathInfo())) {
			beanName = this.urlMap.get(pattern);
			if (log.isDebugEnabled())
				log.debug("Matching success. Using bean name  [" + beanName + "]");
			
			break;
		}
	}
		
	if (beanName == null)
		beanName = request.getPathInfo();
	
	return beanName;
}
 
开发者ID:chelu,项目名称:jdal,代码行数:31,代码来源:UrlBeanNameUiMapping.java

示例13: getRegisteredService

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Gets the registered service by id that would either match an ant or regex pattern.
 *
 * @param id the id
 * @return the registered service
 */
private AbstractRegisteredService getRegisteredService(@NotNull final String id) {
    if (RegexUtils.isValidRegex(id)) {
        return new RegexRegisteredService();
    }

    if (new AntPathMatcher().isPattern(id)) {
        return new RegisteredServiceImpl();
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:DefaultLdapRegisteredServiceMapper.java

示例14: determineServiceTypeByPattern

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Determine service type by pattern.
 *
 * @param serviceId the service id
 * @return the abstract registered service
 */
private AbstractRegisteredService determineServiceTypeByPattern(final String serviceId) {
    try {
        Pattern.compile(serviceId);
        LOGGER.debug("Service id {} is a valid regex.", serviceId);
        return new RegexRegisteredService();
    } catch (final PatternSyntaxException exception) {
        LOGGER.debug("Service id {} is not a valid regex. Checking ant patterns...", serviceId);
        if (new AntPathMatcher().isPattern(serviceId)) {
            LOGGER.debug("Service id {} is a valid ant pattern.", serviceId);
            return new RegisteredServiceImpl();
        }
    }
    throw new RuntimeException("Service id " + serviceId + " cannot be resolve to a service type");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:DefaultRegisteredServiceMapper.java

示例15: getRegisteredService

import org.springframework.util.AntPathMatcher; //导入依赖的package包/类
/**
 * Gets the registered service by id that would either match an ant or regex pattern.
 *
 * @param id the id
 * @return the registered service
 */
private AbstractRegisteredService getRegisteredService(@NotNull final String id) {
    if (isValidRegexPattern(id)) {
        return new RegexRegisteredService();
    }

    if (new AntPathMatcher().isPattern(id)) {
        return new RegisteredServiceImpl();
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:DefaultLdapRegisteredServiceMapper.java


注:本文中的org.springframework.util.AntPathMatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。