List of usage examples for java.util Properties isEmpty
@Override public boolean isEmpty()
From source file:org.eclipse.gyrex.cloud.internal.queue.ZooKeeperQueueService.java
private byte[] getQueueData(final Map<String, ?> properties) throws IOException { final ByteArrayOutputStream queueData = new ByteArrayOutputStream(); if (properties != null) { final Properties p = new Properties(); final Object timeout = properties.get(IQueueServiceProperties.MESSAGE_RECEIVE_TIMEOUT); if (timeout != null) { p.setProperty(IQueueServiceProperties.MESSAGE_RECEIVE_TIMEOUT, String.valueOf(timeout)); }/*w w w .j a va2 s . c o m*/ if (!p.isEmpty()) { p.store(queueData, null); } } return queueData.toByteArray(); }
From source file:org.wso2.carbon.datasource.ui.DatasourceManagementClient.java
public boolean testConnection(DataSourceInformation dataSourceInformation) throws DataSourceManagementException, RemoteException { validateDataSourceInformation(dataSourceInformation); if (log.isDebugEnabled()) { log.debug("Going to add DatasourceInformation :" + dataSourceInformation); }//from w w w. j ava2 s.c o m Properties properties = DataSourceInformationSerializer.serialize(dataSourceInformation); if (properties.isEmpty()) { handleException("Empty Properties"); } OMElement element = createOMElement(properties); validateDataSourceElement(element); if (log.isDebugEnabled()) { log.debug("DataSourceconfiguration :" + element); } return stub.testConnection(dataSourceInformation.getAlias(), element); }
From source file:org.wso2.carbon.datasource.ui.DatasourceManagementClient.java
public void addDataSourceInformation(DataSourceInformation dataSourceInformation) throws DataSourceManagementException, RemoteException { validateDataSourceInformation(dataSourceInformation); if (log.isDebugEnabled()) { log.debug("Going to add DatasourceInformation :" + dataSourceInformation); }//from w w w. j av a 2s. c o m Properties properties = DataSourceInformationSerializer.serialize(dataSourceInformation); if (properties.isEmpty()) { handleException("Empty Properties"); } OMElement element = createOMElement(properties); validateDataSourceElement(element); if (log.isDebugEnabled()) { log.debug("DataSourceconfiguration :" + element); } stub.addDataSourceInformation(dataSourceInformation.getAlias(), element); }
From source file:alluxio.shell.command.MountCommand.java
@Override public int run(CommandLine cl) throws AlluxioException, IOException { String[] args = cl.getArgs(); AlluxioURI alluxioPath = new AlluxioURI(args[0]); AlluxioURI ufsPath = new AlluxioURI(args[1]); MountOptions options = MountOptions.defaults(); String propertyFile = cl.getOptionValue('P'); if (propertyFile != null) { Properties cmdProps = new Properties(); try (InputStream inStream = new FileInputStream(propertyFile)) { cmdProps.load(inStream);/*w ww . j a va2 s .c o m*/ } catch (IOException e) { throw new IOException("Unable to load property file: " + propertyFile); } if (!cmdProps.isEmpty()) { // Use the properties from the properties file for the mount options. Map<String, String> properties = new HashMap<>(); for (Map.Entry<Object, Object> entry : cmdProps.entrySet()) { properties.put(entry.getKey().toString(), entry.getValue().toString()); } options.setProperties(properties); System.out.println("Using properties from file: " + propertyFile); } } if (cl.hasOption("readonly")) { options.setReadOnly(true); } if (cl.hasOption("shared")) { options.setShared(true); } mFileSystem.mount(alluxioPath, ufsPath, options); System.out.println("Mounted " + ufsPath + " at " + alluxioPath); return 0; }
From source file:com.cisco.oss.foundation.logging.FoundationLogger.java
private static void setupJULSupport(URL resource) { boolean julSupportEnabled = Boolean.valueOf(log4jConfigProps .getProperty(FoundationLoggerConstants.Foundation_JUL_SUPPORT_ENABLED.toString(), "false")); if (julSupportEnabled) { String appenderRef = log4jConfigProps .getProperty(FoundationLoggerConstants.Foundation_JUL_APPENDER_REF.toString()); if (StringUtils.isBlank(appenderRef)) { Enumeration allAppenders = Logger.getRootLogger().getAllAppenders(); while (allAppenders.hasMoreElements()) { Appender appender = (Appender) allAppenders.nextElement(); if (appender instanceof FileAppender) { appenderRef = appender.getName(); getLogger(FoundationLogger.class) .info("*** Using '" + appenderRef + "' as the Java util logging appender ref ***"); System.err.println( "*** Using '" + appenderRef + "' as the Java util logging appender ref ***"); break; }/*from w w w . j av a2s. c o m*/ } } if (StringUtils.isBlank(appenderRef)) { throw new IllegalArgumentException( "Java util support was enabled but couldn't find a matching appender under the '" + FoundationLoggerConstants.Foundation_JUL_APPENDER_REF.toString() + "' key."); } Handler handler = null; Appender appender = Logger.getRootLogger().getAppender(appenderRef); if (appender == null) { Enumeration allAppenders = Logger.getRootLogger().getAllAppenders(); while (allAppenders.hasMoreElements()) { Appender tempAppender = (Appender) allAppenders.nextElement(); if (tempAppender instanceof AsyncAppender) { AsyncAppender asyncAppender = (AsyncAppender) tempAppender; Enumeration asyncAppenderAllAppenders = asyncAppender.getAllAppenders(); while (asyncAppenderAllAppenders.hasMoreElements()) { Appender asyncTempAppender = (Appender) asyncAppenderAllAppenders.nextElement(); if (appenderRef.equals(asyncTempAppender.getName())) { appender = asyncTempAppender; break; } } if (appender != null) { break; } } } } if (appender instanceof FileAppender) { try { handler = new FileHandler(((FileAppender) appender).getFile()); } catch (IOException e) { throw new IllegalArgumentException( "IOException encountered when trying to setup jul logging: " + e, e); } } else if (appender instanceof ConsoleAppender) { handler = new ConsoleHandler(); } else { getLogger(FoundationLogger.class) .error("got a reference to an unsupported appender: " + appenderRef); } if (handler != null) { // System.setProperty("java.util.logging.config.file",resource.getPath()); java.util.logging.LogManager.getLogManager().reset(); try { java.util.logging.LogManager.getLogManager().readConfiguration(resource.openStream()); } catch (IOException e) { throw new IllegalArgumentException( "IOException encountered when trying to read log4j properties file: " + e, e); } handler.setLevel(java.util.logging.Level.FINEST); handler.setFormatter(new FoundationLogFormatter()); java.util.logging.Logger rootLogger = java.util.logging.Logger.getLogger(""); rootLogger.addHandler(handler); rootLogger.setLevel(java.util.logging.Level.SEVERE); Properties julLoggerSubset = getPropertiesSubset("jul.logger"); if (!julLoggerSubset.isEmpty()) { Set<Object> keySet = julLoggerSubset.keySet(); for (Object key : keySet) { java.util.logging.Logger logger = java.util.logging.Logger.getLogger((String) key); logger.setLevel(java.util.logging.Level.parse((String) julLoggerSubset.get(key))); } } } } }
From source file:org.echocat.jomon.resources.FileResource.java
protected void saveProperties(@Nonnull Properties properties) throws IOException { final File propertiesFile = getPropertiesFile(); if (properties.isEmpty()) { if (propertiesFile.exists() && !propertiesFile.delete()) { throw new IOException( "Could not delete the old and not longer needed properties file: " + propertiesFile); }/* w w w .j ava2 s . c om*/ } else { forceMkdir(propertiesFile.getParentFile()); try (final OutputStream os = new FileOutputStream(propertiesFile)) { try (final Writer writer = new OutputStreamWriter(os, "UTF-8")) { properties.store(writer, null); } } } }
From source file:com.github.mrstampy.poisonivy.PoisonIvy.java
private void addDOptions(CommandLine cli, List<String> command) { Properties props = cli.getOptionProperties("D"); if (props == null || props.isEmpty()) return;//from ww w . j a v a 2 s .c o m for (Entry<Object, Object> entry : props.entrySet()) { command.add("-D" + entry.getKey() + "=" + entry.getValue()); } }
From source file:io.fabric8.vertx.maven.plugin.SetupMojoTest.java
@Test public void testVerticleCreatPom() throws Exception { new File("target/unit/nopom").mkdirs(); File pomFile = new File("target/unit/nopom/pom.xml"); String vertxVersion = MojoUtils.getVersion("vertx-core-version"); Map<String, String> tplContext = new HashMap<>(); tplContext.put("mProjectGroupId", "com.example.vertx"); tplContext.put("mProjectArtifactId", "vertx-example"); tplContext.put("mProjectVersion", "1.0-SNAPSHOT"); tplContext.put("vertxVersion", vertxVersion); tplContext.put("vertxVerticle", "com.example.vertx.MainVerticle"); tplContext.put("fabric8VMPVersion", MojoUtils.getVersion("vertx-maven-plugin-version")); SetupTemplateUtils.createPom(tplContext, pomFile); assertThat(pomFile).isFile();/* w w w. j a v a2s .c om*/ MavenXpp3Reader xpp3Reader = new MavenXpp3Reader(); Model model = xpp3Reader.read(new FileInputStream(pomFile)); MavenProject project = new MavenProject(model); Optional<Plugin> vmPlugin = MojoUtils.hasPlugin(project, "io.fabric8:vertx-maven-plugin"); assertTrue(vmPlugin.isPresent()); Plugin vmp = project.getPlugin("io.fabric8:vertx-maven-plugin"); assertNotNull(vmp); Xpp3Dom pluginConfig = (Xpp3Dom) vmp.getConfiguration(); assertNotNull(pluginConfig); String redeploy = pluginConfig.getChild("redeploy").getValue(); assertNotNull(redeploy); assertTrue(Boolean.valueOf(redeploy)); Properties projectProps = project.getProperties(); assertNotNull(projectProps); assertFalse(projectProps.isEmpty()); assertEquals(project.getGroupId(), "com.example.vertx"); assertEquals(project.getArtifactId(), "vertx-example"); assertEquals(project.getVersion(), "1.0-SNAPSHOT"); assertEquals(projectProps.getProperty("vertx.version"), vertxVersion); assertThat(projectProps.getProperty("vertx-maven-plugin.version")) .containsPattern("^(\\d?\\.?\\d?)(\\-?SNAPSHOT?|\\.?\\d?)$"); assertEquals(projectProps.getProperty("vertx.verticle"), "com.example.vertx.MainVerticle"); DependencyManagement dependencyManagement = project.getDependencyManagement(); assertThat(dependencyManagement).isNotNull(); assertThat(dependencyManagement.getDependencies()).isNotEmpty(); Dependency vertxBom = project.getDependencyManagement().getDependencies().get(0); assertThat(vertxBom.getGroupId()).isEqualTo("io.vertx"); assertThat(vertxBom.getArtifactId()).isEqualTo("vertx-dependencies"); assertThat(vertxBom.getVersion()).isEqualTo("${vertx.version}"); assertThat(vertxBom.getType()).isEqualTo("pom"); assertThat(vertxBom.getScope()).isEqualTo("import"); assertThat(project.getDependencies()).isNotEmpty(); Dependency vertxCore = project.getDependencies().get(0); assertThat(vertxCore).isNotNull(); assertThat(vertxCore.getGroupId()).isEqualTo("io.vertx"); assertThat(vertxCore.getArtifactId()).isEqualTo("vertx-core"); }
From source file:io.reactiverse.vertx.maven.plugin.SetupMojoTest.java
@Test public void testVerticleCreatPom() throws Exception { new File("target/unit/nopom").mkdirs(); File pomFile = new File("target/unit/nopom/pom.xml"); String vertxVersion = MojoUtils.getVersion("vertx-core-version"); Map<String, String> tplContext = new HashMap<>(); tplContext.put("mProjectGroupId", "com.example.vertx"); tplContext.put("mProjectArtifactId", "vertx-example"); tplContext.put("mProjectVersion", "1.0-SNAPSHOT"); tplContext.put("vertxVersion", vertxVersion); tplContext.put("vertxVerticle", "com.example.vertx.MainVerticle"); tplContext.put("reactiverseVMPVersion", MojoUtils.getVersion("vertx-maven-plugin-version")); SetupTemplateUtils.createPom(tplContext, pomFile); assertThat(pomFile).isFile();/*from ww w. j a v a2 s . c o m*/ MavenXpp3Reader xpp3Reader = new MavenXpp3Reader(); Model model = xpp3Reader.read(new FileInputStream(pomFile)); MavenProject project = new MavenProject(model); Optional<Plugin> vmPlugin = MojoUtils.hasPlugin(project, "io.reactiverse:vertx-maven-plugin"); assertTrue(vmPlugin.isPresent()); Plugin vmp = project.getPlugin("io.reactiverse:vertx-maven-plugin"); assertNotNull(vmp); Xpp3Dom pluginConfig = (Xpp3Dom) vmp.getConfiguration(); assertNotNull(pluginConfig); String redeploy = pluginConfig.getChild("redeploy").getValue(); assertNotNull(redeploy); assertTrue(Boolean.valueOf(redeploy)); Properties projectProps = project.getProperties(); assertNotNull(projectProps); assertFalse(projectProps.isEmpty()); assertEquals(project.getGroupId(), "com.example.vertx"); assertEquals(project.getArtifactId(), "vertx-example"); assertEquals(project.getVersion(), "1.0-SNAPSHOT"); assertEquals(projectProps.getProperty("vertx.version"), vertxVersion); assertThat(projectProps.getProperty("vertx-maven-plugin.version")) .contains(MojoUtils.getVersion("vertx-maven-plugin-version")); assertEquals(projectProps.getProperty("vertx.verticle"), "com.example.vertx.MainVerticle"); DependencyManagement dependencyManagement = project.getDependencyManagement(); assertThat(dependencyManagement).isNotNull(); assertThat(dependencyManagement.getDependencies()).isNotEmpty(); Dependency vertxBom = project.getDependencyManagement().getDependencies().get(0); assertThat(vertxBom.getGroupId()).isEqualTo("io.vertx"); assertThat(vertxBom.getArtifactId()).isEqualTo("vertx-dependencies"); assertThat(vertxBom.getVersion()).isEqualTo("${vertx.version}"); assertThat(vertxBom.getType()).isEqualTo("pom"); assertThat(vertxBom.getScope()).isEqualTo("import"); assertThat(project.getDependencies()).isNotEmpty(); Dependency vertxCore = project.getDependencies().get(0); assertThat(vertxCore).isNotNull(); assertThat(vertxCore.getGroupId()).isEqualTo("io.vertx"); assertThat(vertxCore.getArtifactId()).isEqualTo("vertx-core"); }
From source file:org.ebayopensource.turmeric.tools.codegen.ServiceGeneratorSharedConsumerTest.java
private String getPackage(Properties props, File wsdl) throws WSDLException { String intfClass = null;//from ww w. j a v a 2s .c o m String intfPackage = null; if (!props.isEmpty()) { intfClass = props.getProperty("service_interface_class_name"); if (StringUtils.isNotBlank(intfClass)) { int idx = intfClass.lastIndexOf('.'); if (idx >= 0) { intfPackage = intfClass.substring(0, idx); } } } if (StringUtils.isBlank(intfPackage)) { String namespace = getTargetNamespace(wsdl); return WSDLUtil.getPackageFromNamespace(namespace); } return intfPackage; }