MobilityData / gtfs-realtime-validator

Java-based tool that validates General Transit Feed Specification (GTFS)-realtime feeds
Other
41 stars 10 forks source link

Allow loading rules from an external library at runtime #53

Open isabelle-dr opened 2 years ago

isabelle-dr commented 2 years ago

Issue by barbeau Oct 26, 2017 Originally opened as https://github.com/CUTR-at-USF/gtfs-realtime-validator/issues/300


Summary:

I'd like to allow developers to load their own custom rules into the validator at runtime.

User story is as follow:

Sean works at a transit agency and is responsible for quality control over the AVL system, including the GTFS-relatime feed. The AVL vendor keeps having problems with one specific data element that is frequently incorrect, but the gtfs-realtime-validator doesn't have a rule that covers this. Sean would like to write his own code for a rule that could be plugged into the gtfs-realtime-validator so that the validator will check for this custom rule and report occurrences of this error or warning just like it would report rules that are built into the validator. Sean doesn't want to fork the entire gtfs-realtime-validator project, and would prefer to just compile a simple JAR file that contains the rule that could somehow be plugged into the already-built gtfs-realtime-validator release JARs.

From a technical perspective this means we'd need to discover a JAR file on the classpath and load any classes that implement the FeedEntityValidator interface, and run each feed message through these custom Validators in addition to our *Validator classes. A good place to start: https://stackoverflow.com/questions/435890/find-java-classes-implementing-an-interface

For security purposes this feature should require an explicit command line option to load external validators, so that the code doesn't just load and execute any JAR that's dropped into the same directory.

Steps to reproduce:

Try to add your own rules to an already build gtfs-realtime-validator release JAR

Expected behavior:

Give me some way to add custom rules at runtime

Observed behavior:

You can't add rules at runtime cc @kurtraschke