List of usage examples for org.springframework.util StringUtils commaDelimitedListToStringArray
public static String[] commaDelimitedListToStringArray(@Nullable String str)
From source file:nivance.simplecass.cassandra.core.CassandraClusterFactory.java
public void initCluster() { Cluster.Builder builder = Cluster.builder(); builder.addContactPoints(StringUtils.commaDelimitedListToStringArray(contactPoints)).withPort(port); builder.withCompression(Compression.NONE); {// www . j a v a2 s . co m PoolingOptions options = new PoolingOptions(); options.setCoreConnectionsPerHost(HostDistance.LOCAL, 100); options.setMaxConnectionsPerHost(HostDistance.LOCAL, 200); options.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, 200); options.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, 50); options.setCoreConnectionsPerHost(HostDistance.REMOTE, 50); options.setMaxConnectionsPerHost(HostDistance.REMOTE, 100); options.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, 200); options.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, 50); builder.withPoolingOptions(options); } { SocketOptions options = new SocketOptions(); options.setConnectTimeoutMillis(20 * 1000); options.setKeepAlive(true); options.setTcpNoDelay(true); options.setReadTimeoutMillis(20 * 1000); options.setReceiveBufferSize(8192); options.setSendBufferSize(8192); options.setReuseAddress(true); builder.withSocketOptions(options); } LoadBalancingPolicy loadBalancingPolicy = Policies.defaultLoadBalancingPolicy(); ReconnectionPolicy reconnectionPolicy = new ConstantReconnectionPolicy(1000); RetryPolicy retryPolicy = Policies.defaultRetryPolicy(); builder.withLoadBalancingPolicy(loadBalancingPolicy); builder.withReconnectionPolicy(reconnectionPolicy); builder.withRetryPolicy(retryPolicy); if (!metricsEnabled) { builder.withoutMetrics(); } Cluster cluster = null; try { cluster = builder.build(); } catch (RuntimeException ex) { throw ex; } // initialize property this.cluster = cluster; }
From source file:org.focusns.common.web.widget.mvc.method.WidgetModelAttributeMethodProcessor.java
@Override protected void validateIfApplicable(WebDataBinder binder, MethodParameter parameter) { //// w w w . j a va2s . co m WebRequest webRequest = webRequestLocal.get(); String groupsStr = webRequest.getParameter("groups"); if (StringUtils.hasText(groupsStr)) { List<Object> hintList = new ArrayList<Object>(); String[] groups = StringUtils.commaDelimitedListToStringArray(groupsStr); for (String group : groups) { try { hintList.add(ClassUtils.forName(group, getClass().getClassLoader())); } catch (ClassNotFoundException e) { e.printStackTrace(); } } // hintList.add(Default.class); // Annotation[] annotations = parameter.getParameterAnnotations(); for (Annotation annot : annotations) { if (annot.annotationType().getSimpleName().startsWith("Valid")) { Object hints = hintList.toArray(new Object[hintList.size()]); binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] { hints }); } } } }
From source file:org.cloudfoundry.identity.varz.BootstrapTests.java
private GenericXmlApplicationContext getServletContext(String... resources) { String profiles = null;/*from www . ja v a2 s.c om*/ String[] resourcesToLoad = resources; if (!resources[0].endsWith(".xml")) { profiles = resources[0]; resourcesToLoad = new String[resources.length - 1]; System.arraycopy(resources, 1, resourcesToLoad, 0, resourcesToLoad.length); } GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load(resourcesToLoad); if (profiles != null) { context.getEnvironment().setActiveProfiles(StringUtils.commaDelimitedListToStringArray(profiles)); } // Simulate what happens in the webapp when the YamlServletProfileInitializer kicks in YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources( new Resource[] { new FileSystemResource("./src/test/resources/test/config/varz.yml") }); context.getEnvironment().getPropertySources() .addLast(new PropertiesPropertySource("servletProperties", factory.getObject())); context.refresh(); return context; }
From source file:org.cloudfoundry.identity.login.BootstrapTests.java
private GenericXmlApplicationContext getServletContext(String... resources) { String profiles = null;/*from w w w.j av a 2s.c om*/ String[] resourcesToLoad = resources; if (!resources[0].endsWith(".xml")) { profiles = resources[0]; resourcesToLoad = new String[resources.length - 1]; System.arraycopy(resources, 1, resourcesToLoad, 0, resourcesToLoad.length); } GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load(resourcesToLoad); if (profiles != null) { context.getEnvironment().setActiveProfiles(StringUtils.commaDelimitedListToStringArray(profiles)); } // Simulate what happens in the webapp when the YamlServletProfileInitializer kicks in YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources( new Resource[] { new FileSystemResource("./src/test/resources/test/config/login.yml") }); context.getEnvironment().getPropertySources() .addLast(new PropertiesPropertySource("servletProperties", factory.getObject())); context.refresh(); return context; }
From source file:org.cloudfoundry.identity.batch.BootstrapTests.java
private GenericXmlApplicationContext getServletContext(String... resources) { String profiles = null;//www . j a v a 2s. c om String[] resourcesToLoad = resources; if (!resources[0].endsWith(".xml")) { profiles = resources[0]; resourcesToLoad = new String[resources.length - 1]; System.arraycopy(resources, 1, resourcesToLoad, 0, resourcesToLoad.length); } GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load(resourcesToLoad); if (profiles != null) { context.getEnvironment().setActiveProfiles(StringUtils.commaDelimitedListToStringArray(profiles)); } // Simulate what happens in the webapp when the YamlServletProfileInitializer kicks in YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources( new Resource[] { new FileSystemResource("./src/test/resources/test/config/batch.yml") }); context.getEnvironment().getPropertySources() .addLast(new PropertiesPropertySource("servletProperties", factory.getObject())); context.refresh(); return context; }
From source file:org.cloudfoundry.identity.uaa.authentication.AuthzAuthenticationRequest.java
@Override public Collection<? extends GrantedAuthority> getAuthorities() { if (null != info.get("authorities")) { Collection<ExtendedUaaAuthority> returnAuthorities = new LinkedHashSet(); String[] authorities = StringUtils.commaDelimitedListToStringArray(info.get("authorities")); for (String authority : authorities) { returnAuthorities.add(new ExtendedUaaAuthority(authority, null)); }/*from w w w . ja v a 2 s. c om*/ return returnAuthorities; } else { return Collections.emptySet(); } }
From source file:com.reactive.hzdfs.JobRunner.java
@Override public void run() { future = job.mapper(new Mapper<Integer, String, String, Integer>() { /**//from ww w . j a va 2 s . c o m * */ private static final long serialVersionUID = 1L; @Override public void map(Integer key, String value, Context<String, Integer> context) { String[] splits = StringUtils.commaDelimitedListToStringArray(value); context.emit(splits[splits.length - 1], 1); } }).reducer(new ReducerFactory<String, Integer, Integer>() { /** * */ private static final long serialVersionUID = 1L; @Override public Reducer<Integer, Integer> newReducer(String key) { return new Reducer<Integer, Integer>() { int n = 0; @Override public void reduce(Integer value) { n += value; } @Override public Integer finalizeReduce() { return n; } }; } }).submit(); }
From source file:org.zilverline.web.CustomCollectionEditor.java
public void setAsText(String text) throws IllegalArgumentException { log.debug("In CustomCollectionEditor.setText for " + text); // create a String array to feed to setValue setValue(StringUtils.commaDelimitedListToStringArray(text)); }
From source file:com.bose.aem.spring.config.ConfigServicePropertySourceLocator.java
@Override public org.springframework.core.env.PropertySource<?> locate( org.springframework.core.env.Environment environment) { ConfigClientProperties client = this.defaults.override(environment); CompositePropertySource composite = new CompositePropertySource("configService"); RestTemplate restTemplate = this.restTemplate == null ? getSecureRestTemplate(client) : this.restTemplate; Exception error = null;//w w w.j a va2s . co m String errorBody = null; //logger.info("Fetching config from server at: " + client.getRawUri()); try { String[] labels = new String[] { "" }; if (StringUtils.hasText(client.getLabel())) { labels = StringUtils.commaDelimitedListToStringArray(client.getLabel()); } // Try all the labels until one works for (String label : labels) { Environment result = getRemoteEnvironment(restTemplate, client.getRawUri(), client.getName(), client.getProfile(), label.trim()); if (result != null) { // logger.info(String.format("Located environment: name=%s, profiles=%s, label=%s, version=%s", // result.getName(), // result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), // result.getLabel(), result.getVersion())); for (PropertySource source : result.getPropertySources()) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) source.getSource(); composite.addPropertySource(new MapPropertySource(source.getName(), map)); } return composite; } } } catch (HttpServerErrorException e) { error = e; if (MediaType.APPLICATION_JSON.includes(e.getResponseHeaders().getContentType())) { errorBody = e.getResponseBodyAsString(); } } catch (Exception e) { error = e; } if (client != null && client.isFailFast()) { throw new IllegalStateException( "Could not locate PropertySource and the fail fast property is set, failing", error); } // logger.warn("Could not locate PropertySource: " // + (errorBody == null ? error == null ? "label not found" : error.getMessage() : errorBody)); return null; }
From source file:org.cloudfoundry.identity.uaa.varz.VarzEndpointTests.java
@Test public void testVarzWithConfig() throws Exception { Properties properties = StringUtils.splitArrayElementsIntoProperties( StringUtils.commaDelimitedListToStringArray("foo=bar,password=spam,client.secret=baz"), "="); endpoint.setEnvironmentProperties(properties); Map<String, ?> varz = endpoint.getVarz("http://uua.vcap.me"); // System.err.println(varz); @SuppressWarnings("unchecked") Map<String, ?> map = (Map<String, ?>) varz.get("config"); assertNotNull(map);//from w ww. j a v a 2 s .co m assertTrue(map.containsKey("foo")); assertEquals("#", map.get("password")); assertEquals("#", map.get("client.secret")); }