[jboss-svn-commits] JBL Code SVN: r29880 - in labs/jbossesb/trunk/product/tools/jonplugin: as4/src/main/resources/META-INF and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 30 12:45:47 EDT 2009


Author: kevin.conner at jboss.com
Date: 2009-10-30 12:45:47 -0400 (Fri, 30 Oct 2009)
New Revision: 29880

Added:
   labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBDeploymentComponent.java
   labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5DeploymentComponent.java
Removed:
   labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java
   labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java
Modified:
   labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBComponent.java
   labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/resources/META-INF/rhq-plugin.xml
   labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5Component.java
   labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/resources/META-INF/rhq-plugin.xml
   labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/AbstractDeploymentComponent.java
   labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBDiscoveryComponent.java
Log:
Fix deployment component to support discoverDeployedPackages: JBESB-2920

Deleted: labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -1,322 +0,0 @@
-package org.jbosson.plugins.jbossesb;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.mc4j.ems.connection.bean.EmsBean;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.content.PackageDetailsKey;
-import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
-import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
-import org.rhq.core.domain.content.transfer.DeployPackageStep;
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
-import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceStatus;
-import org.rhq.core.pluginapi.content.ContentContext;
-import org.rhq.core.pluginapi.content.ContentFacet;
-import org.rhq.core.pluginapi.content.ContentServices;
-import org.rhq.core.pluginapi.event.EventContext;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.operation.OperationContext;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.plugins.jbossas.JBossASServerComponent;
-import org.rhq.plugins.jbossas.util.FileContentDelegate;
-import org.rhq.plugins.jmx.JMXComponent;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-
-/**
- * Component for ESB package deployment.
- *
- * @author Tom Cunningham
- * @param <T>
- */
-public class DeploymentComponent extends MBeanResourceComponent<JMXComponent> implements 
-	OperationFacet, DeleteResourceFacet, ContentFacet {
-    public static final String JBOSS_WEB_NAME = "jbossWebName";
-    private EmsBean jbossWebMBean;
-    private File configPath;
-
-    private ResourceContext resourceContext;
-    private ContentContext contentContext;
-    private OperationContext operationContext;
-    private EventContext eventContext;
-    
-    // The following constants reference the exact name of the package types as defined in the plugin descriptor
-    private static final String PACKAGE_TYPE_PATCH = "cumulativePatch";
-    private static final String PACKAGE_TYPE_LIBRARY = "library";
-
-
-    private static final String RESOURCE_TYPE_ESB = "JBoss ESB Deployments";
-
-    public File getConfigurationPath() {
-        return this.configPath;
-    }
-        
-    public CreateResourceReport createResource(CreateResourceReport report) {
-        String resourceTypeName = report.getResourceType().getName();
-
-        if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-        	esbCreate(report, resourceTypeName);
-        } else {
-            throw new UnsupportedOperationException("Unknown Resource type: " + resourceTypeName);
-        }
-
-        return report;
-    }
-
-    private void esbCreate(CreateResourceReport report, String resourceTypeName) {
-        ResourcePackageDetails details = report.getPackageDetails();
-        PackageDetailsKey key = details.getKey();
-        String archiveName = key.getName();
-
-        try {
-            // First check to see if the file name has the correct extension. Reject if the user attempts to
-            // deploy a WAR file with a bad extension.
-            String expectedExtension;
-            if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-                expectedExtension = "esb";
-            } else {
-            	expectedExtension = "";
-            }
-            
-            int lastPeriod = archiveName.lastIndexOf(".");
-            String extension = archiveName.substring(lastPeriod + 1);
-            if (lastPeriod == -1 || !expectedExtension.equals(extension)) {
-                report.setStatus(CreateResourceStatus.FAILURE);
-                report.setErrorMessage("Incorrect extension specified on filename [" + archiveName + "]. Expected ["
-                    + expectedExtension + "]");
-                return;
-            }
-
-            Configuration deployTimeConfiguration = details.getDeploymentTimeConfiguration();
-            String deployDirectory = deployTimeConfiguration.getSimple("deployDirectory").getStringValue();
-
-            // Verify the user did not enter a path that represents a security issue:
-            // - No absolute directories; must be relative to the configuration path
-            // - Cannot contain parent directory references
-            File testPath = new File(deployDirectory);
-
-            if (testPath.isAbsolute()) {
-                throw new RuntimeException("Path to deploy (deployDirectory) must be a relative path. Path specified: "
-                    + deployDirectory);
-            }
-
-            if (deployDirectory.contains("..")) {
-                throw new RuntimeException(
-                    "Path to deploy (deployDirectory) may not reference the parent directory. Path specified: "
-                        + deployDirectory);
-            }
-
-            // Perform the deployment
-            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath() + File.separator
-                + deployDirectory), "", details.getPackageTypeName());
-
-            PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");
-
-            if (zipProperty != null && zipProperty.getBooleanValue() != null) {
-                boolean zip = zipProperty.getBooleanValue();
-
-                File tempDir = resourceContext.getTemporaryDirectory();
-                File tempFile = new File(tempDir.getAbsolutePath(), "esb.bin");
-                OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));
-
-                ContentServices contentServices = contentContext.getContentServices();
-                contentServices
-                    .downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);
-
-                osForTempDir.close();
-
-                // check for content 
-                boolean valid = isOfType(tempFile, resourceTypeName);
-                if (!valid) {
-                    report.setStatus(CreateResourceStatus.FAILURE);
-                    report.setErrorMessage("Expected a " + resourceTypeName
-                        + " file, but its format/content did not match");
-                    return;
-                }
-
-                InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
-                deployer.createContent(details, isForTempDir, !zip, false);
-
-                // Resource key should match the following:      
-                // EAR: jboss.management.local:J2EEServer=Local,j2eeType=J2EEApplication,name=rhq.ear      
-                // WAR: jboss.management.local:J2EEApplication=null,J2EEServer=Local,j2eeType=WebModule,name=embedded-console.war
-
-                String resourceKey;
-                if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-                    resourceKey = "jboss.esb:deployment="
-                        + archiveName;
-                } 
-
-                report.setResourceName(archiveName);
-                //report.setResourceKey(resourceKey);
-                report.setStatus(CreateResourceStatus.SUCCESS);
-                sleepAfterConfigXmlUpdate();
-            } else {
-                report.setStatus(CreateResourceStatus.FAILURE);
-                report.setErrorMessage("Zipped property is required");
-            }
-        } catch (Throwable t) {
-            log.error("Error deploying application for report: " + report, t);
-            report.setException(t);
-            report.setStatus(CreateResourceStatus.FAILURE);
-        }
-    }
-
-    /**
-     * Check to see if the passed file is actually in jar format and contains a 
-     * <ul>
-     * <li>WEB-INF/web.xml for .war </li>
-     * <li>META-INF/application.xml for .ear</li>
-     * <li>META-INF/jboss.service.xml for .sar</li>
-     * </ul>
-     * @param file File to check
-     * @param type Type to match - see RESOURCE_TYPE_SAR, RESOURCE_TYPE_WAR and RESOURCE_TYPE_EAR
-     * @return true is the file is in jar format and matches the type
-     */
-    private boolean isOfType(File file, String type) {
-        JarFile jfile = null;
-        try {
-            jfile = new JarFile(file);
-            JarEntry entry;
-            if (RESOURCE_TYPE_ESB.equals(type))
-                entry = jfile.getJarEntry("META-INF/jboss-esb.xml");
-            else {
-                entry = null; // unknown type
-                log.warn("isOfType: " + type + " is unknown - not a valid file");
-            }
-
-            if (entry != null)
-                return true;
-
-            return false;
-        } catch (Exception e) {
-            log.info(e.getMessage());
-            return false;
-        } finally {
-            if (jfile != null)
-                try {
-                    jfile.close();
-                } catch (IOException e) {
-                    log.info("Exception when trying to close the war file: " + e.getMessage());
-                }
-        }
-    }
-    
-    private void sleepAfterConfigXmlUpdate() {
-        // JBNADM-1984 - The contract with this method is that the newly created managed resource should be discoverable.
-        //               Wait here so JBoss can recognize that the new managed resource has been created.
-        try {
-            Thread.sleep(5000L);
-        } catch (InterruptedException e) {
-            log.info("Sleep after Resource create interrupted", e);
-        }
-    }
-    
-    @Override
-	public AvailabilityType getAvailability() {
-        //        JBossASTomcatServerComponent parentTomcatComponent = (JBossASTomcatServerComponent) super.resourceContext
-        //            .getParentResourceComponent();
-        //        EmsConnection connection = parentTomcatComponent.getEmsConnection();
-        boolean isreg = bean.isRegistered();
-        return isreg ? AvailabilityType.UP : AvailabilityType.DOWN;
-    }
-    
-    /**
-     * Recursively deletes a series of files. Any directories found in the list of files will be recursively deleted as
-     * well.
-     *
-     * @param contents list of files to delete
-     */
-    public static void deleteDirectoryContents(File[] contents) {
-        for (File file : contents) {
-            if (file.isDirectory()) {
-                deleteDirectoryContents(file.listFiles());
-            }
-
-            file.delete();
-        }
-    }
-    
-	public void deleteResource() throws Exception {
-        Configuration pluginConfiguration = super.resourceContext.getPluginConfiguration();
-        String fullFileName = pluginConfiguration.getSimple("deployment").getStringValue();
-        
-        ESBComponent jbossASComponent = (ESBComponent) super.resourceContext.getParentResourceComponent();
-        //File deploymentFile = jbossASComponent.getDeploymentFilePath(super.resourceContext.getResourceKey());
-
-        File file = new File(jbossASComponent.getConfigurationPath() + "/deploy/" + fullFileName);
-
-        if (!file.exists()) {
-            throw new Exception("Cannot find application file to delete: " + fullFileName);
-        }
-
-        if (file.isDirectory()) {
-            deleteDirectoryContents(file.listFiles());
-        }
-
-        boolean result = file.delete();
-
-        if (!result) {
-            throw new Exception("File delete call returned unsuccessful with no further detail");
-        }
-	}
-
-	public DeployPackagesResponse deployPackages(
-			Set<ResourcePackageDetails> packages,
-			ContentServices contentServices) {
-        ContentResponseResult overallResult = ContentResponseResult.SUCCESS;
-        List<DeployIndividualPackageResponse> individualResponses = new ArrayList<DeployIndividualPackageResponse>(
-            packages.size());
-
-        for (ResourcePackageDetails pkg : packages) {
-            log.info("Attempting to deploy package: " + pkg);
-
-            String packageTypeName = pkg.getPackageTypeName();
-            if (packageTypeName.equals(PACKAGE_TYPE_LIBRARY)) {
-                throw new UnsupportedOperationException("Deployment of new libraries is not supported by the plugin.");
-            }
-        }
-
-        DeployPackagesResponse response = new DeployPackagesResponse(overallResult);
-        response.getPackageResponses().addAll(individualResponses);
-
-        return response;
-	}
-
-	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
-		return null;
-	}
-
-	public List<DeployPackageStep> generateInstallationSteps(
-			ResourcePackageDetails packageDetails) {
-		return null;
-	}
-
-	public RemovePackagesResponse removePackages(
-			Set<ResourcePackageDetails> packages) {
-		return null;
-	}
-
-	public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
-		return null;
-	}
-
-}

Modified: labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBComponent.java
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBComponent.java	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -7,79 +7,23 @@
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
 
 import org.rhq.core.domain.configuration.Configuration;
 import org.rhq.core.domain.configuration.PropertySimple;
 import org.rhq.core.domain.content.PackageDetailsKey;
-import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
-import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
-import org.rhq.core.domain.content.transfer.DeployPackageStep;
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
 import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.measurement.AvailabilityType;
 import org.rhq.core.domain.resource.CreateResourceStatus;
-import org.rhq.core.pluginapi.content.ContentContext;
-import org.rhq.core.pluginapi.content.ContentFacet;
 import org.rhq.core.pluginapi.content.ContentServices;
-import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
 import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.operation.OperationContext;
-import org.rhq.core.pluginapi.util.ResponseTimeLogParser;
 import org.rhq.plugins.jbossas.JBossASServerComponent;
 import org.rhq.plugins.jbossas.util.FileContentDelegate;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
 
 public class ESBComponent extends AbstractESBComponent {
-   private static final String RESOURCE_TYPE_ESB = "JBoss ESB Deployment";
-
-   private String configSet;
-   private ResponseTimeLogParser logParser;
-   private File configPath;
-
-   private ContentContext contentContext;
-   private OperationContext operationContext;
-   public static final String CONTEXT_ROOT_CONFIG_PROP = "contextRoot";
-   // The following constants reference the exact name of the package types as defined in the plugin descriptor
-   private static final String PACKAGE_TYPE_PATCH = "cumulativePatch";
-   private static final String PACKAGE_TYPE_LIBRARY = "library";
-
-   public static final String CONFIGURATION_PATH_CONFIG_PROP = "configurationPath";
-   public static final String SCRIPT_PREFIX_CONFIG_PROP = "scriptPrefix";
-   public static final String CONFIGURATION_SET_CONFIG_PROP = "configurationSet";
-
-   public static final String JBOSS_HOME_DIR_CONFIG_PROP = "jbossHomeDir";
-
-   
-   @Override
-   public void start(ResourceContext context) {
-	   super.start(context);
-	   Configuration pluginConfig = context.getPluginConfiguration();
-
-	   this.configPath = getConfigurationPath();
-	   if (!this.configPath.exists()) {
-		   throw new InvalidPluginConfigurationException("Configuration path '" + configPath + "' does not exist.");
-	   }
-	   this.configSet = pluginConfig.getSimpleValue(CONFIGURATION_SET_CONFIG_PROP, this.configPath.getName());
-   }
-   
    public File getConfigurationPath() {
 	   JBossASServerComponent jass = (JBossASServerComponent) resourceContext.getParentResourceComponent();
 	   return jass.getConfigurationPath();
    }
-     
-   @Override
-   public AvailabilityType getAvailability() {
-	   AvailabilityType av = super.getAvailability();
-	   return av;
-   }
-      
+
    protected void esbCreate(CreateResourceReport report, String resourceTypeName) {
         ResourcePackageDetails details = report.getPackageDetails();
         PackageDetailsKey key = details.getKey();
@@ -124,8 +68,8 @@
 	        }
 
 	        // Perform the deployment
-            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath() + File.separator
-            	+ deployDirectory), "", details.getPackageTypeName());
+            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath(), deployDirectory),
+                    "", details.getPackageTypeName());
 
             PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");
 
@@ -165,64 +109,4 @@
             report.setStatus(CreateResourceStatus.FAILURE);
         }
     }
-	
-	public CreateResourceReport createResource(CreateResourceReport report) {
-        String resourceTypeName = report.getResourceType().getName();
-
-        if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-            esbCreate(report, resourceTypeName);
-        } else {
-            throw new UnsupportedOperationException("Unknown Resource type: " + resourceTypeName);
-        }
-
-        // JBNADM-1984 - The contract with this method is that the newly created managed resource should be discoverable.
-        //               Wait here so JBoss can recognize that the new managed resource has been created.
-        try {
-            Thread.sleep(5000L);
-        } catch (InterruptedException e) {
-            log.info("Sleep after datasource create interrupted", e);
-        }
-
-        return report;
-    }
-
-	public DeployPackagesResponse deployPackages(
-			Set<ResourcePackageDetails> packages,
-			ContentServices contentServices) {
-        ContentResponseResult overallResult = ContentResponseResult.SUCCESS;
-        List<DeployIndividualPackageResponse> individualResponses = new ArrayList<DeployIndividualPackageResponse>(
-            packages.size());
-
-        for (ResourcePackageDetails pkg : packages) {
-            log.info("Attempting to deploy package: " + pkg);
-
-            String packageTypeName = pkg.getPackageTypeName();
-            if (packageTypeName.equals(PACKAGE_TYPE_LIBRARY)) {
-                throw new UnsupportedOperationException("Deployment of new libraries is not supported by the plugin.");
-            }
-        }
-
-        DeployPackagesResponse response = new DeployPackagesResponse(overallResult);
-        response.getPackageResponses().addAll(individualResponses);
-
-        return response;
-	}
-
-	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
-		return null;
-	}
-
-	public List<DeployPackageStep> generateInstallationSteps(
-			ResourcePackageDetails packageDetails) {
-		return null;
-	}
-
-	public RemovePackagesResponse removePackages(
-			Set<ResourcePackageDetails> packages) {
-        throw new UnsupportedOperationException();
-	}
-
-	public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
-        throw new UnsupportedOperationException();
-	}
 }

Copied: labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBDeploymentComponent.java (from rev 29865, labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java)
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBDeploymentComponent.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/java/org/jbosson/plugins/jbossesb/ESBDeploymentComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -0,0 +1,150 @@
+package org.jbosson.plugins.jbossesb;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.plugins.jbossas.util.FileContentDelegate;
+
+/**
+ * Component for ESB package deployment.
+ *
+ * @author Tom Cunningham
+ * @param <T>
+ */
+public class ESBDeploymentComponent extends AbstractDeploymentComponent {
+    protected void esbCreate(CreateResourceReport report, String resourceTypeName) {
+        ResourcePackageDetails details = report.getPackageDetails();
+        PackageDetailsKey key = details.getKey();
+        String archiveName = key.getName();
+
+        try {
+            // First check to see if the file name has the correct extension. Reject if the user attempts to
+            // deploy a WAR file with a bad extension.
+            String expectedExtension;
+            if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
+                expectedExtension = "esb";
+            } else {
+            	expectedExtension = "";
+            }
+            
+            int lastPeriod = archiveName.lastIndexOf(".");
+            String extension = archiveName.substring(lastPeriod + 1);
+            if (lastPeriod == -1 || !expectedExtension.equals(extension)) {
+                report.setStatus(CreateResourceStatus.FAILURE);
+                report.setErrorMessage("Incorrect extension specified on filename [" + archiveName + "]. Expected ["
+                    + expectedExtension + "]");
+                return;
+            }
+
+            Configuration deployTimeConfiguration = details.getDeploymentTimeConfiguration();
+            String deployDirectory = deployTimeConfiguration.getSimple("deployDirectory").getStringValue();
+
+            // Verify the user did not enter a path that represents a security issue:
+            // - No absolute directories; must be relative to the configuration path
+            // - Cannot contain parent directory references
+            File testPath = new File(deployDirectory);
+
+            if (testPath.isAbsolute()) {
+                throw new RuntimeException("Path to deploy (deployDirectory) must be a relative path. Path specified: "
+                    + deployDirectory);
+            }
+
+            if (deployDirectory.contains("..")) {
+                throw new RuntimeException(
+                    "Path to deploy (deployDirectory) may not reference the parent directory. Path specified: "
+                        + deployDirectory);
+            }
+
+            // Perform the deployment
+            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath(), deployDirectory),
+                    "", details.getPackageTypeName());
+
+            PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");
+
+            if (zipProperty != null && zipProperty.getBooleanValue() != null) {
+                boolean zip = zipProperty.getBooleanValue();
+
+                File tempDir = resourceContext.getTemporaryDirectory();
+                File tempFile = new File(tempDir.getAbsolutePath(), "esb.bin");
+                OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));
+
+                ContentServices contentServices = contentContext.getContentServices();
+                contentServices
+                    .downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);
+
+                osForTempDir.close();
+
+                // check for content 
+                boolean valid = isOfType(tempFile, resourceTypeName);
+                if (!valid) {
+                    report.setStatus(CreateResourceStatus.FAILURE);
+                    report.setErrorMessage("Expected a " + resourceTypeName
+                        + " file, but its format/content did not match");
+                    return;
+                }
+
+                InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
+                deployer.createContent(details, isForTempDir, !zip, false);
+
+                // Resource key should match the following:      
+                // EAR: jboss.management.local:J2EEServer=Local,j2eeType=J2EEApplication,name=rhq.ear      
+                // WAR: jboss.management.local:J2EEApplication=null,J2EEServer=Local,j2eeType=WebModule,name=embedded-console.war
+
+                String resourceKey;
+                if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
+                    resourceKey = "jboss.esb:deployment="
+                        + archiveName;
+                } 
+
+                report.setResourceName(archiveName);
+                //report.setResourceKey(resourceKey);
+                report.setStatus(CreateResourceStatus.SUCCESS);
+                sleepAfterConfigXmlUpdate();
+            } else {
+                report.setStatus(CreateResourceStatus.FAILURE);
+                report.setErrorMessage("Zipped property is required");
+            }
+        } catch (Throwable t) {
+            log.error("Error deploying application for report: " + report, t);
+            report.setException(t);
+            report.setStatus(CreateResourceStatus.FAILURE);
+        }
+    }
+    
+	public void deleteResource() throws Exception {
+        Configuration pluginConfiguration = super.resourceContext.getPluginConfiguration();
+        String fullFileName = pluginConfiguration.getSimple("deployment").getStringValue();
+        
+        ESBComponent jbossASComponent = (ESBComponent) super.resourceContext.getParentResourceComponent();
+        //File deploymentFile = jbossASComponent.getDeploymentFilePath(super.resourceContext.getResourceKey());
+
+        final File deploy = new File(jbossASComponent.getConfigurationPath(), "deploy");
+        final File file = new File(deploy, fullFileName);
+
+        if (!file.exists()) {
+            throw new Exception("Cannot find application file to delete: " + fullFileName);
+        }
+
+        if (file.isDirectory()) {
+            deleteDirectoryContents(file.listFiles());
+        }
+
+        boolean result = file.delete();
+
+        if (!result) {
+            throw new Exception("File delete call returned unsuccessful with no further detail");
+        }
+	}
+}

Modified: labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/resources/META-INF/rhq-plugin.xml	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as4/src/main/resources/META-INF/rhq-plugin.xml	2009-10-30 16:45:47 UTC (rev 29880)
@@ -69,7 +69,7 @@
       </content>
    <service name="JBoss ESB Deployment"
       discovery="org.jbosson.plugins.jbossesb.ESBDiscoveryComponent"
-      class="org.jbosson.plugins.jbossesb.DeploymentComponent"
+      class="org.jbosson.plugins.jbossesb.ESBDeploymentComponent"
       description="Statistics for JBoss ESB Deployments"
       creationDataType="content"	
       createDeletePolicy="both">

Deleted: labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -1,322 +0,0 @@
-package org.jbosson.plugins.jbossesb;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.mc4j.ems.connection.bean.EmsBean;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.content.PackageDetailsKey;
-import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
-import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
-import org.rhq.core.domain.content.transfer.DeployPackageStep;
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
-import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceStatus;
-import org.rhq.core.pluginapi.content.ContentContext;
-import org.rhq.core.pluginapi.content.ContentFacet;
-import org.rhq.core.pluginapi.content.ContentServices;
-import org.rhq.core.pluginapi.event.EventContext;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.operation.OperationContext;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.plugins.jbossas5.ApplicationServerComponent;
-import org.rhq.plugins.jbossas5.util.FileContentDelegate;
-import org.rhq.plugins.jmx.JMXComponent;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-
-/**
- * Component for ESB package deployment.
- *
- * @author Tom Cunningham
- * @param <T>
- */
-public class DeploymentComponent extends MBeanResourceComponent<JMXComponent> implements 
-	OperationFacet, DeleteResourceFacet, ContentFacet {
-    public static final String JBOSS_WEB_NAME = "jbossWebName";
-    private EmsBean jbossWebMBean;
-    private File configPath;
-
-    private ResourceContext resourceContext;
-    private ContentContext contentContext;
-    private OperationContext operationContext;
-    private EventContext eventContext;
-    
-    // The following constants reference the exact name of the package types as defined in the plugin descriptor
-    private static final String PACKAGE_TYPE_PATCH = "cumulativePatch";
-    private static final String PACKAGE_TYPE_LIBRARY = "library";
-
-
-    private static final String RESOURCE_TYPE_ESB = "JBoss ESB Deployments";
-
-    public File getConfigurationPath() {
-        return this.configPath;
-    }
-        
-    public CreateResourceReport createResource(CreateResourceReport report) {
-        String resourceTypeName = report.getResourceType().getName();
-
-        if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-        	esbCreate(report, resourceTypeName);
-        } else {
-            throw new UnsupportedOperationException("Unknown Resource type: " + resourceTypeName);
-        }
-
-        return report;
-    }
-
-    private void esbCreate(CreateResourceReport report, String resourceTypeName) {
-        ResourcePackageDetails details = report.getPackageDetails();
-        PackageDetailsKey key = details.getKey();
-        String archiveName = key.getName();
-
-        try {
-            // First check to see if the file name has the correct extension. Reject if the user attempts to
-            // deploy a WAR file with a bad extension.
-            String expectedExtension;
-            if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-                expectedExtension = "esb";
-            } else {
-            	expectedExtension = "";
-            }
-            
-            int lastPeriod = archiveName.lastIndexOf(".");
-            String extension = archiveName.substring(lastPeriod + 1);
-            if (lastPeriod == -1 || !expectedExtension.equals(extension)) {
-                report.setStatus(CreateResourceStatus.FAILURE);
-                report.setErrorMessage("Incorrect extension specified on filename [" + archiveName + "]. Expected ["
-                    + expectedExtension + "]");
-                return;
-            }
-
-            Configuration deployTimeConfiguration = details.getDeploymentTimeConfiguration();
-            String deployDirectory = deployTimeConfiguration.getSimple("deployDirectory").getStringValue();
-
-            // Verify the user did not enter a path that represents a security issue:
-            // - No absolute directories; must be relative to the configuration path
-            // - Cannot contain parent directory references
-            File testPath = new File(deployDirectory);
-
-            if (testPath.isAbsolute()) {
-                throw new RuntimeException("Path to deploy (deployDirectory) must be a relative path. Path specified: "
-                    + deployDirectory);
-            }
-
-            if (deployDirectory.contains("..")) {
-                throw new RuntimeException(
-                    "Path to deploy (deployDirectory) may not reference the parent directory. Path specified: "
-                        + deployDirectory);
-            }
-
-            // Perform the deployment
-            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath() + File.separator
-                + deployDirectory), "", details.getPackageTypeName());
-
-            PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");
-
-            if (zipProperty != null && zipProperty.getBooleanValue() != null) {
-                boolean zip = zipProperty.getBooleanValue();
-
-                File tempDir = resourceContext.getTemporaryDirectory();
-                File tempFile = new File(tempDir.getAbsolutePath(), "esb.bin");
-                OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));
-
-                ContentServices contentServices = contentContext.getContentServices();
-                contentServices
-                    .downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);
-
-                osForTempDir.close();
-
-                // check for content 
-                boolean valid = isOfType(tempFile, resourceTypeName);
-                if (!valid) {
-                    report.setStatus(CreateResourceStatus.FAILURE);
-                    report.setErrorMessage("Expected a " + resourceTypeName
-                        + " file, but its format/content did not match");
-                    return;
-                }
-
-                InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
-                deployer.createContent(details, isForTempDir, !zip, false);
-
-                // Resource key should match the following:      
-                // EAR: jboss.management.local:J2EEServer=Local,j2eeType=J2EEApplication,name=rhq.ear      
-                // WAR: jboss.management.local:J2EEApplication=null,J2EEServer=Local,j2eeType=WebModule,name=embedded-console.war
-
-                String resourceKey;
-                if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-                    resourceKey = "jboss.esb:deployment="
-                        + archiveName;
-                } 
-
-                report.setResourceName(archiveName);
-                //report.setResourceKey(resourceKey);
-                report.setStatus(CreateResourceStatus.SUCCESS);
-                sleepAfterConfigXmlUpdate();
-            } else {
-                report.setStatus(CreateResourceStatus.FAILURE);
-                report.setErrorMessage("Zipped property is required");
-            }
-        } catch (Throwable t) {
-            log.error("Error deploying application for report: " + report, t);
-            report.setException(t);
-            report.setStatus(CreateResourceStatus.FAILURE);
-        }
-    }
-
-    /**
-     * Check to see if the passed file is actually in jar format and contains a 
-     * <ul>
-     * <li>WEB-INF/web.xml for .war </li>
-     * <li>META-INF/application.xml for .ear</li>
-     * <li>META-INF/jboss.service.xml for .sar</li>
-     * </ul>
-     * @param file File to check
-     * @param type Type to match - see RESOURCE_TYPE_SAR, RESOURCE_TYPE_WAR and RESOURCE_TYPE_EAR
-     * @return true is the file is in jar format and matches the type
-     */
-    private boolean isOfType(File file, String type) {
-        JarFile jfile = null;
-        try {
-            jfile = new JarFile(file);
-            JarEntry entry;
-            if (RESOURCE_TYPE_ESB.equals(type))
-                entry = jfile.getJarEntry("META-INF/jboss-esb.xml");
-            else {
-                entry = null; // unknown type
-                log.warn("isOfType: " + type + " is unknown - not a valid file");
-            }
-
-            if (entry != null)
-                return true;
-
-            return false;
-        } catch (Exception e) {
-            log.info(e.getMessage());
-            return false;
-        } finally {
-            if (jfile != null)
-                try {
-                    jfile.close();
-                } catch (IOException e) {
-                    log.info("Exception when trying to close the war file: " + e.getMessage());
-                }
-        }
-    }
-    
-    private void sleepAfterConfigXmlUpdate() {
-        // JBNADM-1984 - The contract with this method is that the newly created managed resource should be discoverable.
-        //               Wait here so JBoss can recognize that the new managed resource has been created.
-        try {
-            Thread.sleep(5000L);
-        } catch (InterruptedException e) {
-            log.info("Sleep after Resource create interrupted", e);
-        }
-    }
-    
-    @Override
-	public AvailabilityType getAvailability() {
-        //        JBossASTomcatServerComponent parentTomcatComponent = (JBossASTomcatServerComponent) super.resourceContext
-        //            .getParentResourceComponent();
-        //        EmsConnection connection = parentTomcatComponent.getEmsConnection();
-        boolean isreg = bean.isRegistered();
-        return isreg ? AvailabilityType.UP : AvailabilityType.DOWN;
-    }
-    
-    /**
-     * Recursively deletes a series of files. Any directories found in the list of files will be recursively deleted as
-     * well.
-     *
-     * @param contents list of files to delete
-     */
-    public static void deleteDirectoryContents(File[] contents) {
-        for (File file : contents) {
-            if (file.isDirectory()) {
-                deleteDirectoryContents(file.listFiles());
-            }
-
-            file.delete();
-        }
-    }
-    
-	public void deleteResource() throws Exception {
-        Configuration pluginConfiguration = super.resourceContext.getPluginConfiguration();
-        String fullFileName = pluginConfiguration.getSimple("deployment").getStringValue();
-        
-        ESB5Component jbossASComponent = (ESB5Component) super.resourceContext.getParentResourceComponent();
-        //File deploymentFile = jbossASComponent.getDeploymentFilePath(super.resourceContext.getResourceKey());
-
-        File file = new File(jbossASComponent.getConfigurationPath() + "/deploy/" + fullFileName);
-
-        if (!file.exists()) {
-            throw new Exception("Cannot find application file to delete: " + fullFileName);
-        }
-
-        if (file.isDirectory()) {
-            deleteDirectoryContents(file.listFiles());
-        }
-
-        boolean result = file.delete();
-
-        if (!result) {
-            throw new Exception("File delete call returned unsuccessful with no further detail");
-        }
-	}
-
-	public DeployPackagesResponse deployPackages(
-			Set<ResourcePackageDetails> packages,
-			ContentServices contentServices) {
-        ContentResponseResult overallResult = ContentResponseResult.SUCCESS;
-        List<DeployIndividualPackageResponse> individualResponses = new ArrayList<DeployIndividualPackageResponse>(
-            packages.size());
-
-        for (ResourcePackageDetails pkg : packages) {
-            log.info("Attempting to deploy package: " + pkg);
-
-            String packageTypeName = pkg.getPackageTypeName();
-            if (packageTypeName.equals(PACKAGE_TYPE_LIBRARY)) {
-                throw new UnsupportedOperationException("Deployment of new libraries is not supported by the plugin.");
-            }
-        }
-
-        DeployPackagesResponse response = new DeployPackagesResponse(overallResult);
-        response.getPackageResponses().addAll(individualResponses);
-
-        return response;
-	}
-
-	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
-		return null;
-	}
-
-	public List<DeployPackageStep> generateInstallationSteps(
-			ResourcePackageDetails packageDetails) {
-		return null;
-	}
-
-	public RemovePackagesResponse removePackages(
-			Set<ResourcePackageDetails> packages) {
-		return null;
-	}
-
-	public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
-		return null;
-	}
-
-}

Modified: labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5Component.java
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5Component.java	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5Component.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -47,7 +47,7 @@
     ResourceContext rc = jass.getResourceContext();
     Configuration config = rc.getPluginConfiguration();
 
-    String configurationPath = config.getSimpleValue("homeDir", null);
+    String configurationPath = config.getSimpleValue("serverHomeDir", null);
 
     return new File(configurationPath);
   }
@@ -96,8 +96,8 @@
 	        }
 
 	        // Perform the deployment
-          FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath() + File.separator
-          	+ deployDirectory), "", details.getPackageTypeName());
+          FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath(),deployDirectory),
+                  "", details.getPackageTypeName());
 
           PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");
 

Copied: labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5DeploymentComponent.java (from rev 29865, labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/DeploymentComponent.java)
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5DeploymentComponent.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/java/org/jbosson/plugins/jbossesb/ESB5DeploymentComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -0,0 +1,173 @@
+package org.jbosson.plugins.jbossesb;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.ContentResponseResult;
+import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.event.EventContext;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.operation.OperationContext;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.plugins.jbossas5.util.FileContentDelegate;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * Component for ESB package deployment.
+ *
+ * @author Tom Cunningham
+ * @param <T>
+ */
+public class ESB5DeploymentComponent extends AbstractDeploymentComponent {
+    protected void esbCreate(CreateResourceReport report, String resourceTypeName) {
+        ResourcePackageDetails details = report.getPackageDetails();
+        PackageDetailsKey key = details.getKey();
+        String archiveName = key.getName();
+
+        try {
+            // First check to see if the file name has the correct extension. Reject if the user attempts to
+            // deploy a WAR file with a bad extension.
+            String expectedExtension;
+            if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
+                expectedExtension = "esb";
+            } else {
+            	expectedExtension = "";
+            }
+            
+            int lastPeriod = archiveName.lastIndexOf(".");
+            String extension = archiveName.substring(lastPeriod + 1);
+            if (lastPeriod == -1 || !expectedExtension.equals(extension)) {
+                report.setStatus(CreateResourceStatus.FAILURE);
+                report.setErrorMessage("Incorrect extension specified on filename [" + archiveName + "]. Expected ["
+                    + expectedExtension + "]");
+                return;
+            }
+
+            Configuration deployTimeConfiguration = details.getDeploymentTimeConfiguration();
+            String deployDirectory = deployTimeConfiguration.getSimple("deployDirectory").getStringValue();
+
+            // Verify the user did not enter a path that represents a security issue:
+            // - No absolute directories; must be relative to the configuration path
+            // - Cannot contain parent directory references
+            File testPath = new File(deployDirectory);
+
+            if (testPath.isAbsolute()) {
+                throw new RuntimeException("Path to deploy (deployDirectory) must be a relative path. Path specified: "
+                    + deployDirectory);
+            }
+
+            if (deployDirectory.contains("..")) {
+                throw new RuntimeException(
+                    "Path to deploy (deployDirectory) may not reference the parent directory. Path specified: "
+                        + deployDirectory);
+            }
+
+            // Perform the deployment
+            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath(), deployDirectory),
+                    "", details.getPackageTypeName());
+
+            PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");
+
+            if (zipProperty != null && zipProperty.getBooleanValue() != null) {
+                boolean zip = zipProperty.getBooleanValue();
+
+                File tempDir = resourceContext.getTemporaryDirectory();
+                File tempFile = new File(tempDir.getAbsolutePath(), "esb.bin");
+                OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));
+
+                ContentServices contentServices = contentContext.getContentServices();
+                contentServices
+                    .downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);
+
+                osForTempDir.close();
+
+                // check for content 
+                boolean valid = isOfType(tempFile, resourceTypeName);
+                if (!valid) {
+                    report.setStatus(CreateResourceStatus.FAILURE);
+                    report.setErrorMessage("Expected a " + resourceTypeName
+                        + " file, but its format/content did not match");
+                    return;
+                }
+
+                InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
+                deployer.createContent(details, isForTempDir, !zip, false);
+
+                // Resource key should match the following:      
+                // EAR: jboss.management.local:J2EEServer=Local,j2eeType=J2EEApplication,name=rhq.ear      
+                // WAR: jboss.management.local:J2EEApplication=null,J2EEServer=Local,j2eeType=WebModule,name=embedded-console.war
+
+                String resourceKey;
+                if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
+                    resourceKey = "jboss.esb:deployment="
+                        + archiveName;
+                } 
+
+                report.setResourceName(archiveName);
+                //report.setResourceKey(resourceKey);
+                report.setStatus(CreateResourceStatus.SUCCESS);
+                sleepAfterConfigXmlUpdate();
+            } else {
+                report.setStatus(CreateResourceStatus.FAILURE);
+                report.setErrorMessage("Zipped property is required");
+            }
+        } catch (Throwable t) {
+            log.error("Error deploying application for report: " + report, t);
+            report.setException(t);
+            report.setStatus(CreateResourceStatus.FAILURE);
+        }
+    }
+    
+	public void deleteResource() throws Exception {
+        Configuration pluginConfiguration = super.resourceContext.getPluginConfiguration();
+        String fullFileName = pluginConfiguration.getSimple("deployment").getStringValue();
+        
+        ESB5Component jbossASComponent = (ESB5Component) super.resourceContext.getParentResourceComponent();
+        //File deploymentFile = jbossASComponent.getDeploymentFilePath(super.resourceContext.getResourceKey());
+
+        final File deploy = new File(jbossASComponent.getConfigurationPath(), "deploy");
+        final File file = new File(deploy, fullFileName);
+
+        if (!file.exists()) {
+            throw new Exception("Cannot find application file to delete: " + fullFileName);
+        }
+
+        if (file.isDirectory()) {
+            deleteDirectoryContents(file.listFiles());
+        }
+
+        boolean result = file.delete();
+
+        if (!result) {
+            throw new Exception("File delete call returned unsuccessful with no further detail");
+        }
+	}
+}

Modified: labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/resources/META-INF/rhq-plugin.xml	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/as5/src/main/resources/META-INF/rhq-plugin.xml	2009-10-30 16:45:47 UTC (rev 29880)
@@ -69,7 +69,7 @@
       </content>
    <service name="JBoss ESB Deployment"
       discovery="org.jbosson.plugins.jbossesb.ESBDiscoveryComponent"
-      class="org.jbosson.plugins.jbossesb.DeploymentComponent"
+      class="org.jbosson.plugins.jbossesb.ESB5DeploymentComponent"
       description="Statistics for JBoss ESB Deployments"
       creationDataType="content"	
       createDeletePolicy="both">

Modified: labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/AbstractDeploymentComponent.java
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/AbstractDeploymentComponent.java	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/AbstractDeploymentComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -1,14 +1,10 @@
 package org.jbosson.plugins.jbossesb;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.jar.JarEntry;
@@ -16,7 +12,6 @@
 
 import org.mc4j.ems.connection.bean.EmsBean;
 import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
 import org.rhq.core.domain.content.PackageDetailsKey;
 import org.rhq.core.domain.content.PackageType;
 import org.rhq.core.domain.content.transfer.ContentResponseResult;
@@ -26,7 +21,6 @@
 import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
 import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
 import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceStatus;
 import org.rhq.core.pluginapi.content.ContentContext;
 import org.rhq.core.pluginapi.content.ContentFacet;
 import org.rhq.core.pluginapi.content.ContentServices;
@@ -43,25 +37,39 @@
 public abstract class AbstractDeploymentComponent extends MBeanResourceComponent<JMXComponent> implements 
 	OperationFacet, DeleteResourceFacet, ContentFacet {
     public static final String JBOSS_WEB_NAME = "jbossWebName";
-    private EmsBean jbossWebMBean;
-    private File configPath;
+    protected EmsBean jbossWebMBean;
+    protected File configPath;
+    private static final String PKG_TYPE_FILE = "file";
+    private static final String ARCHITECTURE = "noarch";
 
-    private ResourceContext resourceContext;
-    private ContentContext contentContext;
-    private OperationContext operationContext;
-    private EventContext eventContext;
+    protected ResourceContext resourceContext;
+    protected ContentContext contentContext;
+    protected OperationContext operationContext;
+    protected EventContext eventContext;
     
     // The following constants reference the exact name of the package types as defined in the plugin descriptor
-    private static final String PACKAGE_TYPE_PATCH = "cumulativePatch";
-    private static final String PACKAGE_TYPE_LIBRARY = "library";
+    protected static final String PACKAGE_TYPE_PATCH = "cumulativePatch";
+    protected static final String PACKAGE_TYPE_LIBRARY = "library";
 
 
-    private static final String RESOURCE_TYPE_ESB = "JBoss ESB Deployments";
+    protected static final String RESOURCE_TYPE_ESB = "JBoss ESB Deployments";
 
     public File getConfigurationPath() {
         return this.configPath;
     }
         
+    public CreateResourceReport createResource(CreateResourceReport report) {
+        String resourceTypeName = report.getResourceType().getName();
+
+        if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
+        	esbCreate(report, resourceTypeName);
+        } else {
+            throw new UnsupportedOperationException("Unknown Resource type: " + resourceTypeName);
+        }
+
+        return report;
+    }
+    
     /**
      * Check to see if the passed file is actually in jar format and contains a 
      * <ul>
@@ -73,7 +81,7 @@
      * @param type Type to match - see RESOURCE_TYPE_SAR, RESOURCE_TYPE_WAR and RESOURCE_TYPE_EAR
      * @return true is the file is in jar format and matches the type
      */
-    private boolean isOfType(File file, String type) {
+    protected boolean isOfType(File file, String type) {
         JarFile jfile = null;
         try {
             jfile = new JarFile(file);
@@ -102,7 +110,7 @@
         }
     }
     
-    private void sleepAfterConfigXmlUpdate() {
+    protected void sleepAfterConfigXmlUpdate() {
         // JBNADM-1984 - The contract with this method is that the newly created managed resource should be discoverable.
         //               Wait here so JBoss can recognize that the new managed resource has been created.
         try {
@@ -137,47 +145,7 @@
         }
     }
     
-    public void deleteResource() throws Exception {
-    }
-    /*
-	public void deleteResource() throws Exception {
-        Configuration pluginConfiguration = super.resourceContext.getPluginConfiguration();
-        String fullFileName = pluginConfiguration.getSimple("deployment").getStringValue();
-        
-        ESBComponent jbossASComponent = (ESBComponent) super.resourceContext.getParentResourceComponent();
-        //File deploymentFile = jbossASComponent.getDeploymentFilePath(super.resourceContext.getResourceKey());
-
-        File file = new File(jbossASComponent.getConfigurationPath() + "/deploy/" + fullFileName);
-
-        if (!file.exists()) {
-            throw new Exception("Cannot find application file to delete: " + fullFileName);
-        }
-
-        if (file.isDirectory()) {
-            deleteDirectoryContents(file.listFiles());
-        }
-
-        boolean result = file.delete();
-
-        if (!result) {
-            throw new Exception("File delete call returned unsuccessful with no further detail");
-        }
-	}
-	*/
-
-    public CreateResourceReport createResource(CreateResourceReport report) {
-        String resourceTypeName = report.getResourceType().getName();
-
-        if (resourceTypeName.equals(RESOURCE_TYPE_ESB)) {
-        	esbCreate(report, resourceTypeName);
-        } else {
-            throw new UnsupportedOperationException("Unknown Resource type: " + resourceTypeName);
-        }
-
-        return report;
-    }
-    
-    abstract void esbCreate(CreateResourceReport report, String resourceTypeName);
+    protected abstract void esbCreate(CreateResourceReport report, String resourceTypeName);
 	
 	public DeployPackagesResponse deployPackages(
 			Set<ResourcePackageDetails> packages,
@@ -201,10 +169,49 @@
         return response;
 	}
 
-	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
-		return null;
-	}
+    public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
+        final Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();
+        
+        final ResourceContext<JMXComponent> resourceContext = getResourceContext();
+        final Configuration pluginConfiguration = resourceContext.getPluginConfiguration();
 
+        final String fullFileName = pluginConfiguration.getSimple("deployment").getStringValue();
+        
+        if (fullFileName == null) {
+            throw new IllegalStateException("Plugin configuration does not contain the deployment name of the ESB file.");
+        }
+        
+        final String version = getResourceContext().getVersion();
+        
+        /*
+         * For now we assume it is in the deploy directory.  This is not safe but it is
+         * an assumption made in other parts of the codebase and is consistent (for now).
+         * We need to rework this to discover the actual deployment location, but that will
+         * be part of a larger work.
+         */
+        final AbstractESBComponent esbComponent = (AbstractESBComponent) resourceContext.getParentResourceComponent();
+        final File deploy = new File(esbComponent.getConfigurationPath(), "deploy");
+        final File file = new File(deploy, fullFileName);
+        if (file.exists())
+        {
+            // Package name and file name of the application are the same
+            String fileName = new File(fullFileName).getName();
+            
+            PackageDetailsKey key = new PackageDetailsKey(fileName, version, PKG_TYPE_FILE, ARCHITECTURE);
+            ResourcePackageDetails details = new ResourcePackageDetails(key);
+            details.setFileName(fileName);
+            details.setLocation(file.getPath());
+            if (!file.isDirectory())
+                details.setFileSize(file.length());
+            
+            details.setFileCreatedDate(file.lastModified()); // TODO: get created date via SIGAR
+            
+            packages.add(details);
+        }
+        
+        return packages;
+    }
+
 	public List<DeployPackageStep> generateInstallationSteps(
 			ResourcePackageDetails packageDetails) {
 		return null;

Modified: labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBDiscoveryComponent.java
===================================================================
--- labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBDiscoveryComponent.java	2009-10-30 15:45:18 UTC (rev 29879)
+++ labs/jbossesb/trunk/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBDiscoveryComponent.java	2009-10-30 16:45:47 UTC (rev 29880)
@@ -14,9 +14,9 @@
  *
  * @author Tom Cunningham
  */
-public class ESBDiscoveryComponent<T extends JMXComponent> extends MBeanResourceDiscoveryComponent<T> {    
+public class ESBDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> {    
 	@Override
-	public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context) {
+	public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) {
         Set<DiscoveredResourceDetails> jmxResources = super.discoverResources(context);
 
         String versionNumber;



More information about the jboss-svn-commits mailing list