List of usage examples for org.springframework.util StringUtils tokenizeToStringArray
public static String[] tokenizeToStringArray(@Nullable String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens)
From source file:com.workingmouse.webservice.axis.SpringAxisServlet.java
/** * Instantiate the WebApplicationContext for the SpringAxisServlet, either a default * XmlWebApplicationContext or a custom context class if set. This implementation * expects custom contexts to implement ConfigurableWebApplicationContext. * Can be overridden in subclasses.// w w w .ja va2 s. c o m * * @throws org.springframework.beans.BeansException * if the context couldn't be initialized * * @see #setContextClass * * @see org.springframework.web.context.support.XmlWebApplicationContext */ protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException { if (LOG.isDebugEnabled()) { LOG.debug("Servlet with name '" + getServletName() + "' will try to create custom WebApplicationContext context of class '" + getContextClass().getName() + "'" + " using parent context [" + parent + "]"); } if (!ConfigurableWebApplicationContext.class.isAssignableFrom(getContextClass())) { throw new ApplicationContextException("Fatal initialization error in servlet with name '" + getServletName() + "': custom WebApplicationContext class [" + getContextClass().getName() + "] is not of type ConfigurableWebApplicationContext"); } ConfigurableWebApplicationContext wac = createContextInstance(); wac.setParent(parent); wac.setServletContext(getServletContext()); wac.setNamespace(getNamespace()); if (this.contextConfigLocation != null) { wac.setConfigLocations(StringUtils.tokenizeToStringArray(this.contextConfigLocation, ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS, true, true)); } wac.refresh(); return wac; }
From source file:org.impalaframework.web.servlet.ResourceServlet.java
/** * Set allowed resources as an comma separated String of URL patterns, e.g. "META-INF/** /*.js", The paths may be * any Ant-style pattern parsable by AntPathMatcher. * //www .ja v a2 s. com * @see AntPathMatcher */ public void setAllowedResourcePaths(String allowedResourcePaths) { this.allowedResourcePaths = new HashSet<String>( Arrays.asList(StringUtils.tokenizeToStringArray(allowedResourcePaths, ",", true, true))); }
From source file:org.impalaframework.web.servlet.ResourceServlet.java
/** * Set comma separated MIME types that should have gzip compression applied. Typically, gzip compression is only * useful for text based content. Ant-style patterns are supported, e.g. "text/*". * * @see AntPathMatcher/*from w w w . ja v a 2 s . c om*/ */ public void setCompressedMimeTypes(String compressedMimeTypes) { this.compressedMimeTypes = new HashSet<String>( Arrays.asList(StringUtils.tokenizeToStringArray(compressedMimeTypes, ",", true, true))); }
From source file:org.springframework.beans.factory.access.JndiBeanFactoryLocator.java
/** * Load/use a bean factory, as specified by a factoryKey which is a JNDI * address, of the form <code>java:comp/env/ejb/BeanFactoryPath</code>. The * contents of this JNDI location must be a string containing one or more * classpath resource names (separated by any of the delimiters * '<code>,; \t\n</code>' if there is more than one. The resulting * BeanFactory (or subclass) will be created from the combined resources. *///from www . j a va2 s.c o m public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException { String beanFactoryPath = null; try { beanFactoryPath = (String) (new JndiTemplate()).lookup(factoryKey); logger.info("BeanFactoryPath from JNDI is [" + beanFactoryPath + "]"); String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS, true, true); return createBeanFactory(paths); } catch (NamingException ex) { throw new BootstrapException("Define an environment variable 'ejb/BeanFactoryPath' containing " + "the class path locations of XML bean definition files", ex); } }
From source file:org.springframework.data.jdbc.config.oracle.RacFailoverInterceptorBeanDefinitionParser.java
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { //attributes//from w ww. j a va2s . c o m List<Integer> recoverableErrorCodesList = new ArrayList<Integer>(); String recoverableErrorCodes = element.getAttribute(RECOVERABLE_ERROR_CODES_ATTRIBUTE); if (StringUtils.hasText(recoverableErrorCodes)) { String[] parsedRecoverableErrorCodes = StringUtils.tokenizeToStringArray(recoverableErrorCodes, ",", true, true); for (int i = 0; i < parsedRecoverableErrorCodes.length; i++) { try { recoverableErrorCodesList.add(new Integer(parsedRecoverableErrorCodes[i])); } catch (NumberFormatException e) { parserContext.getReaderContext().error("Error parsing recoverable error code list: \"" + recoverableErrorCodes + "\"; " + e.getClass().getName() + " - " + e.getMessage(), element); } } if (logger.isDebugEnabled()) { logger.debug( "Using provided " + RECOVERABLE_ERROR_CODES_ATTRIBUTE + ": " + recoverableErrorCodesList); } } String maxNumberOfRetries = element.getAttribute(MAX_NUMBER_OF_RETRIES_ATTRIBUTE); if (logger.isDebugEnabled()) { if (StringUtils.hasText(maxNumberOfRetries)) { logger.debug("Using provided " + MAX_NUMBER_OF_RETRIES_ATTRIBUTE + ": " + maxNumberOfRetries); } } String backOffPolicyRef = null; if (element.hasAttribute(BACK_OFF_POLICY_ATTRIBUTE)) { backOffPolicyRef = element.getAttribute(BACK_OFF_POLICY_ATTRIBUTE); if (logger.isDebugEnabled()) { logger.debug("Using provided " + BACK_OFF_POLICY_ATTRIBUTE + ": " + backOffPolicyRef); } } BeanDefinitionBuilder retryTemplateBuilder = BeanDefinitionBuilder.genericBeanDefinition(); retryTemplateBuilder.getRawBeanDefinition().setBeanClassName(RETRY_TEMPLATE_CLASS); BeanDefinitionBuilder racFailoverRetryPolicyBuilder = BeanDefinitionBuilder.genericBeanDefinition(); racFailoverRetryPolicyBuilder.getRawBeanDefinition().setBeanClassName(RAC_FAILOVER_RETRY_POLICY_CLASS); if (recoverableErrorCodesList.size() > 0) { racFailoverRetryPolicyBuilder.addPropertyValue(RECOVERABLE_ERROR_CODES_PROPERTY, recoverableErrorCodesList); } if (StringUtils.hasText(maxNumberOfRetries)) { racFailoverRetryPolicyBuilder.addPropertyValue(MAX_NUMBER_OF_RETRIES_PROPERTY, maxNumberOfRetries); } retryTemplateBuilder.addPropertyValue(RETRY_POLICY_PROPERTY, racFailoverRetryPolicyBuilder.getRawBeanDefinition()); if (StringUtils.hasText(backOffPolicyRef)) { retryTemplateBuilder.addPropertyReference(BACK_OFF_POLICY_PROPERTY, backOffPolicyRef); } builder.addPropertyValue(RETRY_OPERATIONS_PROPERTY, retryTemplateBuilder.getRawBeanDefinition()); if (logger.isDebugEnabled()) { logger.debug("Using retry policy: " + racFailoverRetryPolicyBuilder.getRawBeanDefinition().getBeanClassName()); } builder.setRole(BeanDefinition.ROLE_SUPPORT); }