How can I write my own plugins/modules?
Put into the installation directory, subdirectory lib, a JAR named
UserServices.jar with
one ore more implementations of org.jphototagger.api.plugin.Plugin or
org.jphototagger.api.modules.Module and publish them through the
Java
Service Provider Interface (SPI).
To avoid compiler errors, the minimum JAR file in the class path you need,
is API.jar. If you do not want manually create the
META-INF/services folder and stay relaxed during
refactorings, you should include org-openide-util-lookup.jar
and use the @ServiceProvider annotations. If you want
receive messages, include eventbus.jar. To access domain objects,
such as stored metadata info, include Domain.jar. Some other common used
library is jsl.jar. All JARs located in the lib sub
directory of JPhotoTagger's installation directory.
The best way to find reference implementations, is browsing the source code. Even better is, clone it and open in in the NetBeans IDE. The clone contains all source code and libraries.
Minimum Example for a user defined Module (Displays a message as soon as the module is loaded):
package org.myorg.jphototaggerplugin;
import javax.swing.JOptionPane;
import org.openide.util.lookup.ServiceProvider;
import org.jphototagger.api.modules.Module;
@ServiceProvider(service = Module.class)
public final class MyModule implements Module {
@Override
public void init() {
JOptionPane.showMessageDialog(null, "My module");
}
@Override
public void remove() {
}
}
Within the UserServices.jar you can implement as many Plugins/Modules as you need.
Author: Elmar
Write e-Mail
Status of this document: 2011-10-10