Removing not needed jar by reflection

This commit is contained in:
Spyros Zoupanos 2020-09-07 20:54:47 +03:00
parent 719f9e3cd9
commit 81102dd791
1 changed files with 0 additions and 46 deletions

View File

@ -1,11 +1,6 @@
package eu.dnetlib.oa.graph.usagestats.export;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Properties;
import org.apache.log4j.Logger;
@ -25,54 +20,13 @@ public class UsageStatsExporter {
static String irusUKReportPath = "/user/spyros/logs/usage_stats_logs3/irusUKReports";
static String sarcsReportPath = "/user/spyros/logs/usage_stats_logs3/sarcReports";
private static final Class[] parameters = new Class[] {
URL.class
};
public UsageStatsExporter(Properties properties) {
this.properties = properties;
}
public static void addFile(String s) throws IOException {
File f = new File(s);
addFile(f);
}// end method
public static void addFile(File f) throws IOException {
addURL(f.toURL());
}// end method
public static void addURL(URL u) throws IOException {
URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class sysclass = URLClassLoader.class;
try {
Method method = sysclass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(sysloader, new Object[] {
u
});
} catch (Throwable t) {
t.printStackTrace();
throw new IOException("Error, could not add URL to system classloader");
} // end try catch
}// end method
// public void export() throws Exception {
public void export() throws Exception {
// read workdflow parameters
// String matomoAuthToken = properties.getProperty("matomo_AuthToken");
// String matomoBaseURL = properties.getProperty("matomo_BaseUrl");
// String repoLogPath = properties.getProperty("repo_LogPath");
// String portalLogPath = properties.getProperty("portal_LogPath");
// String portalMatomoID = properties.getProperty("portal_MatomoID");
// String irusUKBaseURL = properties.getProperty("IRUS_UK_BaseUrl");
// addFile("/usr/share/cmf/common_jars/hive-hcatalog-core-1.1.0-cdh5.14.0.jar");
// connect to DB
System.out.println("====> Initialising DB properties");
ConnectDB.init(properties);