List of usage examples for java.util Properties isEmpty
@Override public boolean isEmpty()
From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.reporters.trace.MsgTraceReporter.java
protected static void pollConfigQueue(Map<String, ?> config, Properties kafkaProperties, Map<String, TraceCommandDeserializer.TopicTraceCommand> traceConfig) { Properties props = new Properties(); if (config != null) { props.putAll(config);//from w w w .j a v a 2s . c o m } if (kafkaProperties != null) { props.putAll(extractKafkaProperties(kafkaProperties)); } if (!props.isEmpty()) { props.put(ConsumerConfig.CLIENT_ID_CONFIG, "kafka-x-ray-message-trace-reporter-config-listener"); // NON-NLS props.remove(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG); KafkaConsumer<String, TraceCommandDeserializer.TopicTraceCommand> consumer = getKafkaConsumer(props); while (true) { ConsumerRecords<String, TraceCommandDeserializer.TopicTraceCommand> records = consumer.poll(100); if (records.count() > 0) { LOGGER.log(OpLevel.DEBUG, StreamsResources.getBundle(KafkaStreamConstants.RESOURCE_BUNDLE_NAME), "MsgTraceReporter.polled.commands", records.count(), records.iterator().next()); for (ConsumerRecord<String, TraceCommandDeserializer.TopicTraceCommand> record : records) { if (record.value() != null) { traceConfig.put(record.value().topic, record.value()); } } break; } } } }
From source file:eionet.cr.harvest.util.MediaTypeToDcmiTypeConverter.java
/** * Loads the mimetypes from the file and puts them into mimeToRdfMap. *//*from ww w .j a v a2 s . com*/ private static void initialize() { mappings = new LinkedHashMap<String, String>(); InputStream inputStream = null; Properties properties = new Properties(); try { inputStream = MediaTypeToDcmiTypeConverter.class.getClassLoader() .getResourceAsStream(MAPPINGS_FILENAME); properties.loadFromXML(inputStream); } catch (IOException e) { LOGGER.error("Failed to load XML-formatted properties from " + MAPPINGS_FILENAME, e); } finally { if (inputStream != null) { IOUtils.closeQuietly(inputStream); } } if (!properties.isEmpty()) { for (Map.Entry entry : properties.entrySet()) { String rdfType = entry.getKey().toString(); String[] mediaTypes = entry.getValue().toString().split("\\s+"); if (!StringUtils.isBlank(rdfType) && mediaTypes != null && mediaTypes.length > 0) { for (int i = 0; i < mediaTypes.length; i++) { if (!StringUtils.isBlank(mediaTypes[i])) { mappings.put(mediaTypes[i].trim(), rdfType.trim()); } } } } } }
From source file:org.escidoc.browser.elabsmodul.service.ELabsService.java
private static List<String[]> buildConfiguration(final List<Map<String, String>> list) { Preconditions.checkNotNull(list, "Config list is null"); final List<String[]> result = new ArrayList<String[]>(); if (list.isEmpty()) { LOG.error("There is not ConfigMap to process!"); return null; }//from w w w.j a va 2s .c om for (final Map<String, String> map : list) { final Properties config = new Properties(); config.putAll(map); if (!config.isEmpty()) { LOG.debug(config.toString()); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { config.storeToXML(out, ""); LOG.debug("Configuration Properties XML \n" + out.toString()); } catch (final IOException e) { LOG.error(e.getMessage()); } result.add(new String[] { config.getProperty(ELabsServiceConstants.E_SYNC_DAEMON_ENDPOINT), out.toString() }); } else { LOG.error("Configuration is empty!"); } } return result; }
From source file:org.wisdom.maven.utils.Properties2HoconConverter.java
/** * Converts the given properties file (props) to hocon. * * @param props the properties file, must exist and be a valid properties file. * @param backup whether or not a backup should be generated. It backup is set to true, a ".backup" file is * generated before the conversion. * @return the output file. It's the input file, except if the props' name does not end with ".conf", in that * case it generates a new file with this extension. * @throws IOException if something bad happens. *//*from ww w .j a va 2 s . com*/ public static File convert(File props, boolean backup) throws IOException { if (!props.isFile()) { throw new IllegalArgumentException( "The given properties file does not exist : " + props.getAbsolutePath()); } Properties properties; try { properties = readFileAsProperties(props); } catch (IOException e) { throw new IllegalArgumentException("Cannot convert " + props.getName() + " to hocon - the file is not a " + "valid properties file", e); } // Properties cannot be null there, but might be empty if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Cannot convert an empty file : " + props.getAbsolutePath()); } // The conversion can start if (backup) { // Generate backup try { generateBackup(props); } catch (IOException e) { throw new IllegalStateException("Cannot generate the backup for " + props.getName(), e); } } String hocon = convertToHocon(props); File output = props; if (!props.getName().endsWith(".conf")) { // Replace extension output = new File(props.getParentFile(), props.getName().substring(0, props.getName().lastIndexOf(".")) + ".conf"); } FileUtils.write(output, hocon); return output; }
From source file:org.nuxeo.theme.themes.ThemeRepairer.java
private static void cleanupStyles(Element element) { Widget widget = (Widget) ElementFormatter.getFormatFor(element, "widget"); Style style = (Style) ElementFormatter.getFormatFor(element, "style"); String xpath = element.computeXPath(); // Simplify styles by removing disallowed layout properties and by // cleaning up paths without properties if (style != null && widget != null) { String viewName = widget.getName(); List<String> pathsToClear = new ArrayList<String>(); for (String path : style.getPathsForView(viewName)) { Properties styleProperties = style.getPropertiesFor(viewName, path); if (styleProperties == null) { continue; }/* ww w . j a v a 2 s . c om*/ for (String key : LAYOUT_PROPERTIES) { if (styleProperties.containsKey(key)) { styleProperties.remove(key); log.debug("Removed property: '" + key + "' from <style> for element " + xpath); } } if (styleProperties.isEmpty()) { pathsToClear.add(path); continue; } List<String> stylePropertiesToRemove = new ArrayList<String>(); for (Object key : styleProperties.keySet()) { String propertyName = (String) key; if ((widget instanceof PageElement && !Utils.contains(PAGE_STYLE_PROPERTIES, propertyName)) || (widget instanceof SectionElement && !Utils.contains(SECTION_STYLE_PROPERTIES, propertyName)) || (widget instanceof CellElement && !Utils.contains(CELL_STYLE_PROPERTIES, propertyName))) { stylePropertiesToRemove.add(propertyName); } } for (String propertyName : stylePropertiesToRemove) { styleProperties.remove(propertyName); log.debug("Removed style property: '" + propertyName + " in path: " + path + "' for element " + xpath); } } for (String path : pathsToClear) { style.clearPropertiesFor(viewName, path); log.debug("Removed empty style path: '" + path + "' for element " + xpath); } } }
From source file:org.wso2.carbon.sts.STSDeploymentInterceptor.java
/** * Updates STS service during deployment * * @param config AxisConfiguration//from ww w .j a v a 2 s . c om * @throws Exception */ public static void updateSTSService(AxisConfiguration config) throws Exception { AxisService service = null; Registry configRegistry = null; Registry governRegistry = null; String keyPassword = null; KeyStoreAdmin admin = null; KeyStoreData[] keystores = null; String privateKeyAlias = null; String keyStoreName = null; String issuerName = null; ServerConfiguration serverConfig = null; int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); configRegistry = STSServiceDataHolder.getInstance().getRegistryService().getConfigSystemRegistry(tenantId); governRegistry = STSServiceDataHolder.getInstance().getRegistryService() .getGovernanceSystemRegistry(tenantId); if (configRegistry == null || config.getService(ServerConstants.STS_NAME) == null) { if (log.isDebugEnabled()) { log.debug("configRegistry not set or STS service is unavailable"); } return; } serverConfig = ServerConfiguration.getInstance(); admin = new KeyStoreAdmin(tenantId, governRegistry); if (MultitenantConstants.SUPER_TENANT_ID == tenantId) { keyPassword = serverConfig.getFirstProperty(SECURITY_KEY_STORE_KEY_PASSWORD); keystores = admin.getKeyStores(true); for (int i = 0; i < keystores.length; i++) { if (KeyStoreUtil.isPrimaryStore(keystores[i].getKeyStoreName())) { keyStoreName = keystores[i].getKeyStoreName(); privateKeyAlias = KeyStoreUtil.getPrivateKeyAlias(KeyStoreManager .getInstance(MultitenantConstants.SUPER_TENANT_ID).getKeyStore(keyStoreName)); break; } } } else { // this is not the proper way to find out the primary key store of the tenant. We need // check a better way TODO String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if (tenantDomain == null) { tenantDomain = STSServiceDataHolder.getInstance().getRealmService().getTenantManager() .getDomain(tenantId); } if (tenantDomain != null) { // assuming domain always in this format -> example.com keyStoreName = tenantDomain.replace(".", "-") + ".jks"; KeyStore keyStore = KeyStoreManager.getInstance(tenantId).getKeyStore(keyStoreName); if (keyStore != null) { privateKeyAlias = KeyStoreUtil.getPrivateKeyAlias(keyStore); keyPassword = KeyStoreManager.getInstance(tenantId).getKeyStorePassword(keyStoreName); } else { log.warn("No key store is exist as " + keyStoreName + ". STS would be fail"); } } else { throw new Exception("Tenant Domain can not be null"); } } issuerName = serverConfig.getFirstProperty(HOST_NAME); if (issuerName == null) { // HostName not set :-( use wso2wsas-sts issuerName = ServerConstants.STS_NAME; } if (privateKeyAlias != null) { service = config.getService(ServerConstants.STS_NAME); String cryptoProvider = ServerCrypto.class.getName(); Properties props = RampartConfigUtil.getServerCryptoProperties(new String[] { keyStoreName }, keyStoreName, privateKeyAlias); SAMLTokenIssuerConfig stsSamlConfig = new SAMLTokenIssuerConfig(issuerName, cryptoProvider, props); stsSamlConfig.setIssuerKeyAlias(privateKeyAlias); stsSamlConfig.setIssuerKeyPassword(keyPassword); stsSamlConfig.setAddRequestedAttachedRef(true); stsSamlConfig.setAddRequestedUnattachedRef(true); stsSamlConfig.setKeyComputation(2); stsSamlConfig.setProofKeyType(TokenIssuerUtil.BINARY_SECRET); String resourcePath = null; resourcePath = RegistryResources.SERVICE_GROUPS + ServerConstants.STS_NAME + RegistryResources.SERVICES + ServerConstants.STS_NAME + "/trustedServices"; if (configRegistry.resourceExists(resourcePath)) { Resource trustedService = null; Properties properties = null; Iterator iterator = null; trustedService = configRegistry.get(resourcePath); properties = trustedService.getProperties(); if (properties != null && !properties.isEmpty()) { iterator = properties.entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); if (RegistryUtils.isHiddenProperty(entry.getKey().toString())) { continue; } stsSamlConfig.addTrustedServiceEndpointAddress((String) entry.getKey(), (String) ((List) entry.getValue()).get(0)); } } } //Set the TTL value read from the carbon.xml String ttl = serverConfig.getFirstProperty(STS_TIME_TO_LIVE); if (StringUtils.isNotBlank(ttl)) { try { stsSamlConfig.setTtl(Long.parseLong(ttl)); if (log.isDebugEnabled()) { log.debug("STSTimeToLive read from carbon.xml " + ttl); } } catch (NumberFormatException e) { log.error("Error while reading STSTimeToLive from carbon.xml", e); } } //set if token store is disabled String tokenStoreDisabled = serverConfig.getFirstProperty(SECURITY_DISABLE_TOKEN_STORE); if (tokenStoreDisabled != null) { stsSamlConfig.setTokenStoreDisabled(Boolean.parseBoolean(tokenStoreDisabled)); } //Set persister configuration reading from carbon.xml String persisterClassName = serverConfig.getFirstProperty(SECURITY_TOKEN_PERSISTER_CLASS); String persistingFilePath = serverConfig.getFirstProperty(SECURITY_TOKEN_PERSISTER_STORAGE_PATH); String inMemoryThreshold = serverConfig.getFirstProperty(SECURITY_TOKEN_PERSISTER_IN_MEMORY_THRESHOLD); if (persisterClassName != null) { stsSamlConfig.setPersisterClassName(persisterClassName); } Map<String, String> propertyMap = new HashMap<>(); if (persistingFilePath != null) { propertyMap.put(AbstractIssuerConfig.LOCAL_PROPERTY_STORAGE_PATH, persistingFilePath); } if (inMemoryThreshold != null) { propertyMap.put(AbstractIssuerConfig.LOCAL_PROPERTY_THRESHOLD, inMemoryThreshold); } if (log.isDebugEnabled()) { if (persisterClassName != null && inMemoryThreshold == null) { log.debug("Although persister is defined, threshold not defined."); } } //allow defining any additional properties related to token persister. String[] persisterPropertyNames = serverConfig .getProperties(SECURITY_TOKEN_PERSISTER_PROPERTIES_PROPERTY_NAME); String[] persisterPropertyValues = serverConfig .getProperties(SECURITY_TOKEN_PERSISTER_PROPERTIES_PROPERTY_VALUE); if (!ArrayUtils.isEmpty(persisterPropertyNames) && !ArrayUtils.isEmpty(persisterPropertyValues) && persisterPropertyNames.length == persisterPropertyValues.length) { for (int i = 0; i < persisterPropertyNames.length; i++) { propertyMap.put(persisterPropertyNames[i], persisterPropertyValues[i]); } } if (!propertyMap.isEmpty()) { stsSamlConfig.setPersisterPropertyMap(propertyMap); } try { // remove param is exists Parameter param = service.getParameter(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart()); if (param == null) { // Add new parameter service.addParameter(stsSamlConfig.getParameter()); } } catch (AxisFault e) { log.error("Error while updating " + ServerConstants.STS_NAME + " in STSDeploymentInterceptor", e); } } }
From source file:ddf.security.PropertiesLoader.java
/** * Will attempt to load properties from a file using the given classloader. If that fails, * several other methods will be tried until the properties file is located. * * @param propertiesFile//from w ww . j a v a 2 s . c o m * @param classLoader * @return Properties */ public static Properties loadProperties(String propertiesFile, ClassLoader classLoader) { boolean error = false; Properties properties = new Properties(); if (propertiesFile != null) { try { LOGGER.debug("Attempting to load properties from {} with Spring PropertiesLoaderUtils.", propertiesFile); properties = PropertiesLoaderUtils.loadAllProperties(propertiesFile); } catch (IOException e) { error = true; LOGGER.error("Unable to load properties using default Spring properties loader.", e); } if (error || properties.isEmpty()) { if (classLoader != null) { try { LOGGER.debug( "Attempting to load properties from {} with Spring PropertiesLoaderUtils with class loader.", propertiesFile); properties = PropertiesLoaderUtils.loadAllProperties(propertiesFile, classLoader); error = false; } catch (IOException e) { error = true; LOGGER.error("Unable to load properties using default Spring properties loader.", e); } } else { try { LOGGER.debug( "Attempting to load properties from {} with Spring PropertiesLoaderUtils with class loader.", propertiesFile); properties = PropertiesLoaderUtils.loadAllProperties(propertiesFile, PropertiesLoader.class.getClassLoader()); error = false; } catch (IOException e) { error = true; LOGGER.error("Unable to load properties using default Spring properties loader.", e); } } } if (error || properties.isEmpty()) { LOGGER.debug("Attempting to load properties from file system: {}", propertiesFile); File propFile = new File(propertiesFile); // If properties file has fully-qualified absolute path (which // the blueprint file specifies) then can load it directly. if (propFile.isAbsolute()) { LOGGER.debug("propertiesFile {} is absolute", propertiesFile); propFile = new File(propertiesFile); } else { String karafHome = System.getProperty("karaf.home"); if (karafHome != null && !karafHome.isEmpty()) { propFile = new File(karafHome, propertiesFile); } else { karafHome = System.getProperty("ddf.home"); if (karafHome != null && !karafHome.isEmpty()) { propFile = new File(karafHome, propertiesFile); } else { propFile = new File(propertiesFile); } } } properties = new Properties(); try (InputStreamReader reader = new InputStreamReader(new FileInputStream(propertiesFile), StandardCharsets.UTF_8)) { properties.load(reader); } catch (FileNotFoundException e) { error = true; LOGGER.error("Could not find properties file: {}", propFile.getAbsolutePath(), e); } catch (IOException e) { error = true; LOGGER.error("Error reading properties file: {}", propFile.getAbsolutePath(), e); } } if (error || properties.isEmpty()) { LOGGER.debug("Attempting to load properties as a resource: {}", propertiesFile); InputStream ins = PropertiesLoader.class.getResourceAsStream(propertiesFile); if (ins != null) { try { properties.load(ins); ins.close(); } catch (IOException e) { LOGGER.error("Unable to load properties: {}", propertiesFile, e); } finally { IOUtils.closeQuietly(ins); } } } //replace any ${prop} with system properties Properties filtered = new Properties(); for (Map.Entry<?, ?> entry : properties.entrySet()) { filtered.put(StrSubstitutor.replaceSystemProperties(entry.getKey()), StrSubstitutor.replaceSystemProperties(entry.getValue())); } properties = filtered; } else { LOGGER.debug("Properties file must not be null."); } return properties; }
From source file:com.piusvelte.taplock.server.TapLockServer.java
private static void initialize() { (new File(APP_PATH)).mkdir(); if (OS == OS_WIN) Security.addProvider(new BouncyCastleProvider()); System.out.println("APP_PATH: " + APP_PATH); try {//from ww w .j a v a 2s .c o m sLogFileHandler = new FileHandler(sLog); } catch (SecurityException e) { writeLog("sLogFileHandler init: " + e.getMessage()); } catch (IOException e) { writeLog("sLogFileHandler init: " + e.getMessage()); } File propertiesFile = new File(sProperties); if (!propertiesFile.exists()) { try { propertiesFile.createNewFile(); } catch (IOException e) { writeLog("propertiesFile.createNewFile: " + e.getMessage()); } } Properties prop = new Properties(); try { prop.load(new FileInputStream(sProperties)); if (prop.isEmpty()) { prop.setProperty(sPassphraseKey, sPassphrase); prop.setProperty(sDisplaySystemTrayKey, Boolean.toString(sDisplaySystemTray)); prop.setProperty(sDebuggingKey, Boolean.toString(sDebugging)); prop.store(new FileOutputStream(sProperties), null); } else { if (prop.containsKey(sPassphraseKey)) sPassphrase = prop.getProperty(sPassphraseKey); else prop.setProperty(sPassphraseKey, sPassphrase); if (prop.containsKey(sDisplaySystemTrayKey)) sDisplaySystemTray = Boolean.parseBoolean(prop.getProperty(sDisplaySystemTrayKey)); else prop.setProperty(sDisplaySystemTrayKey, Boolean.toString(sDisplaySystemTray)); if (prop.containsKey(sDebuggingKey)) sDebugging = Boolean.parseBoolean(prop.getProperty(sDebuggingKey)); else prop.setProperty(sDebuggingKey, Boolean.toString(sDebugging)); } } catch (FileNotFoundException e) { writeLog("prop load: " + e.getMessage()); } catch (IOException e) { writeLog("prop load: " + e.getMessage()); } if (sLogFileHandler != null) { sLogger = Logger.getLogger("TapLock"); sLogger.setUseParentHandlers(false); sLogger.addHandler(sLogFileHandler); SimpleFormatter sf = new SimpleFormatter(); sLogFileHandler.setFormatter(sf); writeLog("service starting"); } if (sDisplaySystemTray && SystemTray.isSupported()) { final SystemTray systemTray = SystemTray.getSystemTray(); Image trayIconImg = Toolkit.getDefaultToolkit() .getImage(TapLockServer.class.getResource("/systemtrayicon.png")); final TrayIcon trayIcon = new TrayIcon(trayIconImg, "Tap Lock"); trayIcon.setImageAutoSize(true); PopupMenu popupMenu = new PopupMenu(); MenuItem aboutItem = new MenuItem("About"); CheckboxMenuItem toggleSystemTrayIcon = new CheckboxMenuItem("Display Icon in System Tray"); toggleSystemTrayIcon.setState(sDisplaySystemTray); CheckboxMenuItem toggleDebugging = new CheckboxMenuItem("Debugging"); toggleDebugging.setState(sDebugging); MenuItem shutdownItem = new MenuItem("Shutdown Tap Lock Server"); popupMenu.add(aboutItem); popupMenu.add(toggleSystemTrayIcon); if (OS == OS_WIN) { MenuItem setPasswordItem = new MenuItem("Set password"); popupMenu.add(setPasswordItem); setPasswordItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel panel = new JPanel(); JLabel label = new JLabel("Enter your Windows account password:"); JPasswordField passField = new JPasswordField(32); panel.add(label); panel.add(passField); String[] options = new String[] { "OK", "Cancel" }; int option = JOptionPane.showOptionDialog(null, panel, "Tap Lock", JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); if (option == 0) { String password = encryptString(new String(passField.getPassword())); if (password != null) { Properties prop = new Properties(); try { prop.load(new FileInputStream(sProperties)); prop.setProperty(sPasswordKey, password); prop.store(new FileOutputStream(sProperties), null); } catch (FileNotFoundException e1) { writeLog("prop load: " + e1.getMessage()); } catch (IOException e1) { writeLog("prop load: " + e1.getMessage()); } } } } }); } popupMenu.add(toggleDebugging); popupMenu.add(shutdownItem); trayIcon.setPopupMenu(popupMenu); try { systemTray.add(trayIcon); } catch (AWTException e) { writeLog("systemTray.add: " + e.getMessage()); } aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String newline = System.getProperty("line.separator"); newline += newline; JOptionPane.showMessageDialog(null, "Tap Lock" + newline + "Copyright (c) 2012 Bryan Emmanuel" + newline + "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version." + newline + "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details." + newline + "You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." + newline + "Bryan Emmanuel piusvelte@gmail.com"); } }); toggleSystemTrayIcon.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setTrayIconDisplay(e.getStateChange() == ItemEvent.SELECTED); if (!sDisplaySystemTray) systemTray.remove(trayIcon); } }); toggleDebugging.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setDebugging(e.getStateChange() == ItemEvent.SELECTED); } }); shutdownItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { shutdown(); } }); } synchronized (sConnectionThreadLock) { (sConnectionThread = new ConnectionThread()).start(); } }
From source file:com.glaf.core.config.DBConfiguration.java
public static Properties getDataSourcePropertiesByName(String name) { if (name == null) { return null; }//from w w w .ja v a 2 s .com logger.debug("->name:" + name); ConnectionDefinition conn = getConnectionDefinition(name); Properties props = toProperties(conn); if (props == null || props.isEmpty()) { // props = getDefaultDataSourceProperties(); } return props; }
From source file:com.glaf.core.config.DBConfiguration.java
public static ConnectionDefinition toConnectionDefinition(Properties props) { if (props != null && !props.isEmpty()) { ConnectionDefinition model = new ConnectionDefinition(); model.setDatasource(props.getProperty(JDBC_DATASOURCE)); model.setDriver(props.getProperty(JDBC_DRIVER)); model.setUrl(props.getProperty(JDBC_URL)); model.setName(props.getProperty(JDBC_NAME)); model.setUser(props.getProperty(JDBC_USER)); model.setPassword(props.getProperty(JDBC_PASSWORD)); model.setSubject(props.getProperty(SUBJECT)); model.setProvider(props.getProperty(JDBC_PROVIDER)); model.setType(props.getProperty(JDBC_TYPE)); model.setHost(props.getProperty(HOST)); model.setDatabase(props.getProperty(DATABASE)); if (StringUtils.isNotEmpty(props.getProperty(PORT))) { model.setPort(Integer.parseInt(props.getProperty(PORT))); }/*from w ww. j av a 2s.c o m*/ if (StringUtils.equals("true", props.getProperty(JDBC_AUTOCOMMIT))) { model.setAutoCommit(true); } Properties p = new Properties(); Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = props.getProperty(key); p.put(key, value); } model.setProperties(p); return model; } return null; }