本文整理汇总了Java中com.sun.jmx.mbeanserver.GetPropertyAction类的典型用法代码示例。如果您正苦于以下问题:Java GetPropertyAction类的具体用法?Java GetPropertyAction怎么用?Java GetPropertyAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GetPropertyAction类属于com.sun.jmx.mbeanserver包,在下文中一共展示了GetPropertyAction类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMLetMethods
import com.sun.jmx.mbeanserver.GetPropertyAction; //导入依赖的package包/类
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
// Check if security manager installed
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
return;
}
// Check for addURL and getMBeansFromURL methods
if (!operation.equals("addURL") &&
!operation.equals("getMBeansFromURL")) {
return;
}
// Check if MBean is instance of MLet
if (!getMBeanServer().isInstanceOf(name,
"javax.management.loading.MLet")) {
return;
}
// Throw security exception
if (operation.equals("addURL")) { // addURL
throw new SecurityException("Access denied! MLet method addURL " +
"cannot be invoked unless a security manager is installed.");
} else { // getMBeansFromURL
// Whether or not calling getMBeansFromURL is allowed is controlled
// by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
// system property. If the value of this property is true, calling
// the MLet's getMBeansFromURL method is allowed. The default value
// for this property is false.
final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
GetPropertyAction propAction = new GetPropertyAction(propName);
String propValue = AccessController.doPrivileged(propAction);
boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
if (!allowGetMBeansFromURL) {
throw new SecurityException("Access denied! MLet method " +
"getMBeansFromURL cannot be invoked unless a " +
"security manager is installed or the system property " +
"-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
"is specified.");
}
}
}
示例2: TabularDataSupport
import com.sun.jmx.mbeanserver.GetPropertyAction; //导入依赖的package包/类
/**
* Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
* and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
*
* @param tabularType the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
* cannot be null.
*
* @param initialCapacity the initial capacity of the HashMap.
*
* @param loadFactor the load factor of the HashMap
*
* @throws IllegalArgumentException if the initial capacity is less than zero,
* or the load factor is nonpositive,
* or the tabular type is null.
*/
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {
// Check tabularType is not null
//
if (tabularType == null) {
throw new IllegalArgumentException("Argument tabularType cannot be null.");
}
// Initialize this.tabularType (and indexNamesArray for convenience)
//
this.tabularType = tabularType;
List<String> tmpNames = tabularType.getIndexNames();
this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);
// Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
// if very unlikely that we might be the server of a 1.3 client. In
// that case you'll need to set this property. See CR 6334663.
String useHashMapProp = AccessController.doPrivileged(
new GetPropertyAction("jmx.tabular.data.hash.map"));
boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);
// Construct the empty contents HashMap
//
this.dataMap = useHashMap ?
new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
示例3: checkClassNameOverride
import com.sun.jmx.mbeanserver.GetPropertyAction; //导入依赖的package包/类
private void checkClassNameOverride() throws SecurityException {
if (this.getClass().getClassLoader() == null)
return; // We trust bootstrap classes.
if (overridesGetClassName(this.getClass())) {
final GetPropertyAction getExtendOpenTypes =
new GetPropertyAction("jmx.extend.open.types");
if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
throw new SecurityException("Cannot override getClassName() " +
"unless -Djmx.extend.open.types");
}
}
}
示例4: TabularDataSupport
import com.sun.jmx.mbeanserver.GetPropertyAction; //导入依赖的package包/类
/**
* Creates an empty {@code TabularDataSupport} instance whose open-type is <var>tabularType</var>,
* and whose underlying {@code HashMap} has the specified initial capacity and load factor.
*
* @param tabularType the <i>tabular type</i> describing this {@code TabularData} instance;
* cannot be null.
*
* @param initialCapacity the initial capacity of the HashMap.
*
* @param loadFactor the load factor of the HashMap
*
* @throws IllegalArgumentException if the initial capacity is less than zero,
* or the load factor is nonpositive,
* or the tabular type is null.
*/
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {
// Check tabularType is not null
//
if (tabularType == null) {
throw new IllegalArgumentException("Argument tabularType cannot be null.");
}
// Initialize this.tabularType (and indexNamesArray for convenience)
//
this.tabularType = tabularType;
List<String> tmpNames = tabularType.getIndexNames();
this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);
// Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
// if very unlikely that we might be the server of a 1.3 client. In
// that case you'll need to set this property. See CR 6334663.
String useHashMapProp = AccessController.doPrivileged(
new GetPropertyAction("jmx.tabular.data.hash.map"));
boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);
// Construct the empty contents HashMap
//
this.dataMap = useHashMap ?
new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}