db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kathey Marsden (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-295) Standardize calling mechanism for classes with main() routines
Date Thu, 07 May 2009 21:10:45 GMT

    [ https://issues.apache.org/jira/browse/DERBY-295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707112#action_12707112
] 

Kathey Marsden commented on DERBY-295:
--------------------------------------

I wonder if this is still relevant.  For NetworkServerControl we have a public API and ij
has methods besides main you can call.  I am thinking of closing this Won't fix. Let me know
if you object.


> Standardize calling mechanism for classes with main() routines
> --------------------------------------------------------------
>
>                 Key: DERBY-295
>                 URL: https://issues.apache.org/jira/browse/DERBY-295
>             Project: Derby
>          Issue Type: Improvement
>          Components: Tools
>    Affects Versions: 10.1.1.0
>            Reporter: David Van Couvering
>            Priority: Minor
>
> We need a standard, common agreed upon design pattern and mechanism for how 
> applications can embed and invoke classes that have a main() routine in them,
> like ij, dblook, etc.
> See
>  http://mail-archives.apache.org/mod_mbox/db-derby-dev/200504.mbox/%3c124244851.1114624173884.JavaMail.jira@ajax.apache.org%3e
> (or http://tinyurl.com/b4qjc)
> for the mail thread that discusses this.
> The conclusion was the following:
> - There should be a *non-static* public method that can be used to execute a class
> with a main() routine
> - Properties are set prior to calling this public method using the standard
> JavaBeans get/set pattern
> - We should have a new interface called Executable or something similar that
> defines this contract, and our tools should be modified to implement this
> interface
> - The main() routine should call this method after processing arguments.
> The Executable interface would look something like:
> public interface Executable
> {
>   public void execute() throws Exception;
> }
> So then you would have:
> public class MyMain implements Executable
> {
>   public int length;
>   public int duration;
>   public static void main(String[] args)
>   {
>     try
>     {
>        MyMain me = new myMain();
>        me.processArgs(args);
>        me.execute();
>     }
>     catch ( Exception e )
>     {
>        e.printStackTrace();
>        System.exit(1);
>     }
>     System.exit(0);
>   }
>   public void processArgs(String[] args)
>   {
>     // handwaving around argument processing
>     setLength(getLength(args));
>     setDuration(getDuration(args));
>   }
>   public void setLength(int length)
>   {
>     this.length = length;
>   }
>   public void setDuration(int duration)
>   {
>     this.duration = duration;
>   }
>   public void execute() throws Exception
>   {
>     // this is where the real work happens...
>   }
> }
> An example embedded use:
> MyTool tool = new MyTool();
> tool.setLength(2);
> tool.setDuration(12);
> tool.execute();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message