|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.aspectj.tools.ajc.Main
public class Main
Programmatic and command-line interface to AspectJ compiler. The compiler is an ICommand obtained by reflection. Not thread-safe. By default, messages are printed as they are emitted; info messages go to the output stream, and warnings and errors go to the error stream.
Clients can handle all messages by registering a holder:
Main main = new Main(); IMessageHolder holder = new MessageHandler(); main.setHolder(holder);Clients can get control after each command completes by installing a Runnable:
main.setCompletionRunner(new Runnable() {..});
Nested Class Summary | |
---|---|
static class |
Main.CommandController
controller for repeatable command delays until input or file changed or removed |
static class |
Main.LogModeMessagePrinter
|
static class |
Main.MessagePrinter
interceptor IMessageHandler to print as we go. |
Field Summary | |
---|---|
protected ICommand |
command
|
protected java.lang.String |
commandName
ReflectionFactory identifier for command (compiler) |
protected Main.CommandController |
controller
control iteration/continuation for command (compiler) |
protected MessageHandler |
ourHandler
internally-set message sink |
static java.lang.String |
THROWN_PREFIX
Header used when rendering exceptions for users |
Constructor Summary | |
---|---|
Main()
|
Method Summary | |
---|---|
static int |
bareMain(java.lang.String[] args,
boolean useSystemExit,
java.util.List fails,
java.util.List errors,
java.util.List warnings,
java.util.List infos)
Convenience method to run ajc and collect String lists of messages. |
protected static void |
fail(IMessageHandler handler,
java.lang.String message,
java.lang.Throwable thrown)
convenience API to make fail messages (without MessageUtils's fail prefix) |
IMessageHolder |
getHolder()
|
MessageHandler |
getMessageHandler()
|
static void |
main(java.lang.String[] args)
|
protected void |
outMessage(java.lang.String message)
Messages to the user |
void |
quit()
call this to stop after the next iteration of incremental compile |
static java.lang.String |
renderExceptionForUser(java.lang.Throwable thrown)
|
protected boolean |
report(boolean pass,
IMessageHolder holder)
Report results from a (possibly-incremental) compile run. |
void |
run(java.lang.String[] args,
IMessageHolder holder)
Run without using System.exit(..), putting all messages in holder: ERROR: compiler error WARNING: compiler warning FAIL: command error (bad arguments, exception thrown) This handles incremental behavior: If args include "-incremental", repeat for every input char until 'q' is entered. |
void |
runMain(java.lang.String[] args,
boolean useSystemExit)
Run without throwing exceptions but optionally using System.exit(..). |
void |
setCommand(ICommand command)
|
void |
setCompletionRunner(java.lang.Runnable runner)
Install a Runnable to be invoked synchronously after each compile completes. |
void |
setHolder(IMessageHolder holder)
Set holder to be passed all messages. |
protected void |
systemExit(IMessageHolder messages)
Call System.exit(int) with values derived from the number of failures/aborts or errors in messages. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String THROWN_PREFIX
protected Main.CommandController controller
protected java.lang.String commandName
protected ICommand command
protected final MessageHandler ourHandler
Constructor Detail |
---|
public Main()
Method Detail |
---|
public static void main(java.lang.String[] args) throws java.io.IOException
args
- the String[] of command-line arguments
java.io.IOException
public static int bareMain(java.lang.String[] args, boolean useSystemExit, java.util.List fails, java.util.List errors, java.util.List warnings, java.util.List infos)
args
- the String[] args to pass to the compileruseSystemExit
- if true and errors, return System.exit(errs)fails
- the List sink, if any, for String failure (or worse) messageserrors
- the List sink, if any, for String error messageswarnings
- the List sink, if any, for String warning messagesinfo
- the List sink, if any, for String info messages
any
- unchecked exceptions the compiler doespublic static java.lang.String renderExceptionForUser(java.lang.Throwable thrown)
java.lang.NullPointerException
- if thrown is nullpublic MessageHandler getMessageHandler()
public void setCommand(ICommand command)
public void runMain(java.lang.String[] args, boolean useSystemExit)
args
- the String[] command line for the compileruseSystemExit
- if true, use System.exit(int) to complete unless one of the args is -noExit. and signal result (0 no
exceptions/error, <0 exceptions, >0 compiler errors).public void run(java.lang.String[] args, IMessageHolder holder)
args
- the String[] command line for the compilerholder
- the MessageHandler sink for messages.public void quit()
public void setHolder(IMessageHolder holder)
holder
- the IMessageHolder sink for all messages (use null to restore default behavior)public IMessageHolder getHolder()
public void setCompletionRunner(java.lang.Runnable runner)
runner
- the Runnable to invoke - null to disableprotected void systemExit(IMessageHolder messages)
messages
- the IMessageHolder to interrogate.messages
- protected void outMessage(java.lang.String message)
protected boolean report(boolean pass, IMessageHolder holder)
pass
- true result of the commandholder
- IMessageHolder with messages from the command
reportCommandResults(IMessageHolder)
protected static void fail(IMessageHandler handler, java.lang.String message, java.lang.Throwable thrown)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |