[Carbon-commits] [Carbon-Components] svn commit r68223 - in trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse: . src/main/java/org/wso2/carbon/application/deployer/synapse

isuru at wso2.com isuru at wso2.com
Sat Jun 19 06:40:55 PDT 2010


Author: isuru
Date: Sat Jun 19 06:40:54 2010
New Revision: 68223
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=68223

Log:
updating synapse artifact deployers for apps

Added:
   trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployerConstants.java
   trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppUndeployer.java
Modified:
   trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/pom.xml
   trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployer.java

Modified: trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/pom.xml
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/pom.xml?rev=68223&r1=68222&r2=68223&view=diff
==============================================================================
--- trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/pom.xml	(original)
+++ trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/pom.xml	Sat Jun 19 06:40:54 2010
@@ -112,8 +112,12 @@
                         <Bundle-Vendor>WSO2 Inc</Bundle-Vendor>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                         <Private-Package>
-                            org.wso2.carbon.application.deployer.synapse.*,
+                            org.wso2.carbon.application.deployer.synapse.internal
                         </Private-Package>
+                        <Export-Package>
+                            !org.wso2.carbon.application.deployer.synapse.internal,
+                            org.wso2.carbon.application.deployer.synapse.*
+                        </Export-Package>
                         <Import-Package>
                             org.wso2.carbon.application.deployer.*,
                             org.apache.commons.logging.*,

Modified: trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployer.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployer.java?rev=68223&r1=68222&r2=68223&view=diff
==============================================================================
--- trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployer.java	(original)
+++ trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployer.java	Sat Jun 19 06:40:54 2010
@@ -1,65 +1,66 @@
 package org.wso2.carbon.application.deployer.synapse;
 
-import org.wso2.carbon.application.deployer.AppDeploymentHandler;
 import org.wso2.carbon.application.deployer.CarbonApplication;
 import org.wso2.carbon.application.deployer.AppDeployerUtils;
-import org.wso2.carbon.application.deployer.AppDeployerConstants;
-import org.wso2.carbon.application.deployer.config.Component;
+import org.wso2.carbon.application.deployer.config.Artifact;
+import org.wso2.carbon.application.deployer.config.CappFile;
+import org.wso2.carbon.application.deployer.handler.AppDeploymentHandler;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.util.List;
-import java.io.*;
+import java.io.File;
 
 public class SynapseAppDeployer implements AppDeploymentHandler {
 
     private static final Log log = LogFactory.getLog(SynapseAppDeployer.class);
 
-    public static final String SEQUENCE_TYPE = "sequence";
-    public static final String ENDPOINT_TYPE = "endpoint";
-    public static final String PROXY_SERVICE_TYPE = "proxy-service";
-    public static final String LOCAL_ENTRY_TYPE = "local-entry";
-    public static final String EVENT_SOURCE_TYPE = "event-source";
-    public static final String TASK_TYPE = "task";
-
     /**
      * Deploy the artifacts which can be deployed through this deployer (endpoints, sequences,
      * proxy service etc.).
      *
-     * @param carbonApp - store info in this object after deploying
+     * @param carbonApp - CarbonApplication instance to check for artifacts
      */
     public void deployArtifacts(CarbonApplication carbonApp) {
         log.info("***Synapse App Deployer***");
 
-        List<Component> components = carbonApp.getAppConfig().getComponents();
+        List<Artifact> artifacts = carbonApp.getAppConfig().getApplicationArtifact()
+                .getDependencies();
+
         String artifactPath, destPath;
-        for (Component comp : components) {
-            artifactPath = carbonApp.getExtractedPath() + comp.getId() +
-                    File.separator + comp.getArtifactName();
-            if (SEQUENCE_TYPE.equals(comp.getType())) {
-                destPath = AppDeployerUtils.getSynapseRepo() + AppDeployerConstants.APP_SEQUENCES;
-                carbonApp.addSequence(comp.getArtifactName());
-            } else if (ENDPOINT_TYPE.equals(comp.getType())) {
-                destPath = AppDeployerUtils.getSynapseRepo() + AppDeployerConstants.APP_ENDPOINTS;
-                carbonApp.addEndpoint(comp.getArtifactName());
-            } else if (PROXY_SERVICE_TYPE.equals(comp.getType())) {
-                destPath = AppDeployerUtils.getSynapseRepo() + AppDeployerConstants.APP_PROXY_SERVICES;
-                carbonApp.addProxyService(comp.getArtifactName());
-            } else if (LOCAL_ENTRY_TYPE.equals(comp.getType())) {
-                destPath = AppDeployerUtils.getSynapseRepo() + AppDeployerConstants.APP_LOCAL_ENTRIES;
-                carbonApp.addLocalEntry(comp.getArtifactName());
-            } else if (EVENT_SOURCE_TYPE.equals(comp.getType())) {
-                destPath = AppDeployerUtils.getSynapseRepo() + AppDeployerConstants.APP_EVENTS;
-                carbonApp.addEvent(comp.getArtifactName());
-            } else if (TASK_TYPE.equals(comp.getType())) {
-                destPath = AppDeployerUtils.getSynapseRepo() + AppDeployerConstants.APP_TASKS;
-                carbonApp.addTask(comp.getArtifactName());
+        for (Artifact artifact : artifacts) {
+            if (SynapseAppDeployerConstants.SEQUENCE_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.SEQUENCES_FOLDER;
+            } else if (SynapseAppDeployerConstants.ENDPOINT_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.ENDPOINTS_FOLDER;
+            } else if (SynapseAppDeployerConstants.PROXY_SERVICE_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.PROXY_SERVICES_FOLDER;
+            } else if (SynapseAppDeployerConstants.LOCAL_ENTRY_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.LOCAL_ENTRIES_FOLDER;
+            } else if (SynapseAppDeployerConstants.EVENT_SOURCE_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.EVENTS_FOLDER;
+            } else if (SynapseAppDeployerConstants.TASK_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.TASKS_FOLDER;
             } else {
                 continue;
             }
+
+            List<CappFile> files = artifact.getFiles();
+            if (files.size() != 1) {
+                log.error("Synapse artifact types must have a single file to " +
+                        "be deployed. But " + files.size() + " files found.");
+                continue;
+            }
+            String fileName = artifact.getFiles().get(0).getName();
+            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
             AppDeployerUtils.createDir(destPath);
-            AppDeployerUtils.copyFile(artifactPath, destPath + File.separator +
-                    comp.getArtifactName());
+            AppDeployerUtils.copyFile(artifactPath, destPath + File.separator + fileName);
         }
     }
 }

Added: trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployerConstants.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployerConstants.java?pathrev=68223
==============================================================================
--- (empty file)
+++ trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppDeployerConstants.java	Sat Jun 19 06:40:54 2010
@@ -0,0 +1,20 @@
+package org.wso2.carbon.application.deployer.synapse;
+
+public class SynapseAppDeployerConstants {
+
+    // Application artifact types
+    public static final String SEQUENCE_TYPE = "esb/sequence";
+    public static final String ENDPOINT_TYPE = "esb/endpoint";
+    public static final String PROXY_SERVICE_TYPE = "esb/proxy-service";
+    public static final String LOCAL_ENTRY_TYPE = "esb/local-entry";
+    public static final String EVENT_SOURCE_TYPE = "esb/event-source";
+    public static final String TASK_TYPE = "esb/task";
+
+    // Deployment folders for synapse artifacts
+    public static final String SEQUENCES_FOLDER = "/sequences/";
+    public static final String ENDPOINTS_FOLDER = "/endpoints/";
+    public static final String PROXY_SERVICES_FOLDER = "/proxy-services/";
+    public static final String LOCAL_ENTRIES_FOLDER = "/local-entries/";
+    public static final String EVENTS_FOLDER = "/event-sources/";
+    public static final String TASKS_FOLDER = "/tasks/";
+}

Added: trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppUndeployer.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppUndeployer.java?pathrev=68223
==============================================================================
--- (empty file)
+++ trunk/carbon/components/application-deployers/org.wso2.carbon.application.deployer.synapse/src/main/java/org/wso2/carbon/application/deployer/synapse/SynapseAppUndeployer.java	Sat Jun 19 06:40:54 2010
@@ -0,0 +1,68 @@
+package org.wso2.carbon.application.deployer.synapse;
+
+import org.wso2.carbon.application.deployer.handler.AppUndeploymentHandler;
+import org.wso2.carbon.application.deployer.CarbonApplication;
+import org.wso2.carbon.application.deployer.AppDeployerUtils;
+import org.wso2.carbon.application.deployer.config.Artifact;
+import org.wso2.carbon.application.deployer.config.CappFile;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.io.File;
+
+public class SynapseAppUndeployer implements AppUndeploymentHandler {
+
+    private static final Log log = LogFactory.getLog(SynapseAppUndeployer.class);
+
+    /**
+     * Undeploys Synapse artifacts found in this application. Just delete the files from the
+     * hot folders. Synapse hot deployer will do the rest..
+     *
+     * @param carbonApplication - CarbonApplication instance
+     */
+    public void undeployArtifacts(CarbonApplication carbonApplication) {
+        log.info("Synapse App Undeployer");
+
+        List<Artifact> artifacts = carbonApplication.getAppConfig().getApplicationArtifact()
+                .getDependencies();
+
+        String artifactPath, destPath;
+        for (Artifact artifact : artifacts) {
+            if (SynapseAppDeployerConstants.SEQUENCE_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.SEQUENCES_FOLDER;
+            } else if (SynapseAppDeployerConstants.ENDPOINT_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.ENDPOINTS_FOLDER;
+            } else if (SynapseAppDeployerConstants.PROXY_SERVICE_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.PROXY_SERVICES_FOLDER;
+            } else if (SynapseAppDeployerConstants.LOCAL_ENTRY_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.LOCAL_ENTRIES_FOLDER;
+            } else if (SynapseAppDeployerConstants.EVENT_SOURCE_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.EVENTS_FOLDER;
+            } else if (SynapseAppDeployerConstants.TASK_TYPE.equals(artifact.getType())) {
+                destPath = AppDeployerUtils.getSynapseRepo() +
+                        SynapseAppDeployerConstants.TASKS_FOLDER;
+            } else {
+                continue;
+            }
+
+            List<CappFile> files = artifact.getFiles();
+            if (files.size() != 1) {
+                log.error("AAR and JAXWS service types must have a single file. But " +
+                        files.size() + " files found.");
+                continue;
+            }
+            String fileName = artifact.getFiles().get(0).getName();
+            artifactPath = destPath + File.separator + fileName;
+            File artifactFile = new File(artifactPath);
+            if (artifactFile.exists() && !artifactFile.delete()) {
+                log.warn("Couldn't delete App artifact file : " + artifactPath);
+            }
+        }
+    }
+}



More information about the Carbon-commits mailing list