use of org.talend.designer.codegen.config.LightJetBean in project tdi-studio-se by Talend.
the class EmfEmittersPersistence method loadEmittersPool.
/**
* DOC mhirt Comment method "loadEmittersPool".
*
* @return
* @throws IOException
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
public List<LightJetBean> loadEmittersPool() {
List<LightJetBean> emittersToReturn = new ArrayList<LightJetBean>();
byte[] poolAsBytes = null;
try {
poolAsBytes = loadEmfPoolFactory(persistantFile);
} catch (IOException e) {
//$NON-NLS-1$
log.info(Messages.getString("EmfEmittersPersistence.CodeGen.DataMissing"));
// Nothing to do if persistent file not found
return emittersToReturn;
}
if (poolAsBytes != null) {
ByteArrayInputStream stream = new ByteArrayInputStream(poolAsBytes);
if (stream.available() > 0) {
try {
ObjectInputStream oin = new ObjectInputStream(stream);
emittersToReturn = (List<LightJetBean>) oin.readObject();
oin.close();
return emittersToReturn;
} catch (IOException e) {
log.error(e.getMessage(), e);
} catch (ClassNotFoundException e) {
log.error(e.getMessage(), e);
}
}
}
return new ArrayList<LightJetBean>();
}
use of org.talend.designer.codegen.config.LightJetBean in project tdi-studio-se by Talend.
the class CodeGeneratorEmittersPoolFactory method extractEmfPersistenData.
/**
* DOC mhirt Comment method "extractEmfPersistenData".
*
* @param alreadyCompiledEmitters
* @return
*/
private static List<LightJetBean> extractEmfPersistenData(List<JetBean> alreadyCompiledEmitters) {
List<LightJetBean> toReturn = new ArrayList<LightJetBean>();
for (JetBean unit : alreadyCompiledEmitters) {
// long unitCRC = extractTemplateHashCode(unit);
long unitCRC = unit.getCrc();
toReturn.add(new LightJetBean(unit.getTemplateRelativeUri(), unit.getClassName(), unit.getMethodName(), unit.getVersion(), unit.getLanguage(), unitCRC));
}
return toReturn;
}
use of org.talend.designer.codegen.config.LightJetBean in project tdi-studio-se by Talend.
the class CodeGeneratorEmittersPoolFactory method loadEmfPersistentData.
private static List<JetBean> loadEmfPersistentData(List<LightJetBean> datas, List<JetBean> completeJetBeanList, IProgressMonitor monitorWrap) throws BusinessException {
List<JetBean> toReturn = new ArrayList<JetBean>();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
//$NON-NLS-1$
IProject project = workspace.getRoot().getProject(".JETEmitters");
URL url = null;
try {
IFile file = project.getFile(Path.fromOSString("runtime"));
url = file.getLocationURI().toURL();
int lightBeanIndex = 0;
LightJetBean lightBean = null;
LightJetBean myLightJetBean = null;
//$NON-NLS-1$
String unitTemplateFullURI = "";
long unitTemplateHashCode = 0;
HashMap<String, LightJetBean> mapOnName = new HashMap<String, LightJetBean>();
boolean forceMethodLoad = ComponentCompilations.getMarkers();
if (forceMethodLoad) {
// init specific map based on component name : mapOnName
for (LightJetBean ljb : datas) {
//$NON-NLS-1$
mapOnName.put(ljb.getTemplateRelativeUri().substring(ljb.getTemplateRelativeUri().lastIndexOf("/")), ljb);
}
}
int monitorBuffer = 0;
for (JetBean unit : completeJetBeanList) {
monitorBuffer++;
if (monitorBuffer % 200 == 0) {
monitorWrap.worked(200);
monitorBuffer = 0;
}
unitTemplateFullURI = unit.getTemplateRelativeUri();
unitTemplateHashCode = unit.getCrc();
myLightJetBean = new LightJetBean(unitTemplateFullURI, unit.getVersion(), unitTemplateHashCode);
if (((lightBeanIndex = datas.indexOf(myLightJetBean)) > -1) || forceMethodLoad) {
if (!forceMethodLoad) {
lightBean = datas.get(lightBeanIndex);
} else {
lightBean = mapOnName.get(myLightJetBean.getTemplateRelativeUri().substring(//$NON-NLS-1$
myLightJetBean.getTemplateRelativeUri().lastIndexOf("/")));
}
if (lightBean != null && lightBean.getCrc() == unit.getCrc()) {
unit.setClassName(lightBean.getClassName());
unit.setMethodName(lightBean.getMethodName());
toReturn.add(unit);
}
}
}
monitorWrap.worked(monitorBuffer);
} catch (MalformedURLException e) {
//$NON-NLS-1$
log.error(Messages.getString("CodeGeneratorEmittersPoolFactory.JETEmitters.NoPresent"));
throw new BusinessException(e);
}
return toReturn;
}
Aggregations