Java 类org.springframework.util.PatternMatchUtils 实例源码

项目:spring-cloud-netflix-zuul-websocket    文件:ProxyWebSocketHandler.java   
private ZuulWebSocketProperties.WsBrokerage getWebSocketBrokarage(URI uri) {
    String path = uri.toString();
    if (path.contains(":")) {
        path = UriComponentsBuilder.fromUriString(path).build().getPath();
    }

    for (Map.Entry<String, ZuulWebSocketProperties.WsBrokerage> entry : zuulWebSocketProperties
            .getBrokerages().entrySet()) {
        ZuulWebSocketProperties.WsBrokerage wsBrokerage = entry.getValue();
        if (wsBrokerage.isEnabled()) {
            for (String endPoint : wsBrokerage.getEndPoints()) {
                if (PatternMatchUtils.simpleMatch(toPattern(endPoint), path + "/")) {
                    return wsBrokerage;
                }
            }
        }
    }

    return null;
}
项目:haven-platform    文件:ImagesForUpdate.java   
/**
 * Find image by its name, or id
 * @param name
 * @param imageId
 * @return
 */
public Image findImage(String name, String imageId) {
    Image res = null;
    if(imageId != null) {
        res = imagesByName.get(imageId);
    }
    String withoutTag = ImageName.withoutTagOrNull(name);
    if(res == null && withoutTag != null) {
        res = imagesByName.get(withoutTag);
    }
    if(res == null && (imageId != null || withoutTag != null)) {
        for(Image img: imagesWithPattern) {
            String pattern = img.getName();
            if(withoutTag != null && PatternMatchUtils.simpleMatch(pattern, withoutTag) ||
               imageId != null && PatternMatchUtils.simpleMatch(pattern, imageId)) {
                res = img;
                break;
            }
        }
    }
    return res;
}
项目:lams    文件:SQLErrorCodesFactory.java   
/**
 * Return the {@link SQLErrorCodes} instance for the given database.
 * <p>No need for a database metadata lookup.
 * @param dbName the database name (must not be {@code null})
 * @return the {@code SQLErrorCodes} instance for the given database
 * @throws IllegalArgumentException if the supplied database name is {@code null}
 */
public SQLErrorCodes getErrorCodes(String dbName) {
    Assert.notNull(dbName, "Database product name must not be null");

    SQLErrorCodes sec = this.errorCodesMap.get(dbName);
    if (sec == null) {
        for (SQLErrorCodes candidate : this.errorCodesMap.values()) {
            if (PatternMatchUtils.simpleMatch(candidate.getDatabaseProductNames(), dbName)) {
                sec = candidate;
                break;
            }
        }
    }
    if (sec != null) {
        checkCustomTranslatorRegistry(dbName, sec);
        if (logger.isDebugEnabled()) {
            logger.debug("SQL error codes for '" + dbName + "' found");
        }
        return sec;
    }

    // Could not find the database among the defined ones.
    if (logger.isDebugEnabled()) {
        logger.debug("SQL error codes for '" + dbName + "' not found");
    }
    return new SQLErrorCodes();
}
项目:lams    文件:ClassPathBeanDefinitionScanner.java   
/**
 * Apply further settings to the given bean definition,
 * beyond the contents retrieved from scanning the component class.
 * @param beanDefinition the scanned bean definition
 * @param beanName the generated bean name for the given bean
 */
protected void postProcessBeanDefinition(AbstractBeanDefinition beanDefinition, String beanName) {
    beanDefinition.applyDefaults(this.beanDefinitionDefaults);
    if (this.autowireCandidatePatterns != null) {
        beanDefinition.setAutowireCandidate(PatternMatchUtils.simpleMatch(this.autowireCandidatePatterns, beanName));
    }
}
项目:spring-cloud-netflix-zuul-websocket    文件:ProxyWebSocketHandler.java   
private String getWebSocketServerPath(ZuulWebSocketProperties.WsBrokerage wsBrokerage,
        URI uri) {
    String path = uri.toString();
    if (path.contains(":")) {
        path = UriComponentsBuilder.fromUriString(path).build().getPath();
    }

    for (String endPoint : wsBrokerage.getEndPoints()) {
        if (PatternMatchUtils.simpleMatch(toPattern(endPoint), path + "/")) {
            return endPoint;
        }
    }

    return null;
}
项目:spring4-understanding    文件:MessageHeaderAccessor.java   
private List<String> getMatchingHeaderNames(String pattern, Map<String, Object> headers) {
    List<String> matchingHeaderNames = new ArrayList<String>();
    if (headers != null) {
        for (String key : headers.keySet()) {
            if (PatternMatchUtils.simpleMatch(pattern, key)) {
                matchingHeaderNames.add(key);
            }
        }
    }
    return matchingHeaderNames;
}
项目:spring4-understanding    文件:ClassPathBeanDefinitionScanner.java   
/**
 * Apply further settings to the given bean definition,
 * beyond the contents retrieved from scanning the component class.
 * @param beanDefinition the scanned bean definition
 * @param beanName the generated bean name for the given bean
 */
protected void postProcessBeanDefinition(AbstractBeanDefinition beanDefinition, String beanName) {
    beanDefinition.applyDefaults(this.beanDefinitionDefaults);
    if (this.autowireCandidatePatterns != null) {
        beanDefinition.setAutowireCandidate(PatternMatchUtils.simpleMatch(this.autowireCandidatePatterns, beanName));
    }
}
项目:spring4-understanding    文件:SQLErrorCodesFactory.java   
/**
 * Return the {@link SQLErrorCodes} instance for the given database.
 * <p>No need for a database metadata lookup.
 * @param dbName the database name (must not be {@code null})
 * @return the {@code SQLErrorCodes} instance for the given database
 * @throws IllegalArgumentException if the supplied database name is {@code null}
 */
public SQLErrorCodes getErrorCodes(String dbName) {
    Assert.notNull(dbName, "Database product name must not be null");

    SQLErrorCodes sec = this.errorCodesMap.get(dbName);
    if (sec == null) {
        for (SQLErrorCodes candidate : this.errorCodesMap.values()) {
            if (PatternMatchUtils.simpleMatch(candidate.getDatabaseProductNames(), dbName)) {
                sec = candidate;
                break;
            }
        }
    }
    if (sec != null) {
        checkCustomTranslatorRegistry(dbName, sec);
        if (logger.isDebugEnabled()) {
            logger.debug("SQL error codes for '" + dbName + "' found");
        }
        return sec;
    }

    // Could not find the database among the defined ones.
    if (logger.isDebugEnabled()) {
        logger.debug("SQL error codes for '" + dbName + "' not found");
    }
    return new SQLErrorCodes();
}
项目:my-spring-cache-redis    文件:ClassPathBeanDefinitionScanner.java   
/**
 * Apply further settings to the given bean definition,
 * beyond the contents retrieved from scanning the component class.
 * @param beanDefinition the scanned bean definition
 * @param beanName the generated bean name for the given bean
 */
protected void postProcessBeanDefinition(AbstractBeanDefinition beanDefinition, String beanName) {
    beanDefinition.applyDefaults(this.beanDefinitionDefaults);
    if (this.autowireCandidatePatterns != null) {
        beanDefinition.setAutowireCandidate(PatternMatchUtils.simpleMatch(this.autowireCandidatePatterns, beanName));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AstUtils.java   
/**
 * Determine if an {@link AnnotatedNode} has one or more of the specified annotations.
 * N.B. the annotation type names are not normally fully qualified.
 * @param node the node to examine
 * @param annotations the annotations to look for
 * @return {@code true} if at least one of the annotations is found, otherwise
 * {@code false}
 */
public static boolean hasAtLeastOneAnnotation(AnnotatedNode node,
        String... annotations) {
    for (AnnotationNode annotationNode : node.getAnnotations()) {
        for (String annotation : annotations) {
            if (PatternMatchUtils.simpleMatch(annotation,
                    annotationNode.getClassNode().getName())) {
                return true;
            }
        }
    }
    return false;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricExportProperties.java   
/**
 * Find a matching trigger configuration.
 * @param name the bean name to match
 * @return a matching configuration if there is one
 */
public TriggerProperties findTrigger(String name) {
    for (SpecificTriggerProperties value : this.triggers.values()) {
        if (PatternMatchUtils.simpleMatch(value.getNames(), name)) {
            return value;
        }
    }
    return this;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricCopyExporter.java   
private boolean isMatch(Metric<?> metric) {
    String[] includes = MetricCopyExporter.this.includes;
    String[] excludes = MetricCopyExporter.this.excludes;
    String name = metric.getName();
    if (ObjectUtils.isEmpty(includes)
            || PatternMatchUtils.simpleMatch(includes, name)) {
        return !PatternMatchUtils.simpleMatch(excludes, name);
    }
    return false;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JobLauncherCommandLineRunner.java   
private void executeLocalJobs(JobParameters jobParameters)
        throws JobExecutionException {
    for (Job job : this.jobs) {
        if (StringUtils.hasText(this.jobNames)) {
            String[] jobsToRun = this.jobNames.split(",");
            if (!PatternMatchUtils.simpleMatch(jobsToRun, job.getName())) {
                logger.debug("Skipped job: " + job.getName());
                continue;
            }
        }
        execute(job, jobParameters);
    }
}
项目:haven-platform    文件:ImagesForUpdate.java   
private static boolean match(String pattern, String image, String imageId) {
    if(isAll(pattern)) {
        return true;
    }
    boolean isPattern = isPattern(pattern);
    if(ImageName.isId(image) && !isPattern) {
        return pattern.equals(imageId == null? image : imageId);
    }
    String imageVersion = ContainerUtils.getImageVersion(image);
    if(isPattern) {
        return PatternMatchUtils.simpleMatch(pattern, imageVersion);
    } else {
        return pattern.equals(imageVersion);
    }
}
项目:haven-platform    文件:PatternFilter.java   
@Override
protected boolean innerTest(CharSequence text) {
    if(text == null) {
        //obviously that '*' math null strings too
        return "*".equals(pattern);
    }
    return PatternMatchUtils.simpleMatch(pattern, text.toString());
}
项目:spring    文件:ClassPathBeanDefinitionScanner.java   
/**
 * Apply further settings to the given bean definition,
 * beyond the contents retrieved from scanning the component class.
 * @param beanDefinition the scanned bean definition
 * @param beanName the generated bean name for the given bean
 */
protected void postProcessBeanDefinition(AbstractBeanDefinition beanDefinition, String beanName) {
    beanDefinition.applyDefaults(this.beanDefinitionDefaults);
    if (this.autowireCandidatePatterns != null) {
        beanDefinition.setAutowireCandidate(PatternMatchUtils.simpleMatch(this.autowireCandidatePatterns, beanName));
    }
}
项目:spring-boot-concourse    文件:AstUtils.java   
/**
 * Determine if an {@link AnnotatedNode} has one or more of the specified annotations.
 * N.B. the annotation type names are not normally fully qualified.
 * @param node the node to examine
 * @param annotations the annotations to look for
 * @return {@code true} if at least one of the annotations is found, otherwise
 * {@code false}
 */
public static boolean hasAtLeastOneAnnotation(AnnotatedNode node,
        String... annotations) {
    for (AnnotationNode annotationNode : node.getAnnotations()) {
        for (String annotation : annotations) {
            if (PatternMatchUtils.simpleMatch(annotation,
                    annotationNode.getClassNode().getName())) {
                return true;
            }
        }
    }
    return false;
}
项目:spring-boot-concourse    文件:MetricExportProperties.java   
/**
 * Find a matching trigger configuration.
 * @param name the bean name to match
 * @return a matching configuration if there is one
 */
public TriggerProperties findTrigger(String name) {
    for (SpecificTriggerProperties value : this.triggers.values()) {
        if (PatternMatchUtils.simpleMatch(value.getNames(), name)) {
            return value;
        }
    }
    return this;
}
项目:spring-boot-concourse    文件:MetricCopyExporter.java   
private boolean isMatch(Metric<?> metric) {
    String[] includes = MetricCopyExporter.this.includes;
    String[] excludes = MetricCopyExporter.this.excludes;
    String name = metric.getName();
    if (ObjectUtils.isEmpty(includes)
            || PatternMatchUtils.simpleMatch(includes, name)) {
        return !PatternMatchUtils.simpleMatch(excludes, name);
    }
    return false;
}
项目:spring-boot-concourse    文件:JobLauncherCommandLineRunner.java   
private void executeLocalJobs(JobParameters jobParameters)
        throws JobExecutionException {
    for (Job job : this.jobs) {
        if (StringUtils.hasText(this.jobNames)) {
            String[] jobsToRun = this.jobNames.split(",");
            if (!PatternMatchUtils.simpleMatch(jobsToRun, job.getName())) {
                logger.debug("Skipped job: " + job.getName());
                continue;
            }
        }
        execute(job, jobParameters);
    }
}
项目:contestparser    文件:AstUtils.java   
/**
 * Determine if an {@link AnnotatedNode} has one or more of the specified annotations.
 * N.B. the annotation type names are not normally fully qualified.
 * @param node the node to examine
 * @param annotations the annotations to look for
 * @return {@code true} if at least one of the annotations is found, otherwise
 * {@code false}
 */
public static boolean hasAtLeastOneAnnotation(AnnotatedNode node,
        String... annotations) {
    for (AnnotationNode annotationNode : node.getAnnotations()) {
        for (String annotation : annotations) {
            if (PatternMatchUtils.simpleMatch(annotation,
                    annotationNode.getClassNode().getName())) {
                return true;
            }
        }
    }
    return false;
}
项目:contestparser    文件:MetricExportProperties.java   
/**
 * Find a matching trigger configuration.
 * @param name the bean name to match
 * @return a matching configuration if there is one
 */
public TriggerProperties findTrigger(String name) {
    for (SpecificTriggerProperties value : this.triggers.values()) {
        if (PatternMatchUtils.simpleMatch(value.getNames(), name)) {
            return value;
        }
    }
    return this;
}
项目:contestparser    文件:MetricCopyExporter.java   
private boolean isMatch(Metric<?> metric) {
    String[] includes = MetricCopyExporter.this.includes;
    String[] excludes = MetricCopyExporter.this.excludes;
    String name = metric.getName();
    if (ObjectUtils.isEmpty(includes)
            || PatternMatchUtils.simpleMatch(includes, name)) {
        return !PatternMatchUtils.simpleMatch(excludes, name);
    }
    return false;
}
项目:contestparser    文件:JobLauncherCommandLineRunner.java   
private void executeLocalJobs(JobParameters jobParameters)
        throws JobExecutionException {
    for (Job job : this.jobs) {
        if (StringUtils.hasText(this.jobNames)) {
            String[] jobsToRun = this.jobNames.split(",");
            if (!PatternMatchUtils.simpleMatch(jobsToRun, job.getName())) {
                logger.debug("Skipped job: " + job.getName());
                continue;
            }
        }
        execute(job, jobParameters);
    }
}
项目:ribbondemo    文件:DemoServerListFilter.java   
private List<Server> filter(List<Server> servers, String pattern) {
    List<Server> filtered = new ArrayList<>();
    for (Server server : servers) {
        if (PatternMatchUtils.simpleMatch(pattern, server.getId())) {
            filtered.add(server);
        }
    }
    return filtered;
}
项目:ribbondemo    文件:DemoLoadBalancer.java   
private Server filter(String pattern) {
    if (StringUtils.hasText(pattern)) {
        List<Server> servers = getServerList(true);
        for (Server server : servers) {
            if (PatternMatchUtils.simpleMatch(pattern, server.getId())) {
                return server;
            }
        }
    }
    return null;
}
项目:spring-cloud-stream    文件:ApplicationMetricsProperties.java   
private boolean isMatch(String name, String[] includes, String[] excludes) {
    if (ObjectUtils.isEmpty(includes)
            || PatternMatchUtils.simpleMatch(includes, name)) {
        return !PatternMatchUtils.simpleMatch(excludes, name);
    }
    return false;
}
项目:spring-cloud-stream    文件:ApplicationMetricsExporter.java   
/**
 * Copy of similarly named method in {@link MetricCopyExporter}.
 */
private boolean isMatch(String name, String[] includes, String[] excludes) {
    if (ObjectUtils.isEmpty(includes)
            || PatternMatchUtils.simpleMatch(includes, name)) {
        return !PatternMatchUtils.simpleMatch(excludes, name);
    }
    return false;
}
项目:class-guard    文件:ClassPathBeanDefinitionScanner.java   
/**
 * Apply further settings to the given bean definition,
 * beyond the contents retrieved from scanning the component class.
 * @param beanDefinition the scanned bean definition
 * @param beanName the generated bean name for the given bean
 */
protected void postProcessBeanDefinition(AbstractBeanDefinition beanDefinition, String beanName) {
    beanDefinition.applyDefaults(this.beanDefinitionDefaults);
    if (this.autowireCandidatePatterns != null) {
        beanDefinition.setAutowireCandidate(PatternMatchUtils.simpleMatch(this.autowireCandidatePatterns, beanName));
    }
}
项目:class-guard    文件:SQLErrorCodesFactory.java   
/**
 * Return the {@link SQLErrorCodes} instance for the given database.
 * <p>No need for a database metadata lookup.
 * @param dbName the database name (must not be {@code null})
 * @return the {@code SQLErrorCodes} instance for the given database
 * @throws IllegalArgumentException if the supplied database name is {@code null}
 */
public SQLErrorCodes getErrorCodes(String dbName) {
    Assert.notNull(dbName, "Database product name must not be null");

    SQLErrorCodes sec = this.errorCodesMap.get(dbName);
    if (sec == null) {
        for (SQLErrorCodes candidate : this.errorCodesMap.values()) {
            if (PatternMatchUtils.simpleMatch(candidate.getDatabaseProductNames(), dbName)) {
                sec = candidate;
                break;
            }
        }
    }
    if (sec != null) {
        checkCustomTranslatorRegistry(dbName, sec);
        if (logger.isDebugEnabled()) {
            logger.debug("SQL error codes for '" + dbName + "' found");
        }
        return sec;
    }

    // Could not find the database among the defined ones.
    if (logger.isDebugEnabled()) {
        logger.debug("SQL error codes for '" + dbName + "' not found");
    }
    return new SQLErrorCodes();
}
项目:spring-cloud-cli    文件:BaseStreamCompilerAutoConfiguration.java   
static boolean isTransport(ClassNode node, String type) {
    for (AnnotationNode annotationNode : node.getAnnotations()) {
        String annotation = "EnableBinding";
        if (PatternMatchUtils.simpleMatch(annotation,
                annotationNode.getClassNode().getName())) {
            Expression expression = annotationNode.getMembers().get("transport");
            String transport = expression == null ? "rabbit" : expression.getText();
            if (transport != null) {
                transport = SystemPropertyUtils.resolvePlaceholders(transport);
            }
            return transport.equals(type);
        }
    }
    return false;
}
项目:spring-cloud-config    文件:MultipleJGitEnvironmentRepository.java   
public boolean matches(String application, String profile, String label) {
    if (this.pattern == null || this.pattern.length == 0) {
        return false;
    }
    String[] profiles = StringUtils.commaDelimitedListToStringArray(profile);
    for (int i = profiles.length; i-- > 0;) {
        if (PatternMatchUtils.simpleMatch(this.pattern,
                application + "/" + profiles[i])) {
            return true;
        }
    }
    return false;
}
项目:spring-cloud-config    文件:MultipleJGitEnvironmentRepository.java   
@Override
public Environment findOne(String application, String profile, String label) {

    if (this.pattern == null || this.pattern.length == 0) {
        return null;
    }

    if (PatternMatchUtils.simpleMatch(this.pattern,
            application + "/" + profile)) {
        return super.findOne(application, profile, label);
    }

    return null;

}
项目:aspectj-in-action-code    文件:MappingBasedSecurityMetadataSource.java   
public List<ConfigAttribute> getAttributes(Object jp) {
    String methodName = ((JoinPoint) jp).getSignature().getName();
    for (String pattern : mapping.keySet()) {
        if (PatternMatchUtils.simpleMatch(pattern, methodName)) {
            String role = mapping.get(pattern);
            return SecurityConfig.createList(role);
        }
    }
    throw new IllegalArgumentException("Unknown mapping for " + methodName);
}
项目:aspectj-in-action-code    文件:MappingBasedSecurityMetadataSource.java   
public List<ConfigAttribute> getAttributes(Object jp) {
    String methodName = ((JoinPoint) jp).getSignature().getName();
    for (String pattern : mapping.keySet()) {
        if (PatternMatchUtils.simpleMatch(pattern, methodName)) {
            String role = mapping.get(pattern);
            return SecurityConfig.createList(role);
        }
    }
    throw new IllegalArgumentException("Unknown mapping for " + methodName);
}
项目:tsquare    文件:WildcardAggregatorFactory.java   
@Override
public Aggregator getAggregatorForMetric(String metricName) {
    for (final Map.Entry<String, Aggregator> entry : aggregatorsByWildcard.entrySet()) {
        if (PatternMatchUtils.simpleMatch(entry.getKey(), metricName)) {
            log.debug("Metric {} matched wildcard {} -> {}", metricName, entry.getKey(), entry.getValue());
            return entry.getValue();
        }
    }

    return null;
}
项目:asura    文件:ReadWriteDataSourceProcessor.java   
protected boolean isMatch(String methodName, String mappedName) {
    return PatternMatchUtils.simpleMatch(mappedName, methodName);
}
项目:spring-boot-starter-dynamic-datasource    文件:DataSourceAspect.java   
/**
 * 通配符匹配
 */
protected boolean isMatch(String methodName, String mappedName) {
    return PatternMatchUtils.simpleMatch(mappedName, methodName);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PatternPropertyNamePatternsMatcher.java   
@Override
public boolean matches(String propertyName) {
    return PatternMatchUtils.simpleMatch(this.patterns, propertyName);
}
项目:spring-boot-concourse    文件:PatternPropertyNamePatternsMatcher.java   
@Override
public boolean matches(String propertyName) {
    return PatternMatchUtils.simpleMatch(this.patterns, propertyName);
}