geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1375681 - in /geronimo/server/branches/3.0: framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/ framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ p...
Date Tue, 21 Aug 2012 17:40:00 GMT
Author: gawor
Date: Tue Aug 21 17:39:59 2012
New Revision: 1375681

URL: http://svn.apache.org/viewvc?rev=1375681&view=rev
Log:
GERONIMO-6381: Exponse additional method to update EBA archive only

Modified:
    geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
    geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
    geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
    geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
    geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java?rev=1375681&r1=1375680&r2=1375681&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
Tue Aug 21 17:39:59 2012
@@ -36,8 +36,24 @@ public interface EBADeploymentManager {
     
     public void updateEBAContent(AbstractName applicationGBeanName, long bundleId, File bundleFile)
throws Exception;
     
+    /**
+     * Attempts to hot swap classes of a single bundle within the OSGi application.
+     *  
+     * @param bundleId id of the bundle to update.
+     * @param file file containing updated class files of the bundle.
+     * @param updateArchive indicates if the application archive file should be updated with
the changes. 
+     */
     public boolean hotSwapEBAContent(AbstractName applicationGBeanName, long bundleId, File
changesFile, boolean updateArchive) throws Exception;
-    
+
+    /**
+     * Updates OSGi application archive with new bundle contents.
+     *  
+     * @param bundleId id of the bundle to update.
+     * @param file file containing partial or full contents of the bundle.
+     * @param partial true if file contains partial bundle contents. False, otherwise.  
+     */
+    public boolean updateEBAArchive(AbstractName applicationGBeanName, long bundleId, File
file, boolean partial) throws Exception;
+
     public AbstractName getApplicationGBeanName(Artifact configurationId);
     
 }

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java?rev=1375681&r1=1375680&r2=1375681&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
Tue Aug 21 17:39:59 2012
@@ -326,6 +326,12 @@ public abstract class ExtendedDeployment
         String[] argumentTypes = new String[] {long.class.getName(), File.class.getName(),
boolean.class.getName()};
         return (Boolean) kernel.invoke(applicationGBeanName, "hotSwapApplicationContent",
arguments, argumentTypes);
     }
+        
+    public boolean updateEBAArchive(AbstractName applicationGBeanName, long bundleId, File
file, boolean partial) throws Exception {
+        Object[] arguments = new Object[] {bundleId, file, partial};
+        String[] argumentTypes = new String[] {long.class.getName(), File.class.getName(),
boolean.class.getName()};
+        return (Boolean) kernel.invoke(applicationGBeanName, "updateApplicationArchive",
arguments, argumentTypes);
+    }
     
     /**
      * Returns application gbean name for the specified configuration id of the OSGi application.

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=1375681&r1=1375680&r2=1375681&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
Tue Aug 21 17:39:59 2012
@@ -204,32 +204,35 @@ public class RemoteDeploymentManager ext
     }
 
     @Override
-    public void updateEBAContent(AbstractName applicationGBeanName, long bundleId, File bundleFile)
throws GBeanNotFoundException, NoSuchOperationException, Exception{
-        if(!isSameMachine) {
-            throw new UnsupportedOperationException("Update EBA content operation is not
supportted from a remote JMX connection");
-        }
-        
+    public void updateEBAContent(AbstractName applicationGBeanName, long bundleId, File bundleFile)
throws Exception {
+        isSameMachine("updateEBAContent");
         super.updateEBAContent(applicationGBeanName, bundleId, bundleFile);
     }
     
     @Override
-    public boolean hotSwapEBAContent(AbstractName applicationGBeanName, long bundleId, File
changesFile, boolean updateArchive) throws GBeanNotFoundException, NoSuchOperationException,
Exception{
-        if(!isSameMachine) {
-            throw new UnsupportedOperationException("Update EBA content operation is not
supportted from a remote JMX connection");
-        }
-        
+    public boolean hotSwapEBAContent(AbstractName applicationGBeanName, long bundleId, File
changesFile, boolean updateArchive) throws Exception {
+        isSameMachine("hotSwapEBAContent");
         return super.hotSwapEBAContent(applicationGBeanName, bundleId, changesFile, updateArchive);
     }
+        
+    @Override
+    public boolean updateEBAArchive(AbstractName applicationGBeanName, long bundleId, File
file, boolean partial) throws Exception {
+        isSameMachine("updateEBAArchive");
+        return super.updateEBAArchive(applicationGBeanName, bundleId, file, partial);
+    }
     
     @Override
     public long recordInstall(File bundleFile, String gourpId, int startLevel) throws IOException
{
-        if(!isSameMachine) {
-            throw new UnsupportedOperationException("recordBundle operation is not supportted
from a remote JMX connection.");
-        }
-        
+        isSameMachine("recordInstall");
         return super.recordInstall(bundleFile, gourpId, startLevel);
     }
     
+    private void isSameMachine(String operation) {
+        if (!isSameMachine) {
+            throw new UnsupportedOperationException(operation + " operation is not supported
from a remote JMX connection.");
+        }
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
     public static final String GBEAN_REF_MODULE_CONFIGURERS = "ModuleConfigurers";
 

Modified: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java?rev=1375681&r1=1375680&r2=1375681&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
(original)
+++ geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
Tue Aug 21 17:39:59 2012
@@ -213,6 +213,32 @@ public class ApplicationGBean implements
         return updateHelper.updateBundleClasses(targetBundle, changesFile, updateArchive);
     }
    
+    /*
+     * Update application archive with new bundle contents.
+     * 
+     * @param bundleId id of the bundle to update.
+     * @param file file containing new contents of the bundle. The file can contain partial
or full contents.
+     * @param partial true if file contains partial contents. False, otherwise.
+     */
+    public synchronized boolean updateApplicationArchive(long bundleId, File file, boolean
partial) throws Exception {
+        Bundle targetBundle = findBundle(bundleId);
+        if (targetBundle == null) {
+            throw new IllegalArgumentException("Could not find bundle with id " + bundleId
+ " in the application");
+        }
+        try {
+            if (partial) {
+                updateHelper.updateEBAPartial(targetBundle, file);
+            } else {
+                updateHelper.updateEBA(targetBundle, file);
+            }
+            return true;
+        } catch (Exception e) {
+            LOG.warn("Error updating application archive with the new contents. " +
+                     "Changes made might be gone next time the application or server is restarted.",
e);
+            return false;
+        }
+    }
+        
     protected File getApplicationArchive() throws IOException {
         File ebaArchive = installer.getApplicationLocation(configId);
         if (ebaArchive == null || !ebaArchive.exists()) {

Modified: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java?rev=1375681&r1=1375680&r2=1375681&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
(original)
+++ geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
Tue Aug 21 17:39:59 2012
@@ -185,41 +185,8 @@ public class ApplicationUpdateHelper {
         }
         
         if (updateArchive) {
-            File ebaArchive = applicationGBean.getApplicationArchive();
-            
-            String bundleNameInApp = getBundleNameInArchive(targetBundle);
-            
-            LOG.debug("Updating {} application archive with new contents for {}", ebaArchive,
bundleNameInApp);
-            
             try {
-                if (ebaArchive.isDirectory()) {
-                    // eba is a directory
-                    File bundleFile = new File(ebaArchive, bundleNameInApp);
-                    if (!bundleFile.exists()) {
-                        throw new IOException("Unable to locate " + bundleNameInApp + " in
" + ebaArchive);
-                    }
-                    if (bundleFile.isFile()) {
-                        // bundle file is a file - update the jar file
-                        File updatedBundleFile = createUpdateJarFileDirectory(changesFile,
ebaArchive, bundleNameInApp);
-                        try {
-                            updateApplicationDirectory(ebaArchive, updatedBundleFile, bundleNameInApp);
-                        } finally {
-                            deleteFile(updatedBundleFile);
-                        }
-                    } else {
-                        // bundle file is a directory - just update class files
-                        ZipFile zipFile = new ZipFile(changesFile);
-                        JarUtils.unzipToDirectory(zipFile, bundleFile);
-                    }
-                } else {
-                    // eba is an file                   
-                    File updatedBundleFile = createUpdateJarFileArchive(changesFile, ebaArchive,
bundleNameInApp);
-                    try {
-                        updateApplicationArchive(ebaArchive, updatedBundleFile, bundleNameInApp);
-                    } finally {
-                        deleteFile(updatedBundleFile);
-                    }
-                }
+                updateEBAPartial(targetBundle, changesFile);
             } catch (Exception e) {
                 LOG.warn("Error updating application archive with the new contents. " +
                          "Changes made might be gone next time the application or server
is restarted.", e);
@@ -229,6 +196,43 @@ public class ApplicationUpdateHelper {
         return true;
     }
     
+    protected void updateEBAPartial(Bundle targetBundle, File changesFile) throws IOException
{
+        File ebaArchive = applicationGBean.getApplicationArchive();
+            
+        String bundleNameInApp = getBundleNameInArchive(targetBundle);
+            
+        LOG.debug("Updating {} application archive with new contents for {}", ebaArchive,
bundleNameInApp);
+            
+        if (ebaArchive.isDirectory()) {
+            // eba is a directory
+            File bundleFile = new File(ebaArchive, bundleNameInApp);
+            if (!bundleFile.exists()) {
+                throw new IOException("Unable to locate " + bundleNameInApp + " in " + ebaArchive);
+            }
+            if (bundleFile.isFile()) {
+                // bundle file is a file - update the jar file
+                File updatedBundleFile = createUpdateJarFileDirectory(changesFile, ebaArchive,
bundleNameInApp);
+                try {
+                    updateApplicationDirectory(ebaArchive, updatedBundleFile, bundleNameInApp);
+                } finally {
+                    deleteFile(updatedBundleFile);
+                }
+            } else {
+                // bundle file is a directory - just update class files
+                ZipFile zipFile = new ZipFile(changesFile);
+                JarUtils.unzipToDirectory(zipFile, bundleFile);
+            }
+        } else {
+            // eba is an file                   
+            File updatedBundleFile = createUpdateJarFileArchive(changesFile, ebaArchive,
bundleNameInApp);
+            try {
+                updateApplicationArchive(ebaArchive, updatedBundleFile, bundleNameInApp);
+            } finally {
+                deleteFile(updatedBundleFile);
+            }
+        }        
+    }
+    
     private boolean hotSwapClasses(Bundle bundle, File changesFile) {
         String bundleName = bundle.getSymbolicName();
         
@@ -478,7 +482,7 @@ public class ApplicationUpdateHelper {
         }
     }
     
-    private void updateEBA(Bundle bundle, File newBundleFile) throws IOException {
+    protected void updateEBA(Bundle bundle, File newBundleFile) throws IOException {
         File ebaArchive = applicationGBean.getApplicationArchive();
 
         String bundleNameInApp = getBundleNameInArchive(bundle);



Mime
View raw message