List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:org.apache.pig.data.SchemaTupleFrontend.java
/** * This method "registers" a Schema to be generated. It allows a portions of the code * to register a Schema for generation without knowing whether code generation is enabled. * A unique ID will be passed back that can be used internally to refer to generated SchemaTuples * (such as in the case of serialization and deserialization). The context is necessary to allow * the client to restrict where generated code can be used. * @param udfSchema This is the Schema of a Tuple that we will potentially generate * @param isAppendable This specifies whether or not we want the SchemaTuple to be appendable * @param context This is the context in which users should be able to access the SchemaTuple * @return identifier/*w ww . ja v a 2 s . c o m*/ */ public static int registerToGenerateIfPossible(Schema udfSchema, boolean isAppendable, GenContext context) { if (stf == null) { if (pigContextToReset != null) { Properties prop = pigContextToReset.getProperties(); prop.remove(GENERATED_CLASSES_KEY); prop.remove(LOCAL_CODE_DIR); pigContextToReset = null; } SchemaTupleBackend.reset(); SchemaTupleClassGenerator.resetGlobalClassIdentifier(); stf = new SchemaTupleFrontend(); } if (udfSchema == null) { return -1; } try { udfSchema = udfSchema.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Unable to clone Schema: " + udfSchema, e); } stripAliases(udfSchema); return stf.internalRegisterToGenerateIfPossible(udfSchema, isAppendable, context); }
From source file:net.roboconf.agent.internal.misc.UserDataUtils.java
/** * Reconfigures the messaging./* w ww . ja v a 2s . co m*/ * @param etcDir the KARAF_ETC directory * @param msgData the messaging configuration parameters */ public static void reconfigureMessaging(String etcDir, Map<String, String> msgData) throws IOException { String messagingType = msgData.get(MessagingConstants.MESSAGING_TYPE_PROPERTY); Logger.getLogger(UserDataUtils.class.getName()) .fine("Messaging type for reconfiguration: " + messagingType); if (!Utils.isEmptyOrWhitespaces(etcDir)) { // Write the messaging configuration Properties props = new Properties(); props.putAll(msgData); props.remove(Constants.MESSAGING_TYPE); File f = new File(etcDir, "net.roboconf.messaging." + messagingType + ".cfg"); Utils.writePropertiesFile(props, f); // Set the messaging type f = new File(etcDir, CONF_FILE_AGENT); props = Utils.readPropertiesFileQuietly(f, Logger.getLogger(UserDataUtils.class.getName())); props.put(Constants.MESSAGING_TYPE, messagingType); Utils.writePropertiesFile(props, f); } }
From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.InterceptorsTest.java
private static Consumer<String, String> initConsumer() throws Exception { Properties props = new Properties(); props.load(new FileReader(System.getProperty("consumer.config"))); // NON-NLS topicName = props.getProperty("test.app.topic.name", "tnt4j_streams_kafka_intercept_test_page_visits"); // NON-NLS props.remove("test.app.topic.name"); Consumer<String, String> consumer = new KafkaConsumer<>(props); consumer.subscribe(Collections.singletonList(topicName)); return consumer; }
From source file:io.fabric8.profiles.ProfilesHelpers.java
public static void merge(Properties target, Properties source) { if (source.contains(DELETED)) { target.clear();//ww w .j a v a 2 s . c o m } else { for (Map.Entry<Object, Object> entry : source.entrySet()) { if (DELETED.equals(entry.getValue())) { target.remove(entry.getKey()); } else { target.put(entry.getKey(), entry.getValue()); } } } }
From source file:com.hypersocket.i18n.I18N.java
public static void removeOverrideMessage(Locale locale, Message message) { File overrideFile = getOverrideFile(locale, message.getBundle()); if (!overideProperties.containsKey(overrideFile)) { overideProperties.put(overrideFile, new Properties()); if (overrideFile.exists()) { Properties p = overideProperties.get(overrideFile); InputStream in = null; try { in = new FileInputStream(overrideFile); p.load(in);// ww w. j av a 2 s . c o m } catch (IOException e) { } finally { IOUtils.closeQuietly(in); } } } Properties properties = overideProperties.get(overrideFile); properties.remove(message.getId()); }
From source file:com.asakusafw.bulkloader.testutil.UnitTestUtil.java
public static void tearDownEnv() throws Exception { Properties p = System.getProperties(); p.remove(Constants.ASAKUSA_HOME); p.remove(Constants.THUNDER_GATE_HOME); ConfigurationLoader.setSysProp(p);/*ww w .j ava 2 s. c om*/ System.setProperties(p); }
From source file:org.mousephenotype.dcc.exportlibrary.impressexamplesgeneration.ExampleGeneratorTest.java
@BeforeClass public static void setup() { System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "WARNING"); Properties properties = null; try {//from w w w . j a va2 s. c om reader = new Reader("xmlvalidationresources.derby.properties"); } catch (ConfigurationException ex) { logger.error("", ex); Assert.fail(); } properties = reader.getProperties(); Assert.assertNotNull(properties); properties.remove("hibernate.hbm2ddl.auto"); impressHibernateManager = new HibernateManager(properties, persistenceUnitname); exampleGenerator = new ExampleGenerator(impressHibernateManager, centreILARcode, ExampleGenerator.projects[new Random().nextInt(ExampleGenerator.projects.length)], pipeline, experimentID, specimenID); }
From source file:com.cssweb.android.common.CssIniFile.java
public static boolean delIniWithAPPEND(Context context, int parmInt, String key) { Properties properties = new Properties(); try {/*from ww w. j a v a 2 s . co m*/ FileOutputStream stream = context.openFileOutput(GetFileName(parmInt), Context.MODE_APPEND);// properties.remove(key); stream.close(); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } return true; }
From source file:com.heliosapm.streams.collector.ds.pool.PoolConfig.java
/** * Creates and deploys an ObjectPool based on the passed config props * @param p The configuration properties * @return the created GenericObjectPool *//*from ww w . jav a 2s .com*/ @SuppressWarnings({ "rawtypes", "unchecked" }) private static GenericObjectPool<?> deployPool(final Properties p) { final String factoryName = (String) p.remove(POOLED_OBJECT_FACTORY_KEY); final String poolName = p.getProperty(NAME.name().toLowerCase()); if (poolName == null || poolName.trim().isEmpty()) throw new RuntimeException("Pool was not assigned a name"); if (factoryName == null || factoryName.trim().isEmpty()) throw new RuntimeException("No pooled object factory defined"); final GenericObjectPoolConfig cfg = DEFAULT_CONFIG.clone(); try { final Class<PooledObjectFactoryBuilder<?>> clazz = loadFactoryClass(factoryName); final Constructor<PooledObjectFactoryBuilder<?>> ctor = clazz.getDeclaredConstructor(Properties.class); final PooledObjectFactoryBuilder<?> factory = ctor.newInstance(p); for (final String key : p.stringPropertyNames()) { if (isPoolConfig(key)) { final PoolConfig pc = decode(key); pc.apply(cfg, p.get(key)); } } final PooledObjectFactory<?> pooledObjectFactory = factory.factory(); GenericObjectPool<?> pool = new GenericObjectPool(pooledObjectFactory, cfg); pool.setSwallowedExceptionListener(EX_LISTENER); if (factory instanceof PoolAwareFactory) { ((PoolAwareFactory) factory).setPool(pool); } GlobalCacheService.getInstance().put("pool/" + poolName, pool); pool.setAbandonedConfig(Abandoned.create(p)); pool.preparePool(); return pool; } catch (Exception ex) { throw new RuntimeException("Failed to create GenericObjectPool from properties [" + p + "]", ex); } }
From source file:org.apache.pig.data.SchemaTupleFrontend.java
/** * This must be called when the code has been generated and the generated code needs to be shipped * to the cluster, so that it may be used by the mappers and reducers. * @param pigContext/*from w ww .j a v a2 s . c om*/ * @param conf */ public static void copyAllGeneratedToDistributedCache(PigContext pigContext, Configuration conf) { if (stf == null) { LOG.debug("Nothing registered to generate."); return; } SchemaTupleFrontendGenHelper stfgh = new SchemaTupleFrontendGenHelper(pigContext, conf); stfgh.generateAll(stf.getSchemasToGenerate()); stfgh.internalCopyAllGeneratedToDistributedCache(); Properties prop = pigContext.getProperties(); String value = conf.get(GENERATED_CLASSES_KEY); if (value != null) { prop.setProperty(GENERATED_CLASSES_KEY, value); } else { prop.remove(GENERATED_CLASSES_KEY); } value = conf.get(LOCAL_CODE_DIR); if (value != null) { prop.setProperty(LOCAL_CODE_DIR, value); } else { prop.remove(LOCAL_CODE_DIR); } }