List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:com.github.safrain.remotegsh.server.RgshFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { if (filterConfig.getInitParameter("charset") != null) { charset = filterConfig.getInitParameter("charset"); } else {// w ww. j ava 2s. com charset = DEFAULT_CHARSET; } if (filterConfig.getInitParameter("shellSessionTimeout") != null) { shellSessionTimeout = Long.valueOf(filterConfig.getInitParameter("shellSessionTimeout")); } else { shellSessionTimeout = SESSION_PURGE_INTERVAL; } String scriptExtensionCharset; if (filterConfig.getInitParameter("scriptExtensionCharset") != null) { scriptExtensionCharset = filterConfig.getInitParameter("scriptExtensionCharset"); } else { scriptExtensionCharset = DEFAULT_CHARSET; } //Compile script extensions List<String> scriptExtensionPaths = new ArrayList<String>(); if (filterConfig.getInitParameter("scriptExtensions") != null) { Collections.addAll(scriptExtensionPaths, filterConfig.getInitParameter("scriptExtensions").split(",")); } else { scriptExtensionPaths.add(RESOURCE_PATH + "extension/spring.groovy"); } scriptExtensions = new HashMap<String, CompiledScript>(); for (String path : scriptExtensionPaths) { String scriptContent; try { scriptContent = getResource(path, scriptExtensionCharset); } catch (IOException e) { throw new ServletException(e); } Compilable compilable = (Compilable) createGroovyEngine(); try { CompiledScript compiledScript = compilable.compile(scriptContent); scriptExtensions.put(path, compiledScript); } catch (ScriptException e) { //Ignore exceptions while compiling script extensions,there may be compilation errors due to missing dependency log.log(Level.WARNING, String.format("Error compiling script extension '%s'", path), e); } } // Setup a timer to purge timeout shell sessions Timer timer = new Timer("Remote Groovy Shell session purge daemon", true); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { purgeTimeOutSessions(); } }, 0, SESSION_PURGE_INTERVAL); }
From source file:com.github.philippn.springremotingautoconfigure.client.annotation.HttpInvokerProxyFactoryBeanRegistrar.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { Set<String> basePackages = new HashSet<>(); for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition definition = registry.getBeanDefinition(beanName); if (definition.getBeanClassName() != null) { try { Class<?> resolvedClass = ClassUtils.forName(definition.getBeanClassName(), null); EnableHttpInvokerAutoProxy autoProxy = AnnotationUtils.findAnnotation(resolvedClass, EnableHttpInvokerAutoProxy.class); if (autoProxy != null) { if (autoProxy.basePackages().length > 0) { Collections.addAll(basePackages, autoProxy.basePackages()); } else { basePackages.add(resolvedClass.getPackage().getName()); }/*from w ww . j a va 2s.co m*/ } } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to inspect class " + definition.getBeanClassName() + " for @EnableHttpInvokerAutoProxy annotations"); } } } ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false) { /* (non-Javadoc) * @see org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider#isCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) */ @Override protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { return beanDefinition.getMetadata().isInterface() && beanDefinition.getMetadata().isIndependent(); } }; scanner.addIncludeFilter(new AnnotationTypeFilter(RemoteExport.class)); for (String basePackage : basePackages) { for (BeanDefinition definition : scanner.findCandidateComponents(basePackage)) { if (definition.getBeanClassName() != null) { try { Class<?> resolvedClass = ClassUtils.forName(definition.getBeanClassName(), null); setupProxy(resolvedClass, registry); } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to inspect class " + definition.getBeanClassName() + " for @RemoteExport annotations"); } } } } }
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get information and layers of WMTS server indicated by url parameter * * @param request the {@code HttpServletRequest}. * @return ResponseEntity with wmtsInfo/* w ww . ja v a 2s .c o m*/ */ @RequestMapping(params = "findWmtsCapabilities", headers = "Accept=application/json", produces = { "application/json; charset=UTF-8" }) @ResponseBody public ResponseEntity<WMTSInfo> findWmtsCapabilitiesByAjax(WebRequest request) { String urlServer = request.getParameter("url"); boolean useCrsSelected = Boolean.parseBoolean(request.getParameter("useCrsSelected")); String crsParam = request.getParameter("crs"); TreeSet<String> listCrs = new TreeSet<String>(); if (StringUtils.isNotEmpty(crsParam)) { Collections.addAll(listCrs, crsParam.split(",")); } WMTSInfo wmtsInfo = null; if (StringUtils.isNotEmpty(urlServer)) { wmtsInfo = ogcInfoServ.getCapabilitiesFromWMTS(urlServer, listCrs, useCrsSelected); } return new ResponseEntity<WMTSInfo>(wmtsInfo, HttpStatus.OK); }
From source file:com.qpark.eip.core.spring.auth.DatabaseUserProvider.java
/** * Read the {@link AuthenticationType}s out of the database and put the * mapped {@link User} into the {@value #userMap}. *///from www .ja va2 s .com private void setupUserMap() { this.logger.trace("+setupUserMap"); List<AuthenticationType> auths = this.authorityDao.getAuthenticationTypes(Boolean.TRUE); this.logger.trace(" setupUserMap found {} AuthenticationTypes", auths.size()); /* Add all defined users. */ for (AuthenticationType auth : auths) { this.userMap.put(auth.getUserName(), this.getUser(auth)); } /* Remove not existing users out of the user map. */ List<String> userNames = new ArrayList<String>(this.userMap.size()); Collections.addAll(userNames, this.userMap.keySet().toArray(new String[this.userMap.keySet().size()])); boolean foundUserNameInDatabase; for (String userName : userNames) { foundUserNameInDatabase = false; for (AuthenticationType auth : auths) { if (auth.getUserName().equals(userName)) { foundUserNameInDatabase = true; break; } } if (!foundUserNameInDatabase) { this.userMap.remove(userName); } } this.logger.trace("-setupUserMap"); }
From source file:edu.ku.brc.specify.prefs.SystemPrefs.java
/** * Constructor./*from w ww. jav a2 s. c o m*/ */ public SystemPrefs() { createForm("Preferences", "System"); JButton clearCache = form.getCompById("clearcache"); clearCache.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearCache(); } }); ValBrowseBtnPanel browse = form.getCompById("7"); if (browse != null) { oldSplashPath = localPrefs.get(SPECIFY_BG_IMG_PATH, null); browse.setValue(oldSplashPath, null); } final ValComboBox localeCBX = form.getCompById("5"); localeCBX.getComboBox().setRenderer(new LocaleRenderer()); localeCBX.setEnabled(false); SwingWorker workerThread = new SwingWorker() { protected int inx = -1; @Override public Object construct() { Vector<Locale> locales = new Vector<Locale>(); Collections.addAll(locales, Locale.getAvailableLocales()); Collections.sort(locales, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName().compareTo(o2.getDisplayName()); } }); int i = 0; String language = AppPreferences.getLocalPrefs().get("locale.lang", Locale.getDefault().getLanguage()); String country = AppPreferences.getLocalPrefs().get("locale.country", Locale.getDefault().getCountry()); String variant = AppPreferences.getLocalPrefs().get("locale.var", Locale.getDefault().getVariant()); Locale prefLocale = new Locale(language, country, variant); int justLangIndex = -1; Locale cachedLocale = Locale.getDefault(); for (Locale l : locales) { try { Locale.setDefault(l); ResourceBundle rb = ResourceBundle.getBundle("resources", l); boolean isOK = (l.getLanguage().equals("en") && StringUtils.isEmpty(l.getCountry())) || (l.getLanguage().equals("pt") && l.getCountry().equals("PT")); if (isOK && rb.getKeys().hasMoreElements()) { if (l.getLanguage().equals(prefLocale.getLanguage())) { justLangIndex = i; } if (l.equals(prefLocale)) { inx = i; } localeCBX.getComboBox().addItem(l); i++; } } catch (MissingResourceException ex) { } } if (inx == -1 && justLangIndex > -1) { inx = justLangIndex; } Locale.setDefault(cachedLocale); return null; } @Override public void finished() { UIValidator.setIgnoreAllValidation("SystemPrefs", true); localeCBX.setEnabled(true); localeCBX.getComboBox().setSelectedIndex(inx); JTextField loadingLabel = form.getCompById("6"); if (loadingLabel != null) { loadingLabel.setText(UIRegistry.getResourceString("LOCALE_RESTART_REQUIRED")); } UIValidator.setIgnoreAllValidation("SystemPrefs", false); } }; // start the background task workerThread.start(); ValCheckBox chk = form.getCompById("2"); chk.setValue(localPrefs.getBoolean(VERSION_CHECK, true), "true"); chk = form.getCompById("3"); chk.setValue(remotePrefs.getBoolean(SEND_STATS, true), "true"); chk = form.getCompById("9"); chk.setValue(remotePrefs.getBoolean(SEND_ISA_STATS, true), "true"); chk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection collection = AppContextMgr.getInstance().getClassObject(Collection.class); if (collection != null) { String isaNumber = collection.getIsaNumber(); if (StringUtils.isNotEmpty(isaNumber) && !((JCheckBox) e.getSource()).isSelected()) { UIRegistry.showLocalizedMsg("ISA_STATS_WARNING"); } } } }); // Not sure why the form isn't picking up the pref automatically /* remove if worldwind is broken*/ValCheckBox useWWChk = form.getCompById(USE_WORLDWIND); /* remove if worldwind is broken*/ValCheckBox hasOGLChk = form.getCompById(SYSTEM_HasOpenGL); /* remove if worldwind is broken*/useWWChk.setValue(localPrefs.getBoolean(USE_WORLDWIND, false), null); /* remove if worldwind is broken*/hasOGLChk.setValue(localPrefs.getBoolean(SYSTEM_HasOpenGL, false), null); /* remove if worldwind is broken*/hasOGLChk.setEnabled(false); //ValCheckBox askCollChk = form.getCompById(ALWAYS_ASK_COLL); //askCollChk.setValue(localPrefs.getBoolean(ALWAYS_ASK_COLL, false), null); }
From source file:org.jdesktop.swingworker.AccumulativeRunnable.java
/** * appends arguments and sends this {@code Runnable} for the * execution if needed.//from w ww . j ava2 s .co m * <p> * This implementation uses {@see #submit} to send this * {@code Runnable} for execution. * @param args the arguments to accumulate */ public final synchronized void add(T... args) { boolean isSubmitted = true; if (arguments == null) { isSubmitted = false; arguments = new ArrayList<T>(); } Collections.addAll(arguments, args); if (!isSubmitted) { submit(); } }
From source file:com.asakusafw.compiler.bootstrap.OperatorCompilerDriver.java
private static List<String> toArguments(File sourcePath, File outputPath, Charset encoding) { assert sourcePath != null; assert outputPath != null; assert encoding != null; List<String> results = Lists.create(); Collections.addAll(results, "-proc:only"); //$NON-NLS-1$ Collections.addAll(results, "-source", "1.6"); //$NON-NLS-1$ //$NON-NLS-2$ Collections.addAll(results, "-target", "1.6"); //$NON-NLS-1$ //$NON-NLS-2$ Collections.addAll(results, "-encoding", encoding.displayName()); //$NON-NLS-1$ Collections.addAll(results, "-sourcepath", sourcePath.getAbsolutePath()); //$NON-NLS-1$ Collections.addAll(results, "-s", outputPath.getAbsolutePath()); //$NON-NLS-1$ return results; }
From source file:org.neo4j.nlp.examples.author.main.java
private static void trainOnText(String[] text, String[] label) { List<String> labelSet = new ArrayList<>(); List<String> textSet = new ArrayList<>(); Collections.addAll(labelSet, label); Collections.addAll(textSet, text); JsonArray labelArray = new JsonArray(); JsonArray textArray = new JsonArray(); labelSet.forEach((s) -> labelArray.add(new JsonPrimitive(s))); textSet.forEach((s) -> textArray.add(new JsonPrimitive(s))); JsonObject jsonParam = new JsonObject(); jsonParam.add("text", textArray); jsonParam.add("label", labelArray); jsonParam.add("focus", new JsonPrimitive(2)); String jsonPayload = new Gson().toJson(jsonParam); System.out.println(executePost("http://localhost:7474/service/graphify/training", jsonPayload)); }
From source file:nc.noumea.mairie.appock.viewmodel.ListeCommandeServiceTermineViewModel.java
public List<EtatCommandeService> getListeEtatCommandeService() { List<EtatCommandeService> result = new ArrayList<>(); result.add(null);//from www .j a v a 2s . c om Collections.addAll(result, EtatCommandeService.values()); return result; }
From source file:com.evolveum.midpoint.prism.path.ItemPath.java
public ItemPath(ItemPathSegment... segments) { this.segments = new ArrayList<>(segments.length); Collections.addAll(this.segments, segments); }