List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:com.iyonger.apm.web.configuration.Config.java
/** * Load system related properties. (system.conf) *///from ww w. j a va 2s .c om public synchronized void loadProperties() { Properties properties = checkNotNull(home).getProperties("system.conf"); properties.put("NGRINDER_HOME", home.getDirectory().getAbsolutePath()); if (exHome.exists()) { Properties exProperties = exHome.getProperties("system-ex.conf"); if (exProperties.isEmpty()) { exProperties = exHome.getProperties("system.conf"); } properties.putAll(exProperties); } properties.putAll(System.getProperties()); // Override if exists controllerProperties = new PropertiesWrapper(properties, controllerPropertiesKeyMapper); //clusterProperties = new PropertiesWrapper(properties, clusterPropertiesKeyMapper); }
From source file:org.azyva.dragom.cliutil.CliUtil.java
/** * Sets up an {@link ExecContext} assuming an {@link ExecContextFactory} that * supports the concept of workspace directory. * <p>/* ww w .j a va 2 s.c o m*/ * {@link ExecContextFactoryHolder} is used to get the ExecContextFactory so it * is not guaranteed that it will support the concept of workspace directory and * implement {@link WorkspaceExecContextFactory}. In such as case an exception is * raised. * <p> * The strategy for setting up the ExecContext supports a user service * implementation where a single JVM remains running in the background in the * context of a given user account (not system-wide) and can execute Dragom tools * for multiple different workspaces while avoiding tool startup overhead. * <a href="http://www.martiansoftware.com/nailgun/" target="_blank">Nailgun</a> * can be useful for that purpose. * <p> * A user service implementation is supported by differentiating between workspace * initialization Properties passed to {@link ExecContextFactory#getExecContext} * and tool initialization Properties passed to * {@link ToolLifeCycleExecContext#startTool}. * <p> * Workspace initialization Properties are constructed in the following way: * <ul> * <li>Dragom properties are merged into System properties using * {@link Util#applyDragomSystemProperties}. System properties take precedence * over Dragom properties; * <li>Initialize an empty Properties with system properties (System.getProperties) * that are prefixed with "org.azyva.dragom.init-property" as defaults. This * Properties when fully initialized will become the workspace initialization * Properties; * <li>If the org.azyva.IndUserProperties system property is defined, load the * Properties defined in the properties file specified by the * user-properties command line option. If not defined, use the properties * file specified by the org.azyva.DefaultUserProperties system property. If * not defined or if the properties file does not exist, do not load the * Properties; * <li>The workspace directory is added to the Properties created above. * </ul> * The name of the user-properties command line option can be overridden with the * org.azyva.dragom.UserPropertiesCommandLineOption system property. * <p> * Tool initialization Properties are constructed in the following way (if indSet): * <ul> * <li>Initialize an empty Properties. This Properties when fully initialized will * become the tool initialization Properties; * <li>If the org.azyva.IndToolProperties system property is defined, load the * Properties defined in the Properties file specified by the * tool-properties command line option. If not defined or if the properties * file does not exist, do not load the Properties. * </ul> * The name of the tool-properties command line option can be overridden with the * org.azyva.dragom.ToolPropertiesCommandLineOption system property. * <p> * It is possible that ExecContextFactory.getExecContext uses a cached ExecContext * corresponding to a workspace that has already been initialized previously. In * that case workspace initialization Properties will not be considered since * ExecContextFactory.getExecContext considers them only when a new ExecContext is * created. This is not expected to be a problem or source of confusion since this * can happen only if a user service implementation is actually used and in such a * case Dragom and system properties are expected to be considered only once when * initializing the user service and users are expected to understand that user * properties are considered only when initializing a new workspace. * <p> * If indSet, {@link ExecContextHolder#setAndStartTool} is called with the * ExecContext to make it easier for tools to prepare for execution. But it is * still the tool's responsibility to call * {@link ExecContextHolder#endToolAndUnset} before exiting. This is somewhat * asymmetric, but is sufficiently convenient to be warranted. The case where it * can be useful to set indSet to false is for subsequently calling * {@link ExecContextHolder#forceUnset}. * <p> * If indSet, the IND_NO_CONFIRM and {@code IND_NO_CONFIRM.<context>} runtime * properties are read from the CommandLine. * * @param commandLine CommandLine where to obtain the user and tool properties * files as well as the workspace path. * @param indSet Indicates to set the ExecContext in ExecContextHolder. * @return ExecContext. */ public static ExecContext setupExecContext(CommandLine commandLine, boolean indSet) { ExecContextFactory execContextFactory; WorkspaceExecContextFactory workspaceExecContextFactory; Properties propertiesInit; String workspaceDir; String stringPropertiesFile; ExecContext execContext; execContextFactory = ExecContextFactoryHolder.getExecContextFactory(); if (!(execContextFactory instanceof WorkspaceExecContextFactory)) { throw new RuntimeException("The ExecContextFactory does not support the workspace directory concept."); } workspaceExecContextFactory = (WorkspaceExecContextFactory) execContextFactory; propertiesInit = Util.getPropertiesDefaultInit(); Util.applyDragomSystemProperties(); if (Util.isNotNullAndTrue(System.getProperty(CliUtil.SYS_PROPERTY_IND_USER_PROPERTIES))) { stringPropertiesFile = commandLine.getOptionValue(CliUtil.getUserPropertiesFileCommandLineOption()); if (stringPropertiesFile == null) { stringPropertiesFile = System.getProperty(CliUtil.SYS_PROPERTY_DEFAULT_USER_PROPERTIES_FILE); } if (stringPropertiesFile != null) { propertiesInit = CliUtil.loadProperties(stringPropertiesFile, propertiesInit); } } // In general initialization properties defined as system properties with the // "org.azyva.dragom.init-property." prefix are expected to have been provided // as -D JVM arguments and as such are expected by the user to have precedence // over initialization properties provided in the user properties file loaded just // above. Initialization properties defined in the dragom.properties file // (see Util#applyDragomSystemProperties) will therefore also have precedence, // which is generally not desirable. That is why a separate dragom-init.properties // file (loaded with Util.getPropertiesDefaultInit above) is used for default // initialization properties. for (String initProperty : System.getProperties().stringPropertyNames()) { if (initProperty.startsWith(CliUtil.SYS_PROPERTY_PREFIX_INIT_PROPERTY)) { propertiesInit.setProperty( initProperty.substring(CliUtil.SYS_PROPERTY_PREFIX_INIT_PROPERTY.length()), System.getProperty(initProperty)); } } workspaceDir = commandLine.getOptionValue(CliUtil.getWorkspacePathCommandLineOption()); if (workspaceDir != null) { propertiesInit.setProperty(workspaceExecContextFactory.getWorkspaceDirInitProperty(), workspaceDir); } execContext = execContextFactory.getExecContext(propertiesInit); if (indSet) { Properties propertiesTool; propertiesTool = null; if (Util.isNotNullAndTrue(System.getProperty(CliUtil.SYS_PROPERTY_IND_TOOL_PROPERTIES))) { stringPropertiesFile = commandLine.getOptionValue(CliUtil.getToolPropertiesFileCommandLineOption()); if (stringPropertiesFile != null) { propertiesTool = CliUtil.loadProperties(stringPropertiesFile, null); } } if (Util.isNotNullAndTrue(System.getProperty(CliUtil.SYS_PROPERTY_IND_SINGLE_TOOL_PROPERTIES))) { Properties propertiesToolSingle; propertiesToolSingle = commandLine.getOptionProperties("D"); if (propertiesTool != null) { // Explicit single properties override similar properties defined in the tool // properties file. propertiesTool.putAll(propertiesToolSingle); } else { propertiesTool = propertiesToolSingle; } } if (propertiesTool == null) { propertiesTool = new Properties(); } // The following properties can also be generically specified as single tool // properties. But they are supported as explicit command line arguments since // they are general and often used. if (commandLine.hasOption(CliUtil.getNoConfirmCommandLineOption())) { propertiesTool.setProperty(Util.RUNTIME_PROPERTY_IND_NO_CONFIRM, "true"); } else { String[] tabNoConfirmContext; tabNoConfirmContext = commandLine.getOptionValues(CliUtil.getNoConfirmContextCommandLineOption()); if (tabNoConfirmContext != null) { for (String context : tabNoConfirmContext) { propertiesTool.setProperty(Util.RUNTIME_PROPERTY_IND_NO_CONFIRM + '.' + context, "true"); } } } ExecContextHolder.setAndStartTool(execContext, propertiesTool); } return execContext; }
From source file:eu.trentorise.game.config.AppConfig.java
@Bean public Scheduler quartzScheduler() { try {/* ww w . j ava 2s .c o m*/ boolean activatePersistence = env.getProperty("task.persistence.activate", Boolean.class, false); if (activatePersistence) { LogHub.info(null, logger, "task persistence active..load quartz properties"); Properties props = new Properties(); Map<String, Object> propsMap = new HashMap<String, Object>(); propsMap.put("org.quartz.jobStore.class", env.getProperty("org.quartz.jobStore.class", "com.novemberain.quartz.mongodb.MongoDBJobStore")); propsMap.put("org.quartz.jobStore.addresses", env.getProperty("org.quartz.jobStore.addresses", "localhost")); propsMap.put("org.quartz.jobStore.dbName", env.getProperty("org.quartz.jobStore.dbName", "gamification_task_store")); propsMap.put("org.quartz.jobStore.collectionPrefix", env.getProperty("org.quartz.jobStore.collectionPrefix", "quartz")); propsMap.put("org.quartz.threadPool.threadCount", env.getProperty("org.quartz.threadPool.threadCount", "10")); props.putAll(propsMap); return new StdSchedulerFactory(props).getScheduler(); } else { LogHub.info(null, logger, "task persistence unactive"); return new StdSchedulerFactory().getScheduler(); } } catch (SchedulerException e) { LogHub.error(null, logger, "Error creating scheduler"); return null; } }
From source file:de.pawlidi.openaletheia.license.LicenseProperties.java
public static Properties createProperties(Properties properties, License license) { // check parameter if (license == null) { return null; }//from www . j av a 2s. co m // write data PropertiesUtils.setStringProperty(properties, LicenseProperties.PRODUCT, license.getProduct()); PropertiesUtils.setStringProperty(properties, LicenseProperties.VERSION, license.getProductVersion()); PropertiesUtils.setDateProperty(properties, LicenseProperties.CREATED, license.getCreated()); PropertiesUtils.setDateProperty(properties, LicenseProperties.MODIFIED, license.getModified()); PropertiesUtils.setStringProperty(properties, LicenseProperties.ADDRESS, license.getAddress()); PropertiesUtils.setObjectProperty(properties, LicenseProperties.HOST, license.getMaxHost()); PropertiesUtils.setObjectProperty(properties, LicenseProperties.MAX_USER, license.getMaxUser()); PropertiesUtils.setStringProperty(properties, LicenseProperties.COMPANY, license.getCompany()); PropertiesUtils.setStringProperty(properties, LicenseProperties.DESCRIPTION, license.getDescription()); PropertiesUtils.setStringProperty(properties, LicenseProperties.OWNER, license.getOwner()); PropertiesUtils.setStringProperty(properties, LicenseProperties.OS, license.getOperatingSystem()); PropertiesUtils.setDateProperty(properties, LicenseProperties.DUE_DATE, license.getDueDate()); if (BooleanUtils.isFalse(license.getRemote())) { PropertiesUtils.setObjectProperty(properties, LicenseProperties.REMOTE, license.getRemote()); } List<String> users = new ArrayList<String>(0); for (User user : license.getUsers()) { users.add(user.toString()); } PropertiesUtils.setListProperty(properties, LicenseProperties.USER, users); if (!PropertiesUtils.isEmpty(license.getProperties())) { properties.putAll(license.getProperties()); } return properties; }
From source file:ch.entwine.weblounge.kernel.site.SiteDispatcherServiceImpl.java
/** * Adds a new site.//from w w w . ja va 2s . c om * * This method may be long-running and therefore is executed in its own * thread. * * @param site * the site */ private void addSite(final Site site) { Thread t = new Thread(new Runnable() { public void run() { Bundle siteBundle = siteManager.getSiteBundle(site); WebXml webXml = createWebXml(site, siteBundle); Properties initParameters = new Properties(); // Prepare the init parameters // initParameters.put("load-on-startup", Integer.toString(1)); initParameters.putAll(webXml.getContextParams()); initParameters.putAll(jasperConfig); // Create the site URI String contextRoot = webXml.getContextParam(DispatcherConfiguration.WEBAPP_CONTEXT_ROOT, DEFAULT_WEBAPP_CONTEXT_ROOT); String bundleURI = webXml.getContextParam(DispatcherConfiguration.BUNDLE_URI, site.getIdentifier()); String siteContextURI = webXml.getContextParam(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT_URI, DEFAULT_BUNDLE_CONTEXT_ROOT_URI); String siteRoot = UrlUtils.concat(contextRoot, siteContextURI, bundleURI); // Prepare the Jasper work directory String scratchDirPath = PathUtils.concat(jasperConfig.get(OPT_JASPER_SCRATCHDIR), site.getIdentifier()); File scratchDir = new File(scratchDirPath); boolean jasperArtifactsExist = scratchDir.isDirectory() && scratchDir.list().length > 0; try { FileUtils.forceMkdir(scratchDir); logger.debug("Temporary jsp source files and classes go to {}", scratchDirPath); } catch (IOException e) { logger.warn("Unable to create jasper scratch directory at {}: {}", scratchDirPath, e.getMessage()); } try { // Create and register the site servlet SiteServlet siteServlet = new SiteServlet(site, siteBundle, environment); siteServlet.setSecurityService(securityService); Dictionary<String, String> servletRegistrationProperties = new Hashtable<String, String>(); servletRegistrationProperties.put(Site.class.getName().toLowerCase(), site.getIdentifier()); servletRegistrationProperties.put(SharedHttpContext.ALIAS, siteRoot); servletRegistrationProperties.put(SharedHttpContext.SERVLET_NAME, site.getIdentifier()); servletRegistrationProperties.put(SharedHttpContext.CONTEXT_ID, SharedHttpContext.WEBLOUNGE_CONTEXT_ID); servletRegistrationProperties.put(SharedHttpContext.INIT_PREFIX + OPT_JASPER_SCRATCHDIR, scratchDirPath); ServiceRegistration servletRegistration = siteBundle.getBundleContext() .registerService(Servlet.class.getName(), siteServlet, servletRegistrationProperties); servletRegistrations.put(site, servletRegistration); // We are using the Whiteboard pattern to register servlets. Wait for // the http service to pick up the servlet and initialize it synchronized (servletRegistrations) { boolean warnedOnce = false; while (!siteServlet.isInitialized()) { if (!warnedOnce) { logger.info("Waiting for site '{}' to be online", site.getIdentifier()); warnedOnce = true; } logger.debug("Waiting for http service to pick up {}", siteServlet); servletRegistrations.wait(500); if (shutdown) { logger.info("Giving up waiting for registration of site '{}'"); servletRegistrations.remove(site); return; } } } siteServlets.put(site, siteServlet); logger.info("Site '{}' is online and registered under site://{}", site, siteRoot); // Did we already miss the "siteStarted()" event? If so, we trigger it // for ourselves, so the modules are being started. site.addSiteListener(SiteDispatcherServiceImpl.this); if (site.isOnline()) { siteStarted(site); } // Start the precompiler if requested if (precompile) { String compilationKey = X_COMPILE_PREFIX + siteBundle.getBundleId(); Date compileDate = null; boolean needsCompilation = true; // Check if this site has been precompiled already if (preferencesService != null) { Preferences preferences = preferencesService.getSystemPreferences(); String compileDateString = preferences.get(compilationKey, null); if (compileDateString != null) { compileDate = WebloungeDateFormat.parseStatic(compileDateString); needsCompilation = false; logger.info("Site '{}' has already been precompiled on {}", site.getIdentifier(), compileDate); } } else { logger.info( "Precompilation status cannot be determined, consider deploying a preferences service implementation"); } // Does the scratch dir exist? if (!jasperArtifactsExist) { needsCompilation = true; logger.info("Precompiled artifacts for '{}' have been removed", site.getIdentifier()); } // Let's do the work anyways if (needsCompilation) { Precompiler precompiler = new Precompiler(compilationKey, siteServlet, environment, securityService, logCompileErrors); precompilers.put(site, precompiler); precompiler.precompile(); } } logger.debug("Site '{}' registered under site://{}", site, siteRoot); } catch (Throwable t) { logger.error("Error setting up site '{}' for http requests: {}", new Object[] { site, t.getMessage() }); logger.error(t.getMessage(), t); } } }); t.setDaemon(true); t.start(); }
From source file:org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer.java
@Override public void createInterpreter(String interpreterGroupId, String sessionId, String className, Map<String, String> properties, String userName) throws TException { if (interpreterGroup == null) { interpreterGroup = new InterpreterGroup(interpreterGroupId); angularObjectRegistry = new AngularObjectRegistry(interpreterGroup.getId(), intpEventClient); hookRegistry = new InterpreterHookRegistry(); resourcePool = new DistributedResourcePool(interpreterGroup.getId(), intpEventClient); interpreterGroup.setInterpreterHookRegistry(hookRegistry); interpreterGroup.setAngularObjectRegistry(angularObjectRegistry); interpreterGroup.setResourcePool(resourcePool); intpEventClient.setIntpGroupId(interpreterGroupId); String localRepoPath = properties.get("zeppelin.interpreter.localRepo"); if (properties.containsKey("zeppelin.interpreter.output.limit")) { InterpreterOutput.limit = Integer.parseInt(properties.get("zeppelin.interpreter.output.limit")); }//from w w w . ja v a 2 s . c o m depLoader = new DependencyResolver(localRepoPath); appLoader = new ApplicationLoader(resourcePool, depLoader); } try { Class<Interpreter> replClass = (Class<Interpreter>) Object.class.forName(className); Properties p = new Properties(); p.putAll(properties); setSystemProperty(p); Constructor<Interpreter> constructor = replClass.getConstructor(new Class[] { Properties.class }); Interpreter repl = constructor.newInstance(p); repl.setClassloaderUrls(new URL[] {}); logger.info("Instantiate interpreter {}", className); repl.setInterpreterGroup(interpreterGroup); repl.setUserName(userName); interpreterGroup.addInterpreterToSession(new LazyOpenInterpreter(repl), sessionId); } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { logger.error(e.toString(), e); throw new TException(e); } }
From source file:org.codehaus.plexus.tools.cli.AbstractCli.java
private Properties getExecutionProperties(CommandLine commandLine) { Properties executionProperties = new Properties(); // ---------------------------------------------------------------------- // Options that are set on the command line become system properties // and therefore are set in the session properties. System properties // are most dominant. // ---------------------------------------------------------------------- if (commandLine.hasOption(SET_SYSTEM_PROPERTY)) { String[] defStrs = commandLine.getOptionValues(SET_SYSTEM_PROPERTY); for (int i = 0; i < defStrs.length; ++i) { setCliProperty(defStrs[i], executionProperties); }/* w ww . j a v a2 s . c o m*/ } executionProperties.putAll(System.getProperties()); return executionProperties; }
From source file:org.apache.sqoop.manager.SqlManager.java
/** * Create a connection to the database; usually used only from within * getConnection(), which enforces a singleton guarantee around the * Connection object./*from w ww. jav a 2s . co m*/ */ protected Connection makeConnection() throws SQLException { Connection connection; String driverClass = getDriverClass(); try { Class.forName(driverClass); } catch (ClassNotFoundException cnfe) { throw new RuntimeException("Could not load db driver class: " + driverClass); } String username = options.getUsername(); String password = options.getPassword(); String connectString = options.getConnectString(); Properties connectionParams = options.getConnectionParams(); if (connectionParams != null && connectionParams.size() > 0) { LOG.debug( "User specified connection params. " + "Using properties specific API for making connection."); Properties props = new Properties(); if (username != null) { props.put("user", username); } if (password != null) { props.put("password", password); } props.putAll(connectionParams); connection = DriverManager.getConnection(connectString, props); } else { LOG.debug("No connection paramenters specified. " + "Using regular API for making connection."); if (username == null) { connection = DriverManager.getConnection(connectString); } else { connection = DriverManager.getConnection(connectString, username, password); } } // We only use this for metadata queries. Loosest semantics are okay. connection.setTransactionIsolation(getMetadataIsolationLevel()); connection.setAutoCommit(false); return connection; }
From source file:org.cloudifysource.esc.driver.provisioning.jclouds.DefaultProvisioningDriver.java
private JCloudsDeployer createDeployer(final Cloud cloud) throws IOException { logger.fine("Creating JClouds context deployer with user: " + cloud.getUser().getUser()); final ComputeTemplate cloudTemplate = cloud.getCloudCompute().getTemplates().get(cloudTemplateName); logger.fine("Cloud Template: " + cloudTemplateName + ". Details: " + cloudTemplate); final Properties props = new Properties(); props.putAll(cloudTemplate.getOverrides()); deployer = new JCloudsDeployer(cloud.getProvider().getProvider(), cloud.getUser().getUser(), cloud.getUser().getApiKey(), props); deployer.setImageId(cloudTemplate.getImageId()); deployer.setMinRamMegabytes(cloudTemplate.getMachineMemoryMB()); deployer.setHardwareId(cloudTemplate.getHardwareId()); deployer.setExtraOptions(cloudTemplate.getOptions()); return deployer; }
From source file:com.ai.alm.launcher.Launcher.java
public Launcher() { Properties properties = new Properties(); try {/*from w ww . ja v a 2s. c o m*/ ClassLoader loader = Launcher.class.getClassLoader(); URL url = loader.getResource(CONF_FILE); properties.load(url.openStream()); // from file String propFile = System.getProperty(CONF_PARAM); if (null != propFile) { properties.load(new FileInputStream(propFile)); } // Load system properties.putAll(System.getProperties()); } catch (Exception ignored) { // ignored.printStackTrace(); } // Defaults host = properties.getProperty("jetty.host", host_default); port = Integer.parseInt(properties.getProperty("jetty.port", port_default)); secret = properties.getProperty("jetty.secret", secret_default); contextPath = properties.getProperty("jetty.contextPath", contextPath_default); workDirPath = properties.getProperty("jetty.workDir", workDirPath_default); // Detailed Logs logsEnabled = Boolean.parseBoolean(properties.getProperty("jetty.logs", logsEnabled_default)); out.println("Jetty Configuration Properties ===>> " + "\n\thost=" + host + "\n\tport=" + port + "\n\tcontext=" + contextPath + "\n\tsecret=" + secret + "\n\twork-dir=" + workDirPath + "\n\tlogs=" + logsEnabled); }