List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:com.glaf.core.startup.BootstrapManager.java
public void startup(ServletContext context) { if (!running.get()) { try {// w w w .j a v a2s. co m running.set(true); BootstrapProperties.reload(); Properties props = BootstrapProperties.getProperties(); if (props != null && props.keys().hasMoreElements()) { Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String className = (String) e.nextElement(); String value = props.getProperty(className); try { Object obj = ClassUtils.instantiateObject(className); if (obj instanceof Bootstrap) { Bootstrap bootstrap = (Bootstrap) obj; bootstrap.startup(context, value); } } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } } ConnectionConfigProperties.reload(); Properties p = ConnectionConfigProperties.getProperties(); if (p != null && p.keys().hasMoreElements()) { Enumeration<?> e = p.keys(); while (e.hasMoreElements()) { String className = (String) e.nextElement(); try { Object object = ClassUtils.instantiateObject(className); if (object instanceof ConnectionConfig) { ConnectionConfig model = (ConnectionConfig) object; List<ConnectionDefinition> rows = model.getConnectionDefinitions(); if (rows != null && !rows.isEmpty()) { for (ConnectionDefinition conn : rows) { if (DBConnectionFactory.checkConnection(conn.getName())) { continue; } String dbType = conn.getType(); String host = conn.getHost(); int port = conn.getPort(); String databaseName = conn.getDatabase(); String user = conn.getUser(); String password = conn.getPassword(); DBConfiguration.addDataSourceProperties(conn.getName(), dbType, host, port, databaseName, user, password); } } } } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { running.set(false); } } }
From source file:com.glaf.base.business.AuthorizeBean.java
/** * /*ww w .ja va2s . co m*/ * * @param request */ public SysUser login(String account, HttpServletRequest request, HttpServletResponse response) { logger.debug(account + " start login........................"); // SysUser bean = getSysUserService().findByAccount(account); if (bean != null) { // ? Properties props = CallbackProperties.getProperties(); if (props != null && props.keys().hasMoreElements()) { Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String className = (String) e.nextElement(); try { Object obj = ClassUtils.instantiateObject(className); if (obj instanceof LoginCallback) { LoginCallback callback = (LoginCallback) obj; callback.afterLogin(bean.getAccount(), request, null); } } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } } ContextUtil.put(bean.getAccount(), bean);// ?? RequestUtils.setLoginUser(request, response, "default", bean.getAccount()); } return bean; }
From source file:pt.webdetails.cda.connections.mondrian.JdbcConnection.java
@Override public DataSourceProvider getInitializedDataSourceProvider() throws InvalidConnectionException { logger.debug("Creating new jdbc connection"); final DriverDataSourceProvider connectionProvider = new DriverDataSourceProvider(); connectionProvider.setDriver(connectionInfo.getDriver()); connectionProvider.setUrl(connectionInfo.getUrl()); final Properties properties = connectionInfo.getProperties(); final Enumeration<Object> keys = properties.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); final String value = properties.getProperty(key); connectionProvider.setProperty(key, value); }/*from w w w . ja va 2 s .co m*/ return connectionProvider; }
From source file:org.pentaho.platform.engine.core.system.objfac.spring.BarrierBeanProcessor.java
/** * This method can be run multiple times for multiple barrierBean property sets. Only one list of barrierBeans is maintained * so that plugins can add their own barrierBeans if necessary. Registered barrierBeans will be held just prior * to bean initialization. See {@link BarrierBeanPostProcessor} * /* ww w .j a va2 s .c o m*/ * @param barrierBeanFilePath * @return */ @SuppressWarnings("unchecked") public void registerBarrierBeans(Properties barrierBeanProperties) { Enumeration<Object> enuKeys = barrierBeanProperties.keys(); while (enuKeys.hasMoreElements()) { String barrierName = (String) enuKeys.nextElement(); IServiceBarrier barrier = serviceBarrierManager.getServiceBarrier(barrierName); List<BarrierBean> theseBarrierBeans = BarrierBean .convertString(barrierBeanProperties.getProperty(barrierName)); if (theseBarrierBeans.size() > 0) { for (BarrierBean barrierBean : theseBarrierBeans) { //Add the beans/barriers to the maps if (beanBarriers.containsKey(barrierBean.getBeanName())) { beanBarriers.get(barrierBean.getBeanName()).add(barrierName); } else { Set<String> newSet = new HashSet<String>(); newSet.add(barrierName); beanBarriers.put(barrierBean.getBeanName(), newSet); } } List<BarrierBean> finalBarrierBeans = (List<BarrierBean>) barrierBeans.get(barrierName); finalBarrierBeans = finalBarrierBeans == null ? theseBarrierBeans : ListUtils.union(finalBarrierBeans, theseBarrierBeans); barrierBeans.put(barrierName, finalBarrierBeans); } } }
From source file:org.exem.flamingo.web.util.ApplicationInformationDisplayContextListener.java
private int getMaxLength(Properties props) { Enumeration<Object> keys = props.keys(); int maxLength = -1; while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (maxLength < 0) { maxLength = key.getBytes().length; } else if (maxLength < key.getBytes().length) { maxLength = key.getBytes().length; }// www . j a va 2 s . c om } return maxLength; }
From source file:com.astamuse.asta4d.web.initialization.SimplePropertyFileIntializer.java
@Override public void initliaze(InputStream input, WebApplicationConfiguration configuration) throws Exception { Properties ps = new Properties(); ps.load(input);/*from ww w. ja v a2 s .com*/ BeanUtilsBean bu = retrieveBeanUtilsBean(); Enumeration<Object> keys = ps.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement().toString(); String value = ps.getProperty(key); fillConfiguration(configuration, bu, key, value); } }
From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplication.java
/** * Prints the system properties./*from w w w . j av a 2s.c om*/ * @param properties the properties to print out */ protected void printProperties(Properties properties) { Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = (String) properties.get(key); logger.info(key + ": " + value); } }
From source file:org.jumpmind.symmetric.DbFillCommand.java
private Map<String, int[]> parseTableProperties() { Map<String, int[]> tableProperties = new HashMap<String, int[]>(); Properties properties = engine.getProperties(); Enumeration<Object> keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = (String) properties.get(key); if (key.startsWith("fill.")) { String tableName = null; tableName = key.substring(key.lastIndexOf(".") + 1); int[] iudVal = new int[3]; int i = 0; for (String str : value.split(",")) { iudVal[i++] = Integer.valueOf(str).intValue(); }//from w w w .jav a 2s . c o m tableProperties.put(tableName, iudVal); } } return tableProperties; }
From source file:pt.webdetails.cda.connections.dataservices.DataservicesConnection.java
public ConnectionProvider getInitializedConnectionProvider() throws InvalidConnectionException { logger.debug("Creating new dataservices connection"); IDataservicesLocalConnection dataservicesLocalConnection = CdaEngine.getEnvironment() .getDataServicesLocalConnection(); try {/*from w w w .j av a 2 s .c om*/ final DriverConnectionProvider connectionProvider = dataservicesLocalConnection .getDriverConnectionProvider(); final Properties properties = connectionInfo.getProperties(); final Enumeration<Object> keys = properties.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); final String value = properties.getProperty(key); connectionProvider.setProperty(key, value); } logger.debug("Opening connection"); final Connection connection = connectionProvider.createConnection(null, null); connection.close(); logger.debug("Connection opened"); return connectionProvider; } catch (MalformedURLException e) { throw new InvalidConnectionException( "DataservicesConnection: Found MalformedURLException: " + Util.getExceptionDescription(e), e); } catch (SQLException e) { throw new InvalidConnectionException( "DataservicesConnection: Found SQLException: " + Util.getExceptionDescription(e), e); } }
From source file:pt.webdetails.cda.connections.sql.JdbcConnection.java
@Override public ConnectionProvider getInitializedConnectionProvider() throws InvalidConnectionException { logger.debug("Creating new jdbc connection"); final DriverConnectionProvider connectionProvider = new DriverConnectionProvider(); connectionProvider.setDriver(connectionInfo.getDriver()); connectionProvider.setUrl(connectionInfo.getUrl()); final Properties properties = connectionInfo.getProperties(); final Enumeration<Object> keys = properties.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); final String value = properties.getProperty(key); connectionProvider.setProperty(key, value); }//from ww w . jav a 2 s. co m logger.debug("Opening connection"); try { final Connection connection = connectionProvider.createConnection(connectionInfo.getUser(), connectionInfo.getPass()); connection.close(); } catch (SQLException e) { throw new InvalidConnectionException( "JdbcConnection: Found SQLException: " + Util.getExceptionDescription(e), e); } logger.debug("Connection opened"); return connectionProvider; }