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; }
/** * 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; }
/** * 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(); }
/** * 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)); } }
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; }
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; }
/** * 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; }
/** * 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; }
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; }
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); } }
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); } }
@Override protected boolean innerTest(CharSequence text) { if(text == null) { //obviously that '*' math null strings too return "*".equals(pattern); } return PatternMatchUtils.simpleMatch(pattern, text.toString()); }
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; }
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; }
private boolean isMatch(String name, String[] includes, String[] excludes) { if (ObjectUtils.isEmpty(includes) || PatternMatchUtils.simpleMatch(includes, name)) { return !PatternMatchUtils.simpleMatch(excludes, name); } return false; }
/** * 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; }
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; }
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; }
@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; }
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); }
@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; }
protected boolean isMatch(String methodName, String mappedName) { return PatternMatchUtils.simpleMatch(mappedName, methodName); }
/** * 通配符匹配 */ protected boolean isMatch(String methodName, String mappedName) { return PatternMatchUtils.simpleMatch(mappedName, methodName); }
@Override public boolean matches(String propertyName) { return PatternMatchUtils.simpleMatch(this.patterns, propertyName); }