Search in sources :

Example 1 with JarBuilder

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JarBuilder in project tdi-studio-se by Talend.

the class JobJavaScriptOSGIForESBManager method addRoutinesResources.

@Override
protected void addRoutinesResources(ExportFileResource[] processes, ExportFileResource libResource) {
    File jarFile = new File(getTmpFolder() + File.separatorChar + JavaUtils.ROUTINES_JAR);
    // make a jar file of system routine classes
    File classRootFileLocation = getClassRootFileLocation();
    if (classRootFileLocation == null) {
        return;
    }
    try {
        JarBuilder jarbuilder = new JarBuilder(classRootFileLocation, jarFile);
        jarbuilder.setIncludeDir(getRoutinesPaths());
        Collection<File> includeRoutines = new ArrayList<File>(getRoutineDependince(processes, true, USER_ROUTINES_PATH));
        includeRoutines.addAll(getRoutineDependince(processes, false, getIncludeRoutinesPath()));
        jarbuilder.setIncludeRoutines(includeRoutines);
        jarbuilder.buildJar();
        libResource.addResources(Collections.singletonList(jarFile.toURI().toURL()));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) JarBuilder(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JarBuilder) IOException(java.io.IOException) File(java.io.File)

Example 2 with JarBuilder

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JarBuilder in project tbd-studio-se by Talend.

the class HadoopConfsUtils method buildAndDeployConfsJar.

public static void buildAndDeployConfsJar(HadoopClusterConnectionItem connectionItem, String contextGroup, String dir, String jarName) {
    try {
        File parentFile = new File(getConfsJarTempFolder());
        File jarFile = new File(parentFile, jarName);
        File rootDir = new File(dir);
        JarBuilder jarBuilder = new JarBuilder(rootDir, jarFile);
        jarBuilder.setIncludeDir(null);
        jarBuilder.setExcludeDir(null);
        jarBuilder.buildJar();
        byte[] confFileByteArray = FileUtils.readFileToByteArray(jarFile);
        HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
        if (connection.isContextMode()) {
            if (contextGroup == null) {
                // $NON-NLS-1$
                throw new Exception("contextGroup cannot be null in context mode!");
            }
            connection.getConfFiles().put(contextGroup, confFileByteArray);
        } else {
            connection.setConfFile(confFileByteArray);
        }
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
            ILibrariesService service = GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
            if (service != null) {
                // Only deploy a new jar, no need to reset all
                service.deployLibrary(jarFile.toURI().toURL());
                addToDeployedCache(connectionItem, jarName);
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : ILibrariesService(org.talend.core.model.general.ILibrariesService) JarBuilder(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JarBuilder) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) File(java.io.File) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 JarBuilder (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JarBuilder)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 ILibrariesService (org.talend.core.model.general.ILibrariesService)1 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)1