You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2008/06/12 02:14:12 UTC
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/
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)
Added:
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy
Modified:
geronimo/server/branches/2.1/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/layout.xml
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy
Modified: geronimo/server/branches/2.1/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/layout.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/layout.xml?rev=666930&r1=666929&r2=666930&view=diff
==============================================================================
--- geronimo/server/branches/2.1/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/layout.xml (original)
+++ geronimo/server/branches/2.1/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/layout.xml Wed Jun 11 17:14:11 2008
@@ -100,6 +100,11 @@
<name>start-client</name>
<id>geronimo-commands:start-client</id>
</command>
+
+ <command>
+ <name>wait-for-server</name>
+ <id>geronimo-commands:wait-for-server</id>
+ </command>
</nodes>
</group>
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.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/AssembleServerCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy Wed Jun 11 17:14:11 2008
@@ -60,10 +60,7 @@
protected Object doExecute() throws Exception {
io.out.println("Listing configurations from Geronimo server")
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
if (!artifact) {
artifact = prompter.readLine("Server artifact name: ")
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")
+ }
- io.out.println("Connection established")
return connection
}
-
- private void disconnect() {
- def connection = variables.get("ServerConnection")
+
+ protected ServerConnection connect() {
+ def connection = variables.get(SERVER_CONNECTION)
+
+ if (!connection) {
+ connection = openConnection(false)
+ }
+
+ return connection
+ }
+
+ protected boolean isConnected() {
+ return variables.contains(SERVER_CONNECTION)
+ }
+
+ protected void disconnect() {
+ def connection = variables.get(SERVER_CONNECTION)
+
if (connection) {
try {
- connection.close()
- } catch (Exception e) {
+ connection.close()
+ }
+ catch (Exception e) {
// ignore
}
}
+
+ variables.parent.unset(SERVER_CONNECTION)
}
+
}
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.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/DeployModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -47,10 +47,7 @@
String modulePlan
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandDeploy()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.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/DisconnectCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy Wed Jun 11 17:14:11 2008
@@ -34,7 +34,7 @@
{
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
+ def connection = variables.get(ConnectCommand.SERVER_CONNECTION)
if (connection) {
io.out.println("Disconnecting from Geronimo server")
try {
@@ -42,7 +42,7 @@
} catch (Exception e) {
// ignore
}
- variables.parent.unset("ServerConnection")
+ variables.parent.unset(ConnectCommand.SERVER_CONNECTION)
io.out.println("Connection ended")
} else {
io.out.println("Not connected")
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.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/DistributeModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -47,10 +47,7 @@
String modulePlan
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandDistribute()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.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/InstallLibraryCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy Wed Jun 11 17:14:11 2008
@@ -41,10 +41,7 @@
String libraryFile
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandInstallLibrary()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.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/InstallPluginCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy Wed Jun 11 17:14:11 2008
@@ -38,10 +38,7 @@
String pluginFile
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandInstallCAR()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.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/ListConfigurationsCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy Wed Jun 11 17:14:11 2008
@@ -47,10 +47,8 @@
List<String> pluginArtifacts
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
+
def command = new CommandListConfigurations()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
def repo = null
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.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/ListModulesCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy Wed Jun 11 17:14:11 2008
@@ -47,10 +47,7 @@
List<String> targets = []
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandListModules()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.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/ListTargetsCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy Wed Jun 11 17:14:11 2008
@@ -35,10 +35,7 @@
class ListTargetsCommand extends ConnectCommand {
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandListTargets()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.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/RedeployModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -44,10 +44,7 @@
List<String> moduleIds
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandRedeploy()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.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/RestartModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -38,10 +38,7 @@
List<String> moduleNames = []
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandRestart()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.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/StartModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -38,10 +38,7 @@
List<String> moduleNames = []
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandStart()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.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/StopModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -38,10 +38,7 @@
List<String> moduleNames = []
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandStop()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.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/StopServerCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy Wed Jun 11 17:14:11 2008
@@ -35,15 +35,9 @@
class StopServerCommand extends ConnectCommand {
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
- RemoteDeploymentManager deploymentManager =
- (RemoteDeploymentManager)connection.getDeploymentManager();
-
- def server = new ServerProxy(deploymentManager.getJMXConnector())
+ def server = new ServerProxy(connection.deploymentManager.getJMXConnector())
io.out.println("Stopping Geronimo server...");
try {
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.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/UndeployModuleCommand.groovy (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy Wed Jun 11 17:14:11 2008
@@ -38,10 +38,7 @@
List<String> moduleNames = []
protected Object doExecute() throws Exception {
- def connection = variables.get("ServerConnection")
- if (!connection) {
- connection = super.doExecute()
- }
+ def connection = connect()
def command = new CommandUndeploy()
def consoleReader = new ConsoleReader(io.inputStream, io.out)
Added: geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy?rev=666930&view=auto
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy (added)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy Wed Jun 11 17:14:11 2008
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.commands
+
+import org.apache.geronimo.gshell.clp.Option
+import org.apache.geronimo.gshell.command.annotation.CommandComponent
+import org.apache.geronimo.gshell.command.CommandSupport
+import org.apache.geronimo.gshell.command.annotation.Requirement
+import org.apache.geronimo.gshell.console.PromptReader
+import org.apache.geronimo.deployment.cli.ServerConnection
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager
+
+/**
+ * Wait for a Geronimo server to start.
+ *
+ * @version $Rev: 664243 $ $Date: 2008-06-06 22:23:20 -0400 (Fri, 06 Jun 2008) $
+ */
+@CommandComponent(id='geronimo-commands:wait-for-server', description='Wait for a Geronimo server to start')
+class WaitForServerCommand
+ extends ConnectCommand
+{
+
+ @Option(name='-t', aliases=['--timeout'], description='Specify the time in seconds to wait while verifying that the server has started. Default 60 seconds')
+ int timeout = 60
+
+ protected Object doExecute() throws Exception {
+ def timer = new Timer(true)
+
+ def timedOut = false
+
+ def timeoutTask
+ if (timeout > 0) {
+ timeoutTask = timer.runAfter(timeout * 1000, {
+ timedOut = true
+ })
+ }
+
+ def started = false
+
+ io.out.println("Waiting for Geronimo server: ${hostname}:${port}")
+
+ def connection
+ def server
+ while (!started) {
+ if (timedOut) {
+ throw new Exception("Unable to verify if the server was started in the given time")
+ }
+
+ try {
+ connection = connect()
+ server = new ServerProxy(connection.deploymentManager.getJMXConnector())
+ } catch (Exception error) {
+ log.debug("Server query failed; ignoring", error)
+ Thread.sleep(1000)
+ continue
+ }
+
+ started = server.isFullyStarted()
+
+ if (!started) {
+ Throwable error = server.getLastError()
+ if (error != null) {
+ log.debug("Server query failed; ignoring", error)
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ timeoutTask?.cancel()
+ timer.cancel()
+
+ io.out.println("Geronimo server is started")
+ }
+
+ protected ServerConnection connect() {
+ def connection = variables.get(SERVER_CONNECTION)
+
+ if (!connection) {
+ connection = openConnection(true)
+ }
+
+ return connection
+ }
+
+}
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/
Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
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