List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:com.khartec.waltz.jobs.sample.AppGenerator.java
public static void main(String[] args) throws IOException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); ApplicationService applicationDao = ctx.getBean(ApplicationService.class); OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class); List<String> animals = IOUtilities .readLines(AppGenerator.class.getClassLoader().getResourceAsStream("animals.txt")); OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]); List<AppRegistrationRequest> registrationRequests = new ArrayList<>(); for (int i = 0; i < 5000; i++) { String animal = randomPick(animals.toArray(new String[0])) + " - " + i; OrganisationalUnit organisationalUnit = randomPick(organisationalUnits); LifecyclePhase phase = rnd.nextInt(10) > 7 ? randomPick(LifecyclePhase.values()) : LifecyclePhase.PRODUCTION; AppRegistrationRequest app = ImmutableAppRegistrationRequest.builder().name(animal) .assetCode("wltz-0" + i).description("All about " + animal) .kind(randomPick(ApplicationKind.values())).lifecyclePhase(phase) .overallRating(randomPick(RagRating.R, RagRating.A, RagRating.A, RagRating.G, RagRating.G)) .organisationalUnitId(organisationalUnit.id().get()).build(); registrationRequests.add(app);//from ww w .j av a 2 s . c o m } dsl.deleteFrom(AUTHORITATIVE_SOURCE).execute(); dsl.deleteFrom(APPLICATION).execute(); registrationRequests.forEach(applicationDao::registerApp); }
From source file:alluxio.fuse.AlluxioFuse.java
/** * Running this class will mount the file system according to * the options passed to this function {@link #parseOptions(String[])}. * The user-space fuse application will stay on the foreground and keep * the file system mounted. The user can unmount the file system by * gracefully killing (SIGINT) the process. * * @param args arguments to run the command line */// w ww. j a va2 s . c o m public static void main(String[] args) { final AlluxioFuseOptions opts = parseOptions(args); if (opts == null) { System.exit(1); } final FileSystem tfs = FileSystem.Factory.get(); final AlluxioFuseFileSystem fs = new AlluxioFuseFileSystem(tfs, opts); final List<String> fuseOpts = opts.getFuseOpts(); // Force direct_io in FUSE: writes and reads bypass the kernel page // cache and go directly to alluxio. This avoids extra memory copies // in the write path. fuseOpts.add("-odirect_io"); try { fs.mount(Paths.get(opts.getMountPoint()), true, opts.isDebug(), fuseOpts.toArray(new String[0])); } finally { fs.umount(); } }
From source file:com.eviware.loadui.launcher.LoadUILauncher.java
public static void main(String[] args) { for (String arg : args) { System.out.println("LoadUILauncher arg: " + arg); if (arg.contains("cmd")) { List<String> argList = new ArrayList<>(Arrays.asList(args)); argList.remove(arg);/*from www . ja va2s . c o m*/ String[] newArgs = argList.toArray(new String[argList.size()]); Application.launch(CommandApplication.class, newArgs); return; } } Application.launch(FXApplication.class, args); // Is the below just old legacy code from JavaFX 1? // System.setSecurityManager( null ); // // LoadUILauncher launcher = new LoadUILauncher( args ); // launcher.init(); // launcher.start(); // // new Thread( new LauncherWatchdog( launcher.framework, 20000 ), "loadUI Launcher Watchdog" ).start(); }
From source file:it.jnrpe.client.JNRPEClient.java
/** * /*from w w w .j a v a 2s . co m*/ * @param args * command line arguments * - */ public static void main(final String[] args) { Parser parser = new Parser(); parser.setGroup(configureCommandLine()); CommandLine cli = null; try { cli = parser.parse(args); if (cli.hasOption("--help")) { printUsage(null); } //timeoutAsUnknown = cli.hasOption("--unknown"); String sHost = (String) cli.getValue("--host"); final Long port = (Long) cli.getValue("--port", Long.valueOf(DEFAULT_PORT)); String sCommand = (String) cli.getValue("--command", "_NRPE_CHECK"); JNRPEClient client = new JNRPEClient(sHost, port.intValue(), !cli.hasOption("--nossl")); client.setTimeout(((Long) cli.getValue("--timeout", Long.valueOf(DEFAULT_TIMEOUT))).intValue()); if (cli.hasOption("--weakCiherSuites")) { client.enableWeakCipherSuites(); } @SuppressWarnings("unchecked") List<String> argList = cli.getValues("--arglist"); ReturnValue ret = client.sendCommand(sCommand, argList.toArray(new String[argList.size()])); System.out.println(ret.getMessage()); System.exit(ret.getStatus().intValue()); } catch (JNRPEClientException exc) { Status returnStatus; Throwable cause = exc.getCause(); if (cli.hasOption("--unknown") && cause instanceof SocketTimeoutException) { returnStatus = Status.UNKNOWN; } else { returnStatus = Status.CRITICAL; } System.out.println(exc.getMessage()); System.exit(returnStatus.intValue()); } catch (OptionException oe) { printUsage(oe); } }
From source file:SyntaxColoring.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); final String PUNCTUATION = "(){}"; styledText.addExtendedModifyListener(new ExtendedModifyListener() { public void modifyText(ExtendedModifyEvent event) { int end = event.start + event.length - 1; if (event.start <= end) { String text = styledText.getText(event.start, end); java.util.List ranges = new java.util.ArrayList(); for (int i = 0, n = text.length(); i < n; i++) { if (PUNCTUATION.indexOf(text.charAt(i)) > -1) { ranges.add(new StyleRange(event.start + i, 1, display.getSystemColor(SWT.COLOR_BLUE), null, SWT.BOLD)); }//from ww w. j a v a 2s . c om } if (!ranges.isEmpty()) { styledText.replaceStyleRanges(event.start, event.length, (StyleRange[]) ranges.toArray(new StyleRange[0])); } } } }); styledText.setBounds(10, 10, 500, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:com.bitsofproof.supernode.main.Main.java
public static void main(String[] args) throws Exception { log.info("bitsofproof supernode (c) 2013 bits of proof zrt."); log.trace("Spring context setup"); if (args.length == 0) { System.err.println(// w ww . ja v a 2 s . co m "Usage: java com.bitsofproof.main.Main profile [profile...] -- [args...] [options...]"); return; } GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); List<String> a = new ArrayList<String>(); boolean profiles = true; for (String s : args) { if (s.equals("--")) { profiles = false; } else { if (profiles) { log.info("Loading profile: " + s); ctx.getEnvironment().addActiveProfile(s); } else { a.add(s); } } } ctx.load("classpath:context/server.xml"); ctx.load("classpath:context/*-profile.xml"); ctx.refresh(); ctx.getBean(App.class).start(a.toArray(new String[0])); }
From source file:alfio.config.SpringBootLauncher.java
/** * Entry point for spring boot/*from ww w . j a va 2 s.c om*/ * @param args original arguments */ public static void main(String[] args) { Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler()); String profiles = System.getProperty("spring.profiles.active", ""); SpringApplication application = new SpringApplication(SpringBootInitializer.class, RepositoryConfiguration.class, DataSourceConfiguration.class, WebSecurityConfig.class, MvcConfiguration.class); List<String> additionalProfiles = new ArrayList<>(); additionalProfiles.add(Initializer.PROFILE_SPRING_BOOT); if ("true".equals(System.getenv("ALFIO_LOG_STDOUT_ONLY"))) { // -> will load application-stdout.properties on top to override the logger configuration additionalProfiles.add("stdout"); } if ("true".equals(System.getenv("ALFIO_DEMO_ENABLED"))) { additionalProfiles.add(Initializer.PROFILE_DEMO); } if ("true".equals(System.getenv("ALFIO_JDBC_SESSION_ENABLED"))) { additionalProfiles.add(Initializer.PROFILE_JDBC_SESSION); } application.setAdditionalProfiles(additionalProfiles.toArray(new String[additionalProfiles.size()])); ConfigurableApplicationContext applicationContext = application.run(args); ConfigurableEnvironment environment = applicationContext.getEnvironment(); log.info("profiles: requested {}, active {}", profiles, String.join(", ", (CharSequence[]) environment.getActiveProfiles())); if ("true".equals(System.getProperty("startDBManager"))) { launchHsqlGUI(); } }
From source file:edu.vt.middleware.ldap.search.PeopleSearch.java
/** * This provides command line access to a <code>PeopleSearch</code>. * * @param args <code>String[]</code> * * @throws Exception if an error occurs *///from w ww . jav a 2 s .co m public static void main(final String[] args) throws Exception { final PeopleSearch ps = createFromSpringContext("/peoplesearch-context.xml", "peopleSearch"); final Query query = new Query(); final List<String> attrs = new ArrayList<String>(); try { for (int i = 0; i < args.length; i++) { if ("-query".equals(args[i])) { query.setRawQuery(args[++i]); } else { attrs.add(args[i]); } } if (query.getRawQuery() == null) { throw new ArrayIndexOutOfBoundsException(); } if (!attrs.isEmpty()) { query.setQueryAttributes(attrs.toArray(new String[0])); } ps.search(query, OutputFormat.LDIF, new BufferedWriter(new OutputStreamWriter(System.out))); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Usage: java " + PeopleSearch.class.getName() + " -query <query> <attributes>"); System.exit(1); } }
From source file:com.mirth.connect.server.launcher.MirthLauncher.java
public static void main(String[] args) { try {// w w w . j a v a 2 s.c o m try { uninstallPendingExtensions(); installPendingExtensions(); } catch (Exception e) { logger.error("Error uninstalling or installing pending extensions.", e); } Properties mirthProperties = new Properties(); String includeCustomLib = null; try { mirthProperties.load(new FileInputStream(new File(MIRTH_PROPERTIES_FILE))); includeCustomLib = mirthProperties.getProperty(PROPERTY_INCLUDE_CUSTOM_LIB); createAppdataDir(mirthProperties); } catch (Exception e) { logger.error("Error creating the appdata directory.", e); } ManifestFile mirthServerJar = new ManifestFile("server-lib/mirth-server.jar"); ManifestFile mirthClientCoreJar = new ManifestFile("server-lib/mirth-client-core.jar"); ManifestDirectory serverLibDir = new ManifestDirectory("server-lib"); serverLibDir.setExcludes(new String[] { "mirth-client-core.jar" }); List<ManifestEntry> manifestList = new ArrayList<ManifestEntry>(); manifestList.add(mirthServerJar); manifestList.add(mirthClientCoreJar); manifestList.add(serverLibDir); // We want to include custom-lib if the property isn't found, or if it equals "true" if (includeCustomLib == null || Boolean.valueOf(includeCustomLib)) { manifestList.add(new ManifestDirectory("custom-lib")); } ManifestEntry[] manifest = manifestList.toArray(new ManifestEntry[manifestList.size()]); // Get the current server version JarFile mirthClientCoreJarFile = new JarFile(mirthClientCoreJar.getName()); Properties versionProperties = new Properties(); versionProperties.load(mirthClientCoreJarFile .getInputStream(mirthClientCoreJarFile.getJarEntry("version.properties"))); String currentVersion = versionProperties.getProperty("mirth.version"); List<URL> classpathUrls = new ArrayList<URL>(); addManifestToClasspath(manifest, classpathUrls); addExtensionsToClasspath(classpathUrls, currentVersion); URLClassLoader classLoader = new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()])); Class<?> mirthClass = classLoader.loadClass("com.mirth.connect.server.Mirth"); Thread mirthThread = (Thread) mirthClass.newInstance(); mirthThread.setContextClassLoader(classLoader); mirthThread.start(); } catch (Exception e) { e.printStackTrace(); } }
From source file:ws.moor.bt.grapher.Grapher.java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.err.println("Please specify a tab-separated values file"); System.exit(1);//w w w. j av a 2s . c o m } File file = new File(args[0]); final CSVMapCollector collector = new CSVMapCollector( new CSVSkipFilter(new CSVInputStream(new FileInputStream(file)), 0 * 1000)); JFrame window = new JFrame("Grapher"); window.setSize(1100, 800); window.setLayout(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(null); List<String> possibleNames = collector.getAvailableStreams(); Collections.sort(possibleNames); TreeNode root = convertToTree(possibleNames); final JTree tree = new JTree(root); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { List<String> names = new ArrayList<String>(); final TreePath[] paths = tree.getSelectionModel().getSelectionPaths(); if (paths == null) { chartPanel.setChart(null); return; } for (TreePath path : paths) { Object lastPath = path.getLastPathComponent(); if (lastPath instanceof DefaultMutableTreeNode) { Object value = ((DefaultMutableTreeNode) lastPath).getUserObject(); if (value instanceof NodeValue) { names.add(value.toString()); } } } chartPanel.setChart(createChart(collector, names.toArray(new String[names.size()]))); } }); Font font = tree.getFont(); tree.setFont(font.deriveFont(10.0f)); JScrollPane scrollPane = new JScrollPane(tree); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(scrollPane); splitPane.setRightComponent(chartPanel); splitPane.setDividerLocation(200); window.setContentPane(splitPane); window.setVisible(true); }