Opened 15 years ago

Closed 15 years ago

#695 closed enhancement (wontfix)

implement run method in AbstractPlugin??

Reported by: Peter Johansson Owned by: everyone
Priority: major Milestone: BASE 2.4
Component: coreplugins Version: trunk
Keywords: Cc:

Description

In docs of Plug-in API is is recommended (example 23.5) to implement the run() method using the following skeleton:

public void run(Request request, Response response, ProgressReporter progress)
{
   // Open a connection to the database
   // sc is set by init() method
   DbControl dc = sc.newDbControl();
   try
   {
      // Insert code for plug-in here

      // Commit the work
      dc.commit();
      response.setDone("Plug-in ended successfully");
   }
   catch (Throwable t)
   {
      // All exceptions must be catched and sent back 
      // using the response object
      response.setError(t.getMessage(), Arrays.asList(t));
   }
   finally
   {
      // IMPORTANT!!! Make sure opened connections are closed
      if (dc != null) dc.close();
   }
}

Wouldn't it make sense to implement this method in AbstractPlugin and replace '// Insert code for plug-in here' with a method, say runPlugin(ProgressReporter progress). This would help plugin developers avoid copying the same code over and over again and rather focus on implementing the runPlugin method. Yet, a developer could, of course, choose to override the run() method not using the provided skeleton.

Change History (1)

comment:1 Changed 15 years ago by Jari Häkkinen

Milestone: BASE 2.4
Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.