[rhq] Branch 'rhq-on-as7' - modules/enterprise

mazz mazz at fedoraproject.org
Mon Aug 27 17:52:01 UTC 2012


 modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java              |   50 ++++++++
 modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/WebJBossASClient.java               |   56 ++++++++++
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java |   16 ++
 3 files changed, 122 insertions(+)

New commits:
commit c2fcf6cd989ad7f1b8f0c18a72430e2b52b662d9
Author: John Mazzitelli <mazz at redhat.com>
Date:   Mon Aug 27 13:51:51 2012 -0400

    make sure the default JBoss welcome screen is disabled
    add the ability to reload the configuraiton at installation end
    also add API to restart the JVM because I have a feeling at some point, we'll need to use that and not reload

diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
index 1ff29bc..00d2f14 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
@@ -135,4 +135,54 @@ public class CoreJBossASClient extends JBossASClient {
             throw new FailureException(response, "Failed to set system property [" + name + "]");
         }
     }
+
+    /**
+     * Invokes the management "reload" operation which will shut down all the app server services and
+     * restart them again. This is required for certain configuration changes to take effect.
+     * This does not shutdown the JVM itself.
+     *
+     * @throws Exception
+     */
+    public void reload() throws Exception {
+        ModelNode request = createRequest("reload", Address.root());
+        request.get("admin-only").set(false);
+        ModelNode response = execute(request);
+        if (!isSuccess(response)) {
+            throw new FailureException(response);
+        }
+        return;
+    }
+
+    /**
+     * Invokes the management "shutdown" operation with the restart option set to true
+     * (see {@link #shutdown(boolean)}).
+     * This means the app server JVM will shutdown but immediately be restarted.
+     * Note that the caller may not be returned to since the JVM in which this call is made
+     * will be killed.
+     *
+     * @throws Exception
+     */
+    public void restart() throws Exception {
+        shutdown(true);
+    }
+
+    /**
+     * Invokes the management "shutdown" operation that kills the JVM completely with System.exit.
+     * If restart is set to true, the JVM will immediately be restarted again. If restart is false,
+     * the JVM is killed and will stay down.
+     * Note that in either case, the caller may not be returned to since the JVM in which this call is made
+     * will be killed.
+     *
+     * @param restart if true, the JVM will be restarted
+     * @throws Exception
+     */
+    public void shutdown(boolean restart) throws Exception {
+        ModelNode request = createRequest("shutdown", Address.root());
+        request.get("restart").set(restart);
+        ModelNode response = execute(request);
+        if (!isSuccess(response)) {
+            throw new FailureException(response);
+        }
+        return;
+    }
 }
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/WebJBossASClient.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/WebJBossASClient.java
new file mode 100644
index 0000000..5424483
--- /dev/null
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/common/jbossas/client/controller/WebJBossASClient.java
@@ -0,0 +1,56 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.common.jbossas.client.controller;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * Convienence methods to access the web management API.
+ *
+ * @author John Mazzitelli
+ */
+public class WebJBossASClient extends JBossASClient {
+
+    public static final String SUBSYSTEM_WEB = "web";
+    public static final String VIRTUAL_SERVER = "virtual-server";
+    public static final String DEFAULT_HOST = "default-host";
+
+    public WebJBossASClient(ModelControllerClient client) {
+        super(client);
+    }
+
+    /**
+     * The enable-welcome-root setting controls whether or not to deploy JBoss' welcome-content application at root context.
+     * If you want to deploy your own app at the root context, you need to disable the enable-welcome-root setting
+     * on the default host virtual server. If you want to show the JBoss' welcome screen, you need to enable this setting.
+     *
+     * @param enableFlag true if the welcome screen at the root context should be enabled; false otherwise
+     * @throws Exception 
+     */
+    public void setEnableWelcomeRoot(boolean enableFlag) throws Exception {
+        Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, VIRTUAL_SERVER, DEFAULT_HOST);
+        ModelNode req = createWriteAttributeRequest("enable-welcome-root", Boolean.toString(enableFlag), address);
+        ModelNode response = execute(req);
+        if (!isSuccess(response)) {
+            throw new FailureException(response);
+        }
+        return;
+    }
+}
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
index 899f423..47a3306 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -39,6 +39,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 import org.jboss.as.controller.client.ModelControllerClient;
 
 import org.rhq.common.jbossas.client.controller.CoreJBossASClient;
+import org.rhq.common.jbossas.client.controller.WebJBossASClient;
 import org.rhq.core.db.DatabaseTypeFactory;
 import org.rhq.core.util.PropertiesFileUpdate;
 import org.rhq.core.util.exception.ThrowableUtil;
@@ -321,6 +322,9 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
         // deploy the EAR and undeploy this installer - this will shut us down within seconds, return fast!
         deployApp();
 
+        // some of the changes we made require the app server container to reload
+        reloadConfiguration();
+
         return;
     }
 
@@ -573,6 +577,9 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
             // setup the email service
             ServerInstallUtil.setupMailService(client, serverProperties);
 
+            // we don't want to the JBossAS welcome screen; turn it off
+            new WebJBossASClient(client).setEnableWelcomeRoot(false);
+
         } catch (Exception e) {
             log("deployServices failed", e);
             throw new Exception("Failed to deploy services: " + ThrowableUtil.getAllMessages(e));
@@ -604,6 +611,15 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
         }
     }
 
+    private void reloadConfiguration() throws Exception {
+        try {
+            final CoreJBossASClient client = new CoreJBossASClient(getClient());
+            client.reload();
+        } catch (Exception e) {
+            log("reloadConfiguration failed - restart the server to complete the installation", e);
+        }
+    }
+
     // left this here in case we want to undeploy the installer in the future; for now, we don't use this
     private void undeployInstaller() throws Exception {
         try {




More information about the rhq-commits mailing list