List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:com.sm.store.server.ClusterServer.java
public static void main(String[] args) { String[] opts = new String[] { "-host", "-configPath", "-dataPath", "-port", "replicaPort", "-start", "-freq" }; String[] defaults = new String[] { "", "", "", "0", "0", "true", "0" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[1]; if (configPath.length() == 0) { logger.error("missing config path"); throw new RuntimeException("missing -configPath"); }/*from w ww .j a va2 s .co m*/ //set configPath to system properties System.setProperty("configPath", configPath); NodeConfig nodeConfig = getNodeConfig(configPath + "/node.properties"); //int clusterNo = Integer.valueOf( paras[0]); String dataPath = paras[2]; if (dataPath.length() == 0) { dataPath = "./data"; } int port = Integer.valueOf(paras[3]); int replicaPort = Integer.valueOf(paras[4]); //get from command line, if not form nodeConfig if (port == 0) port = nodeConfig.getPort(); if (port == 0) { throw new RuntimeException("port is 0"); } else { if (replicaPort == 0) replicaPort = port + 1; } boolean start = Boolean.valueOf(paras[5]); String host = paras[0]; //get from command line, if not form nodeConfig or from getHost if (host.length() == 0) host = nodeConfig.getHost(); if (host.length() == 0) host = getLocalHost(); int freq = Integer.valueOf(paras[6]); logger.info("read clusterNode and storeConfig from " + configPath); BuildClusterNodes bcn = new BuildClusterNodes(configPath + "/clusters.xml"); //BuildStoreConfig bsc = new BuildStoreConfig(configPath+"/stores.xml"); BuildRemoteConfig brc = new BuildRemoteConfig(configPath + "/stores.xml"); List<ClusterNodes> clusterNodesList = bcn.build(); short clusterNo = findClusterNo(host + ":" + port, clusterNodesList); logger.info("create cluster server config for cluster " + clusterNo + " host " + host + " port " + port + " replica port " + replicaPort); ClusterServerConfig serverConfig = new ClusterServerConfig(clusterNodesList, brc.build().getConfigList(), clusterNo, dataPath, configPath, port, replicaPort, host); //over write config from command line if freq > 0 if (freq > 0) serverConfig.setFreq(freq); logger.info("create cluster server"); ClusterStoreServer cs = new ClusterStoreServer(serverConfig, new HessianSerializer()); // start replica server cs.startReplicaServer(); logger.info("hookup jvm shutdown process"); cs.hookShutdown(); if (start) { logger.info("server is starting " + cs.getServerConfig().toString()); cs.start(); } else logger.warn("server is staged and wait to be started"); List list = new ArrayList(); //add jmx metric List<String> stores = cs.getAllStoreNames(); for (String store : stores) { list.add(cs.getStore(store)); } list.add(cs); stores.add("ClusterServer"); JmxService jms = new JmxService(list, stores); }
From source file:com.sm.store.server.grizzly.GZClusterServer.java
public static void main(String[] args) { String[] opts = new String[] { "-host", "-configPath", "-dataPath", "-port", "replicaPort", "-start", "-freq" }; String[] defaults = new String[] { "", "", "", "0", "0", "true", "10" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[1]; if (configPath.length() == 0) { logger.error("missing config path"); throw new RuntimeException("missing -configPath"); }/*from www .j a va 2s .co m*/ System.setProperty("configPath", configPath); NodeConfig nodeConfig = getNodeConfig(configPath + "/node.properties"); //int clusterNo = Integer.valueOf( paras[0]); String dataPath = paras[2]; if (dataPath.length() == 0) { dataPath = "./data"; } int port = Integer.valueOf(paras[3]); int replicaPort = Integer.valueOf(paras[4]); //get from command line, if not form nodeConfig if (port == 0) port = nodeConfig.getPort(); if (port == 0) { throw new RuntimeException("port is 0"); } else { if (replicaPort == 0) replicaPort = port + 1; } boolean start = Boolean.valueOf(paras[5]); String host = paras[0]; //get from command line, if not form nodeConfig or from getHost if (host.length() == 0) host = nodeConfig.getHost(); if (host.length() == 0) host = getLocalHost(); int freq = Integer.valueOf(paras[6]); logger.info("read clusterNode and storeConfig from " + configPath); BuildClusterNodes bcn = new BuildClusterNodes(configPath + "/clusters.xml"); //BuildStoreConfig bsc = new BuildStoreConfig(configPath+"/stores.xml"); BuildRemoteConfig brc = new BuildRemoteConfig(configPath + "/stores.xml"); List<ClusterNodes> clusterNodesList = bcn.build(); short clusterNo = findClusterNo(host + ":" + port, clusterNodesList); logger.info("create cluster server config for cluster " + clusterNo + " host " + host + " port " + port + " replica port " + replicaPort); ClusterServerConfig serverConfig = new ClusterServerConfig(clusterNodesList, brc.build().getConfigList(), clusterNo, dataPath, configPath, port, replicaPort, host); serverConfig.setFreq(freq); logger.info("create cluster server"); GZClusterStoreServer cs = new GZClusterStoreServer(serverConfig, new HessianSerializer()); // start replica server cs.startReplicaServer(); logger.info("hookup jvm shutdown process"); cs.hookShutdown(); if (start) { logger.info("server is starting " + cs.getServerConfig().toString()); cs.start(); } else logger.warn("server is staged and wait to be started"); List list = new ArrayList(); //add jmx metric List<String> stores = cs.getAllStoreNames(); for (String store : stores) { list.add(cs.getStore(store)); } list.add(cs); stores.add("ClusterServer"); JmxService jms = new JmxService(list, stores); try { logger.info("Read from console and wait ...."); int c = System.in.read(); } catch (IOException e) { logger.warn("Error reading " + e.getMessage()); } logger.warn("Exiting from System.in.read()"); }
From source file:msgsendsample.java
public static void main(String[] args) { if (args.length != 4) { usage();/*from w w w . j a v a2 s .com*/ System.exit(1); } System.out.println(); String to = args[0]; String from = args[1]; String host = args[2]; boolean debug = Boolean.valueOf(args[3]).booleanValue(); // create some properties and get the default Session Properties props = new Properties(); props.put("mail.smtp.host", host); if (debug) props.put("mail.debug", args[3]); Session session = Session.getInstance(props, null); session.setDebug(debug); try { // create a message MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject("JavaMail APIs Test"); msg.setSentDate(new Date()); // If the desired charset is known, you can use // setText(text, charset) msg.setText(msgText); Transport.send(msg); } catch (MessagingException mex) { System.out.println("\n--Exception handling in msgsendsample.java"); mex.printStackTrace(); System.out.println(); Exception ex = mex; do { if (ex instanceof SendFailedException) { SendFailedException sfex = (SendFailedException) ex; Address[] invalid = sfex.getInvalidAddresses(); if (invalid != null) { System.out.println(" ** Invalid Addresses"); for (int i = 0; i < invalid.length; i++) System.out.println(" " + invalid[i]); } Address[] validUnsent = sfex.getValidUnsentAddresses(); if (validUnsent != null) { System.out.println(" ** ValidUnsent Addresses"); for (int i = 0; i < validUnsent.length; i++) System.out.println(" " + validUnsent[i]); } Address[] validSent = sfex.getValidSentAddresses(); if (validSent != null) { System.out.println(" ** ValidSent Addresses"); for (int i = 0; i < validSent.length; i++) System.out.println(" " + validSent[i]); } } System.out.println(); if (ex instanceof MessagingException) ex = ((MessagingException) ex).getNextException(); else ex = null; } while (ex != null); } }
From source file:sendfile.java
public static void main(String[] args) { if (args.length != 5) { System.out.println("usage: java sendfile <to> <from> <smtp> <file> true|false"); System.exit(1);/*from w ww .j a va2s.co m*/ } String to = args[0]; String from = args[1]; String host = args[2]; String filename = args[3]; boolean debug = Boolean.valueOf(args[4]).booleanValue(); String msgText1 = "Sending a file.\n"; String subject = "Sending a file"; // create some properties and get the default Session Properties props = System.getProperties(); props.put("mail.smtp.host", host); Session session = Session.getInstance(props, null); session.setDebug(debug); try { // create a message MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject(subject); // create and fill the first message part MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(msgText1); // create the second message part MimeBodyPart mbp2 = new MimeBodyPart(); // attach the file to the message mbp2.attachFile(filename); /* * Use the following approach instead of the above line if * you want to control the MIME type of the attached file. * Normally you should never need to do this. * FileDataSource fds = new FileDataSource(filename) { public String getContentType() { return "application/octet-stream"; } }; mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); */ // create the Multipart and add its parts to it Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); // add the Multipart to the message msg.setContent(mp); // set the Date: header msg.setSentDate(new Date()); /* * If you want to control the Content-Transfer-Encoding * of the attached file, do the following. Normally you * should never need to do this. * msg.saveChanges(); mbp2.setHeader("Content-Transfer-Encoding", "base64"); */ // send the message Transport.send(msg); } catch (MessagingException mex) { mex.printStackTrace(); Exception ex = null; if ((ex = mex.getNextException()) != null) { ex.printStackTrace(); } } catch (IOException ioex) { ioex.printStackTrace(); } }
From source file:com.adguard.compiler.Main.java
/** * Script for building extension/*from w ww .ja va 2 s . c o m*/ * * @param args Arguments * @throws Exception */ public static void main(String[] args) throws Exception { disableSslValidation(); String sourcePath = getParamValue(args, "--source", "../../Extension"); String destPath = getParamValue(args, "--dest", "../../Build"); //final build name String buildName = getParamValue(args, "--name", null); //version String version = getParamValue(args, "--version", null); //build branch String branch = getParamValue(args, "--branch", null); //browser String configBrowser = getParamValue(args, "--browser", null); Browser browser = Browser.getByName(configBrowser); //download filters before build boolean updateFilters = Boolean.valueOf(getParamValue(args, "--update-filters", "false")); //use local filters boolean useLocalScriptRules = Boolean.valueOf(getParamValue(args, "--local-script-rules", "false")); //update url for extension String updateUrl = getParamValue(args, "--update-url", null); //safari extension id String extensionId = getParamValue(args, "--extensionId", null); //pack method String packMethod = getParamValue(args, "--pack", null); if (!validateParameters(sourcePath, buildName, version, extensionId, configBrowser, packMethod)) { System.exit(-1); } File source = new File(sourcePath); buildName = getBuildName(buildName, browser, version); File dest = new File(destPath, buildName); if (updateFilters) { FilterUtils.updateGroupsAndFiltersMetadata(source); FilterUtils.updateLocalFilters(source); } Map<Integer, List<String>> filtersScriptRules = FilterUtils.getScriptRules(source); File buildResult = createBuild(source, dest, useLocalScriptRules, filtersScriptRules, extensionId, updateUrl, browser, version, branch); if (browser == Browser.SAFARI && updateFilters) { FilterUtils.loadEnglishFilterForSafari(new File(buildResult, "filters")); } File packedFile = null; if (packMethod != null) { if (PACK_METHOD_ZIP.equals(packMethod)) { packedFile = PackageUtils.createZip(ZIP_MAKE_PATH, buildResult); FileUtils.deleteQuietly(buildResult); } else if (PACK_METHOD_CRX.equals(packMethod)) { packedFile = PackageUtils.createCrx(CRX_MAKE_PATH, buildResult, CHROME_CERT_FILE); FileUtils.deleteQuietly(buildResult); } else if (PACK_METHOD_XPI.equals(packMethod)) { packedFile = PackageUtils.createXpi(XPI_MAKE_PATH, buildResult, "adguard-adblocker"); FileUtils.deleteQuietly(buildResult); } } log.info("Build created. Version: " + version); if (packedFile != null) { log.info("File: " + packedFile.getName()); } else { log.info("File: " + buildResult.getName()); } if (extensionId != null) { log.info("ExtensionId: " + extensionId); } log.info("Browser: " + browser); if (updateUrl != null) { log.info("UpdateUrl: " + updateUrl); } log.info("LocalScriptRules: " + useLocalScriptRules); log.info("---------------------------------"); }
From source file:sendfile.java
public static void main(String[] args) { if (args.length != 5) { System.out.println("usage: java sendfile <to> <from> <smtp> <file> true|false"); System.exit(1);//w ww .ja v a2 s. c o m } String to = args[0]; String from = args[1]; String host = args[2]; String filename = args[3]; boolean debug = Boolean.valueOf(args[4]).booleanValue(); String msgText1 = "Sending a file.\n"; String subject = "Sending a file"; // create some properties and get the default Session Properties props = System.getProperties(); props.put("mail.smtp.host", host); Session session = Session.getInstance(props, null); session.setDebug(debug); try { // create a message MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject(subject); // create and fill the first message part MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(msgText1); // create the second message part MimeBodyPart mbp2 = new MimeBodyPart(); // attach the file to the message FileDataSource fds = new FileDataSource(filename); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); // create the Multipart and add its parts to it Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); // add the Multipart to the message msg.setContent(mp); // set the Date: header msg.setSentDate(new Date()); // send the message Transport.send(msg); } catch (MessagingException mex) { mex.printStackTrace(); Exception ex = null; if ((ex = mex.getNextException()) != null) { ex.printStackTrace(); } } }
From source file:MainClass.java
public static void main(String[] args) { if (args.length != 4) { usage();/*from w w w . j av a2 s. co m*/ System.exit(1); } System.out.println(); String to = args[0]; String from = args[1]; String host = args[2]; boolean debug = Boolean.valueOf(args[3]).booleanValue(); // create some properties and get the default Session Properties props = new Properties(); props.put("mail.smtp.host", host); if (debug) props.put("mail.debug", args[3]); Session session = Session.getInstance(props, null); session.setDebug(debug); try { // create a message Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = { new InternetAddress(args[0]) }; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject("JavaMail APIs Test"); msg.setSentDate(new Date()); // If the desired charset is known, you can use // setText(text, charset) msg.setText(msgText); Transport.send(msg); } catch (MessagingException mex) { System.out.println("\n--Exception handling in msgsendsample.java"); mex.printStackTrace(); System.out.println(); Exception ex = mex; do { if (ex instanceof SendFailedException) { SendFailedException sfex = (SendFailedException) ex; Address[] invalid = sfex.getInvalidAddresses(); if (invalid != null) { System.out.println(" ** Invalid Addresses"); if (invalid != null) { for (int i = 0; i < invalid.length; i++) System.out.println(" " + invalid[i]); } } Address[] validUnsent = sfex.getValidUnsentAddresses(); if (validUnsent != null) { System.out.println(" ** ValidUnsent Addresses"); if (validUnsent != null) { for (int i = 0; i < validUnsent.length; i++) System.out.println(" " + validUnsent[i]); } } Address[] validSent = sfex.getValidSentAddresses(); if (validSent != null) { System.out.println(" ** ValidSent Addresses"); if (validSent != null) { for (int i = 0; i < validSent.length; i++) System.out.println(" " + validSent[i]); } } } System.out.println(); if (ex instanceof MessagingException) ex = ((MessagingException) ex).getNextException(); else ex = null; } while (ex != null); } }
From source file:com.mirth.connect.server.launcher.MirthLauncher.java
public static void main(String[] args) { try {// w w w . ja 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:MainClass.java
public static void main(String[] args) { if (args.length != 4) { System.out.println("usage: java msgmultisend <to> <from> <smtp> true|false"); return;// w ww.j a va2 s .c o m } String to = args[0]; String from = args[1]; String host = args[2]; boolean debug = Boolean.valueOf(args[3]).booleanValue(); // create some properties and get the default Session Properties props = new Properties(); props.put("mail.smtp.host", host); Session session = Session.getInstance(props, null); session.setDebug(debug); try { // create a message MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject("JavaMail APIs Multipart Test"); msg.setSentDate(new Date()); // create and fill the first message part MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(msgText1); // create and fill the second message part MimeBodyPart mbp2 = new MimeBodyPart(); // Use setText(text, charset), to show it off ! mbp2.setText(msgText2, "us-ascii"); // create the Multipart and its parts to it Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); // add the Multipart to the message msg.setContent(mp); // send the message Transport.send(msg); } catch (MessagingException mex) { mex.printStackTrace(); Exception ex = null; if ((ex = mex.getNextException()) != null) { ex.printStackTrace(); } } }
From source file:com.calamp.services.kinesis.events.processor.CalAmpEventProcessor.java
public static void main(String[] args) throws Exception { checkUsage(args);/*from w w w . j ava2 s. c om*/ //String applicationName = args[0]; //String streamName = args[1]; //Region region = RegionUtils.getRegion(args[2]); boolean isUnordered = Boolean.valueOf(args[3]); String applicationName = isUnordered ? CalAmpParameters.sortAppName : CalAmpParameters.consumeAppName; String streamName = isUnordered ? CalAmpParameters.unorderdStreamName : CalAmpParameters.orderedStreamName; Region region = RegionUtils.getRegion(CalAmpParameters.regionName); if (region == null) { System.err.println(args[2] + " is not a valid AWS region."); System.exit(1); } setLogLevels(); AWSCredentialsProvider credentialsProvider = CredentialUtils.getCredentialsProvider(); ClientConfiguration cc = ConfigurationUtils.getClientConfigWithUserAgent(true); AmazonKinesis kinesisClient = new AmazonKinesisClient(credentialsProvider, cc); kinesisClient.setRegion(region); //Utils.kinesisClient = kinesisClient; String workerId = String.valueOf(UUID.randomUUID()); KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName, streamName, credentialsProvider, workerId).withRegionName(region.getName()).withCommonClientConfig(cc) .withMaxRecords(com.calamp.services.kinesis.events.utils.CalAmpParameters.maxRecPerPoll) .withIdleTimeBetweenReadsInMillis( com.calamp.services.kinesis.events.utils.CalAmpParameters.pollDelayMillis) .withCallProcessRecordsEvenForEmptyRecordList(CalAmpParameters.alwaysPoll) .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON); IRecordProcessorFactory processorFactory = new RecordProcessorFactory(isUnordered); // Create the KCL worker with the stock trade record processor factory Worker worker = new Worker(processorFactory, kclConfig); int exitCode = 0; try { worker.run(); } catch (Throwable t) { LOG.error("Caught throwable while processing data.", t); exitCode = 1; } System.exit(exitCode); }