// do nothing
}
protected void processImpl( Template pTemplate ) {
Template template = pTemplate;
PropertySet tmps = template.getMergedPropertySet();
boolean successful = false;
PrintStream sysOut = null;
PrintStream sysErr = null;
RecordingUserMessageHandler rumh = new RecordingUserMessageHandler();
try {
String cw = makeCodeWriter( tmps );
String cwo = makeCodeWriterOptions( tmps, template );
String[] args = ArgUtil.splitQuoted( cwo );
String jcwp = getCodeWriterPath( tmps );
jcwp = TextUtil.replace( jcwp, ".java", ".class" );
File jcwpf = new File( jcwp );
String cwp = jcwpf.getAbsolutePath();
iUserMessageHandler.debug( UserText.get(UserText.TXT_generating), "class-file:"+cwp+Standard.SPACE+cwo );
// NOTE: has to be _generate to prevent exit
Class cwClass = ClassUtil.makeClassFromFile( cwp );
Object cwInstance = cwClass.newInstance();
Method generateMethod = cwClass.getMethod( "_generate", new Class[] { (new String[] {}).getClass(), Boolean.TYPE } );
// DO NOT use CommandLineUserMessageHandler here - causes infinite recursion
MessageHandlerOutputStream out = new MessageHandlerOutputStream( UserMessageHandler.INFO, rumh );
MessageHandlerOutputStream err = new MessageHandlerOutputStream( UserMessageHandler.ERROR, rumh );
// space out dots to avoid accidental replace on System DOT out search
sysOut = System . out;
sysErr = System . err;
// set context if not null
Object context = template.getContext();
if( null != context ) {
Method setContextMethod = cwClass.getMethod( "_setContext", new Class[] { Object.class } );
setContextMethod.invoke( cwInstance, new Object[] { context } );
}
boolean throwWriterExceptions = tmps.isYes( Property.main_CodeWriter_throwExceptions );
// DO NOT put System.out in MessageHandler as this will case infinite loop
System.setOut( new PrintStream( out ) );
System.setErr( new PrintStream( err ) );
Object result = generateMethod.invoke( cwInstance, new Object[] { args, new Boolean(throwWriterExceptions) } );
WayPointRecorder.add( BasicWayPoint.ExecutingCodeWriter.make( template.getCodeWriterPath().getAbsolutePath() ) );
if( result instanceof Integer ) {
successful = ( 0 == ((Integer)result).intValue() );
}
else {
successful = true;
}
template.setResult( result );
}
catch( InvocationTargetException ite ) {
if( null != sysOut ) {
System.setOut( sysOut );