5.12. JCoMod Wrapper-Beispiel für CIB job: JCibjobjob zur konvertierung eines RTFs zu einer PDF-Ausgabe
package example;
import java.io.File;
import com.cib.comod.jobs.IComodJob;
import com.cib.comod.jobs.JCibJobJob;
import com.cib.comod.jobs.JComodJob;
public class JCoMod {
private static final String s_LICENSECOMPANY = "XXX GmbH";
private static final String s_LICENSEKEY = "XXXX-XXXX-XXXXXXXX";
public static void main(String[] args){
JCoMod test = new JCoMod();
JComodJob j_Job = test.loadJob();
test.executeJob(j_Job);
}
public JComodJob loadJob(){
System.out.println("----------Module - Initialisierung----------");
JComodJob t_Job = new JCibJobJob();
t_Job.initialize();
if (!t_Job.isInitialized()){
System.out.println("Fehler beim Initialisieren des JCibJobJob");
t_Job.dispose(); // Resourcen d. Jobs freigeben
} else {
System.out.println("JCibJobJob initialisiert");
String version = (String) t_Job.getProperty(JComodJob.PROPERTY_VERSIONSTRING);
System.out.println("CIB job version: " + version);
}
return t_Job;
}
public void executeJob(JComodJob t_Job){
try{
t_Job.setProperty(JCibJobJob.PROPERTY_LICENSECOMPANY, s_LICENSECOMPANY);
t_Job.setProperty(JCibJobJob.PROPERTY_LICENSEKEY, s_LICENSEKEY);
if (new File("./input/input.xml").exists())
System.out.println("Input File Exists");
t_Job.setProperty(JCibJobJob.PROPERTY_INPUTFILENAME,"./input/input.xml");
t_Job.setProperty(JCibJobJob.PROPERTY_OUTPUTFILENAME,"./output/output.xml");
t_Job.execute();
//Fehlerbehandlung
int t_Error = ((Integer) t_Job.getProperty(IComodJob.PROPERTY_ERROR)).intValue();
if (t_Error != 0){
// Fehler beim Ausführen des Jobs
String t_Errortext = (String) t_Job.getProperty(IComodJob.PROPERTY_ERRORTEXT);
System.err.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext);
} else {
System.out.println("Job-Ausgabe richtig generiert");
}
} finally {
t_Job.terminate();
}
}
}