本文整理汇总了Java中com.sun.btrace.comm.ErrorCommand类的典型用法代码示例。如果您正苦于以下问题:Java ErrorCommand类的具体用法?Java ErrorCommand怎么用?Java ErrorCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorCommand类属于com.sun.btrace.comm包,在下文中一共展示了ErrorCommand类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCommand
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
@Override
public void onCommand(Command command) throws IOException {
if (command instanceof DataCommand)
onDataCommand((DataCommand)command);
else if (command.getType() == Command.EXIT)
onExitCommand();
else if (command.getType() == Command.ERROR)
onErrorCommand((ErrorCommand)command);
}
示例2: onCommand
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
public void onCommand(Command cmd) throws IOException {
if (out == null) {
throw new IOException("no output stream");
}
if (debug) {
Main.debugPrint("client " + getClassName() + ": got " + cmd);
}
switch (cmd.getType()) {
case Command.EXIT:
onExit(((ExitCommand) cmd).getExitCode());
break;
case Command.ERROR: {
ErrorCommand ecmd = (ErrorCommand) cmd;
Throwable cause = ecmd.getCause();
if (cause != null) {
cause.printStackTrace(out);
out.flush();
}
break;
}
default:
if (cmd instanceof DataCommand) {
((DataCommand) cmd).print(out);
out.flush();
}
break;
}
}
示例3: errorExit
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
protected void errorExit(Throwable th) throws IOException {
if (debug) Main.debugPrint("sending error command");
onCommand(new ErrorCommand(th));
if (debug) Main.debugPrint("sending exit command");
onCommand(new ExitCommand(1));
closeAll();
}
示例4: handleExceptionImpl
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
private void handleExceptionImpl(Throwable th) {
if (currentException.get() != null) {
return;
}
leave();
currentException.set(th);
try {
if (th instanceof ExitException) {
exitImpl(((ExitException)th).exitCode());
} else {
if (exceptionHandler != null) {
try {
exceptionHandler.invoke(null, th);
} catch (Throwable ignored) {
}
} else {
try {
// Do not call send(Command). Exception messages should not
// go to speculative buffers!
queue.put(new ErrorCommand(th));
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
} finally {
currentException.set(null);
}
}
示例5: start
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
private static void start(Consumer cons,
final CommandListener listener)
throws DTraceException {
cons.enable();
cons.go(new ExceptionHandler() {
@Override
public void handleException(Throwable th) {
try {
listener.onCommand(new ErrorCommand(th));
} catch (IOException ioexp) {
ioexp.printStackTrace();
}
}
});
}
示例6: dispatchCommand
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
void dispatchCommand(final Command cmd) {
final Set<MessageDispatcher> dispatchingSet = new HashSet<>();
synchronized(messageDispatchers) {
dispatchingSet.addAll(messageDispatchers);
}
dispatcher.submit(() -> {
for(MessageDispatcher listener : dispatchingSet) {
switch (cmd.getType()) {
case MESSAGE: {
listener.onPrintMessage(((MessageCommand)cmd).getMessage());
break;
}
case RETRANSFORM_CLASS: {
listener.onClassInstrumented(((RetransformClassNotification)cmd).getClassName());
break;
}
case NUMBER: {
NumberDataCommand ndc = (NumberDataCommand)cmd;
listener.onNumberMessage(ndc.getName(), ndc.getValue());
break;
}
case NUMBER_MAP: {
NumberMapDataCommand nmdc = (NumberMapDataCommand)cmd;
listener.onNumberMap(nmdc.getName(), nmdc.getData());
break;
}
case STRING_MAP: {
StringMapDataCommand smdc = (StringMapDataCommand)cmd;
listener.onStringMap(smdc.getName(), smdc.getData());
break;
}
case GRID_DATA: {
GridDataCommand gdc = (GridDataCommand)cmd;
listener.onGrid(gdc.getName(), gdc.getData());
break;
}
case ERROR: {
ErrorCommand ec = (ErrorCommand)cmd;
listener.onError(ec.getCause());
break;
}
}
}
});
}
示例7: onErrorCommand
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void onErrorCommand(ErrorCommand command) {
Throwable cause = command.getCause();
if (cause != null)
cause.printStackTrace();
}
示例8: doStart
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
private boolean doStart(BTraceTask task) {
final AtomicBoolean result = new AtomicBoolean(false);
final BTraceTaskImpl btrace = (BTraceTaskImpl) task;
try {
final CountDownLatch latch = new CountDownLatch(1);
final BTraceCompiler compiler = compilerFactory.newCompiler(btrace);
btrace.setState(BTraceTask.State.COMPILING);
final byte[] bytecode = compiler.compile(btrace.getScript(), task.getClassPath(), outputProvider.getStdErr(task));
if (bytecode.length == 0) {
btrace.setState(BTraceTask.State.FAILED);
return false;
}
btrace.setState(BTraceTask.State.COMPILED);
LOGGER.log(Level.FINEST, "Compiled the trace: {0} bytes", bytecode.length);
commQueue.submit(new Runnable() {
public void run() {
int port = portLocator.getTaskPort(btrace);
LOGGER.log(Level.FINEST, "BTrace agent listening on port {0}", port);
BTraceSettings settings = settingsProvider.getSettings();
final Client client = new Client(port, ".", settings.isDebugMode(), true, btrace.isUnsafe(), settings.isDumpClasses(), settings.getDumpClassPath());
try {
client.attach(String.valueOf(btrace.getPid()), compiler.getAgentJarPath(), compiler.getToolsJarPath(), null);
Thread.sleep(200); // give the server side time to initialize and open the port
client.submit(bytecode, new String[]{}, new CommandListener() {
public void onCommand(Command cmd) throws IOException {
LOGGER.log(Level.FINEST, "Received command: {0}", cmd.toString());
switch (cmd.getType()) {
case Command.SUCCESS: {
if (btrace.getState() == BTraceTask.State.COMPILED) {
btrace.setState(BTraceTask.State.ACCEPTED);
} else if (EnumSet.of(BTraceTask.State.INSTRUMENTING, BTraceTask.State.ACCEPTED).contains(btrace.getState())) {
btrace.setState(BTraceTask.State.RUNNING);
result.set(true);
clientMap.put(btrace, client);
latch.countDown();
}
break;
}
case Command.EXIT: {
btrace.setState(BTraceTask.State.FINISHED);
latch.countDown();
stop(btrace);
break;
}
case Command.RETRANSFORMATION_START: {
int numClasses = ((RetransformationStartNotification)cmd).getNumClasses();
btrace.setInstrClasses(numClasses);
btrace.setState(BTraceTask.State.INSTRUMENTING);
break;
}
case Command.ERROR: {
((ErrorCommand)cmd).getCause().printStackTrace(outputProvider.getStdErr(btrace));
btrace.setState(BTraceTask.State.FAILED);
latch.countDown();
stop(btrace);
break;
}
}
btrace.dispatchCommand(cmd);
}
});
} catch (Exception e) {
LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
result.set(false);
latch.countDown();
}
}
});
latch.await();
} catch (InterruptedException ex) {
LOGGER.log(Level.WARNING, null, ex);
}
return result.get();
}
示例9: dispatchCommand
import com.sun.btrace.comm.ErrorCommand; //导入依赖的package包/类
void dispatchCommand(final Command cmd) {
final Set<MessageDispatcher> dispatchingSet = new HashSet<BTraceTask.MessageDispatcher>();
synchronized(messageDispatchers) {
dispatchingSet.addAll(messageDispatchers);
}
dispatcher.submit(new Runnable() {
@Override
public void run() {
for(MessageDispatcher listener : dispatchingSet) {
switch (cmd.getType()) {
case Command.MESSAGE: {
listener.onPrintMessage(((MessageCommand)cmd).getMessage());
break;
}
case Command.RETRANSFORM_CLASS: {
listener.onClassInstrumented(((RetransformClassNotification)cmd).getClassName());
break;
}
case Command.NUMBER: {
NumberDataCommand ndc = (NumberDataCommand)cmd;
listener.onNumberMessage(ndc.getName(), ndc.getValue());
break;
}
case Command.NUMBER_MAP: {
NumberMapDataCommand nmdc = (NumberMapDataCommand)cmd;
listener.onNumberMap(nmdc.getName(), nmdc.getData());
break;
}
case Command.STRING_MAP: {
StringMapDataCommand smdc = (StringMapDataCommand)cmd;
listener.onStringMap(smdc.getName(), smdc.getData());
break;
}
case Command.GRID_DATA: {
GridDataCommand gdc = (GridDataCommand)cmd;
listener.onGrid(gdc.getName(), gdc.getData());
break;
}
case Command.ERROR: {
ErrorCommand ec = (ErrorCommand)cmd;
listener.onError(ec.getCause());
break;
}
}
}
}
});
}