List of usage examples for java.lang System getProperties
public static Properties getProperties()
From source file:com.nridge.core.base.std.Platform.java
/** * Determines if the current platform that the JVM is executing within is * a Windows-based operating system.//from ww w . j a va 2 s. c om * @return <i>true</i> if it is or <i>false</i> otherwise. */ public static boolean isWindows() { String osName; Properties osProperties; osProperties = System.getProperties(); osName = (String) osProperties.get("os.name"); return StringUtils.isNotEmpty(osName) && osName.startsWith(PLATFORM_WINDOWS); }
From source file:gov.nih.nci.caintegrator.application.mail.SendMail.java
public synchronized void sendMail(String mailTo, String mailCC, String mailBody, String subject) throws ValidationException { try {/*w w w . j ava 2s .c om*/ if (mailTo != null && EmailValidator.getInstance().isValid(mailTo)) { //get system properties Properties props = System.getProperties(); String to = mailTo; // Set up mail server props.put("mail.smtp.host", MailConfig.getInstance(mailProperties).getHost()); //Get session Session session = Session.getDefaultInstance(props, null); //Define Message MimeMessage message = new MimeMessage(session); MailManager mailManager = new MailManager(mailProperties); message.setFrom(new InternetAddress(mailManager.formatFromAddress())); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); if ((mailCC != null) && EmailValidator.getInstance().isValid(mailCC)) message.addRecipient(Message.RecipientType.CC, new InternetAddress(mailCC)); message.setSubject(subject); message.setText(mailBody); //Send Message Transport.send(message); } else { throw new ValidationException("Invalid Email Address"); } } catch (Exception e) { logger.error("Send Mail error", e); } //catch }
From source file:cl.preguntame.controller.PlataformaController.java
@ResponseBody @RequestMapping(value = "/email", method = RequestMethod.POST) public String correo(HttpServletRequest req) { try {/* www . j a v a2 s .com*/ String host = "smtp.gmail.com"; Properties prop = System.getProperties(); prop.put("mail.smtp.starttls.enable", "true"); prop.put("mail.smtp.host", host); prop.put("mail.smtp.user", "hector.riquelme1169@gmail.com"); prop.put("mail.smtp.password", "rriiqquueellmmee"); prop.put("mail.smtp.port", 587); prop.put("mail.smtp.auth", "true"); Session sesion = Session.getDefaultInstance(prop, null); MimeMessage mensaje = new MimeMessage(sesion); mensaje.setFrom(new InternetAddress()); mensaje.setRecipient(Message.RecipientType.TO, new InternetAddress("hector.riquelme1169@gmail.com")); mensaje.setSubject("CONTACTO MIS CONCEPTOS"); mensaje.setText(req.getParameter("mensaje_contacto")); Transport transport = sesion.getTransport("smtp"); transport.connect(host, "hector.riquelme1169@gmail.com", "rriiqquueellmmee"); transport.sendMessage(mensaje, mensaje.getAllRecipients()); transport.close(); } catch (Exception e) { } return req.getParameter("mensaje_contacto") + " - " + req.getParameter("email_contacto"); }
From source file:com.facebook.config.SystemPropOverridingJSONProvider.java
private JSONObject includeSystemProperties(JSONObject jsonObject) throws JSONException { for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); // try first to see if value might be a json Object try { JSONObject valueAsJSONObject = new JSONObject(value); jsonObject.put(key, valueAsJSONObject); } catch (JSONException e) { // means value is just a plain old string jsonObject.put(key, value); }/*from w ww. j a v a2 s . co m*/ } } return jsonObject; }
From source file:com.enonic.vertical.adminweb.PropertiesInfoModelFactory.java
public PropertiesInfoModel createSystemPropertiesModel() { PropertiesInfoModel infoModel = new PropertiesInfoModel(); try {// w w w . ja v a2s .c om infoModel.setSystemProperties(System.getProperties()); infoModel.setDatasourceProperties(this.dataSourceInfoResolver.getInfo(false)); infoModel.setConfigurationProperties(getConfigurationProperties()); infoModel.setVhostProperties(virtualHosts); } catch (Exception e) { throw new VerticalAdminException("Not able to create properties-model", e); } return infoModel; }
From source file:net.sf.ehcache.store.ApacheLruMemoryStoreTest.java
/** * Put back system default.// ww w .ja va2s. c o m * @throws Exception */ protected void tearDown() throws Exception { System.getProperties().remove("net.sf.ehcache.useLRUMap"); super.tearDown(); }
From source file:nz.co.senanque.madura.spring.URLFactoryBean.java
public Object getObject() throws Exception { String urlString = (String) System.getProperties().get(m_name); if (urlString != null) { return new URL(urlString); }// w ww . j av a 2 s . co m return new URL(m_properties.get(m_name).toString()); }
From source file:com.bstek.dorado.core.el.CoreContextVarsInitializer.java
public void initializeContext(Map<String, Object> vars) { try {//from w w w . j a v a 2 s.c o m vars.put("null", null); vars.put("this", null); vars.put("env", System.getenv()); vars.put("system", System.getProperties()); vars.put("configure", Configure.getStore()); vars.put("context", Context.getCurrent()); vars.put("ctx", new ContextWrapperMap(Context.getCurrent())); vars.put("util", SingletonBeanFactory.getInstance(ExpressionUtilsObject.class)); } catch (Exception e) { logger.error(e, e); } }
From source file:test.com.azaptree.services.spring.application.config.ApplicationSpringConfig.java
@Bean public Properties systemProps() { return System.getProperties(); }
From source file:com.googlecode.shutdownlistener.ContextShutdownTest.java
@Before public void setupTest() { ShutdownConfiguration.deleteInstance(); StaticTrackingShutdownListener.reset(); System.getProperties().remove(ShutdownConfiguration.CONFIGURATION_SYSTEM_PROPERTY); }