Add genprocessor project
[dcaegen2/platform.git] / mod / genprocessor / README.md
1 # Genprocessor
2
3 This project is a tool to experiment with generating a Nifi Processor POJO from a DCAE component spec.
4
5 Environment variables needed to run the app:
6
7 For generating -
8
9 `GENPROC_WORKING_DIR` - Full file path to the directory where you will generate class files to and ultimately build the jar to distribute
10 `GENPROC_ONBOARDING_API_HOST` - Onboarding API host URL
11 `GENPROC_PROCESSOR_CLASSFILE_PATH` - Path to the DCAEProcessor class file
12
13 For loading -
14
15 `GENPROC_JAR_INDEX_URL` - URL to the index.json for DCAE processor jars
16
17 ## Build
18
19 NOTE: You need a specific version of the `nifi-api` jar that contains the class `BaseDCAEProcessor`.
20
21 Command to build and to copy dependencies into `target/dependency` directory:
22
23 ```
24 mvn clean package dependency:copy-dependencies
25 ```
26
27 ## Run - Generate jars
28
29 This will pull all component specs from onboarding API and for each component:
30
31 * A class file is generated for a new DCAEProcessor class
32 * Write metadata into META-INF directory
33 * Copy a copy of the DCAEProcessor class file
34 * Package up into a jar 
35
36 Command to run:
37
38 ```
39 java -cp "target/genprocessor-1.0.1.jar:target/dependency/*" org.onap.dcae.genprocessor.App gen
40 ```
41
42 ### More about what goes into META-INF
43
44 #### Processor manifest
45
46 Note the META-INF directory which contains:
47
48 ```
49 $ tree META-INF/
50 META-INF/
51 └── services
52     └── org.apache.nifi.processor.Processor
53 ```
54
55 If you don't have the above in your `GENPROC_TARGET_DIR`, then:
56
57 ```
58 $ mkdir -p META-INF/services
59 $ touch META-INF/services/org.apache.nifi.processor.Processor
60 ```
61
62 Open `META-INF/services/org.apache.nifi.processor.Processor` and write the full class name for each generated processor on a separate line.
63
64 #### MANIFEST.MF
65
66 Write the `MANIFEST.MF` in a file that's arbitrarily named (mymanifest for example).  The content should look like:
67
68 ```
69 $ cat mymanifest 
70 Manifest-Version: 1.0
71 Id: dcae-ves-collector
72 Version: 1.5.0
73 Group: org.onap.dcae
74 ```
75
76 ## Run - Load jars
77
78 This will load all jars listed on an index page and for each jar will do a class load and quick test.
79
80 Command to run:
81
82 ```
83 java -cp "target/genprocessor-1.0.1.jar:target/dependency/*" org.onap.dcae.genprocessor.App load
84 ```