public abstract class PluginFactory extends Object
Base class for plugin factories. To allow loading of plugins implementing a particular interface extend this class and define your own get- methods based on the ones defined by this class.
The class is abstract and it is not intended to be instantiated directly. The point is to give developers an option to hide the functional interface from the method arguments and customize the get- methods, for example with availability checks and error handling.
An example: You want to enable loading of plugins which implement
com.myproject.MyPlugin
interface. If the interface is already known
to the plugin manager
, a simple corresponding plugin
factory may look like:
package com.myproject; import java.util.List; import com.tplan.robot.plugin.*; public class MyPluginFactory extends PluginFactory { // Get a plugin by its code. // @param code a plugin code geturned by the getCode() plugin method. // @return an instance of the plugin or null if there's no plugin // associated with this code. public MyPlugin getMyPlugin(String code) { return (MyPlugin)getPluginByCode(code, MyPlugin.class); } }
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.