[jboss-cvs] JBossAS SVN: r111183 - in projects/jboss-jca/trunk/rhq/src/main: resources/META-INF and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 15 06:21:58 EDT 2011


Author: gaol
Date: 2011-04-15 06:21:58 -0400 (Fri, 15 Apr 2011)
New Revision: 111183

Modified:
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml
Log:
[JBJCA-541] support to deploy new RAR and *-ds.xml file from GUI console.

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java	2011-04-15 07:49:33 UTC (rev 111182)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java	2011-04-15 10:21:58 UTC (rev 111183)
@@ -21,12 +21,72 @@
  */
 package org.jboss.jca.rhq.core;
 
+import org.jboss.jca.rhq.util.ContainerHelper;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+
 /**
  * A IronJacamarResourceComponent
  * 
  * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
  * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a> 
  */
-public class IronJacamarResourceComponent extends BaseResourceComponent
+public class IronJacamarResourceComponent extends AbstractResourceComponent implements CreateChildResourceFacet
 {
+
+   @Override
+   public Configuration loadResourceConfiguration() throws Exception
+   {
+      return new Configuration();
+   }
+
+   @Override
+   public CreateResourceReport createResource(CreateResourceReport report)
+   {
+
+      ResourceType resType = report.getResourceType();
+      String resName = resType.getName();
+      ResourcePackageDetails pkgDetail = report.getPackageDetails();
+      ContentContext contentContext = getResourceContext().getContentContext();
+      ContentServices contentServices = contentContext.getContentServices();
+      String tmpDir = System.getProperty("java.io.tmpdir");
+      File outFile = new File(tmpDir, pkgDetail.getFileName()); // change to plugin configuration ??
+      OutputStream output;
+      try
+      {
+         output = new FileOutputStream(outFile);
+         contentServices.downloadPackageBitsForChildResource(contentContext, resName, pkgDetail.getKey(), output);
+         Deploy deployer = (Deploy)ContainerHelper.getEmbeddedDiscover();
+         deployer.deploy(outFile.toURI().toURL());
+         
+         String resKey = outFile.getName();
+         
+         // set resource key
+         report.setResourceKey(resKey);
+         
+         // set resource name
+         report.setResourceName(resKey);
+         
+         report.setStatus(CreateResourceStatus.SUCCESS);
+      }
+      catch (Throwable e)
+      {
+         e.printStackTrace();
+         report.setStatus(CreateResourceStatus.FAILURE);
+         report.setErrorMessage(e.getMessage());
+         report.setException(e);
+      }
+      return report;
+   }
 }

Modified: projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-04-15 07:49:33 UTC (rev 111182)
+++ projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-04-15 10:21:58 UTC (rev 111183)
@@ -377,8 +377,10 @@
             <operation name="suspend"
                        description="suspend this RAR"/>
                 
-            <content name="file" displayName="RAR File" category="deployable" isCreationType="true">
-                
+            <content name="rar-file" displayName="RAR File" category="deployable" isCreationType="true">
+                <configuration>
+                  <c:simple-property name="override" displayName="Override?" type="boolean" defaultValue="true"/>
+                </configuration>
             </content>
             
             <resource-configuration>
@@ -489,14 +491,20 @@
         
         <!-- Datasource -->
         <service name="Datasources" discovery="org.jboss.jca.rhq.ds.DsResourceDiscoveryComponent" 
-            class="org.jboss.jca.rhq.ds.DsResourceComponent">
+            class="org.jboss.jca.rhq.ds.DsResourceComponent" createDeletePolicy="both" creationDataType="content">
 
         <plugin-configuration>
             <c:group name="general" displayName="General">
                 <c:simple-property name="jndi-name" description="JNDI Name of the datasource" readOnly="true"/>
             </c:group>
         </plugin-configuration>
-
+        
+        <content name="ds-file" displayName="DataSource File" category="deployable" isCreationType="true">
+            <configuration>
+              <c:simple-property name="override" displayName="Override?" type="boolean" defaultValue="true"/>
+            </configuration>
+        </content>
+            
             <resource-configuration>
                 <c:group name="general" displayName="General">
                     <c:simple-property name="jndi-name" displayName="JNDI Name"/>



More information about the jboss-cvs-commits mailing list