本文整理汇总了Java中java.lang.management.ManagementPermission类的典型用法代码示例。如果您正苦于以下问题:Java ManagementPermission类的具体用法?Java ManagementPermission怎么用?Java ManagementPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ManagementPermission类属于java.lang.management包,在下文中一共展示了ManagementPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCollectionUsageThreshold
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public void setCollectionUsageThreshold(long threshold) {
if (!isCollectionUsageThresholdSupported()) {
//lm.13=VM does not support collection usage threshold.
throw new UnsupportedOperationException(Messages.getString("lm.13")); //$NON-NLS-1$
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("control"));
}
if (threshold < 0) {
//lm.15=Collection usage threshold cannot be negative.
throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$
}
if (exceedsMaxPoolSize(threshold)) {
//lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool.
throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$
}
this.setCollectionUsageThresholdImpl(threshold);
}
示例2: setUsageThreshold
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public void setUsageThreshold(long threshold) {
if (!isUsageThresholdSupported()) {
//lm.13=VM does not support collection usage threshold.
throw new UnsupportedOperationException(Messages.getString("lm.13"));
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("control"));
}
if (threshold < 0) {
//lm.15=Collection usage threshold cannot be negative.
throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$
}
if (exceedsMaxPoolSize(threshold)) {
//lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool.
throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$
}
this.setUsageThresholdImpl(threshold);
}
示例3: getBootClassPath
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public String getBootClassPath() {
if (!isBootClassPathSupported()) {
//lm.1A=VM does not support boot classpath
throw new UnsupportedOperationException(Messages.getString("lm.1A")); //$NON-NLS-1$
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("monitor"));
}
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty("sun.boot.class.path");
}// end method run
});
}
示例4: getThreadInfo
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("monitor"));
}
// Validate inputs
for (int i = 0; i < ids.length; i++) {
if (ids[i] <= 0) {
//lm.1B=Thread id must be greater than 0
throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$
}
}
if (maxDepth < 0) {
//lm.1D=maxDepth value cannot be negative.
throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$
}
// Create an array and populate with individual ThreadInfos
ThreadInfo[] tis = new ThreadInfo[ids.length];
for (int i = 0; i < ids.length; i++) {
tis[i] = this.getThreadInfoImpl(ids[i], maxDepth);
}
return tis;
}
示例5: setCollectionUsageThreshold
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public void setCollectionUsageThreshold(long threshold) {
if (!isCollectionUsageThresholdSupported()) {
throw new UnsupportedOperationException(
"VM does not support collection usage threshold.");
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("control"));
}
if (threshold < 0) {
throw new IllegalArgumentException(
"Collection usage threshold cannot be negative.");
}
if (exceedsMaxPoolSize(threshold)) {
throw new IllegalArgumentException(
"Collection usage threshold cannot exceed maximum amount of memory for pool.");
}
this.setCollectionUsageThresholdImpl(threshold);
}
示例6: setUsageThreshold
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public void setUsageThreshold(long threshold) {
if (!isUsageThresholdSupported()) {
throw new UnsupportedOperationException(
"VM does not support usage threshold.");
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("control"));
}
if (threshold < 0) {
throw new IllegalArgumentException(
"Usage threshold cannot be negative.");
}
if (exceedsMaxPoolSize(threshold)) {
throw new IllegalArgumentException(
"Usage threshold cannot exceed maximum amount of memory for pool.");
}
this.setUsageThresholdImpl(threshold);
}
示例7: getBootClassPath
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public String getBootClassPath() {
if (!isBootClassPathSupported()) {
throw new UnsupportedOperationException(
"VM does not support boot classpath.");
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("monitor"));
}
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty("sun.boot.class.path");
}// end method run
});
}
示例8: getThreadInfo
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("monitor"));
}
// Validate inputs
for (int i = 0; i < ids.length; i++) {
if (ids[i] <= 0) {
throw new IllegalArgumentException(
"Thread id must be greater than 0.");
}
}
if (maxDepth < 0) {
throw new IllegalArgumentException(
"maxDepth value cannot be negative.");
}
// Create an array and populate with individual ThreadInfos
ThreadInfo[] tis = new ThreadInfo[ids.length];
for (int i = 0; i < ids.length; i++) {
tis[i] = this.getThreadInfoImpl(ids[i], maxDepth);
}
return tis;
}
示例9: checkSecurity
import java.lang.management.ManagementPermission; //导入依赖的package包/类
/**
* If JVM security manager exists then checks JVM security 'control' permission.
*/
public static void checkSecurity() {
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null) {
securityManager.checkPermission(new ManagementPermission(PERMISSION_NAME_CONTROL));
}
}
示例10: jvmInfo
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public static JvmInfo jvmInfo() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new ManagementPermission("monitor"));
sm.checkPropertyAccess("*");
}
return INSTANCE;
}
示例11: checkManagementPermission
import java.lang.management.ManagementPermission; //导入依赖的package包/类
protected boolean checkManagementPermission(ManagementPermission perm) {
String name = perm.getName();
if (name.equals("monitor")) {
return true;
}
/*
* "control" sounds bit risky
*/
return false;
}
示例12: resetPeakUsage
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public void resetPeakUsage() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("control"));
}
this.resetPeakUsageImpl();
}
示例13: setVerbose
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public void setVerbose(boolean value) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("control"));
}
this.setVerboseImpl(value);
}
示例14: getInputArguments
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public List<String> getInputArguments() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("monitor"));
}
// TODO : Retrieve the input args from the VM
return new ArrayList<String>();
}
示例15: findMonitorDeadlockedThreads
import java.lang.management.ManagementPermission; //导入依赖的package包/类
public long[] findMonitorDeadlockedThreads() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new ManagementPermission("monitor"));
}
return this.findMonitorDeadlockedThreadsImpl();
}