use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getUserRoutine.
/**
* Gets user routine.
*
* @param needUserRoutine
* @return
*/
protected List<URL> getUserRoutine(ExportFileResource[] process) {
try {
boolean useBeans = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (service.isInstanceofCamel(process[0].getItem())) {
useBeans = true;
}
}
String includePath;
String jar;
if (useBeans) {
includePath = USER_BEANS_PATH;
jar = USERBEANS_JAR;
} else {
includePath = USER_ROUTINES_PATH;
jar = USERROUTINE_JAR;
}
List<URL> urlList = new ArrayList<URL>();
File jarFile = new File(getTmpFolder() + File.separatorChar + jar);
// make a jar file of user routine or bean classes
File classRootFileLocation = getClassRootFileLocation();
if (classRootFileLocation == null) {
return Collections.emptyList();
}
JarBuilder jarbuilder = new JarBuilder(classRootFileLocation, jarFile);
jarbuilder.setIncludeDir(Collections.singleton(includePath));
jarbuilder.setIncludeRoutines(getRoutineDependince(process, false, includePath));
jarbuilder.setExcludeDir(// remove all
Arrays.asList(// remove all
SYSTEM_ROUTINES_PATH, // remove all
USER_ROUTINES_PATH, USER_BEANS_PATH, USER_PIGUDF_PATH));
jarbuilder.buildJar();
urlList.add(jarFile.toURI().toURL());
return urlList;
} catch (Exception e) {
ExceptionHandler.process(e);
return Collections.emptyList();
}
}
Aggregations