当前位置: 首页>>代码示例>>Java>>正文


Java JConfig类代码示例

本文整理汇总了Java中org.jnetpcap.util.config.JConfig的典型用法代码示例。如果您正苦于以下问题:Java JConfig类的具体用法?Java JConfig怎么用?Java JConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JConfig类属于org.jnetpcap.util.config包,在下文中一共展示了JConfig类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLogger

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Gets the logger.
 * 
 * @param c
 *          the c
 * @return the logger
 */
public static Logger getLogger(Class<?> c) {
	if (triggerConfigInit && c != JConfig.class) {
		/*
		 * This is needed because of the timing. JConfig reloads the logger
		 * properties and causes all prior initialization to be lost. So we
		 * basically trigger the JConfig initialization on the first getLogger
		 * request. If JConfig has already been initialized some other means, it
		 * won't do it again, but since we don't know we call its init method, the
		 * first time we do anyway. JConfig also preserves its own level, so
		 */
		triggerConfigInit = false;
		JConfig.init();
	}

	return getLogger(c.getName());
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:24,代码来源:JLogger.java

示例2: setLevel

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Sets the level.
 * 
 * @param newLevel
 *          the new level
 * @throws SecurityException
 *           the security exception
 * @see java.util.logging.Logger#setLevel(java.util.logging.Level)
 */
@Override
public void setLevel(Level newLevel) throws SecurityException {
	super.setLevel(newLevel);

	if (triggerConfigInit) {
		triggerConfigInit = false;
		JConfig.init();
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:19,代码来源:JLogger.java

示例3: hasCacheFile

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Checks for cache file.
 * 
 * @return true, if successful
 */
protected boolean hasCacheFile() {
	File file;
	try {
		file = JConfig.getFile(this.name, PROPERTY_RESOLVER_FILE_SEARCH_PATH);
	} catch (IOException e) {
		return false;
	}
	return file != null && file.canRead() && file.length() > 0;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:15,代码来源:AbstractResolver.java

示例4: initProperties

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Inits the properties.
 */
private void initProperties() {
	JConfig.addListener(this,
			String.format(PROPERTY_POSITIVE_TIMEOUT, ""),
			DEFAULT_POSITIVE_TIMEOUT_IN_MILLIS);
	JConfig.addListener(this,
			String.format(PROPERTY_NEGATIVE_TIMEOUT, ""),
			DEFAULT_NEGATIVE_TIMEOUT_IN_MILLIS);
	JConfig.addListener(this,
			String.format(PROPERTY_SAVE_CACHE, ""),
			DEFAULT_SAVE_CACHE);
	JConfig.addListener(this,
			String.format(PROPERTY_MAX_ENTRIES, ""),
			DEFAULT_MAX_ENTRIES);
	JConfig.addListener(this,
			String.format(PROPERTY_BACKOFF, ""),
			DEFAULT_BACKOFF);
	JConfig.addListener(this,
			String.format(PROPERTY_MKDIR_HOME, ""),
			DEFAULT_MKDIR_HOME);

	/*
	 * we don't specify a default for these, as the default would cause the
	 * parent value to be always overriden. A null default will not trigger a
	 * secondary property update and thus leaving everything at the parent's
	 * default defined above.
	 */
	final String n = this.name + ".";
	JConfig
			.addListener(this, String.format(PROPERTY_POSITIVE_TIMEOUT, n), null);
	JConfig
			.addListener(this, String.format(PROPERTY_NEGATIVE_TIMEOUT, n), null);
	JConfig.addListener(this, String.format(PROPERTY_SAVE_CACHE, n), null);
	JConfig.addListener(this, String.format(PROPERTY_MAX_ENTRIES, n), null);
	JConfig.addListener(this,
			String.format(PROPERTY_BACKOFF, this.name + "."),
			null);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:41,代码来源:AbstractResolver.java

示例5: loadCache

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Load cache entries using default mechanism.
 * 
 * @return number of cache entries read
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public int loadCache() throws IOException {

	URL url = JConfig.getURL(this.name, RESOLVER_SEARCH_PATH_PROPERTY);
	if (url == null) {
		logger.fine("cache file " + name + " not found");
		return 0;
	}

	logger.finer("loading cache file " + url.toString());
	return loadCache(new BufferedReader(new InputStreamReader(url.openStream())));
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:19,代码来源:AbstractResolver.java

示例6: testHttpFormattingWithResolveAddressEnabled

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Test http formatting with resolve address enabled.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void testHttpFormattingWithResolveAddressEnabled() throws IOException {
	JLogger.getLogger(JConfig.class).setLevel(Level.FINE);

	JLogger.getLogger(Resolver.class.getPackage()).setLevel(Level.FINER);

	JFormatter out = new TextFormatter(OUT);
	out.setResolveAddresses(true);

	PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

	Ip4 ip = new Ip4();
	Ethernet eth = new Ethernet();
	if (packet.hasHeader(eth)) {
		out.format(eth);
	}
	if (packet.hasHeader(ip)) {
		// out.format(ip);
		out.format(ip);
		System.out.println();
	}

	// out.format(packet);

	// if (true && packet.hasHeader(http)) {
	// Map<String, Http.Entry> map = http.headerFields();
	//
	// for (Entry e : map.values()) {
	// System.out.println(e.toString());
	// }
	// }

	JRegistry.shutdown();
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:40,代码来源:TestHttp.java

示例7: _testCacheSearchPath

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * _test cache search path.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void _testCacheSearchPath() throws IOException {
	logger.setLevel(Level.FINER);

	assertNotNull("failed to locate IP resolver file", JConfig.getInputStream(
	    "IP", Resolver.RESOLVER_SEARCH_PATH_PROPERTY));

}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:TestSearchPaths.java

示例8: _testResourceSearchPathOuiTxtFile

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * _test resource search path oui txt file.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void _testResourceSearchPathOuiTxtFile() throws IOException {
	logger.setLevel(Level.FINER);

	assertNotNull("failed to locate oui.txt resource file", JConfig
	    .getResourceInputStream("oui.txt"));
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:13,代码来源:TestSearchPaths.java

示例9: _testResourceSearchPathOuiTxtURL

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * _test resource search path oui txt url.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void _testResourceSearchPathOuiTxtURL() throws IOException {
	logger.setLevel(Level.FINER);

	URL url = null;
	assertNotNull("failed to locate oui.txt resource file", url =
	    JConfig.getResourceURL("oui.txt"));

	System.out.println(url);

}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:17,代码来源:TestSearchPaths.java

示例10: testSearchPathFromProperty

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Test search path from property.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void testSearchPathFromProperty() throws IOException {
	logger.setLevel(Level.FINER);

	for (SearchPath p : JConfig
	    .createSearchPath(Resolver.RESOLVER_SEARCH_PATH_PROPERTY)) {

		System.out.println(p.toString());
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:16,代码来源:TestSearchPaths.java

示例11: initializeIfNeeded

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Initializes the resolver by first checking if there are any cached entries,
 * if none, it reads the compressed oui database supplied with jNetPcap in the
 * resource directory.
 */
@Override
public void initializeIfNeeded() {
	if (initialized == false && hasCacheFile() == false) {
		initialized = true;

		setCacheCapacity(13000); // There are over 12,000 entries in the db

		super.initializeIfNeeded(); // Allow the baseclass to prep cache

		setPositiveTimeout(INFINITE_TIMEOUT); // Never
		setNegativeTimeout(0);

		/*
		 * First look for compressed OUI database.
		 */

		try {
			URL url = JConfig.getResourceURL(RESOURCE_COMPRESSED_OUI_DATABASE);
			if (url != null) {
				logger
						.fine("loading compressed database file from " + url.toString());
				readOuisFromCompressedIEEEDb(RESOURCE_COMPRESSED_OUI_DATABASE);
				return;
			}

			boolean download =
					Boolean.parseBoolean(JConfig.getProperty(PROPERTY_OUI_DB_DOWNLOAD,
							DEFAULT_OUI_DB_DOWNLOAD));
			String u = JConfig.getProperty(PROPERTY_OUI_DB_URL);
			if (u != null && download) {
				url = new URL(u);
				logger.fine("loading remote database " + url.toString());
				loadCache(url);
				return;
			}
		} catch (IOException e) {
			logger.log(Level.WARNING, "error while reading database", e);
		}
	} else {
		super.initializeIfNeeded();
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:48,代码来源:IEEEOuiPrefixResolver.java

示例12: saveCache

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Save the cache using default mechanism, if set.
 * 
 * @return number of cache entries saved
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public int saveCache() throws IOException {
	timeoutCache();

	if (saveCache == false || isModified == false || timeoutQueue.isEmpty()) {
		return 0;
	}

	URL url = JConfig.getURL(this.name, RESOLVER_SEARCH_PATH_PROPERTY);

	if (url == null) {
		logger.fine("cache file " + name + " not found");

		File dir = JConfig.getDir(PROPERTY_RESOLVER_HOME_SEARCH_PATH);
		if (dir == null) {
			logger.fine("cache directory not found");

			if (mkdirHome == true) {

				logger.fine("attempting to create cache directory using property "
						+ PROPERTY_RESOLVER_HOME);
				dir = JConfig.createDir(PROPERTY_RESOLVER_HOME, DEFAULT_HOME);
				if (dir == null) {
					return 0;
				}
			} else {
				logger.finer("property resolver.home.mkdir set to false, giving up");
				return 0;
			}
		}
		url = new File(dir, filename()).toURI().toURL();
	}

	logger.finer("saving cache " + url.toString());

	int count =
			saveCache(new PrintWriter(new OutputStreamWriter(new FileOutputStream(
					url.getFile()))));
	if (count == 0) {
		throw new IllegalStateException("Saved empty cache");
	}

	return count;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:51,代码来源:AbstractResolver.java

示例13: setNegativeTimeout

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Sets the when failed to resolve to a name, store the failure information in
 * cache and set the negative hit timeout.
 * 
 * @param negativeTimeout
 *          the new when failed to resolve to a name, store the failure
 *          information in cache and set the negative hit timeout
 */
public final void setNegativeTimeout(long negativeTimeout) {
	JConfig.setProperty(String.format(PROPERTY_NEGATIVE_TIMEOUT, this.name
			+ "."),
			Long.toString(negativeTimeout));
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:AbstractResolver.java

示例14: setPositiveTimeout

import org.jnetpcap.util.config.JConfig; //导入依赖的package包/类
/**
 * Sets the resolved to a name.
 * 
 * @param positiveTimeout
 *          the new resolved to a name
 */
public final void setPositiveTimeout(long positiveTimeout) {
	JConfig.setProperty(String.format(PROPERTY_POSITIVE_TIMEOUT, this.name
			+ "."),
			Long.toString(positiveTimeout));
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:12,代码来源:AbstractResolver.java


注:本文中的org.jnetpcap.util.config.JConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。