geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r1083683 - in /geronimo/server/trunk: 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/ framewor...
Date Mon, 21 Mar 2011 06:19:19 GMT
Author: rwonly
Date: Mon Mar 21 06:19:19 2011
New Revision: 1083683

URL: http://svn.apache.org/viewvc?rev=1083683&view=rev
Log:
GERONIMO-5861 Update a bundle within an EBA

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java?rev=1083683&r1=1083682&r2=1083683&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/eba/EBADeploymentManager.java
Mon Mar 21 06:19:19 2011
@@ -17,7 +17,24 @@
 
 package org.apache.geronimo.deployment.plugin.eba;
 
+import java.io.File;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.repository.Artifact;
+
 
 public interface EBADeploymentManager {
-    public String[] getAvailableEBAModuleIds();
+    
+    public Artifact[] getEBAConfigurationIds();
+    
+    public long[] getEBAContentBundleIds(AbstractName applicationGBeanName) throws GBeanNotFoundException,
NoSuchOperationException, Exception;
+    
+    public String getEBAContentBundleSymbolicName(AbstractName applicationGBeanName, long
bundleId) throws GBeanNotFoundException, NoSuchOperationException, Exception;
+    
+    public void updateEBAContent(AbstractName applicationGBeanName, long bundleId, File newfile)
throws GBeanNotFoundException, NoSuchOperationException, Exception;
+    
+    public AbstractName getApplicationGBeanName(Artifact configurationId);
+    
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java?rev=1083683&r1=1083682&r2=1083683&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/ExtendedDeploymentManager.java
Mon Mar 21 06:19:19 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -33,7 +34,10 @@ import org.apache.geronimo.deployment.sp
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
 import org.apache.geronimo.kernel.InvalidGBeanException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.NoSuchStoreException;
@@ -254,19 +258,15 @@ public abstract class ExtendedDeployment
             kernel.getProxyManager().destroyProxy(archiver);
         }
     }
-
-    public String[] getAvailableEBAModuleIds(){
-        
+    
+    public Artifact[] getEBAConfigurationIds(){
         List<AbstractName> stores = configurationManager.listStores();
-        
         if (stores.isEmpty()) {
             return null;
         }
         
-        ArrayList<String> result = new ArrayList<String>();
-        
+        ArrayList<Artifact> result = new ArrayList<Artifact>();
         for (AbstractName store : stores) {
-            
             List infos;
             try {
                 infos = configurationManager.listConfigurations(store);
@@ -274,21 +274,43 @@ public abstract class ExtendedDeployment
                     ConfigurationInfo configInfo = (ConfigurationInfo) info;
                     
                     if (ConfigurationModuleType.EBA.equals(configInfo.getType())) {
-                        String name = configInfo.getConfigID().toString();
-                        
-                        result.add(name);
+                        result.add(configInfo.getConfigID());
                     }
                 }
-                
             } catch (NoSuchStoreException e) {
                 e.printStackTrace();
             }
-
         }
 
-        return result.size() == 0 ? null : result.toArray(new String[result.size()]);
+        return result.size() == 0 ? null : result.toArray(new Artifact[result.size()]);
+    }
+    
+    public long[] getEBAContentBundleIds(AbstractName applicationGBeanName) throws GBeanNotFoundException,
NoSuchOperationException, Exception{
+        long[] ids = (long[])kernel.getAttribute(applicationGBeanName, "applicationContentBundleIds");
         
-
+        return ids;
+    }
+    
+    public String getEBAContentBundleSymbolicName(AbstractName applicationGBeanName, long
bundleId) throws GBeanNotFoundException, NoSuchOperationException, Exception{
+        Object name = kernel.invoke(applicationGBeanName, "getApplicationContentBundleSymbolicName",
new Object[]{bundleId}, new String[]{long.class.getName()});
+        if (name!=null) return (String)name;
+        
+        return null;
+    }
+    
+    /**
+     * Only support local bundle update
+     */
+    public void updateEBAContent(AbstractName applicationGBeanName, long bundleId, File newfile)
throws GBeanNotFoundException, NoSuchOperationException, Exception{
+        kernel.invoke(applicationGBeanName, "updateApplicationContent", new Object[]{bundleId,
newfile.toURI()}, new String[]{long.class.getName(), newfile.toURI().getClass().getName()});
+    }
+    
+    public AbstractName getApplicationGBeanName(Artifact configurationId) {
+        Set<AbstractName> applicationGBeanNames = kernel.listGBeans(new AbstractNameQuery(configurationId,
Collections.EMPTY_MAP, "org.apache.geronimo.aries.builder.ApplicationGBean"));
+        if (applicationGBeanNames.size()!=1){
+            throw new IllegalStateException("An EBA should have one and only one ApplicationGean
object");
+        }
+        return applicationGBeanNames.iterator().next();
     }
     
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=1083683&r1=1083682&r2=1083683&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
Mon Mar 21 06:19:19 2011
@@ -42,6 +42,8 @@ import org.apache.geronimo.deployment.sp
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.system.jmx.KernelDelegate;
 import org.slf4j.Logger;
@@ -201,6 +203,15 @@ public class RemoteDeploymentManager ext
         return super.installLibrary(args[0], groupId);
     }
 
+    @Override
+    public void updateEBAContent(AbstractName applicationGBeanName, long bundleId, File newfile)
throws GBeanNotFoundException, NoSuchOperationException, Exception{
+        if(!isSameMachine) {
+            throw new UnsupportedOperationException("Update EBA content operation is not
supportted from a remote JMX connection");
+        }
+        
+        super.updateEBAContent(applicationGBeanName, bundleId, newfile);
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
     public static final String GBEAN_REF_MODULE_CONFIGURERS = "ModuleConfigurers";
 

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?rev=1083683&r1=1083682&r2=1083683&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
Mon Mar 21 06:19:19 2011
@@ -70,7 +70,7 @@ public class StartCommand extends Comman
                     //TODO might be a hack
                     List kids = loadChildren(kernel, moduleID.toString());
 
-                    // Build a response obect containg the started configuration and a list
of it's contained modules
+                    // Build a response object containing the started configuration and a
list of it's contained modules
                     TargetModuleIDImpl id = new TargetModuleIDImpl(modules[i].getTarget(),
module.getModuleID(),
                             (String[]) kids.toArray(new String[kids.size()]));
                     if (isWebApp(kernel, moduleID.toString())) {
@@ -92,7 +92,7 @@ public class StartCommand extends Comman
                             //TODO might be a hack
                             List kidsChild = loadChildren(kernel, config.toString());
 
-                            // Build a response obect containg the started configuration
and a list of it's contained modules
+                            // Build a response object containing the started configuration
and a list of it's contained modules
                             TargetModuleIDImpl idChild = new TargetModuleIDImpl(null, config.toString(),
                                     (String[]) kidsChild.toArray(new String[kidsChild.size()]));
                             if (isWebApp(kernel, config.toString())) {

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java?rev=1083683&r1=1083682&r2=1083683&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
Mon Mar 21 06:19:19 2011
@@ -16,6 +16,11 @@
  */
 package org.apache.geronimo.aries.builder;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -111,6 +116,55 @@ public class ApplicationGBean implements
             bundleContext.ungetService(applicationManagerReference);
         }
     }
+
+    public long[] getApplicationContentBundleIds(){
+        long[] ids = new long[applicationBundles.size()];
+        int i =0;
+        for (Bundle content : applicationBundles){
+            ids[i++] = content.getBundleId();
+        }
+        return ids;
+    }
+
+    protected ApplicationState getApplicationState() {
+        return applicationState;
+    }
+    
+    public String getApplicationContentBundleSymbolicName(long bundleId){
+        for (Bundle content : applicationBundles){
+            if (content.getBundleId()==bundleId){
+                return content.getSymbolicName();
+            }
+        }
+        return null;
+    }
+    
+    public void updateApplicationContent(long bundleId, URI uri) throws FileNotFoundException,
BundleException{
+        Bundle targetBundle = null;
+        for (Bundle content : applicationBundles){
+            if (content.getBundleId()==bundleId){
+                targetBundle = content;
+                break;
+            }
+        }
+        
+        if (targetBundle!=null){
+            BundleContext context = targetBundle.getBundleContext();
+            ServiceReference reference = context.getServiceReference(PackageAdmin.class.getName());
+            FileInputStream fi;
+            try {
+                // create file object from local uri
+                fi = new FileInputStream(new File(uri));
+                // update bundle
+                targetBundle.update(fi);
+                // refresh bundle
+                PackageAdmin packageAdmin = (PackageAdmin) context.getService(reference);
+                packageAdmin.refreshPackages(new Bundle[]{targetBundle});
+            } finally{
+                context.ungetService(reference);
+            }
+        }
+    }
     
     protected Bundle getBundle() {
         return bundle;
@@ -123,11 +177,7 @@ public class ApplicationGBean implements
     protected Set<Bundle> getApplicationContent() {
         return new HashSet<Bundle>(applicationBundles);
     }
-
-    protected ApplicationState getApplicationState() {
-        return applicationState;
-    }
-            
+    
     private void install() throws Exception {
 
         BundleContext bundleContext = bundle.getBundleContext();



Mime
View raw message