/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2022 Huawei. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.File;
import java.io.FilenameFilter;
+import java.io.InputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
}
}
- private static boolean copyProcessorClassFile(File pathClassFile, File dirBuild) {
+ private static boolean copyProcessorClassFile(String classResourceName, File dirBuild) {
File dirSandbox = new File(dirBuild, "org/onap/dcae/genprocessor");
if (dirSandbox.exists() || dirSandbox.mkdir()) {
- try {
- File dest = new File(dirSandbox, pathClassFile.getName());
- Files.copy(pathClassFile.toPath(), dest.toPath());
+ try (InputStream asStream = App.class.getResourceAsStream(classResourceName)) {
+ File dest = new File(dirSandbox, classResourceName);
+ Files.copy(asStream, dest.toPath());
return true;
} catch (FileAlreadyExistsException e) {
// Do nothing, class file already exists
return true;
}
}
- } catch (InterruptedException e) {
- throw new RuntimeException("Error while creating jar", e);
- } catch (IOException e) {
+ } catch (InterruptedException | IOException e) {
throw new RuntimeException("Error while creating jar", e);
}
return false;
}
- public static void main(String[] args) throws InterruptedException {
+ public static void main(String[] args) throws InterruptedException, URISyntaxException {
if (args.length == 0) {
args = new String[] { "gen" };
String sleepstr = System.getenv("GENPROC_SLEEP_SEC");
long sleepdur = (sleepstr != null)? 1000 * Long.parseLong(sleepstr): 0;
do {
- try {
- main2(args);
- } catch (Exception e) {
- LOG.error(e.toString(), e);
- }
+ try {
+ main2(args);
+ } catch (Exception e) {
+ LOG.error(e.toString(), e);
+ }
Thread.sleep(sleepdur);
} while (sleepdur > 0);
return;
}
- public static void main2(String[] args) {
+ public static void main2(String[] args) throws URISyntaxException {
String argsStr = String.join(", ", args);
if (argsStr.contains("-h")) {
LOG.info("Here are the possible args:");
// Config from env variables
File dirWorking = new File(System.getenv("GENPROC_WORKING_DIR"));
String hostOnboardingAPI = System.getenv("GENPROC_ONBOARDING_API_HOST");
- File processorClassFile = new File(System.getenv("GENPROC_PROCESSOR_CLASSFILE_PATH"));
String urlToJarIndex = System.getenv("GENPROC_JAR_INDEX_URL");
String[] paramsToPrint = new String[] {
writeManifestThing(dirBuild, generateManifestMF(comp.compSpec), "META-INF", "MANIFEST.MF");
writeManifestThing(dirBuild, Arrays.asList(createClassName(comp.compSpec)), "META-INF/services",
"org.apache.nifi.processor.Processor");
- copyProcessorClassFile(processorClassFile, dirBuild);
+ copyProcessorClassFile("DCAEProcessor.class", dirBuild);
packageJar(dirWorking, dirBuild, jarName);
}
}
}
}
}
+