I'm trying to use PF4J in an existing codebase. I've tried to transfer all the necessary from the demo plugins and app to my existing maven project. I've compared the demo and my code, and I can't find anything that is different. And yet, when I build my plugin's .jar file, the generated extensions.idx has a comment in it saying that it was generate3d by PF4J, but is otherwise empty. There should be a reference there to my plugin's inner class, but there is not. In the demo plugins, there is.
I'm guessing that this is a problem with my Maven setup (one of my pom files), but I've looked and looked, and can't figure this out. Here's the Java file for my plugin:
package com.inlet.ifserver.plugin.reaper;
import com.inlet.plugin.InletFetchReaper;
import org.apache.commons.lang.StringUtils;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;
import org.pf4j.RuntimeMode;
/**
* @author Decebal Suiu
*/
public class ReaperAPlugin extends Plugin {
public ReaperAPlugin(PluginWrapper wrapper) {
super(wrapper);
}
@Override
public void start() {
System.out.println("WelcomePlugin.start()");
// for testing the development mode
if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) {
System.out.println(StringUtils.upperCase("WelcomePlugin"));
}
}
@Override
public void stop() {
System.out.println("WelcomePlugin.stop()");
}
@Extension
public static class ReaperA implements InletFetchReaper {
@Override
public void reap() {
System.out.println("ReaperA");
}
}
}
My guess is that my code is not being scanned to find the @Extension annotation. I don't know how that works.
I'm hoping others have hit this problem and know of something simple I've missed. Can anyone tell me why this is happening? If anyone can give me any insight into just how Maven is made to create the extensions.idx file in the .jar file it generates, that might lead me to an answer.
TIA for any help!
I figured this out. I'd defined the interface for my plugin like this:
package com.inlet.plugin;
public interface InletFetchReaper {
void reap();
}
but it should have been (and now is) this:
package com.inlet.plugin;
import org.pf4j.ExtensionPoint;
public interface InletFetchReaper extends ExtensionPoint {
void reap();
}
Figured it would be something simple.