You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Jacek Laskowski <ja...@laskowski.net.pl> on 2008/06/12 09:21:32 UTC

Re: svn commit: r666930 - in /geronimo/server/branches/2.1: assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/ framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/

On Thu, Jun 12, 2008 at 2:14 AM,  <ga...@apache.org> wrote:
> Author: gawor
> Date: Wed Jun 11 17:14:11 2008
> New Revision: 666930
>
> URL: http://svn.apache.org/viewvc?rev=666930&view=rev
> Log:
> wait-for-server ghsell command plus some minor changes ported from trunk (GERONIMO-4115)
...
> Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy?rev=666930&r1=666929&r2=666930&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy (original)
> +++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy Wed Jun 11 17:14:11 2008
> @@ -39,6 +39,8 @@
>  @CommandComponent(id='geronimo-commands:connect', description="Connect to a Geronimo server")
>  class ConnectCommand extends CommandSupport {
>
> +    public static final String SERVER_CONNECTION = 'geronimo.ServerConnection'
> +
>     @Option(name='-s', aliases=['--hostname', '--server'], description='Hostname, default localhost')
>     String hostname = 'localhost'
>
> @@ -54,8 +56,14 @@
>     @Requirement
>     PromptReader prompter
>
> -    protected Object doExecute() throws Exception {
> -        io.out.println("Connecting to Geronimo server: ${hostname}:${port}")
> +    protected Object doExecute() throws Exception {
> +        return openConnection(false)
> +    }
> +
> +    protected ServerConnection openConnection(boolean quiet) throws Exception {
> +        if (!quiet) {
> +            io.out.println("Connecting to Geronimo server: ${hostname}:${port}")
> +        }
>
>         // If the username/password was not configured via cli, then prompt the user for the values
>         if (username == null || password == null) {
> @@ -80,20 +88,42 @@
>
>         disconnect();
>
> -        variables.parent.set("ServerConnection", connection)
> +        variables.parent.set(SERVER_CONNECTION, connection)
> +
> +        if (!quiet) {
> +            io.out.println("Connection established")
> +        }

Why is disconnect *before* the "Connection established" msg?

The snippet is as follows:

        def connection = new ServerConnection(connectionParams,
io.out, io.inputStream, kernel, deploymentFactory)

        // Disconnect previous connection if any
        disconnect()

        variables.parent.set(SERVER_CONNECTION, connection)

        if (!quiet) {
                io.out.println('Connection established')
        }

Shouldn't disconnect() be executed before the other connection is
opened? It'd make the class easier to understand what's going on,
wouldn't it?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl