Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 58437 invoked from network); 7 May 2009 21:11:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 May 2009 21:11:10 -0000 Received: (qmail 17781 invoked by uid 500); 7 May 2009 21:11:10 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 17688 invoked by uid 500); 7 May 2009 21:11:10 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 17647 invoked by uid 99); 7 May 2009 21:11:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 21:11:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 21:11:06 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AD438234C04C for ; Thu, 7 May 2009 14:10:45 -0700 (PDT) Message-ID: <318689122.1241730645708.JavaMail.jira@brutus> Date: Thu, 7 May 2009 14:10:45 -0700 (PDT) From: "Kathey Marsden (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-295) Standardize calling mechanism for classes with main() routines In-Reply-To: <1453563025.1116282666528.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ 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.