本文整理汇总了Java中com.sun.management.DiagnosticCommandMBean类的典型用法代码示例。如果您正苦于以下问题:Java DiagnosticCommandMBean类的具体用法?Java DiagnosticCommandMBean怎么用?Java DiagnosticCommandMBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiagnosticCommandMBean类属于com.sun.management包,在下文中一共展示了DiagnosticCommandMBean类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeDcmd
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
private static String executeDcmd(String cmd, String ... args) {
DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
Object[] dcmdArgs = {args};
String[] signature = {String[].class.getName()};
String cmdString = cmd + " " +
Arrays.stream(args).collect(Collectors.joining(" "));
File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
try (FileWriter fw = new FileWriter(f)) {
fw.write("> " + cmdString + ":");
String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
fw.write(result);
return result;
} catch(Exception ex) {
ex.printStackTrace();
}
return null;
}
示例2: executeDcmd
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
private static String executeDcmd(String cmd, String ... args) {
DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
Object[] dcmdArgs = {args};
String[] signature = {String[].class.getName()};
try {
System.out.print("> " + cmd + " ");
for (String s : args) {
System.out.print(s + " ");
}
System.out.println(":");
String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
System.out.println(result);
return result;
} catch(Exception ex) {
ex.printStackTrace();
}
return null;
}
示例3: getDiagnosticCommandMBean
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
public static synchronized DiagnosticCommandMBean getDiagnosticCommandMBean() {
// Remote Diagnostic Commands may not be supported
if (hsDiagCommandMBean == null && jvm.isRemoteDiagnosticCommandsSupported()) {
hsDiagCommandMBean = new DiagnosticCommandImpl(jvm);
}
return hsDiagCommandMBean;
}
示例4: getPlatformDynamicMBeans
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
public static HashMap<ObjectName, DynamicMBean> getPlatformDynamicMBeans() {
HashMap<ObjectName, DynamicMBean> map = new HashMap<>();
DiagnosticCommandMBean diagMBean = getDiagnosticCommandMBean();
if (diagMBean != null) {
map.put(Util.newObjectName(HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME), diagMBean);
}
return map;
}
示例5: doMethodInBacktraceTestB
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
private void doMethodInBacktraceTestB() throws Exception {
// Start a thread which blocks in method
Thread t = new Thread(RedefineMethodInBacktraceTargetB::methodToRedefine);
t.setDaemon(true);
t.start();
// Wait here until the new thread is in the method we want to redefine
called.await();
// Now redefine the class while the method is still on the stack of the new thread
doRedefine(RedefineMethodInBacktraceTargetB.class);
// Do thread dumps in two different ways (to exercise different code paths)
// while the old class is still on the stack
ThreadInfo[] tis = ManagementFactory.getThreadMXBean().dumpAllThreads(false, false);
for(ThreadInfo ti : tis) {
System.out.println(ti);
}
String[] threadPrintArgs = {};
Object[] dcmdArgs = {threadPrintArgs};
String[] signature = {String[].class.getName()};
DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
System.out.println(dcmd.invoke("threadPrint", dcmdArgs, signature));
// release the thread
stop.countDown();
}
示例6: getDiagnosticCommandMBean
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
static synchronized DiagnosticCommandMBean getDiagnosticCommandMBean() {
VMManagement jvm = ManagementFactoryHelper.getVMManagement();
// Remote Diagnostic Commands may not be supported
if (diagCommandMBean == null && jvm.isRemoteDiagnosticCommandsSupported()) {
diagCommandMBean = new DiagnosticCommandImpl(jvm);
}
return diagCommandMBean;
}
示例7: referenceClassInDirectAndTransitiveDependency
import com.sun.management.DiagnosticCommandMBean; //导入依赖的package包/类
ClassInDirectDependency referenceClassInDirectAndTransitiveDependency(
ClassInTransitiveDependency referenceToClassInTransitiveDependency, double d, Float f, X string) {
final ClassInTransitiveDependency localReference = referenceToClassInTransitiveDependency;
try {
final Long longValue = someTee(Long.class);
} catch (SQLException e) {
//
}
// types that should come from runtime's rt.jar
final DataSource dataSource = null;
final DataSource secondDataSource = null;
final DataSource thirdDataSource = null;
final Text text = null;
final DiagnosticCommandMBean dcmb = null;
final int k = 3 + 4;
final Date date = new Date(System.currentTimeMillis());
float m = Math.max(1, 2);
final Class<String[]> stringArrayClass = String[].class;
final Class<Long[][]> longArrayArrayClass = Long[][].class;
final ClassInDirectDependency directDependency = new ClassInDirectDependency();
final String s = String.valueOf(directDependency.getOne());
return directDependency;
}
开发者ID:ImmobilienScout24,项目名称:illegal-transitive-dependency-check,代码行数:31,代码来源:ClassInMavenProjectSource.java