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

mazz mazz at fedoraproject.org
Tue Aug 7 19:13:37 UTC 2012


 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java |   12 ++
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java       |   45 ++++++++++
 modules/enterprise/scripting/api/pom.xml                                                                                    |    2 
 modules/enterprise/scripting/javascript/pom.xml                                                                             |    2 
 modules/enterprise/scripting/python/pom.xml                                                                                 |    2 
 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/EmailManagerBean.java                            |    2 
 6 files changed, 58 insertions(+), 7 deletions(-)

New commits:
commit 01ab2109195004bf392833a8ee54a2ff8a0bec52
Author: John Mazzitelli <mazz at redhat.com>
Date:   Tue Aug 7 15:13:34 2012 -0400

    setup the mail service

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 d9bc8f6..9a1b792 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
@@ -521,14 +521,20 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
 
     private void deployServices(HashMap<String, String> serverProperties) throws Exception {
         try {
+            ModelControllerClient client = getClient();
+
             // create the security domain needed by the datasources
-            ServerInstallUtil.createDatasourceSecurityDomain(getClient(), serverProperties);
+            ServerInstallUtil.createDatasourceSecurityDomain(client, serverProperties);
 
             // create the JDBC driver configurations for use by datasources
-            ServerInstallUtil.createNewJdbcDrivers(getClient(), serverProperties);
+            ServerInstallUtil.createNewJdbcDrivers(client, serverProperties);
 
             // create the datasources
-            ServerInstallUtil.createNewDatasources(getClient(), serverProperties);
+            ServerInstallUtil.createNewDatasources(client, serverProperties);
+
+            // setup the email service
+            ServerInstallUtil.setupMailService(client, serverProperties);
+
         } catch (Exception e) {
             log("deployServices failed", e);
             throw new Exception("Failed to deploy services: " + ThrowableUtil.getAllMessages(e));
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
index 6fb60bb..b3eea60 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
@@ -45,6 +45,7 @@ import org.apache.tools.ant.helper.ProjectHelper2;
 import org.jboss.as.controller.client.ModelControllerClient;
 import org.jboss.dmr.ModelNode;
 
+import org.rhq.common.jbossas.client.controller.Address;
 import org.rhq.common.jbossas.client.controller.DatasourceJBossASClient;
 import org.rhq.common.jbossas.client.controller.FailureException;
 import org.rhq.common.jbossas.client.controller.JBossASClient;
@@ -84,6 +85,50 @@ public class ServerInstallUtil {
     private static final String JDBC_DRIVER_ORACLE = "oracle";
 
     /**
+     * Prepares the mail service by configuring the SMTP settings.
+     * 
+     * @param mcc JBossAS management client
+     * @param serverProperties the server's properties
+     */
+    public static void setupMailService(ModelControllerClient mcc, HashMap<String, String> serverProperties)
+        throws Exception {
+
+        String fromAddressExpr = "${" + ServerProperties.PROP_EMAIL_FROM_ADDRESS + ":rhqadmin at localhost.com}";
+        String smtpHostExpr = "${" + ServerProperties.PROP_EMAIL_SMTP_HOST + ":localhost}";
+        String smtpPortExpr = "${" + ServerProperties.PROP_EMAIL_SMTP_PORT + ":25}";
+
+        // Tweek the mail configuration that comes out of box. Setup a batch request to write the proper attributes.
+
+        // First, the from address (TODO: there is also a "ssl", "username" and "password" attribute we could set for authz)
+        Address addr = Address.root().add(JBossASClient.SUBSYSTEM, "mail", "mail-session", "java:jboss/mail/Default");
+        ModelNode writeFromAddr = JBossASClient.createRequest(JBossASClient.WRITE_ATTRIBUTE, addr);
+        writeFromAddr.get(JBossASClient.NAME).set("from");
+        writeFromAddr.get(JBossASClient.VALUE).setExpression(fromAddressExpr);
+
+        // now the SMTP host
+        addr = Address.root().add("socket-binding-group", "standard-sockets",
+            "remote-destination-outbound-socket-binding", "mail-smtp");
+        ModelNode writeHost = JBossASClient.createRequest(JBossASClient.WRITE_ATTRIBUTE, addr);
+        writeHost.get(JBossASClient.NAME).set("host");
+        writeHost.get(JBossASClient.VALUE).setExpression(smtpHostExpr);
+
+        // now the SMTP port
+        addr = Address.root().add("socket-binding-group", "standard-sockets",
+            "remote-destination-outbound-socket-binding", "mail-smtp");
+        ModelNode writePort = JBossASClient.createRequest(JBossASClient.WRITE_ATTRIBUTE, addr);
+        writePort.get(JBossASClient.NAME).set("port");
+        writePort.get(JBossASClient.VALUE).setExpression(smtpPortExpr);
+
+        ModelNode batch = JBossASClient.createBatchRequest(writeFromAddr, writeHost, writePort);
+        JBossASClient client = new JBossASClient(mcc);
+        ModelNode response = client.execute(batch);
+        if (!JBossASClient.isSuccess(response)) {
+            throw new FailureException(response, "Failed to setup mail service");
+        }
+        return;
+    }
+
+    /**
      * Give the server properties, this returns the type of database that will be connected to.
      * 
      * @param serverProperties
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/EmailManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/EmailManagerBean.java
index a3909a1..fd1e1f5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/EmailManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/EmailManagerBean.java
@@ -87,7 +87,7 @@ public class EmailManagerBean implements EmailManagerLocal {
      */
     private static final String TEMPLATE_TOKEN_ALERT_URL = "@@@ALERT_URL@@@";
 
-    @Resource(mappedName = "java:/Mail")
+    @Resource(mappedName = "java:jboss/mail/Default")
     private Session mailSession;
 
     /**


commit f51fc2f4b70a5a5ba8b9c381b5fe2235dd5668cd
Author: John Mazzitelli <mazz at redhat.com>
Date:   Tue Aug 7 14:29:22 2012 -0400

    when in dev mode, put the jars in the new ear location

diff --git a/modules/enterprise/scripting/api/pom.xml b/modules/enterprise/scripting/api/pom.xml
index b3d036b..920bd9b 100644
--- a/modules/enterprise/scripting/api/pom.xml
+++ b/modules/enterprise/scripting/api/pom.xml
@@ -29,7 +29,7 @@
             <properties>
                 <rhq.rootDir>../../..</rhq.rootDir>
                 <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
-                <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+                <rhq.deploymentDir>${rhq.containerDir}/jbossas/standalone/deployments/${rhq.earName}/lib</rhq.deploymentDir>
             </properties>
 
             <build>
diff --git a/modules/enterprise/scripting/javascript/pom.xml b/modules/enterprise/scripting/javascript/pom.xml
index 38ead44..a49e55d 100644
--- a/modules/enterprise/scripting/javascript/pom.xml
+++ b/modules/enterprise/scripting/javascript/pom.xml
@@ -73,7 +73,7 @@
          <properties>
             <rhq.rootDir>../../..</rhq.rootDir>
             <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
-            <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+            <rhq.deploymentDir>${rhq.containerDir}/jbossas/standalone/deployments/${rhq.earName}/lib</rhq.deploymentDir>
          </properties>
 
          <build>
diff --git a/modules/enterprise/scripting/python/pom.xml b/modules/enterprise/scripting/python/pom.xml
index 39d3895..a164a8a 100644
--- a/modules/enterprise/scripting/python/pom.xml
+++ b/modules/enterprise/scripting/python/pom.xml
@@ -72,7 +72,7 @@
             <properties>
                 <rhq.rootDir>../../..</rhq.rootDir>
                 <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
-                <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+                <rhq.deploymentDir>${rhq.containerDir}/jbossas/standalone/deployments/${rhq.earName}/lib</rhq.deploymentDir>
             </properties>
 
             <build>




More information about the rhq-commits mailing list