geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1302954 - /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/
Date Tue, 20 Mar 2012 15:56:04 GMT
Author: gawor
Date: Tue Mar 20 15:56:04 2012
New Revision: 1302954

URL: http://svn.apache.org/viewvc?rev=1302954&view=rev
Log:
GERONIMODEVTOOLS-790: Manage server application start

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java?rev=1302954&r1=1302953&r2=1302954&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
Tue Mar 20 15:56:04 2012
@@ -17,7 +17,10 @@
 package org.apache.geronimo.st.v30.core;
 
 import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.geronimo.st.v30.core.internal.Messages;
 import org.apache.geronimo.st.v30.core.internal.Trace;
@@ -95,9 +98,6 @@ public class GeronimoLaunchConfiguration
         vmArgs = vmArgs.replace("$(JRE_HOME)", jreHome.getAbsolutePath());
         vmArgs = vmArgs.replace("$(GERONIMO_HOME)", server.getRuntime().getLocation().toOSString());
         
-        Trace.trace(Trace.INFO, "vmArgs=" + vmArgs, Activator.traceCore);
-        Trace.trace(Trace.INFO, "pgmArgs=" + pgmArgs, Activator.traceCore);
-        
         ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
         Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
         String[] classpath = getClasspath(configuration);
@@ -105,11 +105,14 @@ public class GeronimoLaunchConfiguration
         // Create VM config
         VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
         runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
-        runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+        runConfig.setVMArguments(updateJVMArguments(execArgs.getVMArgumentsArray(), geronimoServer));
         runConfig.setWorkingDirectory(workingDirName);
         runConfig.setEnvironment(envp);
         runConfig.setVMSpecificAttributesMap(vmAttributesMap);
         
+        traceArguments("vmArgs", runConfig.getVMArguments());
+        traceArguments("pgmArgs", runConfig.getProgramArguments());
+        
         // Bootpath
         String[] bootpath = getBootpath(configuration);
         if (bootpath != null && bootpath.length > 0)
@@ -131,4 +134,36 @@ public class GeronimoLaunchConfiguration
         geronimoServer.setProcess(launch.getProcesses()[0]);
     }
 
+    private String[] updateJVMArguments(String[] jvmArguments, GeronimoServerBehaviourDelegate
server) {
+        boolean managedApplicationStart = server.getServerDelegate().isManageApplicationStart();
       
+        Trace.trace(Trace.INFO, "GeronimoLaunchConfigurationDelegate: manageApplicationStart:="
+ managedApplicationStart, Activator.traceCore);
+        if (managedApplicationStart) {
+            Set<String> modifiedConfigs = server.getModifiedConfigIds();
+            if (!modifiedConfigs.isEmpty()) {
+                String[] newJvmArguments = new String[jvmArguments.length + 1];
+                System.arraycopy(jvmArguments, 0, newJvmArguments, 0, jvmArguments.length);
+                newJvmArguments[jvmArguments.length] = toString("-Dgeronimo.loadOnlyConfigList=",
modifiedConfigs);
+                return newJvmArguments;
+            }
+        }
+        return jvmArguments;
+    }
+    
+    private static String toString(String start, Collection<String> list) {
+        Iterator<String> iter = list.iterator();
+        StringBuilder builder = new StringBuilder(start);
+        while(iter.hasNext()) {
+            builder.append(iter.next());
+            if (iter.hasNext()) {
+                builder.append(",");
+            }
+        }
+        return builder.toString();
+    }
+    
+    private static void traceArguments(String name, String[] array) {
+        for (int i = 0; i < array.length; i++) {
+            Trace.trace(Trace.INFO, name + "[" + i + "] = " + array[i], Activator.traceCore);
+        }
+    }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=1302954&r1=1302953&r2=1302954&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
Tue Mar 20 15:56:04 2012
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -217,7 +218,7 @@ public class GeronimoServerBehaviourDele
             if (SocketUtil.isPortInUse(ports[i].getPort(), 5))
                 throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0,
Messages.bind(Messages.errorPortInUse, Integer.toString(sp.getPort()), sp.getName()), null));
         }
-
+        
         stopUpdateServerStateTask();
         setServerState(IServer.STATE_STARTING);
         setMode(launchMode);
@@ -498,7 +499,11 @@ public class GeronimoServerBehaviourDele
             boolean refreshOSGiBundle = getServerDelegate().isRefreshOSGiBundle();
             for (ModuleDeltaList moduleList : publishMap.values()) {  
                 IModule[] rootModule = moduleList.getRootModule();
-                if (refreshOSGiBundle && GeronimoUtils.isEBAModule(rootModule[0])
&& moduleList.hasChangedChildModulesOnly(false)) {
+                AbstractName ebaName = null;
+                if (refreshOSGiBundle &&
+                    GeronimoUtils.isEBAModule(rootModule[0]) &&  
+                    moduleList.hasChangedChildModulesOnly(false) && 
+                    (ebaName = getApplicationGBeanName(rootModule[0])) != null) {
                     List<IModule[]> changedModules = new ArrayList<IModule[]>();
                     List<IModule[]> unChangedModules = new ArrayList<IModule[]>();
                     for (ModuleDelta moduleDelta : moduleList.getChildModules()) {
@@ -508,7 +513,7 @@ public class GeronimoServerBehaviourDele
                             unChangedModules.add(moduleDelta.module);
                         }
                     }
-                    status = refreshBundles(rootModule[0], changedModules, ProgressUtil.getSubMonitorFor(monitor,
3000));
+                    status = refreshBundles(rootModule[0], ebaName, changedModules, ProgressUtil.getSubMonitorFor(monitor,
3000));
                     if (status != null && !status.isOK()) {
                         multi.add(status);
                     }
@@ -537,15 +542,23 @@ public class GeronimoServerBehaviourDele
         Trace.tracePoint("Exit ", Activator.traceCore, "GeronimoServerBehaviourDelegate.publishModules");
     }
         
-    private IStatus refreshBundles(IModule ebaModule, List<IModule[]> bundleModules,
IProgressMonitor monitor) {
-        Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerBehaviourDelegate.refreshBundles",
ebaModule, bundleModules, monitor);
-
-        String configId = null;
+    private AbstractName getApplicationGBeanName(IModule ebaModule) {
+        Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerBehaviourDelegate.getApplicationGBeanName",
ebaModule);
+        IServer server = getServer();
+        AbstractName ebaName = null;
         try {
-            configId = DeploymentUtils.getConfigId(getServer(), ebaModule);
+            String configId = DeploymentUtils.getConfigId(server, ebaModule);
+            ExtendedDeploymentManager dm = (ExtendedDeploymentManager) DeploymentCommandFactory.getDeploymentManager(server);
+            ebaName = dm.getApplicationGBeanName(Artifact.create(configId));
         } catch (CoreException e) {
-            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.bind(Messages.REFRESH_NO_CONFIGURATION_FAIL,
ebaModule.getProject().getName()), e);
+            Trace.trace(Trace.WARNING, "Error getting gbean name", e, Activator.traceCore);
         }
+        Trace.tracePoint("Exit", Activator.traceCore, "GeronimoServerBehaviourDelegate.getApplicationGBeanName",
ebaName);
+        return ebaName;
+    }
+    
+    private IStatus refreshBundles(IModule ebaModule, AbstractName ebaName, List<IModule[]>
bundleModules, IProgressMonitor monitor) {
+        Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerBehaviourDelegate.refreshBundles",
ebaModule, ebaName, bundleModules, monitor);
         
         if (monitor.isCanceled()) {
             return Status.CANCEL_STATUS;
@@ -555,7 +568,6 @@ public class GeronimoServerBehaviourDele
         
         try {
             ExtendedDeploymentManager dm = (ExtendedDeploymentManager) DeploymentCommandFactory.getDeploymentManager(getServer());
-            AbstractName ebaName = dm.getApplicationGBeanName(Artifact.create(configId));
             long[] bundleIds = dm.getEBAContentBundleIds(ebaName);
 
             Map<String, Long> bundleMap = new HashMap<String, Long>();
@@ -1662,4 +1674,47 @@ public class GeronimoServerBehaviourDele
     public boolean isPublished(IModule[] module) {
         return super.hasBeenPublished(module);
     }
+    
+    public boolean hasChanged(IModule rootModule) {
+        IModule[] module = new IModule [] { rootModule };
+        IModuleResourceDelta[] deltaArray = getPublishedResourceDelta(module);
+        if (deltaArray != null && deltaArray.length > 0) {
+            return true;
+        }
+        IModule[] childModules = getServerDelegate().getChildModules(module);
+        if (childModules != null) {
+            for (IModule childModule : childModules) {
+                deltaArray = getPublishedResourceDelta(new IModule[] {rootModule, childModule});
+                if (deltaArray != null && deltaArray.length > 0) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    public Set<String> getModifiedConfigIds() {
+        Trace.tracePoint("Entry", Activator.traceCore, "GeronimoServerBehaviourDelegate.getModifiedConfigIds");
+        
+        IServer server = getServer();
+        Set<String> configIds = new HashSet<String>();
+        IModule[] modules = server.getModules();        
+        if (modules != null) {
+            for (IModule module : modules) {
+                IModule[] rootModule = new IModule[] { module };
+                // only consider modules that have been published and have changed
+                if (isPublished(rootModule) && hasChanged(module)) {
+                    try {
+                        String configId = DeploymentUtils.getConfigId(server, module);
+                        configIds.add(configId);
+                    } catch (CoreException e) {
+                        // ignore
+                    }                    
+                }
+            }
+        }
+        
+        Trace.tracePoint("Exit", Activator.traceCore, "GeronimoServerBehaviourDelegate.getModifiedConfigIds",
configIds);        
+        return configIds;
+    }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java?rev=1302954&r1=1302953&r2=1302954&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
Tue Mar 20 15:56:04 2012
@@ -127,6 +127,16 @@ public class GeronimoServerDelegate exte
     public static final String PROPERTY_SELECT_CLASSPATH_CONTAINERS = "selectClasspathContainers";
     
     public static final String PROPERTY_CLASSPATH_CONTAINERS = "classpathContainers";
+    
+    /**
+     * Let GEP control which applications should be started on server startup.
+     */
+    public static final String PROPERTY_MANAGE_APP_START = "manageApplicationStart";
+    
+    /**
+     * Controls whether SynchronizeProjectOnServerTask will check for removed modules.
+     */
+    public static final String PROPERTY_CHECK_FOR_REMOVED_MODULES = "checkForRemovedModules";
 
     public static final String CONSOLE_INFO = "--long";
 
@@ -1116,6 +1126,38 @@ public class GeronimoServerDelegate exte
         setAttribute(propertyName, Arrays.asList(patterns));
     }       
     
+    //
+    // PROPERTY_MANAGE_APP_START
+    //
+    public boolean isManageApplicationStart() {
+        return getProperty(PROPERTY_MANAGE_APP_START, false);
+    }
+    public void setManageApplicationStart(boolean enable){
+        setAttribute(PROPERTY_MANAGE_APP_START, enable);
+    }
+    
+    //
+    // PROPERTY_CHECK_FOR_REMOVED_MODULES
+    //
+    public boolean isCheckForRemovedModules() {
+        return getProperty(PROPERTY_CHECK_FOR_REMOVED_MODULES, true);
+    }
+    public void setCheckForRemovedModules(boolean enable){
+        setAttribute(PROPERTY_CHECK_FOR_REMOVED_MODULES, enable);
+    }
+    
+    private boolean getProperty(String propertyName, boolean defaultValue) {
+        String value = System.getProperty("org.apache.geronimo.st.v30.core." + propertyName);
+        if (value == null) {
+            value = getAttribute(propertyName, (String) null);
+        }
+        if (value == null) {
+            return defaultValue;
+        } else {
+            return Boolean.valueOf(value);
+        }
+    }
+    
     public String discoverDeploymentFactoryClassName(IPath jarPath) {
         try {
             JarFile deployerJar = new JarFile(jarPath.toFile());

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java?rev=1302954&r1=1302953&r2=1302954&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java
Tue Mar 20 15:56:04 2012
@@ -50,14 +50,9 @@ public class SynchronizeProjectOnServerT
     public SynchronizeProjectOnServerTask(GeronimoServerBehaviourDelegate delegate, IServer
server) {
         this.delegate = delegate;
         this.server = server;
-        this.checkForRemovedModules = getCheckForRemovedModules();
+        this.checkForRemovedModules = delegate.getServerDelegate().isCheckForRemovedModules();
         Trace.trace(Trace.INFO, "SynchronizeProjectOnServerTask: checkForRemovedModules:="
+ checkForRemovedModules, Activator.traceCore);
     }
-
-    private static boolean getCheckForRemovedModules() {
-        String property = System.getProperty(SynchronizeProjectOnServerTask.class.getName()
+ ".checkForRemovedModules");
-        return (property == null) ? true : "true".equalsIgnoreCase(property);
-    }
     
     public synchronized void start() {
         server.addPublishListener(this);



Mime
View raw message