List of usage examples for org.apache.commons.cli CommandLine hasOption
public boolean hasOption(char opt)
From source file:com.opengamma.bbg.referencedata.cache.MongoDBReferenceDataCacheRefresher.java
/** * Runs the tool.//from w w w . ja v a2 s.co m * * @param args empty arguments * @throws Exception */ public static void main(final String[] args) throws Exception { // CSIGNORE PlatformConfigUtils.configureSystemProperties(); System.out.println("Starting connections"); String configLocation = "com/opengamma/bbg/bbg-reference-data-context.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configLocation); try { context.start(); MongoDBValueCachingReferenceDataProvider mongoProvider = context .getBean("bloombergReferenceDataProvider", MongoDBValueCachingReferenceDataProvider.class); MongoDBReferenceDataCacheRefresher refresher = new MongoDBReferenceDataCacheRefresher(mongoProvider); Options options = createOptions(); CommandLineParser parser = new PosixParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (ParseException e) { usage(options); return; } if (line.hasOption(HELP_OPTION)) { usage(options); return; } //TODO other options, e.g. explicitly specify security int numberOfSecurities = Integer.parseInt(line.getArgs()[0]); int id = Integer.parseInt(line.getArgs()[1]); System.out.println("Refreshing " + numberOfSecurities + " securities, id " + id); refresher.refreshCaches(numberOfSecurities, id); System.out.println("Done refreshing"); } catch (Exception ex) { context.close(); throw ex; } }
From source file:ktdiedrich.imagek.SegmentationCMD.java
/** * @author ktdiedrich@gmail.com/*from w ww .j a v a 2 s .co m*/ * @param ags: [file path] [Median filter size] [imageId] * Command line segmentation * @throws org.apache.commons.cli.ParseException */ public static void main(String[] args) throws org.apache.commons.cli.ParseException { int imageIds[] = null; int medianFilterSize = 0; float seed = Extractor3D.SEED_HIST_THRES; String paths[] = null; Options options = new Options(); options.addOption("p", true, "path name to file including filename"); options.addOption("m", true, "median filter size, m*2+1"); options.addOption("i", true, "image ID"); options.addOption("f", true, "Image ID from"); options.addOption("t", true, "Image ID to, (inclusive)"); options.addOption("s", true, "Seed threshold default " + seed); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("s")) { seed = Float.parseFloat(cmd.getOptionValue("s")); } if (cmd.hasOption("i")) { imageIds = new int[1]; imageIds[0] = Integer.parseInt(cmd.getOptionValue("i")); paths = new String[1]; paths[0] = getImageIdPath(imageIds[0]); // TODO get path to image ID from database and properties file. } if (cmd.hasOption("f") && cmd.hasOption("t")) { int from = Integer.parseInt(cmd.getOptionValue("f")); int to = Integer.parseInt(cmd.getOptionValue("t")); int range = to - from + 1; paths = new String[range]; imageIds = new int[range]; for (int i = 0, imId = from; i < range; i++, imId++) { imageIds[i] = imId; paths[i] = getImageIdPath(imId); } } if (paths == null && cmd.hasOption("p")) { paths = new String[1]; paths[0] = cmd.getOptionValue("p"); } if (cmd.hasOption("m")) { medianFilterSize = Integer.parseInt(cmd.getOptionValue("m")); } // System.out.println("ImageID: "+imageId+" Path: "+paths+" Median filter: "+medianFilterSize); if (paths != null) { int i = 0; for (String path : paths) { String p[] = parseDirectoryFileName(path); String dirPath = p[0]; ImagePlus segImage = segment(path, medianFilterSize, imageIds[i], seed); String title = segImage.getShortTitle(); if (title.contains(File.separator)) ; { title = parseDirectoryFileName(title)[1]; } String outputPath = null; if (!dirPath.endsWith(File.separator)) dirPath = dirPath + File.separator; outputPath = dirPath + title + ".zip"; FileSaver fs = new FileSaver(segImage); fs.saveAsZip(outputPath); System.out.println("Saved: " + outputPath); ImagePlus mipYim = MIP.createShortMIP(segImage, MIP.Y_AXIS); fs = new FileSaver(mipYim); title = mipYim.getShortTitle(); if (title.contains(File.separator)) ; { title = parseDirectoryFileName(title)[1]; } outputPath = dirPath + title + ".png"; fs.saveAsPng(outputPath); System.out.println("Saved: " + outputPath + "\n"); i++; } } }
From source file:br.com.riselabs.cotonet.Main.java
/** * @param args// w w w .ja va 2 s .c o m * @throws EmptyContentException * @throws IOException * @throws NullPointerException * @throws InvalidNumberOfTagsException */ public static void main(String[] args) { CommandLineParser parser = new DefaultParser(); Options options = new Options(); options.addOption(Option.builder("c").longOpt("chunkBased").desc( "c - build a conflict chunk-based network with the developers that in fact conflits with each other." + " Additionally to the c argument the user should provide a path. This path should have" + " a file containig the repository's URL of the target systems.") .hasArg().build()); options.addOption(Option.builder("cf").longOpt("chunkBasedFullGraph") .desc("cf - like c, build a conflict chunk-based network adding all developers involved in " + "identified chunk conflicts. Additionally to the cf argument the user should provide a path. " + "This path should have a file containig the repository's URL of the target systems.") .hasArg().build()); options.addOption(Option.builder("f").longOpt("fileBase").desc( " f - build a conflict file-based network. In other others all developers that contribute to some" + " conflict at file level should be part of this network. This network is based on network provides " + "by cf, adding edges between developers of different chunks. Additionally to the f argument the" + " user should provide a path. This path should have afile containig the repository's URL of " + "the target systems.") .hasArg().build()); /* * options.addOption( Option.builder("rw").longOpt("rewrite-aux"). * desc("Rewrite auxilary files (e.g., *.conf, *.sh) " + "_WITHOUT_ " + * "the recreation of the merge scenarios based tags.").hasArg(false). * build()); * * options.addOption( Option.builder("rwt").longOpt("rewrite-tagfile"). * desc("Rewrite auxilary files (e.g., *.conf, *.sh) " + "_INCLUDING_ " * + "the recreation of the merge scenarios based tags.").hasArg(false). * build()); */ options.addOption("h", "help", false, "Print this help page"); File reposListFile = null; Boolean skipCloneAndNetworks = false; try { CommandLine cmd = parser.parse(options, args); // user is looking for help if (cmd.hasOption("h")) { new HelpFormatter().printHelp("java ", options); System.exit(0); } /* "c", "cf", and "f" are the three available options * "c" builds the chunk-based network with developers that contribute to the conflict * "cf" builds the chunk-based network with developers that contribute to the conflict and developers * that are part of the chunk, but don't contribute to the conflict * "f" builds the file-based network with developers that contribute to the chunk into a target file */ else if (cmd.hasOption("c") || cmd.hasOption("cf") || cmd.hasOption("f")) { String urlsFilePath = null; NetworkType type; if (cmd.hasOption("c")) { urlsFilePath = cmd.getOptionValue("c"); type = NetworkType.CHUNK_BASED; } else if (cmd.hasOption("cf")) { urlsFilePath = cmd.getOptionValue("cf"); type = NetworkType.CHUNK_BASED_FULL; } else { urlsFilePath = cmd.getOptionValue("f"); type = NetworkType.FILE_BASED; } System.out.println(urlsFilePath); reposListFile = new File(urlsFilePath); // Ends execution if file not found. if (!reposListFile.exists()) { System.out.println("COTONET ended without retrive any repository.\n\n" + "The file containig the repository's URL of the target systems was not found. " + "Check wether the file \"" + urlsFilePath + "\" exists."); System.exit(1); } skipCloneAndNetworks = (cmd.hasOption("rw") || cmd.hasOption("rwt")) ? true : false; MainThread m = new MainThread(type, reposListFile, skipCloneAndNetworks); m.start(); m.join(); Logger.log("COTONET finished. Files rewritten."); } else { System.out.println("COTONET ended without retrive any repository.\n\n" + "You should use 'h' if you are looking for help. Otherwise," + " the 'l' or 'fc' option is mandatory."); System.exit(1); } } catch (ParseException e) { new HelpFormatter().printHelp("java ", options); } catch (Exception e) { Logger.log(e.getMessage()); } }
From source file:com.ibm.crail.tools.CrailFsck.java
public static void main(String[] args) throws Exception { String type = ""; String filename = "/tmp.dat"; long offset = 0; long length = 1; boolean randomize = false; int storageClass = 0; int locationClass = 0; Option typeOption = Option.builder("t").desc( "type of experiment [getLocations|directoryDump|namenodeDump|blockStatistics|ping|createDirectory]") .hasArg().build();//from www .j a v a 2 s . c o m Option fileOption = Option.builder("f").desc("filename").hasArg().build(); Option offsetOption = Option.builder("y").desc("offset into the file").hasArg().build(); Option lengthOption = Option.builder("l").desc("length of the file [bytes]").hasArg().build(); Option storageOption = Option.builder("c").desc("storageClass for file [1..n]").hasArg().build(); Option locationOption = Option.builder("p").desc("locationClass for file [1..n]").hasArg().build(); Options options = new Options(); options.addOption(typeOption); options.addOption(fileOption); options.addOption(offsetOption); options.addOption(lengthOption); options.addOption(storageOption); options.addOption(locationOption); CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, Arrays.copyOfRange(args, 0, args.length)); if (line.hasOption(typeOption.getOpt())) { type = line.getOptionValue(typeOption.getOpt()); } if (line.hasOption(fileOption.getOpt())) { filename = line.getOptionValue(fileOption.getOpt()); } if (line.hasOption(offsetOption.getOpt())) { offset = Long.parseLong(line.getOptionValue(offsetOption.getOpt())); } if (line.hasOption(lengthOption.getOpt())) { length = Long.parseLong(line.getOptionValue(lengthOption.getOpt())); } if (line.hasOption(storageOption.getOpt())) { storageClass = Integer.parseInt(line.getOptionValue(storageOption.getOpt())); } if (line.hasOption(locationOption.getOpt())) { locationClass = Integer.parseInt(line.getOptionValue(locationOption.getOpt())); } CrailFsck fsck = new CrailFsck(); if (type.equals("getLocations")) { fsck.getLocations(filename, offset, length); } else if (type.equals("directoryDump")) { fsck.directoryDump(filename, randomize); } else if (type.equals("namenodeDump")) { fsck.namenodeDump(); } else if (type.equals("blockStatistics")) { fsck.blockStatistics(filename); } else if (type.equals("ping")) { fsck.ping(); } else if (type.equals("createDirectory")) { fsck.createDirectory(filename, storageClass, locationClass); } else { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("crail fsck", options); System.exit(-1); } }
From source file:DokeosConverter.java
public static void main(String[] arguments) throws Exception { CommandLineParser commandLineParser = new PosixParser(); CommandLine commandLine = commandLineParser.parse(OPTIONS, arguments); int port = SocketOpenOfficeConnection.DEFAULT_PORT; if (commandLine.hasOption(OPTION_PORT.getOpt())) { port = Integer.parseInt(commandLine.getOptionValue(OPTION_PORT.getOpt())); }/*from w ww. j a va2 s . c o m*/ String outputFormat = null; if (commandLine.hasOption(OPTION_OUTPUT_FORMAT.getOpt())) { outputFormat = commandLine.getOptionValue(OPTION_OUTPUT_FORMAT.getOpt()); } boolean verbose = false; if (commandLine.hasOption(OPTION_VERBOSE.getOpt())) { verbose = true; } String dokeosMode = "woogie"; if (commandLine.hasOption(OPTION_DOKEOS_MODE.getOpt())) { dokeosMode = commandLine.getOptionValue(OPTION_DOKEOS_MODE.getOpt()); } int width = 800; if (commandLine.hasOption(OPTION_WIDTH.getOpt())) { width = Integer.parseInt(commandLine.getOptionValue(OPTION_WIDTH.getOpt())); } int height = 600; if (commandLine.hasOption(OPTION_HEIGHT.getOpt())) { height = Integer.parseInt(commandLine.getOptionValue(OPTION_HEIGHT.getOpt())); } String[] fileNames = commandLine.getArgs(); if ((outputFormat == null && fileNames.length != 2 && dokeosMode != null) || fileNames.length < 1) { String syntax = "convert [options] input-file output-file; or\n" + "[options] -f output-format input-file [input-file...]"; HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp(syntax, OPTIONS); System.exit(EXIT_CODE_TOO_FEW_ARGS); } OpenOfficeConnection connection = new DokeosSocketOfficeConnection(port); try { if (verbose) { System.out.println("-- connecting to OpenOffice.org on port " + port); } connection.connect(); } catch (ConnectException officeNotRunning) { System.err.println( "ERROR: connection failed. Please make sure OpenOffice.org is running and listening on port " + port + "."); System.exit(EXIT_CODE_CONNECTION_FAILED); } try { // choose the good constructor to deal with the conversion DocumentConverter converter; if (dokeosMode.equals("oogie")) { converter = new OogieDocumentConverter(connection, new DokeosDocumentFormatRegistry(), width, height); } else if (dokeosMode.equals("woogie")) { converter = new WoogieDocumentConverter(connection, new DokeosDocumentFormatRegistry(), width, height); } else { converter = new OpenOfficeDocumentConverter(connection); } if (outputFormat == null) { File inputFile = new File(fileNames[0]); File outputFile = new File(fileNames[1]); convertOne(converter, inputFile, outputFile, verbose); } else { for (int i = 0; i < fileNames.length; i++) { File inputFile = new File(fileNames[i]); File outputFile = new File(FilenameUtils.getFullPath(fileNames[i]) + FilenameUtils.getBaseName(fileNames[i]) + "." + outputFormat); convertOne(converter, inputFile, outputFile, verbose); } } } catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) { connection.disconnect(); System.err.println("ERROR: conversion failed."); System.exit(EXIT_CODE_CONVERSION_FAILED); } finally { if (verbose) { System.out.println("-- disconnecting"); } connection.disconnect(); } }
From source file:com.github.r351574nc3.amex.assignment1.App.java
public static void main(final String... args) { if (args.length < 1) { printUsage();// www . java 2 s. c o m System.exit(0); } final Options options = new Options(); options.addOption(OptionBuilder.withArgName("output").hasArg(true).withDescription("Path for CSV output") .create("o")); options.addOption( OptionBuilder.withArgName("input").hasArg(true).withDescription("Path for CSV input").create("i")); final CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.out.println(e.getMessage()); printUsage(); System.exit(0); } if ((cmd.hasOption('o') && cmd.hasOption('i')) || !(cmd.hasOption('o') || cmd.hasOption('i')) || (cmd.hasOption('o') && cmd.getArgs().length < 1)) { printUsage(); System.exit(0); } if (cmd.hasOption('o') && cmd.getArgs().length > 0) { final String outputName = cmd.getOptionValue("o"); final int iterations = Integer.parseInt(cmd.getArgs()[cmd.getArgs().length - 1]); new App().run(new File(outputName), iterations); } else if (cmd.hasOption('i')) { final String inputName = cmd.getOptionValue("i"); new App().run(new File(inputName)); } System.exit(0); }
From source file:de.uni_koblenz.west.splendid.tools.NQuadSourceAggregator.java
public static void main(String[] args) { try {/*w ww. j a v a 2 s .c o m*/ // parse the command line arguments CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(OPTIONS, args); // print help message if (cmd.hasOption("h") || cmd.hasOption("help")) { new HelpFormatter().printHelp(USAGE, OPTIONS); System.exit(0); } // get input files (from option -i or all remaining parameters) String[] inputFiles = cmd.getOptionValues("i"); if (inputFiles == null) inputFiles = cmd.getArgs(); if (inputFiles.length == 0) { System.out.println("need at least one input file."); new HelpFormatter().printUsage(new PrintWriter(System.out, true), 80, USAGE); System.exit(1); } String outputFile = cmd.getOptionValue("o"); // process all input files new NQuadSourceAggregator().process(outputFile, inputFiles); } catch (ParseException exp) { // print parse error and display usage message System.out.println(exp.getMessage()); new HelpFormatter().printUsage(new PrintWriter(System.out, true), 80, USAGE, OPTIONS); } }
From source file:com.rabbitmq.perf.PerfTest.java
public static void main(String[] args) { Options options = getOptions();// ww w.j a v a 2 s . c o m CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('?')) { usage(options); System.exit(0); } String testID = new SimpleDateFormat("HHmmss-SSS").format(Calendar.getInstance().getTime()); testID = strArg(cmd, 'd', "test-" + testID); String exchangeType = strArg(cmd, 't', "direct"); String exchangeName = strArg(cmd, 'e', exchangeType); String queueNames = strArg(cmd, 'u', ""); String routingKey = strArg(cmd, 'k', null); boolean randomRoutingKey = cmd.hasOption('K'); int samplingInterval = intArg(cmd, 'i', 1); float producerRateLimit = floatArg(cmd, 'r', 0.0f); float consumerRateLimit = floatArg(cmd, 'R', 0.0f); int producerCount = intArg(cmd, 'x', 1); int consumerCount = intArg(cmd, 'y', 1); int producerTxSize = intArg(cmd, 'm', 0); int consumerTxSize = intArg(cmd, 'n', 0); long confirm = intArg(cmd, 'c', -1); boolean autoAck = cmd.hasOption('a'); int multiAckEvery = intArg(cmd, 'A', 0); int channelPrefetch = intArg(cmd, 'Q', 0); int consumerPrefetch = intArg(cmd, 'q', 0); int minMsgSize = intArg(cmd, 's', 0); int timeLimit = intArg(cmd, 'z', 0); int producerMsgCount = intArg(cmd, 'C', 0); int consumerMsgCount = intArg(cmd, 'D', 0); List<?> flags = lstArg(cmd, 'f'); int frameMax = intArg(cmd, 'M', 0); int heartbeat = intArg(cmd, 'b', 0); boolean predeclared = cmd.hasOption('p'); String uri = strArg(cmd, 'h', "amqp://localhost"); //setup PrintlnStats stats = new PrintlnStats(testID, 1000L * samplingInterval, producerCount > 0, consumerCount > 0, (flags.contains("mandatory") || flags.contains("immediate")), confirm != -1); ConnectionFactory factory = new ConnectionFactory(); factory.setShutdownTimeout(0); // So we still shut down even with slow consumers factory.setUri(uri); factory.setRequestedFrameMax(frameMax); factory.setRequestedHeartbeat(heartbeat); MulticastParams p = new MulticastParams(); p.setAutoAck(autoAck); p.setAutoDelete(true); p.setConfirm(confirm); p.setConsumerCount(consumerCount); p.setConsumerMsgCount(consumerMsgCount); p.setConsumerRateLimit(consumerRateLimit); p.setConsumerTxSize(consumerTxSize); p.setExchangeName(exchangeName); p.setExchangeType(exchangeType); p.setFlags(flags); p.setMultiAckEvery(multiAckEvery); p.setMinMsgSize(minMsgSize); p.setPredeclared(predeclared); p.setConsumerPrefetch(consumerPrefetch); p.setChannelPrefetch(channelPrefetch); p.setProducerCount(producerCount); p.setProducerMsgCount(producerMsgCount); p.setProducerTxSize(producerTxSize); p.setQueueNames(Arrays.asList(queueNames.split(","))); p.setRoutingKey(routingKey); p.setRandomRoutingKey(randomRoutingKey); p.setProducerRateLimit(producerRateLimit); p.setTimeLimit(timeLimit); MulticastSet set = new MulticastSet(stats, factory, p, testID); set.run(true); stats.printFinal(); } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); usage(options); } catch (Exception e) { System.err.println("Main thread caught exception: " + e); e.printStackTrace(); System.exit(1); } }
From source file:Dcm2Txt.java
public static void main(String[] args) { CommandLine cl = parse(args); Dcm2Txt dcm2txt = new Dcm2Txt(); dcm2txt.setWithNames(!cl.hasOption("c")); if (cl.hasOption("w")) dcm2txt.setMaxWidth(parseInt(cl.getOptionValue("w"), "w", MIN_MAX_WIDTH, MAX_MAX_WIDTH)); if (cl.hasOption("l")) dcm2txt.setMaxValLen(parseInt(cl.getOptionValue("l"), "l", MIN_MAX_VAL_LEN, MAX_MAX_VAL_LEN)); File ifile = new File((String) cl.getArgList().get(0)); try {// w ww .j ava 2 s . c o m dcm2txt.dump(ifile); } catch (IOException e) { System.err.println("dcm2txt: Failed to dump " + ifile + ": " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } }
From source file:com.github.zk1931.pulsefs.Main.java
public static void main(String[] args) throws Exception { // Options for command arguments. Options options = new Options(); Option port = OptionBuilder.withArgName("port").hasArg(true).isRequired(true).withDescription("port number") .create("port"); Option addr = OptionBuilder.withArgName("addr").hasArg(true).withDescription("addr (ip:port) for Zab.") .create("addr"); Option join = OptionBuilder.withArgName("join").hasArg(true).withDescription("the addr of server to join.") .create("join"); Option dir = OptionBuilder.withArgName("dir").hasArg(true).withDescription("the directory for logs.") .create("dir"); Option help = OptionBuilder.withArgName("h").hasArg(false).withLongOpt("help") .withDescription("print out usages.").create("h"); Option timeout = OptionBuilder.withArgName("timeout").hasArg(true) .withDescription("session timeout(seconds)").create("timeout"); options.addOption(port).addOption(addr).addOption(join).addOption(dir).addOption(timeout).addOption(help); CommandLineParser parser = new BasicParser(); CommandLine cmd; String usage = "./bin/pulsefs -port port [Options]"; try {//from www . j ava2 s. co m cmd = parser.parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(usage, options); return; } } catch (ParseException exp) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(usage, options); return; } PulseFSConfig config = new PulseFSConfig(); if (cmd.hasOption("addr")) { config.setServerId(cmd.getOptionValue("addr")); } if (cmd.hasOption("join")) { config.setJoinPeer(cmd.getOptionValue("join")); } if (cmd.hasOption("dir")) { config.setLogDir(cmd.getOptionValue("dir")); } if (cmd.hasOption("timeout")) { String sessionTimeout = cmd.getOptionValue("timeout"); config.setSessionTimeout(Integer.parseInt(sessionTimeout)); } if (cmd.hasOption("port")) { config.setPort(Integer.parseInt(cmd.getOptionValue("port"))); } Server server = new Server(config.getPort()); // Suppress "Server" header in HTTP response. for (Connector y : server.getConnectors()) { for (ConnectionFactory x : y.getConnectionFactories()) { if (x instanceof HttpConnectionFactory) { ((HttpConnectionFactory) x).getHttpConfiguration().setSendServerVersion(false); } } } PulseFS fs = new PulseFS(config); SessionFilter sessionFilter = new SessionFilter(fs); FilterHolder filters = new FilterHolder(sessionFilter); ServletContextHandler pulsefs = new ServletContextHandler(ServletContextHandler.SESSIONS); pulsefs.setContextPath(PulseFSConfig.PULSEFS_ROOT); pulsefs.setAllowNullPathInfo(true); pulsefs.addServlet(new ServletHolder(new PulseFSHandler(fs)), "/*"); pulsefs.addFilter(filters, "/*", EnumSet.of(DispatcherType.REQUEST)); ServletContextHandler servers = new ServletContextHandler(ServletContextHandler.SESSIONS); servers.setContextPath(PulseFSConfig.PULSEFS_SERVERS_PATH); // Redirects /pulsefs/servers to /pulsefs/servers/ servers.setAllowNullPathInfo(true); servers.addServlet(new ServletHolder(new PulseFSServersHandler(fs)), "/*"); servers.addFilter(filters, "/*", EnumSet.of(DispatcherType.REQUEST)); ServletContextHandler tree = new ServletContextHandler(ServletContextHandler.SESSIONS); tree.setContextPath("/"); tree.addServlet(new ServletHolder(new TreeHandler(fs)), "/*"); tree.addFilter(filters, "/*", EnumSet.of(DispatcherType.REQUEST)); ServletContextHandler sessions = new ServletContextHandler(ServletContextHandler.SESSIONS); sessions.setContextPath(PulseFSConfig.PULSEFS_SESSIONS_PATH); // Redirects /pulsefs/sessions to /pulsefs/sessions/ sessions.setAllowNullPathInfo(true); sessions.addServlet(new ServletHolder(new PulseFSSessionsHandler(fs)), "/*"); sessions.addFilter(filters, "/*", EnumSet.of(DispatcherType.REQUEST)); ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.setHandlers(new Handler[] { sessions, servers, pulsefs, tree }); server.setHandler(contexts); server.start(); server.join(); }