@@ -0,0 +1,1843 @@
+/*%0A * #%25L%0A * ImageJ interactive debugging tutorials.%0A * %25%25%0A * Copyright (C) 2009 - 2015 Board of Regents of the University of Wisconsin-Madison%0A * %25%25%0A * To the extent possible under law, the ImageJ developers have waived%0A * all copyright and related or neighboring rights to this tutorial code.%0A * %0A * See the CC0 1.0 Universal license for details:%0A * http://creativecommons.org/publicdomain/zero/1.0/%0A * #L%25%0A */%0A%0Apackage net.imagej.trouble.visible;%0A%0Aimport org.scijava.Context;%0Aimport org.scijava.command.Command;%0Aimport org.scijava.console.ConsoleService;%0Aimport org.scijava.console.DefaultConsoleService;%0Aimport org.scijava.plugin.Parameter;%0Aimport org.scijava.plugin.Plugin;%0A%0A/**%0A * Exercise 4: Remote debugging when a plugin behaves differently in new%0A * environments.%0A *%0A * @author Mark Hiner %3Chinerm@gmail.com%3E%0A */%0A@Plugin(type = Command.class,%0A%09menuPath = %22Plugins%3ETroubleshooting%3EE4 - Print ConsoleService%22)%0Apublic class E4RemoteResearch implements Command %7B%0A%0A%09@Parameter%0A%09private ConsoleService consoleService;%0A%0A%09@Override%0A%09public void run() %7B%0A%09%09DefaultConsoleService dcs;%0A%0A%09%09try %7B%0A%09%09%09// Print the class of our console service!%0A%09%09%09// If something goes wrong.. this is a good place to set a breakpoint,%0A%09%09%09// since we're performing a potentially risky conversion.%0A%09%09%09dcs = (DefaultConsoleService) consoleService;%0A%09%09%09System.out.println(%22I found our console service! Look: %22 + dcs%0A%09%09%09%09.getClass());%0A%09%09%7D%0A%09%09catch (final Exception e) %7B%0A%09%09%09throw new RuntimeException(%0A%09%09%09%09%22Oh noes! Our console service is full of lies and deceit! :(%22);%0A%09%09%7D%0A%09%7D%0A%0A%09/*%0A%09 * Helper method to create a minimal context and test this command%0A%09 */%0A%09public static void main(final String... args) throws Exception %7B%0A%09%09final Context c = new Context(DefaultConsoleService.class);%0A%09%09final E4RemoteResearch cmd = new E4RemoteResearch();%0A%09%09c.inject(cmd);%0A%0A%09%09cmd.run();%0A%09%7D%0A%7D%0A

Create Exercise 4