本文整理匯總了Java中org.apache.commons.configuration.BaseConfiguration.addProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java BaseConfiguration.addProperty方法的具體用法?Java BaseConfiguration.addProperty怎麽用?Java BaseConfiguration.addProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.configuration.BaseConfiguration
的用法示例。
在下文中一共展示了BaseConfiguration.addProperty方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testAssertGetPropertyErrorReturnPreviousValue
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
/**
* Asserts that when a property is requested from the configruation, and it fires an error event (ex. Database is not available), the previously stored
* values are not cleared.
*/
@Test
public void testAssertGetPropertyErrorReturnPreviousValue() throws Exception
{
// Get a reloadable property source that loads properties from the configuration every time a property is read.
BaseConfiguration configuration = new BaseConfiguration()
{
@Override
public Object getProperty(String key)
{
fireError(EVENT_READ_PROPERTY, key, null, new IllegalStateException("test exception"));
return null;
}
};
configuration.addProperty(TEST_KEY, TEST_VALUE_1);
ReloadablePropertySource reloadablePropertySource = getNewReloadablePropertiesSource(0L, configuration);
verifyPropertySourceValue(reloadablePropertySource, TEST_VALUE_1);
}
示例2: testAddInputFile
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
@Test
public void testAddInputFile() throws Exception {
final String inputName = "input.txt";
final File input = temp.newFile(inputName);
final BaseConfiguration conf = new BaseConfiguration();
conf.addProperty(ExternalProcess.PROP_EXEC, "test.sh");
conf.addProperty(ExternalProcess.PROP_ARG, "-i ${input.file.name}");
conf.addProperty(ExternalProcess.PROP_ARG, "-path ${input.file}[0]");
conf.addProperty(ExternalProcess.PROP_ARG, "-o ${input.folder}");
GenericExternalProcess gp = new GenericExternalProcess(conf).addInputFile(input);
assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_NAME_EXT), input.getName());
assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PATH), input.getAbsolutePath());
assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PARENT), input.getParentFile().getAbsolutePath());
List<String> cmdLines = gp.buildCmdLine(conf);
// System.out.println(cmdLines.toString());
}
示例3: main
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
public static void main(final String arg[]) throws Exception {
final SimpleJSAP jsap = new SimpleJSAP(Agent.class.getName(), "Starts a BUbiNG agent (note that you must enable JMX by means of the standard Java system properties).",
new Parameter[] {
new FlaggedOption("weight", JSAP.INTEGER_PARSER, "1", JSAP.NOT_REQUIRED, 'w', "weight", "The agent weight."),
new FlaggedOption("group", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g', "group", "The JGroups group identifier (must be the same for all cooperating agents)."),
new FlaggedOption("jmxHost", JSAP.STRING_PARSER, InetAddress.getLocalHost().getHostAddress(), JSAP.REQUIRED, 'h', "jmx-host", "The IP address (possibly specified by a host name) that will be used to expose the JMX RMI connector to other agents."),
new FlaggedOption("rootDir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'r', "root-dir", "The root directory."),
new Switch("new", 'n', "new", "Start a new crawl"),
new FlaggedOption("properties", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'P', "properties", "The properties used to configure the agent."),
new UnflaggedOption("name", JSAP.STRING_PARSER, JSAP.REQUIRED, "The agent name (an identifier that must be unique across the group).")
});
final JSAPResult jsapResult = jsap.parse(arg);
if (jsap.messagePrinted()) System.exit(1);
// JMX *must* be set up.
final String portProperty = System.getProperty(JMX_REMOTE_PORT_SYSTEM_PROPERTY);
if (portProperty == null) throw new IllegalArgumentException("You must specify a JMX service port using the property " + JMX_REMOTE_PORT_SYSTEM_PROPERTY);
final String name = jsapResult.getString("name");
final int weight = jsapResult.getInt("weight");
final String group = jsapResult.getString("group");
final String host = jsapResult.getString("jmxHost");
final int port = Integer.parseInt(portProperty);
final BaseConfiguration additional = new BaseConfiguration();
additional.addProperty("name", name);
additional.addProperty("group", group);
additional.addProperty("weight", Integer.toString(weight));
additional.addProperty("crawlIsNew", Boolean.valueOf(jsapResult.getBoolean("new")));
if (jsapResult.userSpecified("rootDir")) additional.addProperty("rootDir", jsapResult.getString("rootDir"));
new Agent(host, port, new RuntimeConfiguration(new StartupConfiguration(jsapResult.getString("properties"), additional)));
System.exit(0); // Kills remaining FetchingThread instances, if any.
}
示例4: setUp
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
@Before
public void setUp() {
conf = new BaseConfiguration();
// catalog1
String prefix = Catalogs.CATALOG_PREFIX + '.' + "catalog1";
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_NAME, "catalog1Name");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_URL, "catalog1URL");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_TYPE, "catalog1Type");
catalog1ExtraOption = "extraOption";
conf.addProperty(prefix + '.' + catalog1ExtraOption, "catalog1ExtraOption");
// Invalid catalog
prefix = Catalogs.CATALOG_PREFIX + '.' + "catalogInvalid";
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_NAME, "catalogInvalidName");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_TYPE, "catalogInvalidType");
// Not listed catalog
prefix = Catalogs.CATALOG_PREFIX + '.' + "catalogNotListed";
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_NAME, "catalogNotListedName");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_URL, "catalogNotListedURL");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_TYPE, "catalogNotListedType");
// catalog2
prefix = Catalogs.CATALOG_PREFIX + '.' + "catalog2";
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_NAME, "catalog2Name");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_URL, "catalog2URL");
conf.addProperty(prefix + '.' + CatalogConfiguration.PROPERTY_TYPE, "catalog2Type");
// catalogs declaration
conf.addProperty(Catalogs.PROPERTY_CATALOGS, "catalog1, catalogInvalid, catalogMissing, catalog2");
conf.addProperty("dummyProperty", "dummy");
}
示例5: actionPerformed
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent arg0) {
LogImporterAndPort chooseLogImporter = chooseLogImporter();
if (chooseLogImporter == null) {
return;
}
StatusObserver observer = getOtrosApplication().getStatusObserver();
if (logViewPanelWrapper == null) {
logViewPanelWrapper = new LogViewPanelWrapper("Socket", null, TableColumns.values(), getOtrosApplication());
logViewPanelWrapper.goToLiveMode();
BaseConfiguration configuration = new BaseConfiguration();
configuration.addProperty(ConfKeys.TAILING_PANEL_PLAY, true);
configuration.addProperty(ConfKeys.TAILING_PANEL_FOLLOW, true);
logDataCollector = new BufferingLogDataCollectorProxy(logViewPanelWrapper.getDataTableModel(), 4000, configuration);
}
getOtrosApplication().addClosableTab("Socket listener", "Socket listener", Icons.PLUGIN_CONNECT, logViewPanelWrapper, true);
//TODO solve this warning
SocketLogReader logReader = null;
if (logReader == null || logReader.isClosed()) {
logReader = new SocketLogReader(chooseLogImporter.logImporter, logDataCollector, observer, chooseLogImporter.port);
try {
logReader.start();
logReaders.add(logReader);
observer.updateStatus(String.format("Socket opened on port %d with %s.", chooseLogImporter.port, chooseLogImporter.logImporter));
} catch (Exception e) {
e.printStackTrace();
observer.updateStatus("Failed to open listener " + e.getMessage(), StatusObserver.LEVEL_ERROR);
}
}
}
示例6: doInBackground
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
@Override
protected Void doInBackground() throws Exception {
LoadingInfo[] loadingInfos = getLoadingInfo();
Collection<LogImporter> elements = pluginContext.getOtrosApplication().getAllPluginables().getLogImportersContainer().getElements();
LogImporter[] importers = elements.toArray(new LogImporter[elements.size()]);
String[] names = new String[elements.size()];
for (int i = 0; i < names.length; i++) {
names[i] = importers[i].getName();
}
TableColumns[] visibleColumns = {TableColumns.ID,//
TableColumns.TIME,//
TableColumns.LEVEL,//
TableColumns.MESSAGE,//
TableColumns.CLASS,//
TableColumns.METHOD,//
TableColumns.THREAD,//
TableColumns.MARK,//
TableColumns.NOTE,//
TableColumns.LOG_SOURCE
};
BaseConfiguration configuration = new BaseConfiguration();
configuration.addProperty(ConfKeys.TAILING_PANEL_PLAY, true);
configuration.addProperty(ConfKeys.TAILING_PANEL_FOLLOW, true);
logViewPanelWrapper = new LogViewPanelWrapper(tabName, null, visibleColumns, pluginContext.getOtrosApplication());
BufferingLogDataCollectorProxy logDataCollector = new BufferingLogDataCollectorProxy(logViewPanelWrapper.getDataTableModel(), 4000, configuration);
LogImporter importer = getLogImporter(elements);
for (LoadingInfo loadingInfo : loadingInfos) {
openLog(logDataCollector, importer, loadingInfo);
}
publish("All log files loaded");
return null;
}
示例7: dbConfig
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
private Configuration dbConfig() {
BaseConfiguration c = new BaseConfiguration();
c.addProperty("blueprints.orientdb.url", "plocal:" + settings.getOrientGraphDb());
c.addProperty("blueprints.orientdb.username", "admin");
c.addProperty("blueprints.orientdb.password", "admin");
c.addProperty("blueprints.orientdb.lightweightEdges", Boolean.FALSE);
return c;
}
示例8: createConfiguration
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
private static Configuration createConfiguration() {
BaseConfiguration config = new BaseConfiguration();
config.addProperty("foo", "foobar");
return config;
}
示例9: getTestConfiguration
import org.apache.commons.configuration.BaseConfiguration; //導入方法依賴的package包/類
/** Returns a test configuration, contained in the file <code>bubing-test.properties</code> in the data directory.
*
* @param self the test that is requiring the configuration.
* @param prop the additional properties that override (some of) those contained in the file.
* @param newCrawl whether this configuration simulates a new crawl or not.
* @return the configuration.
* @throws ConfigurationException if some configuration error occurs.
*/
public static RuntimeConfiguration getTestConfiguration(Object self, BaseConfiguration prop, boolean newCrawl) throws ConfigurationException, IOException, IllegalArgumentException, ClassNotFoundException {
prop.addProperty("crawlIsNew", Boolean.valueOf(newCrawl));
return new RuntimeConfiguration(getTestStartupConfiguration(self, prop)) ;
}