use of org.talend.designer.codegen.config.TalendJetEmitter in project tdi-studio-se by Talend.
the class CodeGeneratorEmittersPoolFactory method initializeEmittersPool.
/**
* real pool initialization.
*
* @param monitorWrap
*
* @return
* @throws JETException
*/
private static void initializeEmittersPool(List<JetBean> components, ECodeLanguage codeLanguage, IProgressMonitor monitorWrap) {
IProgressMonitor monitor = new NullProgressMonitor();
IProgressMonitor sub = new SubProgressMonitor(monitor, 1);
int monitorBuffer = 0;
HashMap<String, String> globalClasspath = new HashMap<String, String>();
for (JetBean jetBean : components) {
globalClasspath.putAll(jetBean.getClassPath());
// compute the CRC
jetBean.setCrc(extractTemplateHashCode(jetBean));
}
emitterPool = new HashMap<JetBean, JETEmitter>();
List<JetBean> alreadyCompiledEmitters = new ArrayList<JetBean>();
// try {
TalendJetEmitter dummyEmitter = null;
try {
dummyEmitter = new TalendJetEmitter(null, null, sub, globalClasspath, !ComponentCompilations.getMarkers());
} catch (JETException e) {
//$NON-NLS-1$
log.error(Messages.getString("CodeGeneratorEmittersPoolFactory.jetEmitterInitialException") + e.getMessage(), e);
}
boolean isSkeletonChanged = JetSkeletonManager.updateSkeletonPersistenceData();
if (!isSkeletonChanged) {
try {
alreadyCompiledEmitters = loadEmfPersistentData(EmfEmittersPersistenceFactory.getInstance(codeLanguage).loadEmittersPool(), components, monitorWrap);
for (JetBean jetBean : alreadyCompiledEmitters) {
TalendJetEmitter emitter = new TalendJetEmitter(jetBean, dummyEmitter.getTalendEclipseHelper());
emitterPool.put(jetBean, emitter);
monitorBuffer++;
if (monitorBuffer % 100 == 0) {
monitorWrap.worked(100);
monitorBuffer = 0;
}
}
} catch (BusinessException e) {
// error already loggued
emitterPool = new HashMap<JetBean, JETEmitter>();
}
} else {
ComponentCompilations.deleteMarkers();
}
synchronizedComponent(components, sub, alreadyCompiledEmitters, dummyEmitter, monitorBuffer, monitorWrap);
monitorWrap.worked(monitorBuffer);
try {
EmfEmittersPersistenceFactory.getInstance(codeLanguage).saveEmittersPool(extractEmfPersistenData(alreadyCompiledEmitters));
} catch (BusinessException e) {
//$NON-NLS-1$
log.error(Messages.getString("CodeGeneratorEmittersPoolFactory.PersitentData.Error") + e.getMessage(), e);
}
}
use of org.talend.designer.codegen.config.TalendJetEmitter in project tdi-studio-se by Talend.
the class CodeGeneratorEmittersPoolFactory method synchronizedComponent.
private static void synchronizedComponent(List<JetBean> components, IProgressMonitor sub, List<JetBean> alreadyCompiledEmitters, TalendJetEmitter dummyEmitter, int monitorBuffer, IProgressMonitor monitorWrap) {
for (JetBean jetBean : components) {
if (!emitterPool.containsKey(jetBean)) {
ComponentCompilations.deleteMarkers();
// System.out.println("The new file is not in JetPersistence* cache:" + getFullTemplatePath(jetBean));
TalendJetEmitter emitter = new TalendJetEmitter(jetBean, dummyEmitter.getTalendEclipseHelper());
// wzhang modified to fix bug 11439
if (monitorWrap.isCanceled()) {
if (!CommonUIPlugin.isFullyHeadless()) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), //$NON-NLS-1$
Messages.getString("CodeGeneratorEmittersPoolFactory.operationCanceled"), //$NON-NLS-1$
Messages.getString("CodeGeneratorEmittersPoolFactory.dialogContent"));
}
});
}
return;
}
// 10901: Component synchronization fails
try {
emitter.initialize(sub);
} catch (JETException e) {
//$NON-NLS-1$
log.error(//$NON-NLS-1$
Messages.getString("CodeGeneratorEmittersPoolFactory.jetEmitterInitialException") + e.getMessage(), e);
continue;
}
if (emitter.isClassAvailable()) {
alreadyCompiledEmitters.add(jetBean);
} else {
jetFilesCompileFail.add(jetBean);
}
emitterPool.put(jetBean, emitter);
monitorBuffer++;
if (monitorBuffer % 100 == 0) {
monitorWrap.worked(100);
monitorBuffer = 0;
}
}
}
}
Aggregations