本文整理汇总了Java中com.sun.jmx.mbeanserver.Util.newObjectName方法的典型用法代码示例。如果您正苦于以下问题:Java Util.newObjectName方法的具体用法?Java Util.newObjectName怎么用?Java Util.newObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jmx.mbeanserver.Util
的用法示例。
在下文中一共展示了Util.newObjectName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDomains
import com.sun.jmx.mbeanserver.Util; //导入方法依赖的package包/类
public String[] getDomains() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
// Check if the caller has the right to invoke 'getDomains'
//
checkMBeanPermission((String) null, null, null, "getDomains");
// Return domains
//
String[] domains = repository.getDomains();
// Check if the caller has the right to invoke 'getDomains'
// on each specific domain in the list.
//
List<String> result = new ArrayList<String>(domains.length);
for (int i = 0; i < domains.length; i++) {
try {
ObjectName dom = Util.newObjectName(domains[i] + ":x=x");
checkMBeanPermission((String) null, null, dom, "getDomains");
result.add(domains[i]);
} catch (SecurityException e) {
// OK: Do not add this domain to the list
}
}
// Make an array from result.
//
return result.toArray(new String[result.size()]);
} else {
return repository.getDomains();
}
}
示例2: nonDefaultDomain
import com.sun.jmx.mbeanserver.Util; //导入方法依赖的package包/类
private ObjectName nonDefaultDomain(ObjectName name) {
if (name == null || name.getDomain().length() > 0)
return name;
/* The ObjectName looks like ":a=b", and that's what its
toString() will return in this implementation. So
we can just stick the default domain in front of it
to get a non-default-domain name. We depend on the
fact that toString() works like that and that it
leaves wildcards in place (so we can detect an error
if one is supplied where it shouldn't be). */
final String completeName = domain + name;
return Util.newObjectName(completeName);
}
示例3: getInstance
import com.sun.jmx.mbeanserver.Util; //导入方法依赖的package包/类
/**
* <p>Return an instance of ObjectName that can be used anywhere
* the given object can be used. The returned object may be of a
* subclass of ObjectName. If <code>name</code> is of a subclass
* of ObjectName, it is not guaranteed that the returned object
* will be of the same class.</p>
*
* <p>The returned value may or may not be identical to
* <code>name</code>. Calling this method twice with the same
* parameters may return the same object or two equal but not
* identical objects.</p>
*
* <p>Since ObjectName is immutable, it is not usually useful to
* make a copy of an ObjectName. The principal use of this method
* is to guard against a malicious caller who might pass an
* instance of a subclass with surprising behavior to sensitive
* code. Such code can call this method to obtain an ObjectName
* that is known not to have surprising behavior.</p>
*
* @param name an instance of the ObjectName class or of a subclass
*
* @return an instance of ObjectName or a subclass that is known to
* have the same semantics. If <code>name</code> respects the
* semantics of ObjectName, then the returned object is equal
* (though not necessarily identical) to <code>name</code>.
*
* @exception NullPointerException The <code>name</code> is null.
*
*/
public static ObjectName getInstance(ObjectName name) {
if (name.getClass().equals(ObjectName.class))
return name;
return Util.newObjectName(name.getSerializedNameString());
}