List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:com.taobao.tddl.common.SQLPreParserTest.java
public static void main(String[] args) throws IOException { //String fileName = "D:/12_code/tddl/trunk/tddl/tddl-parser/sqlsummary-icsg-db0-db15-group-20100901100337-export.xlsx"; //String fileName = "D:/12_code/tddl/trunk/tddl/tddl-parser/sqlsummary-tcsg-instance-group-20100901100641-export.xlsx"; int count = 0; long time = 0; File home = new File(System.getProperty("user.dir") + "/appsqls"); for (File f : home.listFiles()) { if (f.isDirectory() || !f.getName().endsWith(".xlsx")) { continue; }// w ww .j ava 2s . c om log.info("---------------------- " + f.getAbsolutePath()); faillog.info("---------------------- " + f.getAbsolutePath()); Workbook wb = new XSSFWorkbook(new FileInputStream(f)); Sheet sheet = wb.getSheetAt(0); for (Row row : sheet) { Cell cell = row.getCell(2); if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING) { String sql = cell.getStringCellValue(); long t0 = System.currentTimeMillis(); String tableName = SQLPreParser.findTableName(sql); time += System.currentTimeMillis() - t0; count++; log.info(tableName + " <-- " + sql); if (tableName == null) { sql = sql.trim().toLowerCase(); if (isCRUD(sql)) { System.out.println("failed:" + sql); faillog.error("failed:" + sql); } } } } wb = null; } faillog.fatal("------------------------------- finished --------------------------"); faillog.fatal(count + " sql parsed, total time:" + time + ". average time use per sql:" + (double) time / count + "ms/sql"); }
From source file:io.github.albertopires.mjc.JConsoleM.java
public static void main(String[] args) throws Exception { applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml"); new Thread(new LogInvoker(obterConfiguracaoWildfly(System.getProperty("jvm.host")))).start(); }
From source file:com.kolich.aws.SQSTest.java
public static void main(String[] args) throws Exception { final String key = System.getProperty(AWS_ACCESS_KEY_PROPERTY); final String secret = System.getProperty(AWS_SECRET_PROPERTY); if (key == null || secret == null) { throw new IllegalArgumentException("You are missing the " + "-Daws.key and -Daws.secret required VM " + "properties on your command line."); }/*from ww w . j ava2 s .c o m*/ final HttpClient client = KolichHttpClientFactory.getNewInstanceNoProxySelector(); final SQSClient sqs = new KolichSQSClient(client, key, secret); URI queueURI = null; final Either<HttpFailure, CreateQueueResult> create = sqs.createQueue("----__________"); if (create.success()) { System.out.println("Created queue successfully: " + create.right().getQueueUrl()); queueURI = URI.create(create.right().getQueueUrl()); } else { System.err.println("Failed to create queue: " + create.left().getStatusCode()); } final Either<HttpFailure, ListQueuesResult> list = sqs.listQueues(); if (list.success()) { for (final String queueUrl : list.right().getQueueUrls()) { System.out.println("Queue: " + queueUrl); } } else { System.err.println("Listing queues failed."); } for (int i = 0; i < 5; i++) { final Either<HttpFailure, SendMessageResult> send = sqs.sendMessage(queueURI, "test message: " + ISO8601DateFormat.format(new Date())); if (send.success()) { System.out.println("Sent message [" + i + "]: " + send.right().getMessageId()); } else { System.err.println("Failed to send message."); } } for (int fetched = 0, error = 0; fetched < 5 && error == 0;) { final Either<HttpFailure, ReceiveMessageResult> messages = sqs.receiveMessage(queueURI, 10, 5); if (messages.success()) { fetched += messages.right().getMessages().size(); System.out.println("Loaded " + messages.right().getMessages().size() + " messages."); for (final Message m : messages.right().getMessages()) { System.out.println("Message [" + m.getMessageId() + "]: " + m.getBody()); final Option<HttpFailure> deleteMsg = sqs.deleteMessage(queueURI, m.getReceiptHandle()); if (deleteMsg.isNone()) { System.out.println("Deleted message [" + m.getMessageId() + "]"); } else { System.err.println("Failed to delete message: " + m.getReceiptHandle()); } } } else { error = 1; System.err.println("Loading messages failed."); } } System.out.println("No messages should be on queue... long poll waiting!"); final Either<HttpFailure, ReceiveMessageResult> lp = sqs.receiveMessage(queueURI, 20, 5); if (lp.success()) { System.out.println("Long poll finished waiting successfully."); } else { System.err.println("Failed to long poll wait."); } final Option<HttpFailure> delete = sqs.deleteQueue(queueURI); if (delete.isNone()) { System.out.println("Deleted queue successfully: " + queueURI); } else { System.err.println("Deletion of queue failed: " + queueURI); } }
From source file:com.ahanda.techops.noty.clientTest.Client.java
public static void main(String[] args) throws Exception { if (args.length == 1) { System.setProperty("PINT.conf", args[0]); }//from ww w . j av a 2 s . c o m if (System.getProperty("PINT.conf") == null) throw new IllegalArgumentException(); JsonNode config = null; Config cf = Config.getInstance(); cf.setupConfig(); String scheme = "http"; String host = cf.getHttpHost(); int port = cf.getHttpPort(); if (port == -1) { port = 8080; } if (!"http".equalsIgnoreCase(scheme)) { l.warn("Only HTTP is supported."); return; } // Configure SSL context if necessary. final boolean ssl = "https".equalsIgnoreCase(scheme); final SslContext sslCtx; if (ssl) { sslCtx = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE); } else { sslCtx = null; } // Configure the client. EventLoopGroup group = new NioEventLoopGroup(); try { Bootstrap b = new Bootstrap(); b.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(new HttpClientCodec()); // p.addLast( "decoder", new HttpResponseDecoder()); // p.addLast( "encoder", new HttpRequestEncoder()); // Remove the following line if you don't want automatic content decompression. // p.addLast(new HttpContentDecompressor()); // Uncomment the following line if you don't want to handle HttpContents. p.addLast(new HttpObjectAggregator(10485760)); p.addLast(new ClientHandler()); } }); // Make the connection attempt. Channel ch = b.connect(host, port).sync().channel(); ClientHandler client = new ClientHandler(); client.login(ch, ClientHandler.credential); // ClientHandler.pubEvent( ch, ClientHandler.event ); // Wait for the server to close the connection. ch.closeFuture().sync(); l.info("Closing Client side Connection !!!"); } finally { // Shut down executor threads to exit. group.shutdownGracefully(); } }
From source file:io.github.cdelmas.spike.vertx.Main.java
public static void main(String[] args) { // TODO start a vertx instance // deploy verticles / one per resource in this case Json.mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); Vertx vertx = Vertx.vertx();// www.ja v a 2 s .c o m HttpClientOptions clientOptions = new HttpClientOptions().setSsl(true) .setTrustStoreOptions(new JksOptions().setPath(System.getProperty("javax.net.ssl.trustStore")) .setPassword(System.getProperty("javax.net.ssl.trustStorePassword"))); HttpClient httpClient = vertx.createHttpClient(clientOptions); Router router = Router.router(vertx); AuthHandler auth = new BearerAuthHandler(new FacebookOauthTokenVerifier(httpClient)); router.route("/*").handler(auth); HelloResource helloResource = new HelloResource(httpClient); router.get("/hello").produces("text/plain").handler(helloResource::hello); CarRepository carRepository = new InMemoryCarRepository(); CarsResource carsResource = new CarsResource(carRepository); router.route("/cars*").handler(BodyHandler.create()); router.get("/cars").produces("application/json").handler(carsResource::all); router.post("/cars").consumes("application/json").handler(carsResource::create); CarResource carResource = new CarResource(carRepository); router.get("/cars/:id").produces("application/json").handler(carResource::byId); HttpServerOptions serverOptions = new HttpServerOptions().setSsl(true) .setKeyStoreOptions(new JksOptions().setPath(System.getProperty("javax.net.ssl.keyStorePath")) .setPassword(System.getProperty("javax.net.ssl.keyStorePassword"))) .setPort(8090); HttpServer server = vertx.createHttpServer(serverOptions); server.requestHandler(router::accept).listen(); }
From source file:examples.ssh.X11.java
public static void main(String... args) throws Exception { SSHClient ssh = new SSHClient(); // Compression makes X11 more feasible over slower connections // ssh.useCompression(); ssh.loadKnownHosts();//from w w w . j av a2 s .c o m /* * NOTE: Forwarding incoming X connections to localhost:6000 only works if X is started without the * "-nolisten tcp" option (this is usually not the default for good reason) */ ssh.registerX11Forwarder(new SocketForwardingConnectListener(new InetSocketAddress("localhost", 6000))); ssh.connect("localhost"); try { ssh.authPublickey(System.getProperty("user.name")); Session sess = ssh.startSession(); /* * It is recommendable to send a fake cookie, and in your ConnectListener when a connection comes in replace * it with the real one. But here simply one from `xauth list` is being used. */ sess.reqX11Forwarding("MIT-MAGIC-COOKIE-1", "26e8700422fd3efb99a918ce02324e9e", 0); Command cmd = sess.exec("firefox"); new Pipe("stdout", cmd.getInputStream(), System.out).start(); new Pipe("stderr", cmd.getErrorStream(), System.err).start(); // Wait for session & X11 channel to get closed ssh.getConnection().join(); } finally { ssh.disconnect(); } }
From source file:br.com.RatosDePC.Brpp.BrppCompilerMain.java
public static void main(String[] args) { // TODO Auto-generated method stub File f = new File(FileUtils.getBrinodirectory()); f.mkdirs();/*from ww w.j a v a2s . c om*/ File l = new File(FileUtils.getBrinodirectory() + "/bibliotecas"); l.mkdirs(); Path currentRelativePath = Paths.get(""); String s = currentRelativePath.toAbsolutePath().toString(); File destDir = new File(s + System.getProperty("file.separator") + "Arduino" + System.getProperty("file.separator") + "libraries"); try { JSONUtils.config(s); } catch (IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { FileUtils.copyFolder(l, destDir); KeywordManagerUtils.processLibraries(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } BrppIDEFrame frame = new BrppIDEFrame("Brino " + BrppCompiler.version); frame.setSize(500, 600); frame.setVisible(true); frame.setLocation(100, 30); }
From source file:com.ibm.iotf.connector.Connector.java
public static void main(String[] args) { userDir = System.getProperty("user.dir"); resourceDir = null;/*from w w w . j av a 2s .c om*/ isBluemix = false; IoTFSubscriber subscriber = null; MHubPublisher publisher = null; isBluemix = new File(userDir + File.separator + ".java-buildpack").exists(); try { if (isBluemix) { logger.log(Level.INFO, "Running in Bluemix mode."); resourceDir = userDir + File.separator + "Connector-MessageHub-1.0" + File.separator + "bin" + File.separator + "resources"; if (System.getProperty(JAAS_CONFIG_PROPERTY) == null) { System.setProperty(JAAS_CONFIG_PROPERTY, resourceDir + File.separator + "jaas.conf"); } // Attempt to retrieve the environment configuration for the IoTF and Message Hub services IoTFEnvironment iotEnv = parseIoTFEnv(); if (iotEnv == null) { logger.log(Level.FATAL, "Unable to retrieve the IoTF environment configuration."); System.exit(1); } MessageHubEnvironment messageHubEnv = parseProducerProps(); if (messageHubEnv == null) { logger.log(Level.FATAL, "Unable to retrieve the Message Hub environment configuration."); System.exit(1); } // update the JAAS configuration with auth details from the environment // configuration we have just parsed updateJaasConfiguration(messageHubEnv.getCredentials()); // create a single subscriber/producer subscriber = new IoTFSubscriber(iotEnv); publisher = new MHubPublisher(messageHubEnv); // configure the subscriber to hand off events to the publisher subscriber.setPublisher(publisher); } else { logger.log(Level.INFO, "Running in standalone mode - not currently supported."); System.exit(1); } } catch (Throwable t) { logger.log(Level.FATAL, "An error occurred while configuring and starting the environment: " + t.getMessage(), t); System.exit(1); } logger.log(Level.INFO, "Starting the subscriber run loop."); // The subscriber run method + the thread(s) used by the IoT client libraries will keep // the application alive. subscriber.run(); }
From source file:com.xinge.sample.samples.pptx4j.org.pptx4j.samples.SlideNotes.java
public static void main(String[] args) throws Exception { // Where will we save our new .ppxt? String outputfilepath = System.getProperty("user.dir") + "/sample-docs/OUT_SlideNotes.pptx"; // Create skeletal package, including a MainPresentationPart and a SlideLayoutPart PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage(); // Need references to these parts to create a slide // Please note that these parts *already exist* - they are // created by createPackage() above. See that method // for instruction on how to create and add a part. MainPresentationPart pp = (MainPresentationPart) presentationMLPackage.getParts().getParts() .get(new PartName("/ppt/presentation.xml")); SlideLayoutPart layoutPart = (SlideLayoutPart) presentationMLPackage.getParts().getParts() .get(new PartName("/ppt/slideLayouts/slideLayout1.xml")); // OK, now we can create a slide SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide1.xml")); slidePart.setContents(SlidePart.createSld()); pp.addSlide(0, slidePart);/*from ww w.ja v a 2 s . co m*/ // Slide layout part slidePart.addTargetPart(layoutPart); // Create and add shape Shape sample = ((Shape) XmlUtils.unmarshalString(SAMPLE_SHAPE, Context.jcPML)); slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(sample); // Now add notes slide. // 1. Notes master NotesMasterPart nmp = new NotesMasterPart(); NotesMaster notesmaster = (NotesMaster) XmlUtils.unmarshalString(notesMasterXml, Context.jcPML); nmp.setJaxbElement(notesmaster); // .. connect it to /ppt/presentation.xml Relationship ppRelNmp = pp.addTargetPart(nmp); /* * <p:notesMasterIdLst> <p:notesMasterId r:id="rId3"/> </p:notesMasterIdLst> */ pp.getJaxbElement().setNotesMasterIdLst(createNotesMasterIdListPlusEntry(ppRelNmp.getId())); // .. NotesMasterPart typically has a rel to a theme // .. can we get away without it? // Nope .. read this in from a file ThemePart themePart = new ThemePart(new PartName("/ppt/theme/theme2.xml")); // TODO: read it from a string instead themePart.unmarshal(FileUtils.openInputStream(new File(System.getProperty("user.dir") + "/theme2.xml"))); nmp.addTargetPart(themePart); // 2. Notes slide NotesSlidePart nsp = new NotesSlidePart(); Notes notes = (Notes) XmlUtils.unmarshalString(notesXML, Context.jcPML); nsp.setJaxbElement(notes); // .. connect it to the slide slidePart.addTargetPart(nsp); // .. it also has a rel to the slide nsp.addTargetPart(slidePart); // .. and the slide master nsp.addTargetPart(nmp); // All done: save it presentationMLPackage.save(new File(outputfilepath)); System.out.println("\n\n done .. saved " + outputfilepath); }
From source file:com.impetus.ankush.agent.daemon.AnkushAgent.java
/** * The main method./*from w w w . jav a2 s. c om*/ * * @param args * the arguments */ public static void main(String[] args) { // taskable file name. String file = System.getProperty(Constant.AGENT_INSTALL_DIR) + "/.ankush/agent/conf/taskable.conf"; // iterate always try { // reading the class name lines from the file List<String> classNames = FileUtils.readLines(new File(file)); // iterate over the class names to start the newly added task. for (String className : classNames) { // if an empty string from the file then continue the loop. if (className.isEmpty()) { continue; } // if not started. if (!objMap.containsKey(className)) { // create taskable object LOGGER.info("Creating " + className + " object."); try { Taskable taskable = ActionFactory.getTaskableObject(className); objMap.put(className, taskable); // call start on object ... taskable.start(); } catch (Exception e) { LOGGER.error("Could not start the " + className + " taskable."); } } } // iterating over the existing tasks to stop if it is removed // from the file. Set<String> existingClassNames = new HashSet<String>(objMap.keySet()); for (String className : existingClassNames) { // if not started. if (!classNames.contains(className)) { // create taskable object LOGGER.info("Removing " + className + " object."); Taskable taskable = objMap.get(className); objMap.remove(className); // call stop on object ... taskable.stop(); } } } catch (Exception e) { LOGGER.error(e.getMessage(), e); } while (true) { try { Thread.sleep(TASK_SEARCH_SLEEP_TIME); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } }