Skip to content

Writing Front-Ends

JEB front-end are also referred to as "JEB clients" (or "JEB third-party clients", to contrast with the "official UI desktop client").

JEB back-end API makes writing new clients (aka, front-ends) an easy task. A client can be:

  • An automated client (for testing, for an automation pipeline)
  • A command-line client
  • A graphical front-end (e.g., the official UI desktop client)
  • ...

Info

Not all JEB licenses allow the creation of third-party clients. Verify this by checking your license information in the About dialog box. It should show any-client. Typically, JEB Pro licenses allow the execution of third-party clients.

High-level Instructions#

Use the provided source code template (see below) as a base for your client. The basic steps any client should take are the following:

Refer to the our simplified architecture diagrams to better visualize how those components are connected to one another.

Source Template#

Full source code: Command-line client skeleton on GitHub

public class AutoClient {
    static final ILogger logger = GlobalLog.getLogger(AutoClient.class);
    static {
        GlobalLog.addDestinationStream(System.out);
    }

    // TODO: customize (should be replaced by the LicenseKey entry in your bin/jeb-client.cfg file)
    private static final String licenseKey = "...";

    // TODO: customize
    private static final String baseDir = "...";

    public static void main(String[] argv) throws Exception {
        if(argv.length <= 0) {
            return;
        }

        long t0 = System.currentTimeMillis();
        String location = argv[0];
        List<File> files = AutoUtil.retrieveFiles(location);
        test(files);
        logger.info("Done in %ds", (System.currentTimeMillis() - t0) / 1000);
    }

    /**
     * Initialize a core. Create a context within that core. Then, for each input artifact, a
     * project is created and the artifact is loaded within that project.
     */
    public static void test(List<File> files) throws Exception {
        // create or retrieve a core context (engines container)
        ICoreContext core = JebCoreService.getInstance(licenseKey);

        // create an engines context (project container)
        IFileDatabase projectdb = new JEB2FileDatabase(baseDir);
        IFileStore filestore = new SimpleFSFileStore(baseDir);
        BaseConfiguration cfg = new BaseConfiguration();

        // TODO: customize (alternative is to read your configuration from .cfg file)
        cfg.setProperty(".DevPluginClasspath", "...");

        // TODO: customize
        cfg.setProperty(".DevPluginClassnames", "...");

        IConfiguration config = new CommonsConfigurationWrapper(cfg);
        IDataProvider dataProvider = new DataProvider(null, projectdb, filestore, null, null, config);
        IEnginesContext engctx = core.createEnginesContext(dataProvider, null);

        int i = 0;
        for(File file: files) {
            i++;
            logger.info("Testing file %d/%d : %s ...", i, files.size(), file.getName());

            // create or load a project (artifact container)
            IRuntimeProject prj = engctx.loadProject("ProjectTest" + i);

            // process the artifact, get units
            ILiveArtifact art = prj.processArtifact(new Artifact(file.getName(), new FileInput(file)));

            // proceed with the units
            List<IUnit> units = art.getUnits();

            // TODO: CUSTOMIZE -- this is the important part
            // Basic tests go here
            // example:
            for(IUnit unit: units) {
                logger.info("Unit: %s", unit);
                //if(unit instanceof Xyz) {
                // ...
                //}
            }

            engctx.unloadProject(prj.getKey());
        }

        // close the engines
        JebCoreService.getInstance().closeEnginesContext(engctx);
    }
}