2.17.2: 2011-06-17

net.sf.basedb.plugins.executor
Class AbstractIOSupport

java.lang.Object
  extended by net.sf.basedb.core.plugin.AbstractPlugin
      extended by net.sf.basedb.plugins.executor.AbstractIOSupport
All Implemented Interfaces:
InteractivePlugin, Plugin, IOSupport
Direct Known Subclasses:
BaseFileExporterSupport, BaseFileImporterSupport, BfsExporterSupport, BfsImporterSupport, FileOnlyImporterSupport

public abstract class AbstractIOSupport
extends AbstractPlugin
implements IOSupport

Abstract base class that is useful for plug-ins that need to implement the IOSupport interface and don't want to be visible as standalone plug-ins.

Since:
2.15
Author:
nicklas
See Also:
ExternalProgramExecutor
Last modified
$Date $

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
 
Field Summary
private  ExternalProgramExecutor executor
           
 
Fields inherited from class net.sf.basedb.core.plugin.AbstractPlugin
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc
 
Fields inherited from interface net.sf.basedb.plugins.executor.IOSupport
COMMAND_CONFIGURE_IO_JOB, COMMAND_CONFIGURE_IO_PLUGIN, COMMAND_EXECUTE_IO_JOB
 
Constructor Summary
AbstractIOSupport()
           
 
Method Summary
protected  ExternalProgramExecutor getExecutor()
          Get the external program executor that invoked the plug-in.
 Set<GuiContext> getGuiContexts()
          Get a set containing all items that the plugin handles.
 String getShortName()
          A default implementation to maintain backwards compatibility.
 void init(SessionControl sc, ParameterValues configuration, ParameterValues job, ExternalProgramExecutor executor)
          Replaces the regular plug-in initialisation method.
 String isInContext(GuiContext context, Object item)
          Check if the plugin can be used on the specified object.
protected abstract  String performIO(DbControl dc, ProgressReporter progress)
          Perform the IO operation.
 boolean requiresConfiguration()
          Returns FALSE, since that is how the plugins used to work before this method was introduced.
 void run(Request request, Response response, ProgressReporter progress)
          Accepts the IOSupport.COMMAND_EXECUTE_IO_JOB command.
 boolean supportsConfigurations()
          Returns TRUE, since that is how the plugins used to work before this method was introduced.
 
Methods inherited from class net.sf.basedb.core.plugin.AbstractPlugin
checkInterrupted, cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, getPermissions, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.plugin.InteractivePlugin
configure, getRequestInformation
 
Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, getAbout, getMainType, getPermissions, init
 

Field Detail

executor

private ExternalProgramExecutor executor
Constructor Detail

AbstractIOSupport

public AbstractIOSupport()
Method Detail

supportsConfigurations

public boolean supportsConfigurations()
Description copied from class: AbstractPlugin
Returns TRUE, since that is how the plugins used to work before this method was introduced.

Specified by:
supportsConfigurations in interface Plugin
Overrides:
supportsConfigurations in class AbstractPlugin
Returns:
Always FALSE

requiresConfiguration

public boolean requiresConfiguration()
Description copied from class: AbstractPlugin
Returns FALSE, since that is how the plugins used to work before this method was introduced.

Specified by:
requiresConfiguration in interface Plugin
Overrides:
requiresConfiguration in class AbstractPlugin
Returns:
Always FALSE

getGuiContexts

public Set<GuiContext> getGuiContexts()
Description copied from interface: InteractivePlugin
Get a set containing all items that the plugin handles. Ie. if the plugin imports reporters, return a set containing Item.REPORTER. This information is used by client applications to put the plugin in the proper place in the user interface.

Specified by:
getGuiContexts in interface InteractivePlugin
Returns:
Always null

isInContext

public String isInContext(GuiContext context,
                          Object item)
Description copied from interface: InteractivePlugin
Check if the plugin can be used on the specified object. The item is either a BasicItem or BasicData object, or null if called from a list context. A client application should only call this method for contexts matching one of the contexts in the set returned by the InteractivePlugin.getGuiContexts() method. For GuiContext.Type.ITEM contexts an item of the correct type should be passed as a parameter.

The plug-in can response with a null value indicating success, a warning-level message or throw an exception to indicate an error-level message. Client application should normally only show error-level messages to users, unless the user has requested to see warning messages.

NOTE! Before BASE 2.4 all messages were treated as error-level messages.

Specified by:
isInContext in interface InteractivePlugin
Parameters:
context - The current context of the client application, it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
item - The currently active item, it's type should match the GuiContext.getItem() type, or null if the context is a list context
Returns:
Always null

run

public void run(Request request,
                Response response,
                ProgressReporter progress)
Accepts the IOSupport.COMMAND_EXECUTE_IO_JOB command. The default implementation starts a new transaction and then calls performIO(DbControl, ProgressReporter) which should be implemented by the subclass.

Specified by:
run in interface Plugin
Parameters:
request - Request object with the command and parameters
response - Response object in for the plugin to response through
progress - A ProgressReporter where the plugin can report its progess, can be null

getShortName

public String getShortName()
A default implementation to maintain backwards compatibility. Plug-ins that want to return a different short name should override this method.

Specified by:
getShortName in interface IOSupport
Returns:
The name of the plugin (eg. getAbout().getName())
Since:
2.16

init

public void init(SessionControl sc,
                 ParameterValues configuration,
                 ParameterValues job,
                 ExternalProgramExecutor executor)
Description copied from interface: IOSupport
Replaces the regular plug-in initialisation method. When the plug-in is used as part of the external executor this method is used instead of Plugin.init(SessionControl, ParameterValues, ParameterValues).

Specified by:
init in interface IOSupport
executor - The external executor plug-in

performIO

protected abstract String performIO(DbControl dc,
                                    ProgressReporter progress)
                             throws IOException
Perform the IO operation.

Parameters:
dc - A DbControl that can be used by the subclass
progress - An optional progress reporter
Returns:
A message that is returned as to the external program executor
Throws:
IOException

getExecutor

protected ExternalProgramExecutor getExecutor()
Get the external program executor that invoked the plug-in.


2.17.2: 2011-06-17