Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 31674 invoked from network); 28 Apr 2005 14:18:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Apr 2005 14:18:48 -0000 Received: (qmail 96684 invoked by uid 500); 28 Apr 2005 14:19:51 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 96639 invoked by uid 500); 28 Apr 2005 14:19:51 -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: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 96626 invoked by uid 99); 28 Apr 2005 14:19:51 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from adsl-209-233-18-245.dsl.snfc21.pacbell.net (HELO buttons.boynes.com) (209.233.18.245) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 28 Apr 2005 07:19:51 -0700 Received: from [192.168.37.169] (unknown [192.168.37.169]) by buttons.boynes.com (Postfix) with ESMTP id A2B7312F4A for ; Thu, 28 Apr 2005 07:18:40 -0700 (PDT) Message-ID: <4270F0A1.2070608@apache.org> Date: Thu, 28 Apr 2005 07:18:09 -0700 From: Jeremy Boynes User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Development Subject: Re: [jira] Commented: (DERBY-214) Remove System.exit() calls from the DB2jServerImpl.java References: <124244851.1114624173884.JavaMail.jira@ajax.apache.org> <42707488.4060107@sbcglobal.net> <4270E3CF.5050204@sun.com> <4270E927.9020107@sbcglobal.net> In-Reply-To: <4270E927.9020107@sbcglobal.net> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Kathey Marsden wrote: > David Van Couvering wrote: > > >>We could add an argument that indicates whether or not the main >>program should call System.exit() or just return. It's very valuable >>to have a non-zero exit status when calling a command from the >>command-line, for better scriptability... >> >>e.g. "-noSysExit" >> >>But I think what would be better is if applications like Eclipse don't >>call main() but call the execute() method, which only throws an >>exception. This same issue exists for all the Derby tools, and it >>would be good if we had a policy that didn't require a "-noSysExit" >>option on every command. >> >>I can add an execute() method to NetworkServerControl so it's on the >>same class as the main() method. > > > What do you think about main throwing an exception? If we can do that > then it might avoid changing the public API or doc. > I don't know if that is a commonly accepted practice or not. I tried this. > I have a couple of issues. Firstly, I don't believe the behaviour of the JVM is defined so you don't know what is going to happen to the info from the Exception. Also running this under a GUI (e.g. using javaw) may result in loss of that info all together as there may not be a console. A bigger issue for me is that main is a static entry point that takes command line arguments. This is OK for something called from an external command line but makes little sense for something being embedded in another tool. I would prefer to see the public API as a JavaBean with properties and a single noarg execute method (perhaps by implementing Runnable or Callable). That way the user can instantitate it, initialize the arguments in a typesafe way, and then execute it. The command line interface then becomes a thin wrapper whose main method creates the bean and sets the properties by parsing the arguments. -- Jeremy