List of usage examples for java.lang System getProperties
public static Properties getProperties()
From source file:com.couchbase.shell.CouchbaseShell.java
public CouchbaseShell() { connected = false;//from w w w .j ava2s . co m hasQuery = false; Properties systemProperties = System.getProperties(); systemProperties.put("net.spy.log.LoggerImpl", "net.spy.memcached.compat.log.Log4JLogger"); System.setProperties(systemProperties); }
From source file:ch.cyberduck.core.sds.SDSSearchFeatureTest.java
@Test public void testSearch() throws Exception { final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials( System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key"))); final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final String name = new AlphanumericRandomStringService().random(); final Path room = new SDSDirectoryFeature(session) .mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus()); final Path directory = new SDSDirectoryFeature(session).mkdir( new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); final Path file = new SDSTouchFeature(session).touch(new Path(directory, name, EnumSet.of(Path.Type.file)), new TransferStatus()); final SDSSearchFeature feature = new SDSSearchFeature(session); assertTrue(feature.search(room, new SearchFilter(name), new DisabledListProgressListener()).contains(file)); assertTrue(feature/*from w w w . j a v a 2s .c o m*/ .search(room, new SearchFilter(StringUtils.substring(name, 2)), new DisabledListProgressListener()) .contains(file)); assertTrue(feature.search(room, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)), new DisabledListProgressListener()).contains(file)); assertTrue(feature.search(directory, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)), new DisabledListProgressListener()).contains(file)); try { assertFalse(feature.search( new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new SearchFilter(name), new DisabledListProgressListener()).contains(file)); fail(); } catch (NotfoundException e) { // } final Path subdir = new SDSDirectoryFeature(session).mkdir(new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertNull(feature.search(subdir, new SearchFilter(name), new DisabledListProgressListener()) .find(new SimplePathPredicate(file))); final Path filesubdir = new SDSTouchFeature(session).touch( new Path(subdir, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); { final AttributedList<Path> result = feature.search(directory, new SearchFilter(filesubdir.getName()), new DisabledListProgressListener()); assertNotNull(result.find(new SimplePathPredicate(filesubdir))); assertEquals(subdir, result.find(new SimplePathPredicate(filesubdir)).getParent()); } new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:io.kamax.mxisd.threepid.connector.email.EmailSmtpConnector.java
@Autowired public EmailSmtpConnector(EmailSmtpConfig cfg) { this.cfg = cfg; session = Session.getInstance(System.getProperties()); }
From source file:com.opengamma.language.context.DefaultGlobalContextEventHandler.java
/** * Merges user specified settings into the "system" settings. Typically, settings * will be provided by the O/S launcher (e.g. from the registry on Windows). A * properties file can be used for a fallback if the properties aren't defined in * the registry. For example to provide defaults. * /*from www. j a v a2s. c om*/ * @param systemSettings the default settings to use */ public void setSystemSettings(final Properties systemSettings) { ArgumentChecker.notNull(systemSettings, "systemSettings"); final Properties existingSettings = System.getProperties(); final Enumeration<Object> keys = systemSettings.keys(); while (keys.hasMoreElements()) { final Object keyObject = keys.nextElement(); if (existingSettings.containsKey(keyObject)) { s_logger.debug("Ignoring {} in favour of system property", keyObject); } else { if (keyObject instanceof String) { final String key = (String) keyObject; final String value = systemSettings.getProperty(key); existingSettings.setProperty(key, value); s_logger.debug("Using {}={}", key, value); } } } }
From source file:com.tdclighthouse.prototype.utils.Configuration.java
public Configuration(String systemPropertyName, String defaultPropertiesFileLocation) throws IOException { String propertyFilePath = System.getProperties().getProperty(systemPropertyName); Resource location = null;/* ww w .j av a 2 s . co m*/ if (StringUtils.isNotBlank(propertyFilePath)) { location = new FileSystemResource(propertyFilePath); } else { location = new ClassPathResource(defaultPropertiesFileLocation); } properties = new Properties(); properties.load(location.getInputStream()); }
From source file:ch.cyberduck.core.shared.DefaultCopyFeatureTest.java
@Test public void testSupported() throws Exception { final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("sftp.user"), System.getProperties().getProperty("sftp.password"))); final SFTPSession session = new SFTPSession(host); final Path source = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); assertTrue(new DefaultCopyFeature(session).isSupported(source, target)); session.close();//from ww w . j a v a 2 s .co m }
From source file:com.wso2telco.workflow.notification.EmailService.java
public void sendEmail(final String emailAddress, final String subject, final String content) { new Thread() { @Override//from w w w . j a v a 2 s .co m public void run() { Map<String, String> workflowProperties = WorkflowProperties.loadWorkflowPropertiesFromXML(); String emailHost = workflowProperties.get(Constants.KEY_WORKFLOW_EMAIL_NOTIFICATION_HOST); String fromEmailAddress = workflowProperties .get(Constants.KEY_WORKFLOW_EMAIL_NOTIFICATION_FROM_ADDRESS); String fromEmailPassword = workflowProperties .get(Constants.KEY_WORKFLOW_EMAIL_NOTIFICATION_FROM_PASSWORD); Properties props = System.getProperties(); props.put("mail.smtp.host", emailHost); props.put("mail.smtp.user", fromEmailAddress); props.put("mail.smtp.password", fromEmailPassword); props.put("mail.smtp.port", "587"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); try { Session session = Session.getDefaultInstance(props, null); InternetAddress toAddress = new InternetAddress(emailAddress); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(fromEmailAddress)); message.addRecipient(Message.RecipientType.TO, toAddress); message.setSubject(subject); message.setContent(content, "text/html; charset=UTF-8"); Transport transport = session.getTransport("smtp"); transport.connect(emailHost, fromEmailAddress, fromEmailPassword); transport.sendMessage(message, message.getAllRecipients()); transport.close(); } catch (Exception e) { log.error("Email sending failed. ", e); } } }.start(); }
From source file:ch.cyberduck.core.ftp.FTPDefaultListServiceTest.java
@Test public void testListDefault() throws Exception { final Host host = new Host(new FTPTLSProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("ftp.user"), System.getProperties().getProperty("ftp.password"))); final FTPSession session = new FTPSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final ListService list = new FTPDefaultListService(session, new DisabledPasswordStore(), new DisabledLoginCallback(), new CompositeFileEntryParser(Arrays.asList(new UnixFTPEntryParser())), FTPListService.Command.list); final Path directory = new FTPWorkdirService(session).find(); final Path file = new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new DefaultTouchFeature<Integer>(new DefaultUploadFeature<Integer>(new FTPWriteFeature(session))) .touch(file, new TransferStatus()); assertTrue(list.list(directory, new DisabledListProgressListener()).contains(file)); new FTPDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close();/*from ww w . ja va 2s. co m*/ }
From source file:edu.wright.cs.fa15.ceg3120.concon.server.EmailManager.java
/** * Add an outgoing email to the queue.//from ww w.java 2 s . c o m * @param to Array of email addresses. * @param subject Header * @param body Content * @param attachmentFile Attachment */ public void addEmail(String[] to, String subject, String body, File attachmentFile) { HtmlEmail mail = new HtmlEmail(); Properties sysProps = System.getProperties(); // Setup mail server sysProps.setProperty("mail.smtp.host", props.getProperty("mail_server_hostname")); Session session = Session.getDefaultInstance(sysProps); try { mail.setMailSession(session); mail.setFrom(props.getProperty("server_email_addr"), props.getProperty("server_title")); mail.addTo(to); mail.setSubject(subject); mail.setTextMsg(body); mail.setHtmlMsg(composeAsHtml(mail, body)); if (attachmentFile.exists()) { EmailAttachment attachment = new EmailAttachment(); attachment.setPath(attachmentFile.getPath()); mail.attach(attachment); } } catch (EmailException e) { LOG.warn("Email was not added. ", e); } mailQueue.add(mail); }
From source file:org.camunda.connect.httpclient.HttpConnectorSystemPropertiesTest.java
public void setSystemProperty(String property, String value) { if (!System.getProperties().containsKey(property)) { updatedSystemProperties.add(property); System.setProperty(property, value); } else {/*from www. j ava 2s . co m*/ throw new RuntimeException("Cannot perform test: System property " + property + " is already set. Will not attempt to overwrite this property."); } }