You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kalumet-commits@incubator.apache.org by jb...@apache.org on 2011/10/27 07:50:03 UTC

svn commit: r1189653 - in /incubator/kalumet/trunk: ./ agent/ agent/src/main/java/org/apache/kalumet/agent/updater/ controller/ controller/core/ controller/core/src/ controller/core/src/main/ controller/core/src/main/java/ controller/core/src/main/java...

Author: jbonofre
Date: Thu Oct 27 07:50:02 2011
New Revision: 1189653

URL: http://svn.apache.org/viewvc?rev=1189653&view=rev
Log:
Add the controller module.

Added:
    incubator/kalumet/trunk/agent/NOTICE
      - copied unchanged from r1188737, incubator/kalumet/trunk/NOTICE
    incubator/kalumet/trunk/controller/
    incubator/kalumet/trunk/controller/core/
    incubator/kalumet/trunk/controller/core/NOTICE
      - copied unchanged from r1188737, incubator/kalumet/trunk/NOTICE
    incubator/kalumet/trunk/controller/core/pom.xml
    incubator/kalumet/trunk/controller/core/src/
    incubator/kalumet/trunk/controller/core/src/main/
    incubator/kalumet/trunk/controller/core/src/main/java/
    incubator/kalumet/trunk/controller/core/src/main/java/org/
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/AbstractJ2EEApplicationServerController.java
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/ControllerException.java
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerController.java
    incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerControllerFactory.java
    incubator/kalumet/trunk/controller/pom.xml
    incubator/kalumet/trunk/utils/NOTICE
      - copied unchanged from r1188737, incubator/kalumet/trunk/NOTICE
Modified:
    incubator/kalumet/trunk/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java
    incubator/kalumet/trunk/pom.xml

Modified: incubator/kalumet/trunk/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java?rev=1189653&r1=1189652&r2=1189653&view=diff
==============================================================================
--- incubator/kalumet/trunk/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java (original)
+++ incubator/kalumet/trunk/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java Thu Oct 27 07:50:02 2011
@@ -21,13 +21,18 @@ package org.apache.kalumet.agent.updater
 import org.apache.kalumet.KalumetException;
 import org.apache.kalumet.agent.Configuration;
 import org.apache.kalumet.agent.utils.EventUtils;
-import org.apache.kalumet.agent.utils.NotifierUtils;
 import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.J2EEApplicationServer;
 import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.Software;
 import org.apache.kalumet.model.update.UpdateLog;
+import org.apache.kalumet.model.update.UpdateMessage;
+import org.apache.kalumet.utils.NotifierUtils;
+import org.apache.kalumet.utils.PublisherUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import sun.security.krb5.Config;
+
+import java.util.Iterator;
 
 /**
  * Environment updater.
@@ -73,7 +78,7 @@ public class EnvironmentUpdater {
      * Updates an environment.
      *
      * @param environment the environment to update.
-     * @param force true force the update (even if the autoupdate flag is false), false else
+     * @param force       true force the update (even if the autoupdate flag is false), false else
      * @throws UpdateException in case of update failure.
      */
     public static void update(Environment environment, boolean force) throws UpdateException {
@@ -113,7 +118,106 @@ public class EnvironmentUpdater {
         EventUtils.post(environment, "UPDATE", "Sending a notification and waiting for the update count donw");
         NotifierUtils.waitAndNotify(environment);
 
-        // TODO complete
+        try {
+            // update softwares flagged "before J2EE"
+            LOGGER.info("Updating softwares flagged before J2EE");
+            for (Iterator softwareIterator = environment.getSoftwares().iterator(); softwareIterator.hasNext(); ) {
+                Software software = (Software) softwareIterator.next();
+                try {
+                    if (software.isBeforej2ee()) {
+                        SoftwareUpdater.update(environment, software, updateLog);
+                    }
+                } catch (Exception e) {
+                    if (software.isBlocker()) {
+                        LOGGER.error("Software {} update failed", software.getName());
+                        EventUtils.post(environment, "ERROR", "Software " + software.getName() + " update failed: " + e.getMessage());
+                        updateLog.addUpdateMessage(new UpdateMessage("error", "Software " + software.getName() + " update failed: " + e.getMessage()));
+                        updateLog.setStatus("Environment " + environment.getName() + " update failed");
+                        PublisherUtils.publish(environment);
+                        throw new UpdateException("Software " + software.getName() + " update failed", e);
+                    } else {
+                        LOGGER.warn("Software {} update failed", software.getName());
+                        updateLog.addUpdateMessage(new UpdateMessage("warn", "Software " + software.getName() + " update failed: " + e.getMessage()));
+                        updateLog.addUpdateMessage(new UpdateMessage("info", "Software " + software.getName() + " is not an update blocker, update continues"));
+                        EventUtils.post(environment, "WARN", "Software " + software.getName() + " update failed: " + e.getMessage());
+                        EventUtils.post(environment, "INFO", "Software " + software.getName() + " is not an update blocker, update continues");
+                    }
+                }
+            }
+
+            // update J2EE application servers
+            LOGGER.info("Updating J2EE application servers");
+            for (Iterator j2eeApplicationServersIterator = environment.getJ2EEApplicationServers().getJ2EEApplicationServers().iterator(); j2eeApplicationServersIterator.hasNext(); ) {
+                J2EEApplicationServer j2eeApplicationServer = (J2EEApplicationServer) j2eeApplicationServersIterator.next();
+                try {
+                    J2EEApplicationServerUpdater.update(kalumet, environment, j2eeApplicationServer, updateLog);
+                } catch (Exception e) {
+                    if (j2eeApplicationServer.isBlocker()) {
+                        LOGGER.error("J2EE application server {} update failed", e);
+                        EventUtils.post(environment, "ERROR", "J2EE application server " + j2eeApplicationServer.getName() + " update failed: " + e.getMessage());
+                        updateLog.addUpdateMessage(new UpdateMessage("error", "J2EE application server " + j2eeApplicationServer.getName() + " update failed: " + e.getMessage()));
+                        updateLog.setStatus("Environment " + environment.getName() + " update failed");
+                        PublisherUtils.publish(environment);
+                        throw new UpdateException("J2EE application server " + j2eeApplicationServer.getName() + " update failed", e);
+                    } else {
+                        LOGGER.warn("J2EE application server {} update failed", e);
+                        updateLog.addUpdateMessage(new UpdateMessage("warn", "J2EE application server " + j2eeApplicationServer.getName() + " update failed: " + e.getMessage()));
+                        updateLog.addUpdateMessage(new UpdateMessage("info", "J2EE application server " + j2eeApplicationServer.getName() + " is not an update blocker, update continues"));
+                        EventUtils.post(environment, "WARN", "J2EE application server " + j2eeApplicationServer.getName() + " update failed: " + e.getMessage());
+                        EventUtils.post(environment, "INFO", "J2EE application server " + j2eeApplicationServer.getName() + " is not an update blocker, update continues");
+                    }
+                }
+            }
+
+            // update softwares
+            LOGGER.info("Updating softwares");
+            for (Iterator softwaresIterator = environment.getSoftwares().iterator(); softwaresIterator.hasNext(); ) {
+                Software software = (Software) softwaresIterator.next();
+                try {
+                    if (!software.isBeforej2ee()) {
+                        SoftwareUpdater.update(environment, software, updateLog);
+                    }
+                } catch (Exception e) {
+                    if (software.isBlocker()) {
+                        LOGGER.error("Software {} update failed", software.getName());
+                        EventUtils.post(environment, "ERROR", "Software " + software.getName() + " update failed: " + e.getMessage());
+                        updateLog.addUpdateMessage(new UpdateMessage("error", "Software " + software.getName() + " update failed: " + e.getMessage()));
+                        updateLog.setStatus("Environment " + environment.getName() + " update failed");
+                        PublisherUtils.publish(environment);
+                        throw new UpdateException("Software " + software.getName() + " update failed", e);
+                    } else {
+                        LOGGER.warn("Software {} update failed", software.getName());
+                        updateLog.addUpdateMessage(new UpdateMessage("warn", "Software " + software.getName() + " update failed: " + e.getMessage()));
+                        updateLog.addUpdateMessage(new UpdateMessage("info", "Software " + software.getName() + " is not an update blocker, update continues"));
+                        EventUtils.post(environment, "WARN", "Software " + software.getName() + " update failed: " + e.getMessage());
+                        EventUtils.post(environment, "INFO", "Software " + software.getName() + " is not an update blocker, update continues");
+                    }
+                }
+            }
+        } catch (Exception e) {
+            LOGGER.error("Update failed", e);
+            EventUtils.post(environment, "ERROR", "Update failed: " + e.getMessage());
+            updateLog.setStatus("Environment " + environment.getName() + " update failed");
+            updateLog.addUpdateMessage(new UpdateMessage("error", "Update failed: " + e.getMessage()));
+            LOGGER.info("Publishing update report");
+            PublisherUtils.publish(environment);
+            throw new UpdateException("Update failed", e);
+        }
+
+        // publish update result
+        LOGGER.info("Publishing update report");
+        if (updateLog.isUpdated()) {
+            updateLog.setStatus("Environment " + environment.getName() + " updated");
+        } else {
+            updateLog.setStatus("Environment " + environment.getName() + " already up to date");
+        }
+        updateLog.addUpdateMessage(new UpdateMessage("info", "Environment " + environment.getName() + " update completed"));
+        EventUtils.post(environment, "UPDATE", "Environment " + environment.getName() + " update completed");
+        LOGGER.info("Publishing update report");
+        PublisherUtils.publish(environment);
+
+        LOGGER.info("Update completed");
     }
 
 }
+

Added: incubator/kalumet/trunk/controller/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/controller/core/pom.xml?rev=1189653&view=auto
==============================================================================
--- incubator/kalumet/trunk/controller/core/pom.xml (added)
+++ incubator/kalumet/trunk/controller/core/pom.xml Thu Oct 27 07:50:02 2011
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.kalumet.controller</groupId>
+        <artifactId>controller</artifactId>
+        <version>0.6-incubating</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.kalumet.controller.core</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache Kalumet :: Controller :: Core</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.kalumet</groupId>
+            <artifactId>org.apache.kalumet.common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.kalumet</groupId>
+            <artifactId>org.apache.kalumet.utils</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

Added: incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/AbstractJ2EEApplicationServerController.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/AbstractJ2EEApplicationServerController.java?rev=1189653&view=auto
==============================================================================
--- incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/AbstractJ2EEApplicationServerController.java (added)
+++ incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/AbstractJ2EEApplicationServerController.java Thu Oct 27 07:50:02 2011
@@ -0,0 +1,209 @@
+/*
+ * 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.kalumet.controller.core;
+
+import java.util.List;
+
+/**
+ * Abstract J2EE application server controller.
+ */
+public abstract class AbstractJ2EEApplicationServerController implements J2EEApplicationServerController {
+
+    private String url;
+    private String username;
+    private String password;
+    private String serverName;
+    private boolean cluster;
+
+    /**
+     * Default constructor.
+     *
+     * @param url        JMX URL of the J2EE application server.
+     * @param username   the administrative user.
+     * @param password   the administrative password.
+     * @param serverName the J2EE application server name.
+     * @param cluster    true means that the server is a cluster, or single.
+     * @throws ControllerException in case of connection failure.
+     */
+    public AbstractJ2EEApplicationServerController(String url, String username, String password, String serverName, Boolean cluster) throws ControllerException {
+        this.url = url;
+        this.username = username;
+        this.password = password;
+        this.serverName = serverName;
+        this.cluster = cluster.booleanValue();
+        this.init();
+    }
+
+    /**
+     * Abstract method to initialize a specific J2EE application server.
+     *
+     * @throws ControllerException in case of initialization error.
+     */
+    protected abstract void init() throws ControllerException;
+
+    public String getUrl() {
+        return this.url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUsername() {
+        return this.username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return this.password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getServerName() {
+        return this.serverName;
+    }
+
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public boolean isCluster() {
+        return this.cluster;
+    }
+
+    public void setCluster(boolean cluster) {
+        this.cluster = cluster;
+    }
+
+    public abstract void shutdown() throws ControllerException;
+
+    public abstract String status() throws ControllerException;
+
+    public abstract boolean isStopped() throws ControllerException;
+
+    public abstract boolean isJ2EEApplicationDeployed(String path, String name) throws ControllerException;
+
+    public abstract void deployJ2EEApplication(String path, String name, String classLoaderOrder, String classLoaderPolicy, String virtualHost) throws ControllerException;
+
+    public abstract void undeployJ2EEApplication(String path, String name) throws ControllerException;
+
+    public abstract void redeployJ2EEApplication(String path, String name) throws ControllerException;
+
+    public abstract boolean isJDBCConnectionPoolDeployed(String name) throws ControllerException;
+
+    public abstract boolean isJDBCConnectionPoolUpToDate(String name,
+                                                String jdbcDriverClassName,
+                                                int capacityIncrement,
+                                                int initialCapacity,
+                                                int maxCapacity,
+                                                String username,
+                                                String password,
+                                                String jdbcURL,
+                                                String classPath) throws ControllerException;
+
+    public abstract boolean updateJDBCConnectionPool(String name,
+                                            String jdbcDriverClassName,
+                                            int capacityIncrement,
+                                            int initialCapacity,
+                                            int maxCapacity,
+                                            String username,
+                                            String password,
+                                            String jdbcURL,
+                                            String classPath) throws ControllerException;
+
+    public abstract void deployJDBCConnectionPool(String name,
+                                         String jdbcDriverClassName,
+                                         int capacityIncrement,
+                                         int initialCapacity,
+                                         int maxCapacity,
+                                         String username,
+                                         String password,
+                                         String jdbcURL,
+                                         String classPath) throws ControllerException;
+
+    public abstract void undeployJDBCConnectionPool(String name) throws ControllerException;
+
+    public abstract boolean isJDBCDataSourceDeployed(String name) throws ControllerException;
+
+    public abstract boolean isJDBCDataSourceUpToDate(String name,
+                                            String jdbcConnectionPool,
+                                            String jdbcURL,
+                                            String helpClassName) throws ControllerException;
+
+    public abstract void deployJDBCDataSource(String name,
+                                     String jdbcConnectionPool,
+                                     String jdbcURL,
+                                     String helpClassName) throws ControllerException;
+
+    public abstract void undeployJDBCDataSource(String name) throws ControllerException;
+
+    public abstract boolean updateJDBCDataSource(String name,
+                                        String jdbcConnectionPool,
+                                        String jdbcURL,
+                                        String helperClassName) throws ControllerException;
+
+    public abstract boolean isJMSConnectionFactoryDeployed(String name) throws ControllerException;
+
+    public abstract void deployJMSConnectionFactory(String name) throws ControllerException;
+
+    public abstract void undeployJMSConnectionFactory(String name) throws ControllerException;
+
+    public abstract boolean isJMSServerDeployed(String name) throws ControllerException;
+
+    public abstract boolean isJMSServerUpToDate(String name,
+                                       List queues,
+                                       List topics) throws ControllerException;
+
+    public abstract void deployJMSServer(String name,
+                                List queues,
+                                List topics) throws ControllerException;
+
+    public abstract boolean updateJMSServer(String name,
+                                   List queues,
+                                   List topics) throws ControllerException;
+
+    public abstract void undeployJMSServer(String name) throws ControllerException;
+
+    public abstract boolean isJNDIBindingDeployed(String name) throws ControllerException;
+
+    public abstract void deployJNDIBinding(String name, String jndiName, String jndiAlias, String providerUrl) throws ControllerException;
+
+    public abstract void undeployJNDIBinding(String name) throws ControllerException;
+
+    public abstract boolean isJNDIBindingUpToDate(String name, String jndiName, String jndiAlias, String providerUrl) throws ControllerException;
+
+    public abstract boolean updateJNDIBinding(String name, String jndiName, String jndiAlias, String providerUrl) throws ControllerException;
+
+    public abstract boolean isSharedLibraryDeployed(String name) throws ControllerException;
+
+    public abstract void deploySharedLibrary(String name, String classpath) throws ControllerException;
+
+    public abstract void undeploySharedLibrary(String name) throws ControllerException;
+
+    public abstract boolean isSharedLibraryUpToDate(String name, String classpath) throws ControllerException;
+
+    public abstract boolean updateSharedLibrary(String name, String classpath) throws ControllerException;
+
+}

Added: incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/ControllerException.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/ControllerException.java?rev=1189653&view=auto
==============================================================================
--- incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/ControllerException.java (added)
+++ incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/ControllerException.java Thu Oct 27 07:50:02 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.kalumet.controller.core;
+
+import org.apache.kalumet.KalumetException;
+
+/**
+ * Exception wrapper for the Kalumet controllers.
+ */
+public class ControllerException extends KalumetException {
+
+    /**
+     * Create a controller exception with an explanation message.
+     *
+     * @param message the explanation message.
+     */
+    public ControllerException(String message) {
+        super(message);
+    }
+
+    /**
+     * Create a controller exception with the cause.
+     *
+     * @param cause the cause.
+     */
+    public ControllerException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Create a controller exception with the explanation message and the cause.
+     *
+     * @param message the explanation message.
+     * @param cause the cause.
+     */
+    public ControllerException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}

Added: incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerController.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerController.java?rev=1189653&view=auto
==============================================================================
--- incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerController.java (added)
+++ incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerController.java Thu Oct 27 07:50:02 2011
@@ -0,0 +1,421 @@
+/*
+ * 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.kalumet.controller.core;
+
+import java.util.List;
+
+/**
+ * J2EE application server controller interface.
+ */
+public interface J2EEApplicationServerController {
+
+    /**
+     * Shutdown a J2EE application server.
+     *
+     * @throws ControllerException in case of shutdown failure.
+     */
+    public void shutdown() throws ControllerException;
+
+    /**
+     * Get the current status of a J2EE application server.
+     *
+     * @return the current human readable status.
+     * @throws ControllerException in case of status check failure.
+     */
+    public String status() throws ControllerException;
+
+    /**
+     * Check if an J2EE application server is stopped or not.
+     *
+     * @return true if the J2EE application server is stopped, false if it's running.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isStopped() throws ControllerException;
+
+    /**
+     * Check if a J2EE application is deployed.
+     *
+     * @param path the application local path.
+     * @param name the application name.
+     * @return true if the J2EE application is deployed, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJ2EEApplicationDeployed(String path, String name) throws ControllerException;
+
+    /**
+     * Deploy a J2EE application.
+     *
+     * @param path the J2EE application local path.
+     * @param name the J2EE application name.
+     * @param classLoaderOrder the J2EE application class loader order (PARENT_FIRST/PARENT_LAST).
+     * @param classLoaderPolicy the J2EE application class loader policy (single/multiple).
+     * @param virtualHost the J2EE application virtual host (if applicable).
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deployJ2EEApplication(String path, String name, String classLoaderOrder, String classLoaderPolicy, String virtualHost) throws ControllerException;
+
+    /**
+     * Undeploy a J2EE application.
+     *
+     * @param path the J2EE application local path.
+     * @param name the J2EE application name.
+     * @throws ControllerException in case of undeployment failure.
+     */
+    public void undeployJ2EEApplication(String path, String name) throws ControllerException;
+
+    /**
+     * Redeploy a J2EE application.
+     *
+     * @param path the J2EE application local path.
+     * @param name the J2EE application name.
+     * @throws ControllerException in case of redeployment failure.
+     */
+    public void redeployJ2EEApplication(String path, String name) throws ControllerException;
+
+    /**
+     * Check a JDBC connection pool is deployed.
+     *
+     * @param name the name of the JDBC connection pool.
+     * @return true if the JDBC connection pool is deployed, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJDBCConnectionPoolDeployed(String name) throws ControllerException;
+
+    /**
+     * Check if a JDBC connection pool attributes are up to date.
+     *
+     * @param name the name of the JDBC connection pool.
+     * @param jdbcDriverClassName the JDBC driver class name of the connection pool.
+     * @param capacityIncrement the capacity increment of the JDBC connection pool.
+     * @param initialCapacity the initial capacity of the JDBC connection pool.
+     * @param maxCapacity the max capacity of the JDBC connection pool.
+     * @param username the database username.
+     * @param password the database password.
+     * @param jdbcURL the JDBC URL
+     * @param classPath the class path where to look for the driver
+     * @return true if all attributes are up to date, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJDBCConnectionPoolUpToDate(String name,
+                                           String jdbcDriverClassName,
+                                           int capacityIncrement,
+                                           int initialCapacity,
+                                           int maxCapacity,
+                                           String username,
+                                           String password,
+                                           String jdbcURL,
+                                           String classPath) throws ControllerException;
+
+    /**
+     * Update a JDBC connection pool.
+     *
+     * @param name the name of the JDBC connection pool.
+     * @param jdbcDriverClassName the JDBC driver of the connection pool.
+     * @param capacityIncrement the capacity increment of the JDBC connection pool.
+     * @param initialCapacity the initial capacity of the JDBC connection pool.
+     * @param maxCapacity the max capacity of the JDBC connection pool.
+     * @param username the database username.
+     * @param password the database password.
+     * @param jdbcURL the JDBC URL of the database.
+     * @param classPath the class path of JDBC driver.
+     * @return true if the JDBC connection pool has been updated, false else.
+     * @throws ControllerException in case of update failure.
+     */
+    public boolean updateJDBCConnectionPool(String name,
+                                            String jdbcDriverClassName,
+                                            int capacityIncrement,
+                                            int initialCapacity,
+                                            int maxCapacity,
+                                            String username,
+                                            String password,
+                                            String jdbcURL,
+                                            String classPath) throws ControllerException;
+
+    /**
+     * Deploy a JDBC connection pool.
+     *
+     * @param name the name of the JDBC connection pool.
+     * @param jdbcDriverClassName the JDBC driver of the connection pool.
+     * @param capacityIncrement the capacity increment of the JDBC connection pool.
+     * @param initialCapacity the initial capacity of the JDBC connection pool.
+     * @param maxCapacity the max capacity of the JDBC connection pool.
+     * @param username the database username.
+     * @param password the database password.
+     * @param jdbcURL the database JDBC URL.
+     * @param classPath the class path of the JDBC driver.
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deployJDBCConnectionPool(String name,
+                                         String jdbcDriverClassName,
+                                         int capacityIncrement,
+                                         int initialCapacity,
+                                         int maxCapacity,
+                                         String username,
+                                         String password,
+                                         String jdbcURL,
+                                         String classPath) throws ControllerException;
+
+    /**
+     * Undeploy a JDBC connection pool.
+     *
+     * @param name the name of the JDBC connection pool.
+     * @throws ControllerException in case of an undeployment failure.
+     */
+    public void undeployJDBCConnectionPool(String name) throws ControllerException;
+
+    /**
+     * Check if a JDBC data source is deployed.
+     *
+     * @param name the name of the JDBC data source.
+     * @return true if the JDBC data source is deployed, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJDBCDataSourceDeployed(String name) throws ControllerException;
+
+    /**
+     * Check if a JDBC data source is up to date.
+     *
+     * @param name the name of the JDBC data source.
+     * @param jdbcConnectionPool the name of the JDBC connection pool used by the data source.
+     * @param jdbcURL the JDBC URL of the data source.
+     * @param helpClassName the helper class name of the JDBC data source.
+     * @return true if the JDBC data source is up to date, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJDBCDataSourceUpToDate(String name,
+                                            String jdbcConnectionPool,
+                                            String jdbcURL,
+                                            String helpClassName) throws ControllerException;
+
+    /**
+     * Deploy a JDBC data source.
+     *
+     * @param name the name of the JDBC data source.
+     * @param jdbcConnectionPool the name of the JDBC connection pool used by the data source.
+     * @param jdbcURL the JDBC URL of the data source.
+     * @param helpClassName the helper class name of the JDBC data source.
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deployJDBCDataSource(String name,
+                                     String jdbcConnectionPool,
+                                     String jdbcURL,
+                                     String helpClassName) throws ControllerException;
+
+    /**
+     * Undeploy a JDBC data source.
+     *
+     * @param name the name of the JDBC data source.
+     * @throws ControllerException in case of undeployment failure.
+     */
+    public void undeployJDBCDataSource(String name) throws ControllerException;
+
+    /**
+     * Update a JDBC data source.
+     *
+     * @param name the name of the JDBC data source.
+     * @param jdbcConnectionPool the name of the JDBC connection pool used by the data source.
+     * @param jdbcURL the JDBC URL of the data source.
+     * @param helperClassName the helper class name of the data source.
+     * @return true if the JDBC data source has been updated, false else.
+     * @throws ControllerException in case of update failure.
+     */
+    public boolean updateJDBCDataSource(String name,
+                                        String jdbcConnectionPool,
+                                        String jdbcURL,
+                                        String helperClassName) throws ControllerException;
+
+    /**
+     * Check if a JMS connection factory is deployed.
+     *
+     * @param name the name of the JMS connection factory.
+     * @return true if the JMS connection factory is deployed, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJMSConnectionFactoryDeployed(String name) throws ControllerException;
+
+    /**
+     * Deploy a JMS connection factory.
+     *
+     * @param name the name of the JMS connection factory.
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deployJMSConnectionFactory(String name) throws ControllerException;
+
+    /**
+     * Undeploy a JMS connection factory.
+     *
+     * @param name the name of the JMS connection factory.
+     * @throws ControllerException in case of undeployment failure.
+     */
+    public void undeployJMSConnectionFactory(String name) throws ControllerException;
+
+    /**
+     * Check if a JMS server is deployed.
+     *
+     * @param name the name of the JMS server.
+     * @return true if the JMS server is deployed, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJMSServerDeployed(String name) throws ControllerException;
+
+    /**
+     * Check if a JMS server is up to date.
+     *
+     * @param name the name of the JMS server.
+     * @param queues the queues deployed in the JMS server.
+     * @param topics the topics deployed in the JMS server.
+     * @return true if the JMS server is up to date, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJMSServerUpToDate(String name,
+                                       List queues,
+                                       List topics) throws ControllerException;
+
+    /**
+     * Deploy a JMS server.
+     *
+     * @param name the name of the JMS server.
+     * @param queues the queues to deploy in the JMS server.
+     * @param topics the topics to deploy in the JMS server.
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deployJMSServer(String name,
+                                List queues,
+                                List topics) throws ControllerException;
+
+    /**
+     * Update a JMS server.
+     *
+     * @param name the name of the JMS server.
+     * @param queues the queues in the JMS server.
+     * @param topics the topics in the JMS server.
+     * @return true if the JMS server has been updated, false else.
+     * @throws ControllerException in case of update failure.
+     */
+    public boolean updateJMSServer(String name,
+                                List queues,
+                                List topics) throws ControllerException;
+
+    /**
+     * Undeploy a JMS server.
+     *
+     * @param name the name of the JMS server.
+     * @throws ControllerException in case of undeployment failure.
+     */
+    public void undeployJMSServer(String name) throws ControllerException;
+
+    /**
+     * Check if a JNDI binding is deployed.
+     *
+     * @param name the name of the JNDI binding
+     * @return true if the JNDI binding is deployed, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJNDIBindingDeployed(String name) throws ControllerException;
+
+    /**
+     * Deploy a JNDI binding.
+     *
+     * @param name the name of the JNDI binding.
+     * @param jndiName the name of the JNDI resources.
+     * @param jndiAlias the alias name to the JNDI resources.
+     * @param providerUrl the URL provider of the JNDI binding.
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deployJNDIBinding(String name, String jndiName, String jndiAlias, String providerUrl) throws ControllerException;
+
+    /**
+     * Undeploy a JNDI binding.
+     *
+     * @param name the name of the JNDI binding.
+     * @throws ControllerException in case of undeployment failure.
+     */
+    public void undeployJNDIBinding(String name) throws ControllerException;
+
+    /**
+     * Check if a JNDI binding is up to date.
+     *
+     * @param name the name of the JNDI binding.
+     * @param jndiName the name of the JNDI resources.
+     * @param jndiAlias the alias name to the JNDI resources.
+     * @param providerUrl the URL provider of the JNDI binding.
+     * @return true if the JNDI binding is up to date, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isJNDIBindingUpToDate(String name, String jndiName, String jndiAlias, String providerUrl) throws ControllerException;
+
+    /**
+     * Update a JNDI binding.
+     *
+     * @param name the name of the JNDI binding.
+     * @param jndiName the name of the JNDI resources.
+     * @param jndiAlias the alias name to the JNDI resources.
+     * @param providerUrl the URL provider of the JNDI binding.
+     * @return true if the JNDI binding has been updated, false else.
+     * @throws ControllerException in case of update failure.
+     */
+    public boolean updateJNDIBinding(String name, String jndiName, String jndiAlias, String providerUrl) throws ControllerException;
+
+    /**
+     * Check if a shared library is deployed.
+     *
+     * @param name the name of the shared library.
+     * @return true if the shared library is deployed, false else.
+     * @throws ControllerException
+     */
+    public boolean isSharedLibraryDeployed(String name) throws ControllerException;
+
+    /**
+     * Deploy a shared library.
+     *
+     * @param name the name of the shared library.
+     * @param classpath the class path of the shared library.
+     * @throws ControllerException in case of deployment failure.
+     */
+    public void deploySharedLibrary(String name, String classpath) throws ControllerException;
+
+    /**
+     * Undeploy a shared library.
+     *
+     * @param name the name of the shared library.
+     * @throws ControllerException in case of undeployment failure.
+     */
+    public void undeploySharedLibrary(String name) throws ControllerException;
+
+    /**
+     * Check if a shared library is up to date.
+     *
+     * @param name the name of the shared library.
+     * @param classpath the class path of the shared library.
+     * @return true if the shared library is up to date, false else.
+     * @throws ControllerException in case of status check failure.
+     */
+    public boolean isSharedLibraryUpToDate(String name, String classpath) throws ControllerException;
+
+    /**
+     * Update a shared library.
+     *
+     * @param name the name of the shared library.
+     * @param classpath the class path of the shared library.
+     * @return true if the shared library has been updated, false else.
+     * @throws ControllerException in case of update failure.
+     */
+    public boolean updateSharedLibrary(String name, String classpath) throws ControllerException;
+
+}

Added: incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerControllerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerControllerFactory.java?rev=1189653&view=auto
==============================================================================
--- incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerControllerFactory.java (added)
+++ incubator/kalumet/trunk/controller/core/src/main/java/org/apache/kalumet/controller/core/J2EEApplicationServerControllerFactory.java Thu Oct 27 07:50:02 2011
@@ -0,0 +1,60 @@
+/*
+ * 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.kalumet.controller.core;
+
+import com.sun.org.apache.xpath.internal.operations.Variable;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.J2EEApplicationServer;
+import org.apache.kalumet.utils.VariableUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * Factory to get a <code>J2EEApplicationServerController</code>.
+ */
+public class J2EEApplicationServerControllerFactory {
+
+    private final static transient Logger LOGGER = LoggerFactory.getLogger(J2EEApplicationServerControllerFactory.class);
+
+    public static J2EEApplicationServerController getController(Environment environment, J2EEApplicationServer server) throws ControllerException {
+        LOGGER.debug("Connecting to {}", VariableUtils.replace(server.getJmxurl(), environment.getVariables()));
+        String jmxUrl = VariableUtils.replace(server.getJmxurl(), environment.getVariables());
+        String adminUser = VariableUtils.replace(server.getAdminuser(), environment.getVariables());
+        String adminPassword = VariableUtils.replace(server.getAdminpassword(), environment.getVariables());
+        J2EEApplicationServerController controller = null;
+        try {
+           Class controllerClass = Class.forName(server.getClassname());
+           Constructor controllerConstructor = controllerClass.getConstructor(new Class[] { String.class, String.class, String.class, String.class, Boolean.class });
+           controller = (J2EEApplicationServerController) controllerConstructor.newInstance(new Object[] { jmxUrl, adminUser, adminPassword, server.getName(), new Boolean(environment.getJ2EEApplicationServers().isCluster()) });
+        }
+        catch (Exception e) {
+            LOGGER.error("Can't initialize controller", e);
+            if (e != null) {
+                throw new ControllerException("Can't initialize controller", e);
+            } else {
+                throw new ControllerException("Can't initialize controller. Check if the J2EE application server libraries are present in the agent classpath and check the agent log");
+            }
+        }
+        return controller;
+
+    }
+
+}

Added: incubator/kalumet/trunk/controller/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/controller/pom.xml?rev=1189653&view=auto
==============================================================================
--- incubator/kalumet/trunk/controller/pom.xml (added)
+++ incubator/kalumet/trunk/controller/pom.xml Thu Oct 27 07:50:02 2011
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.kalumet</groupId>
+        <artifactId>kalumet</artifactId>
+        <version>0.6-incubating</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.kalumet.controller</groupId>
+    <artifactId>controller</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Kalumet :: Controller</name>
+
+    <modules>
+        <module>core</module>
+    </modules>
+
+</project>
\ No newline at end of file

Modified: incubator/kalumet/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/pom.xml?rev=1189653&r1=1189652&r2=1189653&view=diff
==============================================================================
--- incubator/kalumet/trunk/pom.xml (original)
+++ incubator/kalumet/trunk/pom.xml Thu Oct 27 07:50:02 2011
@@ -37,6 +37,7 @@
     <modules>
         <module>common</module>
         <module>utils</module>
+        <module>controller</module>
         <module>agent</module>
     </modules>