/*
* Name: ExternalJavaController
* Authors: Richard Rodger
*
* Copyright (c) 2004 Richard Rodger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
// package
package org.jostraca.process;
// import
import org.jostraca.Property;
import org.jostraca.Template;
import org.jostraca.util.Standard;
import org.jostraca.util.PropertySet;
import org.jostraca.util.BasicWayPoint;
import org.jostraca.util.WayPointRecorder;
import org.jostraca.util.StandardException;
import java.util.List;
import java.io.File;
/** Processing class for external java <code>CodeWriter</code> execution.
*/
public class ExternalJavaController extends JavaController {
public ExternalJavaController() {
// do nothing
}
protected void processImpl( Template pTemplate ) {
Template template = pTemplate;
PropertySet tmps = template.getMergedPropertySet();
File codeWriterPath = template.getCodeWriterPath();
String codeWriterSource = template.getCodeWriterSource();
try {
String externalController = makeExternalController( tmps );
String externalControllerOptions = makeExternalControllerOptions( tmps );
String codeWriter = makeCodeWriter( tmps );
String codeWriterOptions = makeCodeWriterOptions( tmps, template );
String cmd
= externalController + Standard.SPACE
+ externalControllerOptions + Standard.SPACE
+ codeWriter + Standard.SPACE
+ codeWriterOptions
;
boolean successful = executeGeneratingCmd( cmd, template );
WayPointRecorder.add( BasicWayPoint.ExecutingCodeWriter.make( template.getCodeWriterPath().getAbsolutePath() ) );
}
catch( StandardException se ) {
throw se;
}
catch( Exception e ) {
// FIX: needs more info
throw new ProcessException( e );
}
}
protected void completeImpl( List pTemplateList ) {
// do nothing
}
protected String makeExternalControllerOptions( PropertySet pPropertySet ) {
String externalControllerOptions = pPropertySet.get( Property.main_ExternalControllerOptions );
if( !JavaUtil.hasClassPathArg( externalControllerOptions ) ) {
externalControllerOptions
= externalControllerOptions
+ JavaUtil.ARG_cp + Standard.SPACE
+ JavaUtil.makeClassPath( pPropertySet )
+ Standard.EMPTY
;
}
return externalControllerOptions;
}
}