Java Code Examples for org.springframework.util.StringUtils#commaDelimitedListToStringArray()
The following examples show how to use
org.springframework.util.StringUtils#commaDelimitedListToStringArray() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring4-understanding File: GroovyMarkupConfigurer.java License: Apache License 2.0 | 6 votes |
/** * Create a parent ClassLoader for Groovy to use as parent ClassLoader * when loading and compiling templates. */ protected ClassLoader createTemplateClassLoader() throws IOException { String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath()); List<URL> urls = new ArrayList<URL>(); for (String path : paths) { Resource[] resources = getApplicationContext().getResources(path); if (resources.length > 0) { for (Resource resource : resources) { if (resource.exists()) { urls.add(resource.getURL()); } } } } ClassLoader classLoader = getApplicationContext().getClassLoader(); return (urls.size() > 0 ? new URLClassLoader(urls.toArray(new URL[urls.size()]), classLoader) : classLoader); }
Example 2
Source Project: bdf3 File: ControlUtils.java License: Apache License 2.0 | 5 votes |
private static Set<String> getComponentPermissionSupportTypes() { if (componentPermissionSupportTypes != null) { return componentPermissionSupportTypes; } String componentPermissionSupportType = Configure.getString("bdf3.componentPermissionSupportType"); if (!StringUtils.isEmpty(componentPermissionSupportType)) { String[] types = StringUtils.commaDelimitedListToStringArray(componentPermissionSupportType); componentPermissionSupportTypes = new HashSet<>(); for (String t : types) { componentPermissionSupportTypes.add(t); } } return componentPermissionSupportTypes; }
Example 3
Source Project: lams File: AbstractPropertyLoadingBeanDefinitionParser.java License: GNU General Public License v2.0 | 5 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { location = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(location); String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 4
Source Project: spring4-understanding File: AbstractPropertyLoadingBeanDefinitionParser.java License: Apache License 2.0 | 5 votes |
@Override protected void doParse(Element element, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 5
Source Project: spring-cloud-config File: RedisEnvironmentRepository.java License: Apache License 2.0 | 5 votes |
@Override public Environment findOne(String application, String profile, String label) { String[] profiles = StringUtils.commaDelimitedListToStringArray(profile); Environment environment = new Environment(application, profiles, label, null, null); final List<String> keys = addKeys(application, Arrays.asList(profiles)); keys.forEach(it -> { Map<?, ?> m = redis.opsForHash().entries(it); environment.add(new PropertySource("redis:" + it, m)); }); return environment; }
Example 6
Source Project: spring-cloud-config File: JdbcEnvironmentRepository.java License: Apache License 2.0 | 5 votes |
@Override public Environment findOne(String application, String profile, String label) { String config = application; if (StringUtils.isEmpty(label)) { label = "master"; } if (StringUtils.isEmpty(profile)) { profile = "default"; } if (!profile.startsWith("default")) { profile = "default," + profile; } String[] profiles = StringUtils.commaDelimitedListToStringArray(profile); Environment environment = new Environment(application, profiles, label, null, null); if (!config.startsWith("application")) { config = "application," + config; } List<String> applications = new ArrayList<String>(new LinkedHashSet<>( Arrays.asList(StringUtils.commaDelimitedListToStringArray(config)))); List<String> envs = new ArrayList<String>( new LinkedHashSet<>(Arrays.asList(profiles))); Collections.reverse(applications); Collections.reverse(envs); for (String app : applications) { for (String env : envs) { Map<String, String> next = (Map<String, String>) this.jdbc.query(this.sql, new Object[] { app, env, label }, this.extractor); if (!next.isEmpty()) { environment.add(new PropertySource(app + "-" + env, next)); } } } return environment; }
Example 7
Source Project: cacheonix-core File: JbossCacheFlushingModel.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Sets the names of the nodes to remove from the cache. * * @param csvNodes * a comma-separated list of Strings containing the nodes to remove * from the cache */ public void setNodes(String csvNodes) { String[] newNodeFqns = null; if (csvNodes != null) { newNodeFqns = StringUtils.commaDelimitedListToStringArray(csvNodes); } setNodes(newNodeFqns); }
Example 8
Source Project: spring-analysis-note File: CacheAdviceParser.java License: MIT License | 5 votes |
<T extends CacheOperation.Builder> T merge(Element element, ReaderContext readerCtx, T builder) { String cache = element.getAttribute("cache"); // sanity check String[] localCaches = this.caches; if (StringUtils.hasText(cache)) { localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim()); } if (localCaches != null) { builder.setCacheNames(localCaches); } else { readerCtx.error("No cache specified for " + element.getNodeName(), element); } builder.setKey(getAttributeValue(element, "key", this.key)); builder.setKeyGenerator(getAttributeValue(element, "key-generator", this.keyGenerator)); builder.setCacheManager(getAttributeValue(element, "cache-manager", this.cacheManager)); builder.setCondition(getAttributeValue(element, "condition", this.condition)); if (StringUtils.hasText(builder.getKey()) && StringUtils.hasText(builder.getKeyGenerator())) { throw new IllegalStateException("Invalid cache advice configuration on '" + element.toString() + "'. Both 'key' and 'keyGenerator' attributes have been set. " + "These attributes are mutually exclusive: either set the SpEL expression used to" + "compute the key at runtime or set the name of the KeyGenerator bean to use."); } return builder; }
Example 9
Source Project: cacheonix-core File: OsCacheCachingModel.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Sets the cache groups from a comma-delimited list of values. * * @param csvGroups * the comma-delimited list of values containing the cache groups. */ public final void setGroups(String csvGroups) { String[] newGroups = null; if (StringUtils.hasText(csvGroups)) { newGroups = StringUtils.commaDelimitedListToStringArray(csvGroups); } setGroups(newGroups); }
Example 10
Source Project: spring4-understanding File: MethodExclusionMBeanInfoAssembler.java License: Apache License 2.0 | 5 votes |
/** * Set the mappings of bean keys to a comma-separated list of method names. * <p>These method names are <b>ignored</b> when creating the management interface. * <p>The property key must match the bean key and the property value must match * the list of method names. When searching for method names to ignore for a bean, * Spring will check these mappings first. */ public void setIgnoredMethodMappings(Properties mappings) { this.ignoredMethodMappings = new HashMap<String, Set<String>>(); for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) { String beanKey = (String) en.nextElement(); String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); this.ignoredMethodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames))); } }
Example 11
Source Project: lams File: MethodNameBasedMBeanInfoAssembler.java License: GNU General Public License v2.0 | 5 votes |
/** * Set the mappings of bean keys to a comma-separated list of method names. * The property key should match the bean key and the property value should match * the list of method names. When searching for method names for a bean, Spring * will check these mappings first. * @param mappings the mappins of bean keys to method names */ public void setMethodMappings(Properties mappings) { this.methodMappings = new HashMap<String, Set<String>>(); for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) { String beanKey = (String) en.nextElement(); String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); this.methodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames))); } }
Example 12
Source Project: lams File: MethodExclusionMBeanInfoAssembler.java License: GNU General Public License v2.0 | 5 votes |
/** * Set the mappings of bean keys to a comma-separated list of method names. * <p>These method names are <b>ignored</b> when creating the management interface. * <p>The property key must match the bean key and the property value must match * the list of method names. When searching for method names to ignore for a bean, * Spring will check these mappings first. */ public void setIgnoredMethodMappings(Properties mappings) { this.ignoredMethodMappings = new HashMap<String, Set<String>>(); for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) { String beanKey = (String) en.nextElement(); String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); this.ignoredMethodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames))); } }
Example 13
Source Project: spring-cloud-config File: CredhubEnvironmentRepository.java License: Apache License 2.0 | 5 votes |
@Override public Environment findOne(String application, String profilesList, String label) { if (StringUtils.isEmpty(profilesList)) { profilesList = DEFAULT_PROFILE; } if (StringUtils.isEmpty(label)) { label = DEFAULT_LABEL; } String[] profiles = StringUtils.commaDelimitedListToStringArray(profilesList); Environment environment = new Environment(application, profiles, label, null, null); for (String profile : profiles) { environment.add(new PropertySource( "credhub-" + application + "-" + profile + "-" + label, findProperties(application, profile, label))); if (!DEFAULT_APPLICATION.equals(application)) { addDefaultPropertySource(environment, DEFAULT_APPLICATION, profile, label); } } if (!Arrays.asList(profiles).contains(DEFAULT_PROFILE)) { addDefaultPropertySource(environment, application, DEFAULT_PROFILE, label); } if (!Arrays.asList(profiles).contains(DEFAULT_PROFILE) && !DEFAULT_APPLICATION.equals(application)) { addDefaultPropertySource(environment, DEFAULT_APPLICATION, DEFAULT_PROFILE, label); } return environment; }
Example 14
Source Project: blog_demos File: BeanDefinitionParserDelegate.java License: Apache License 2.0 | 4 votes |
/** * Return any patterns provided in the 'default-autowire-candidates' * attribute of the top-level {@code <beans/>} element. */ public String[] getAutowireCandidatePatterns() { String candidatePattern = this.defaults.getAutowireCandidates(); return (candidatePattern != null ? StringUtils.commaDelimitedListToStringArray(candidatePattern) : null); }
Example 15
Source Project: lams File: TxAdviceBeanDefinitionParser.java License: GNU General Public License v2.0 | 4 votes |
private void addRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String rollbackForValue) { String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(rollbackForValue); for (String typeName : exceptionTypeNames) { rollbackRules.add(new RollbackRuleAttribute(StringUtils.trimWhitespace(typeName))); } }
Example 16
Source Project: spring4-understanding File: UriComponentsBuilder.java License: Apache License 2.0 | 4 votes |
/** * Create a new {@code UriComponents} object from the URI associated with * the given HttpRequest while also overlaying with values from the headers * "Forwarded" (<a href="http://tools.ietf.org/html/rfc7239">RFC 7239</a>, or * "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if "Forwarded" is * not found. * @param request the source request * @return the URI components of the URI * @since 4.1.5 */ public static UriComponentsBuilder fromHttpRequest(HttpRequest request) { URI uri = request.getURI(); UriComponentsBuilder builder = UriComponentsBuilder.fromUri(uri); String scheme = uri.getScheme(); String host = uri.getHost(); int port = uri.getPort(); String forwardedHeader = request.getHeaders().getFirst("Forwarded"); if (StringUtils.hasText(forwardedHeader)) { String forwardedToUse = StringUtils.commaDelimitedListToStringArray(forwardedHeader)[0]; Matcher m = FORWARDED_HOST_PATTERN.matcher(forwardedToUse); if (m.find()) { host = m.group(1).trim(); } m = FORWARDED_PROTO_PATTERN.matcher(forwardedToUse); if (m.find()) { scheme = m.group(1).trim(); } } else { String hostHeader = request.getHeaders().getFirst("X-Forwarded-Host"); if (StringUtils.hasText(hostHeader)) { String[] hosts = StringUtils.commaDelimitedListToStringArray(hostHeader); String hostToUse = hosts[0]; if (hostToUse.contains(":")) { String[] hostAndPort = StringUtils.split(hostToUse, ":"); host = hostAndPort[0]; port = Integer.parseInt(hostAndPort[1]); } else { host = hostToUse; port = -1; } } String portHeader = request.getHeaders().getFirst("X-Forwarded-Port"); if (StringUtils.hasText(portHeader)) { String[] ports = StringUtils.commaDelimitedListToStringArray(portHeader); port = Integer.parseInt(ports[0]); } String protocolHeader = request.getHeaders().getFirst("X-Forwarded-Proto"); if (StringUtils.hasText(protocolHeader)) { String[] protocols = StringUtils.commaDelimitedListToStringArray(protocolHeader); scheme = protocols[0]; } } builder.scheme(scheme); builder.host(host); builder.port(null); if (scheme.equals("http") && port != 80 || scheme.equals("https") && port != 443) { builder.port(port); } return builder; }
Example 17
Source Project: spring-analysis-note File: GenericConversionServiceTests.java License: MIT License | 4 votes |
@Override public Integer[] convert(String source) { String[] srcArray = StringUtils.commaDelimitedListToStringArray(source); return Arrays.stream(srcArray).map(s -> s.substring(1)).map(Integer::valueOf).toArray(Integer[]::new); }
Example 18
Source Project: lams File: TxAdviceBeanDefinitionParser.java License: GNU General Public License v2.0 | 4 votes |
private void addNoRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String noRollbackForValue) { String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(noRollbackForValue); for (String typeName : exceptionTypeNames) { rollbackRules.add(new NoRollbackRuleAttribute(StringUtils.trimWhitespace(typeName))); } }
Example 19
Source Project: spring4-understanding File: VelocityEngineFactory.java License: Apache License 2.0 | 4 votes |
/** * Initialize a Velocity resource loader for the given VelocityEngine: * either a standard Velocity FileResourceLoader or a SpringResourceLoader. * <p>Called by {@code createVelocityEngine()}. * @param velocityEngine the VelocityEngine to configure * @param resourceLoaderPath the path to load Velocity resources from * @see org.apache.velocity.runtime.resource.loader.FileResourceLoader * @see SpringResourceLoader * @see #initSpringResourceLoader * @see #createVelocityEngine() */ protected void initVelocityResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath) { if (isPreferFileSystemAccess()) { // Try to load via the file system, fall back to SpringResourceLoader // (for hot detection of template changes, if possible). try { StringBuilder resolvedPath = new StringBuilder(); String[] paths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath); for (int i = 0; i < paths.length; i++) { String path = paths[i]; Resource resource = getResourceLoader().getResource(path); File file = resource.getFile(); // will fail if not resolvable in the file system if (logger.isDebugEnabled()) { logger.debug("Resource loader path [" + path + "] resolved to file [" + file.getAbsolutePath() + "]"); } resolvedPath.append(file.getAbsolutePath()); if (i < paths.length - 1) { resolvedPath.append(','); } } velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "file"); velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true"); velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, resolvedPath.toString()); } catch (IOException ex) { if (logger.isDebugEnabled()) { logger.debug("Cannot resolve resource loader path [" + resourceLoaderPath + "] to [java.io.File]: using SpringResourceLoader", ex); } initSpringResourceLoader(velocityEngine, resourceLoaderPath); } } else { // Always load via SpringResourceLoader // (without hot detection of template changes). if (logger.isDebugEnabled()) { logger.debug("File system access not preferred: using SpringResourceLoader"); } initSpringResourceLoader(velocityEngine, resourceLoaderPath); } }
Example 20
Source Project: java-technology-stack File: AbstractAspectJAdvice.java License: MIT License | 2 votes |
/** * Set by creator of this advice object if the argument names are known. * <p>This could be for example because they have been explicitly specified in XML, * or in an advice annotation. * @param argNames comma delimited list of arg names */ public void setArgumentNames(String argNames) { String[] tokens = StringUtils.commaDelimitedListToStringArray(argNames); setArgumentNamesFromStringArray(tokens); }