@Test public void testToProperties() { EmailResourceFactory factory = new EmailResourceFactory(); Vector<RefAddr> initialProperties = new Vector<>(); Enumeration<RefAddr> attributes = initialProperties.elements(); Properties properties = factory.toProperties(attributes); assertNull(properties.getProperty("non.existing.property")); initialProperties.add(new StringRefAddr(CONFIGURATION_MAIL_SMTP_USER, "joe")); attributes = initialProperties.elements(); properties = factory.toProperties(attributes); assertEquals("joe", properties.getProperty(CONFIGURATION_MAIL_SMTP_USER)); Framework.getProperties().put("mail.transport.password", "varExpandedPassword"); initialProperties.add(new StringRefAddr(CONFIGURATION_MAIL_SMTP_PASSWORD, "${mail.transport.password}")); attributes = initialProperties.elements(); properties = factory.toProperties(attributes); assertEquals("varExpandedPassword", properties.getProperty(CONFIGURATION_MAIL_SMTP_PASSWORD)); Framework.getProperties().remove("mail.transport.password"); }
protected Properties toProperties(Enumeration<RefAddr> attributes) { Properties props = new Properties(); while (attributes.hasMoreElements()) { RefAddr attribute = attributes.nextElement(); if ("factory".equals(attribute.getType())) { continue; } String key = attribute.getType(); String value = Framework.expandVars((String) attribute.getContent()); props.put(key, value); } return props; }
EmailResourceFactory implements ObjectFactory { protected Properties toProperties(Enumeration<RefAddr> attributes) { Properties props = new Properties(); while (attributes.hasMoreElements()) { RefAddr attribute = attributes.nextElement(); if ("factory".equals(attribute.getType())) { continue; } String key = attribute.getType(); String value = Framework.expandVars((String) attribute.getContent()); props.put(key, value); } return props; } }
EmailResourceFactory implements ObjectFactory { protected Properties toProperties(Enumeration<RefAddr> attributes) { Properties props = new Properties(); while (attributes.hasMoreElements()) { RefAddr attribute = attributes.nextElement(); if ("factory".equals(attribute.getType())) { continue; } String key = attribute.getType(); String value = Framework.expandVars((String) attribute.getContent()); props.put(key, value); } return props; }  }
EmailResourceFactory implements ObjectFactory { protected Properties toProperties(Enumeration<RefAddr> attributes) { Properties props = new Properties(); while (attributes.hasMoreElements()) { RefAddr attribute = attributes.nextElement(); if ("factory".equals(attribute.getType())) { continue; } String key = attribute.getType(); String value = Framework.expandVars((String) attribute.getContent()); props.put(key, value); } return props; }  @Override Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment); }
EmailResourceFactory implements ObjectFactory { protected Properties toProperties(Enumeration<RefAddr> attributes) { Properties props = new Properties(); while (attributes.hasMoreElements()) { RefAddr attribute = attributes.nextElement(); if ("factory".equals(attribute.getType())) { continue; } String key = attribute.getType(); String value = Framework.expandVars((String) attribute.getContent()); props.put(key, value); } return props; }  @Override Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment);  }