List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:io.starter.datamodel.Sys.java
/** * /* w ww. j a v a2 s . co m*/ * @param params * @throws Exception * * */ public static void sendEmail(String url, final User from, String toEmail, Map params, SqlSession session, CountDownLatch latch) throws Exception { final CountDownLatch ltc = latch; if (from == null) { throw new ServletException("Sys.sendEmail cannot have a null FROM User."); } String fromEmail = from.getEmail(); final String fro = fromEmail; final String to = toEmail; final Map p = params; final String u = url; final SqlSession sr = session; // TODO: check message sender/recipient validity if (!checkEmailValidity(fromEmail)) { throw new RuntimeException( fromEmail + " is not a valid email address. SENDING MESSAGE TO " + toEmail + " FAILED"); } // TODO: check mail server if it's a valid message if (!checkEmailValidity(toEmail)) { throw new RuntimeException( toEmail + " is not a valid email address. SENDING MESSAGE TO " + toEmail + " FAILED"); } // message.setSubject("Testing Email From Starter.io"); // Send the actual HTML message, as big as you like // fetch the content final String content = getText(u); new Thread(new Runnable() { @Override public void run() { // Sender's email ID needs to be mentioned // String sendAccount = "$EMAIL_USER_NAME$"; // final String username = "$EMAIL_USER_NAME$", password = // "hum0rm3"; // Assuming you are sending email from localhost // String host = "gator3083.hostgator.com"; String sendAccount = "$EMAIL_USER_NAME$"; final String username = "$EMAIL_USER_NAME$", password = "$EMAIL_USER_PASS$"; // Assuming you are sending email from localhost String host = SystemConstants.EMAIL_SERVER; // Get system properties Properties props = System.getProperties(); // Setup mail server props.setProperty("mail.smtp.host", host); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.port", "587"); // Get the default Session object. Session session = Session.getInstance(props, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(sendAccount)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(sendAccount)); // Set Subject: header field Object o = p.get("MESSAGE_SUBJECT"); message.setSubject(o.toString()); String ctx = new String(content.toString()); // TODO: String Rep on the params ctx = stringRep(ctx, p); message.setContent(ctx, "text/html; charset=utf-8"); // message.setContent(new Multipart()); // Send message Transport.send(message); Logger.log("Sending message to:" + to + " SUCCESS"); } catch (MessagingException mex) { // mex.printStackTrace(); Logger.log("Sending message to:" + to + " FAILED"); Logger.error("Sys.sendEmail() failed to send message. Messaging Exception: " + mex.toString()); } // log the data Syslog logEntry = new Syslog(); logEntry.setDescription("OK [ email sent from: " + fro + " to: " + to + "]"); logEntry.setUserId(from.getId()); logEntry.setEventType(SystemConstants.LOG_EVENT_TYPE_SEND_EMAIL); logEntry.setSourceId(from.getId()); // unknown logEntry.setSourceType(SystemConstants.TARGET_TYPE_USER); logEntry.setTimestamp(new java.util.Date(System.currentTimeMillis())); SqlSessionFactory sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory(); SqlSession sesh = sqlSessionFactory.openSession(true); sesh.insert("io.starter.dao.SyslogMapper.insert", logEntry); sesh.commit(); if (ltc != null) ltc.countDown(); // release the latch } }).start(); }
From source file:ch.digitalfondue.npjt.TestJdbcConfiguration.java
@Bean public DataSource getDataSource() throws Exception { Properties prop = new Properties(); prop.put("url", "jdbc:hsqldb:mem:extra"); prop.put("user", "sa"); prop.put("password", ""); return JDBCDataSourceFactory.createDataSource(prop); }
From source file:org.cloudfoundry.reconfiguration.tomee.dummy.DummyPropertiesProvider.java
@Override public Properties provide(ServiceInfo serviceInfo, Properties defaultConfiguration) { defaultConfiguration.put(DummyServiceInfo.CONFIG_KEY, DummyServiceInfo.CONFIG_VALUE); return defaultConfiguration; }
From source file:org.cloudfoundry.reconfiguration.tomee.dummy.JdbcPropertiesProvider.java
@Override public Properties provide(ServiceInfo serviceInfo, Properties defaultConfiguration) { defaultConfiguration.put(JdbcServiceInfo.CONFIG_KEY, JdbcServiceInfo.ID); return defaultConfiguration; }
From source file:org.darwinathome.server.email.EnhancedJavaMailSenderImpl.java
@Override public void setUsername(String userName) { if (userName.contains("gmail.com")) { Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); super.setJavaMailProperties(props); }/*from w ww. ja v a 2 s .c o m*/ super.setUsername(userName); }
From source file:io.lavagna.service.LdapConnection.java
InitialDirContextCloseable context(String providerUrl, String principal, String password) throws NamingException { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, providerUrl); env.put(Context.SECURITY_PRINCIPAL, principal); env.put(Context.SECURITY_CREDENTIALS, password); return new InitialDirContextCloseable(env); }
From source file:de.hska.ld.core.config.VelocityConfig.java
@Bean public VelocityEngineFactoryBean velocityEngine() { VelocityEngineFactoryBean factoryBean = new VelocityEngineFactoryBean(); Properties properties = new Properties(); properties.put("resource.loader", "class"); properties.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName()); factoryBean.setVelocityProperties(properties); return factoryBean; }
From source file:com.stratio.decision.configuration.KafkaConfiguration.java
@Bean public Producer<String, String> producer() { Properties properties = new Properties(); properties.put("serializer.class", "kafka.serializer.StringEncoder"); properties.put("metadata.broker.list", configurationContext.getKafkaHostsQuorum()); properties.put("producer.type", "async"); return new Producer<String, String>(new ProducerConfig(properties)); }
From source file:org.openeos.hibernate.internal.configurators.FixedConfigurator.java
@Override public void init(ConfigurationProvider configurationProvider) { LOG.debug("Initializing static fixed configuration"); Configuration conf = configurationProvider.getConfiguration(); Properties props = new Properties(); props.put("hibernate.bytecode.provider", "null"); props.put("hibernate.current_session_context_class", "org.springframework.orm.hibernate4.SpringSessionContext"); props.put("hibernate.jdbc.batch_size", "30"); props.put("hibernate.enable_lazy_load_no_trans", "true"); props.put("javax.persistence.validation.mode", "none"); props.put("show_sql", "true"); conf.addProperties(props);//w w w. j a v a2s .c om configurationProvider.invalidate(); }
From source file:gov.nih.nci.ncicb.cadsr.bulkloader.util.MainTestCase.java
protected static Properties getDBProperties() { Properties properties = new Properties(); properties.put("db.url", getPropertyManager().getUnitDataSourceURL()); properties.put("db.username", getPropertyManager().getUnitDataSourceUser()); properties.put("db.password", getPropertyManager().getUnitDataSourcePassword()); return properties; }