Custom Component Registration

14 views
Skip to first unread message

Alexander Schimpf

unread,
Jul 6, 2021, 3:23:07 PM7/6/21
to OpenMPF

Jeff,

After getting Hello World to register and run in Openmpf manager I started trying to implement my own code. I'm trying to build the docker component but the plugins-packages is not being created. I made sure everything is named correctly and after trying to debug it still wont appear. Are you able to take a look at it? 

Thanks,

-Alex

 

Alexander Schimpf

unread,
Jul 6, 2021, 3:24:00 PM7/6/21
to OpenMPF

Alexander Schimpf

unread,
Jul 6, 2021, 3:31:00 PM7/6/21
to OpenMPF
Im sorry, something is wrong when I try to send the file So I had to send them all individually.  I cant send the whole file because the size is to big.
PdqDetection (2).zip

Jeffrey Robble

unread,
Jul 7, 2021, 10:29:55 AM7/7/21
to OpenMPF
Hi Alex,

This is the structure of the zip you sent:

|-- New\ folder
|   |-- assemblyDescriptor.xml
|   |-- descriptor.json
|   |-- Dockerfile
|   |-- Makefile
|   `-- pom.xml


If you're writing a Java component, you need to have a directory structure that is similar to the one shown here. You need to create the structure yourself.

You're missing a "plugin-files" folder. That should contain a "descriptor" folder, and that should contain your "descriptor.json". Again, you need to create those folders yourself before you do the Docker build.

Also, you're missing a "src" folder, which should include your Java code.

The top-level directory should be the name of your component. Here I see "New folder".

We don't use a Makefile to build our Java components, so that file seems out of place. This is the Maven command that performs the build:

mvn package -Dmpf.assembly.format=dir

That uses "assemblyDescriptor.xml" and "pom.xml".

- Jeff

Alexander Schimpf

unread,
Jul 7, 2021, 1:05:56 PM7/7/21
to OpenMPF
Jeff,
I was able to get the component built successfully, when I go to register the file I get the beans error.

BeansError.PNG
In my  applicationContext.xml file, I have
       <bean id="component" class="org.mitre.mpf.pdqhashing.reg_test.run"/>  
I don't know exactly what the beans id/class is but looking at the sphinx speech detection component I guessed that the bean class is the first program that I want to run.                      The "org.mitre.mpf.pdqhahing.reg_test.run" is the path to my starting program called run. The run program is a shell script that calls other java files. 

Am I able to use shell scripts to call everything? and am I setting this up correctly?

Thanks
-Alex

Jeffrey Robble

unread,
Jul 7, 2021, 3:02:01 PM7/7/21
to OpenMPF
Looking at the applicationContext.xml for the Sphinx component we have:

    <bean id="component"
          class="org.mitre.mpf.detection.sphinx.speech.SphinxSpeechDetectionComponent"/>

         
The value of "class" is set to the fully-qualified name of the SphinxSpeechDetectionComponent Java class, which is this file. It can't be set to a shell script.

That class must extend from MPFDetectionComponentBase. As you can see here our Java component executor will attempt to get an instance of your component class using the "component" bean:

    private static MPFDetectionComponentBase initializeComponent(AbstractApplicationContext context) {
        MPFDetectionComponentBase component = context.getBean("component", MPFDetectionComponentBase.class);
        LOG.info("Found component class {}", component.getClass().getName());

       
The Java component executor will later make calls to your component class to executes jobs. It will call the methods declared here.

In general, think of your component as a library that the OpenMPF Java component executor uses. You don't need a main() or start the process yourself. That's all done for you. Most of your code should be executed inside of the getDetections() methods.
       
- Jeff
Reply all
Reply to author
Forward
0 new messages