本文整理汇总了Java中sun.net.InetAddressCachePolicy类的典型用法代码示例。如果您正苦于以下问题:Java InetAddressCachePolicy类的具体用法?Java InetAddressCachePolicy怎么用?Java InetAddressCachePolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InetAddressCachePolicy类属于sun.net包,在下文中一共展示了InetAddressCachePolicy类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
/**
* Query the cache for the specific host. If found then
* return its CacheEntry, or null if not found.
*/
public CacheEntry get(String host) {
int policy = getPolicy();
if (policy == InetAddressCachePolicy.NEVER) {
return null;
}
CacheEntry entry = cache.get(host);
// check if entry has expired
if (entry != null && policy != InetAddressCachePolicy.FOREVER) {
if (entry.expiration >= 0 &&
entry.expiration < System.currentTimeMillis()) {
cache.remove(host);
entry = null;
}
}
return entry;
}
示例2: get
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
/**
* Query the cache for the specific host. If found then
* return its CacheEntry, or null if not found.
*/
public CacheEntry get(String host) {
int policy = getPolicy();
if (policy == InetAddressCachePolicy.NEVER) {
return null;
}
CacheEntry entry = (CacheEntry)cache.get(host);
// check if entry has expired
if (entry != null && policy != InetAddressCachePolicy.FOREVER) {
if (entry.expiration >= 0 &&
entry.expiration < System.currentTimeMillis()) {
cache.remove(host);
entry = null;
}
}
return entry;
}
示例3: getPolicy
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
private int getPolicy() {
if (type == Type.Positive) {
return InetAddressCachePolicy.get();
} else {
return InetAddressCachePolicy.getNegative();
}
}
示例4: setSecurityManager0
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
private static synchronized
void setSecurityManager0(final SecurityManager s) {
SecurityManager sm = getSecurityManager();
if (sm != null) {
// ask the currently installed security manager if we
// can replace it.
sm.checkPermission(new RuntimePermission
("setSecurityManager"));
}
if ((s != null) && (s.getClass().getClassLoader() != null)) {
// New security manager class is not on bootstrap classpath.
// Cause policy to get initialized before we install the new
// security manager, in order to prevent infinite loops when
// trying to initialize the policy (which usually involves
// accessing some security and/or system properties, which in turn
// calls the installed security manager's checkPermission method
// which will loop infinitely if there is a non-system class
// (in this case: the new security manager class) on the stack).
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
s.getClass().getProtectionDomain().implies
(SecurityConstants.ALL_PERMISSION);
return null;
}
});
}
security = s;
InetAddressCachePolicy.setIfNotSet(InetAddressCachePolicy.FOREVER);
}
示例5: getPolicy
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
private int getPolicy() {
if (type == Type.Positive) {
return InetAddressCachePolicy.get();
} else {
return InetAddressCachePolicy.getNegative();
}
}
示例6: getDnsCachePolicy
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
public static int getDnsCachePolicy()
throws NoSuchFieldException, IllegalAccessException {
return InetAddressCachePolicy.get();
}
示例7: getDnsNegativeCachePolicy
import sun.net.InetAddressCachePolicy; //导入依赖的package包/类
public static int getDnsNegativeCachePolicy()
throws NoSuchFieldException, IllegalAccessException {
return InetAddressCachePolicy.getNegative();
}