geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tki...@apache.org
Subject svn commit: r1071657 - /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/
Date Thu, 17 Feb 2011 15:51:02 GMT
Author: tkirby
Date: Thu Feb 17 15:51:01 2011
New Revision: 1071657

URL: http://svn.apache.org/viewvc?rev=1071657&view=rev
Log:
minor code cleanup to improve code and readability, and reduce warnings

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.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

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.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/DeploymentUtils.java?rev=1071657&r1=1071656&r2=1071657&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java
Thu Feb 17 15:51:01 2011
@@ -49,11 +49,11 @@ import org.eclipse.wst.common.frameworks
 import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.util.ProjectModule;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
 import org.eclipse.wst.server.core.model.IModuleFile;
 import org.eclipse.wst.server.core.model.IModuleFolder;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.eclipse.wst.server.core.util.ProjectModule;
 
 /**
  * @version $Rev$ $Date$
@@ -221,7 +221,7 @@ public class DeploymentUtils {
             }
         }
 
-        Trace.tracePoint("Exit ", "DeploymentUtils.getExportDataModel", null);
+        Trace.tracePoint("Exit ", "DeploymentUtils.getExportDataModel", (Object) null);
         return null;
     }
     
@@ -302,7 +302,7 @@ public class DeploymentUtils {
             }
         }
         
-        Trace.tracePoint("Exit ", "DeploymentUtils.getLastKnownConfigurationId", null);
+        Trace.tracePoint("Exit ", "DeploymentUtils.getLastKnownConfigurationId", (Object)
null);
         return null;
     }
     
@@ -311,7 +311,7 @@ public class DeploymentUtils {
         Trace.tracePoint("Entry", "DeploymentUtils.getAffectedJSPFiles", delta);
 
         if (delta == null) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getAffectedJSPFiles", null);
+            Trace.tracePoint("Exit ", "DeploymentUtils.getAffectedJSPFiles", (Object) null);
             return null;
         }
 
@@ -324,7 +324,7 @@ public class DeploymentUtils {
                 fileList.add(delta);
             }
             else {
-                Trace.tracePoint("Exit ", "DeploymentUtils.getAffectedJSPFiles", null);
+                Trace.tracePoint("Exit ", "DeploymentUtils.getAffectedJSPFiles", (Object)
null);
                 return null;   //not only jsp changed
             }
         }
@@ -334,7 +334,7 @@ public class DeploymentUtils {
                 List<IModuleResourceDelta> deltaChildren = getAffectedJSPFiles(childDelta);
                 if (deltaChildren != null) fileList.addAll(deltaChildren);
                 else {
-                    Trace.tracePoint("Exit ", "DeploymentUtils.getAffectedJSPFiles", null);
+                    Trace.tracePoint("Exit ", "DeploymentUtils.getAffectedJSPFiles", (Object)
null);
                     return null;
                 }
             }
@@ -379,7 +379,7 @@ public class DeploymentUtils {
         
         TargetModuleID[] ids = dm.getAvailableModules(null, dm.getTargets());
         if(ids == null) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.isInstalledModule", null);
+            Trace.tracePoint("Exit ", "DeploymentUtils.isInstalledModule", (Object) null);
             return null;
         }
         if (ids != null) {
@@ -392,7 +392,7 @@ public class DeploymentUtils {
             }
         }
         
-        Trace.tracePoint("Exit ", "DeploymentUtils.isInstalledModule", null);
+        Trace.tracePoint("Exit ", "DeploymentUtils.isInstalledModule", (Object) null);
         return null;
     }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.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/GeronimoServerBehaviour.java?rev=1071657&r1=1071656&r2=1071657&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java
Thu Feb 17 15:51:01 2011
@@ -155,9 +155,9 @@ public class GeronimoServerBehaviour ext
     public boolean isFullyStarted() {
         if (isKernelAlive()) {
             AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName());
-            Set configLists = kernel.listGBeans(query);
+            Set<AbstractName> configLists = kernel.listGBeans(query);
             if (!configLists.isEmpty()) {
-                AbstractName on = (AbstractName) configLists.toArray()[0];
+                AbstractName on = configLists.toArray(new AbstractName[configLists.size()])[0];
                 try {
                     Boolean b = (Boolean) kernel.getAttribute(on, "kernelFullyStarted");
                     return b.booleanValue();
@@ -226,8 +226,7 @@ public class GeronimoServerBehaviour ext
     }
 
     @Override
-    protected List getOrderedModules(IServer server, List modules,
-            List deltaKind) {
+    protected List getOrderedModules(IServer server, List modules, List deltaKind) {
          DependencyHelper dh = new DependencyHelper();
          List list = dh.reorderModules(this.getServer(),modules, deltaKind);
          return list;

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=1071657&r1=1071656&r2=1071657&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
Thu Feb 17 15:51:01 2011
@@ -28,12 +28,9 @@ import java.nio.channels.FileChannel;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
-import java.util.Set;
 import java.util.Timer;
 
 import javax.enterprise.deploy.spi.Target;
@@ -263,7 +260,7 @@ abstract public class GeronimoServerBeha
 
         IStatus status = Status.OK_STATUS;
         if (modules != null && modules.size() > 0 && getGeronimoServer().isInPlaceSharedLib())
{
-            List rootModules = new ArrayList<IModule>();
+            List<IModule> rootModules = new ArrayList<IModule>();
             for(int i = 0; i < modules.size(); i++) {
                 IModule[] module = (IModule[]) modules.get(i);
                 if(!rootModules.contains(module[0])) {
@@ -284,7 +281,7 @@ abstract public class GeronimoServerBeha
             if (monitor.isCanceled())
                 return;
             
-            List rootModulesPublished = new ArrayList<IModule>();
+            List<IModule> rootModulesPublished = new ArrayList<IModule>();
             for (int i = 0; i < size; i++) {
                 IModule[] module = (IModule[]) modules.get(i);
                 int moduleDeltaKind = ((Integer)deltaKind.get(i)).intValue();
@@ -587,78 +584,64 @@ abstract public class GeronimoServerBeha
 
         List<IModuleResourceDelta> jspFiles = new ArrayList<IModuleResourceDelta>();
         for (IModuleResourceDelta delta : deltaArray) {
-            List<IModuleResourceDelta> partJspFiles= DeploymentUtils
-                    .getAffectedJSPFiles(delta);
-            //if not only Jsp files found, need to redeploy the module, so return false;
-            if (partJspFiles == null) return false;
-            else jspFiles.addAll(partJspFiles);
-        }
-            for (IModuleResourceDelta deltaModule : jspFiles) {
-                IModuleFile moduleFile = (IModuleFile) deltaModule
-                        .getModuleResource();
+            List<IModuleResourceDelta> partJspFiles = DeploymentUtils.getAffectedJSPFiles(delta);
+            // if not only Jsp files found, need to redeploy the module, so return false;
+            if (partJspFiles == null)
+                return false;
+            else
+                jspFiles.addAll(partJspFiles);
+        }
+        for (IModuleResourceDelta deltaModule : jspFiles) {
+            IModuleFile moduleFile = (IModuleFile) deltaModule.getModuleResource();
 
                 String target;
-                String relativePath = moduleFile.getModuleRelativePath()
-                        .toOSString();
-                if (relativePath != null && relativePath.length() != 0) {
-                    target = moduleTargetPath.concat(ch).concat(relativePath)
-                            .concat(ch).concat(moduleFile.getName());
-                } else
-                    target = moduleTargetPath.concat(ch).concat(
-                            moduleFile.getName());
-
-                File file = new File(target);
-                switch (deltaModule.getKind()) {
-                case IModuleResourceDelta.REMOVED:
-                    if (file.exists())
-                        file.delete();
-                    break;
-                case IModuleResourceDelta.ADDED:
-                case IModuleResourceDelta.CHANGED:
-                    if (!file.exists())
-                        try {
-                            file.createNewFile();
-                        } catch (IOException e) {
-                            Trace.trace(Trace.SEVERE, "can't create file "
-                                    + file, e);
-                            throw new CoreException(new Status(IStatus.ERROR,
-                                    Activator.PLUGIN_ID, "can't create file "
-                                            + file, e));
-                        }
-
-                    String rootFolder = GeronimoUtils.getVirtualComponent(
-                            module).getRootFolder().getProjectRelativePath()
-                            .toOSString();
-                    String sourceFile = module.getProject().getFile(
-                            rootFolder + ch
-                                    + moduleFile.getModuleRelativePath() + ch
-                                    + moduleFile.getName()).getLocation()
-                            .toString();
+            String relativePath = moduleFile.getModuleRelativePath().toOSString();
+            if (relativePath != null && relativePath.length() != 0) {
+                target = moduleTargetPath.concat(ch).concat(relativePath).concat(ch).concat(moduleFile.getName());
+            } else
+                target = moduleTargetPath.concat(ch).concat(moduleFile.getName());
+
+            File file = new File(target);
+            switch (deltaModule.getKind()) {
+            case IModuleResourceDelta.REMOVED:
+                if (file.exists())
+                    file.delete();
+                break;
+            case IModuleResourceDelta.ADDED:
+            case IModuleResourceDelta.CHANGED:
+                if (!file.exists())
                     try {
-
-                        FileInputStream in = new FileInputStream(sourceFile);
-                        FileOutputStream out = new FileOutputStream(file);
-                        FileChannel inChannel = in.getChannel();
-                        FileChannel outChannel = out.getChannel();
-                        MappedByteBuffer mappedBuffer = inChannel.map(
-                                FileChannel.MapMode.READ_ONLY, 0, inChannel
-                                        .size());
-                        outChannel.write(mappedBuffer);
-
-                        inChannel.close();
-                        outChannel.close();
-                    } catch (FileNotFoundException e) {
-                        Trace.trace(Trace.SEVERE, "can't find file "
-                                + sourceFile, e);
-                        throw new CoreException(new Status(IStatus.ERROR,
-                                Activator.PLUGIN_ID, "can't find file "
-                                        + sourceFile, e));
+                        file.createNewFile();
                     } catch (IOException e) {
-                        Trace.trace(Trace.SEVERE, "can't copy file "
-                                + sourceFile, e);
-                        throw new CoreException(new Status(IStatus.ERROR,
-                                Activator.PLUGIN_ID, "can't copy file "
-                                        + sourceFile, e));
+                        Trace.trace(Trace.SEVERE, "can't create file " + file, e);
+                        throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"can't create file "
+                                + file, e));
+                    }
+
+                String rootFolder = GeronimoUtils.getVirtualComponent(module).getRootFolder().getProjectRelativePath()
+                        .toOSString();
+                String sourceFile = module.getProject()
+                        .getFile(rootFolder + ch + moduleFile.getModuleRelativePath() + ch
+ moduleFile.getName())
+                        .getLocation().toString();
+                try {
+
+                    FileInputStream in = new FileInputStream(sourceFile);
+                    FileOutputStream out = new FileOutputStream(file);
+                    FileChannel inChannel = in.getChannel();
+                    FileChannel outChannel = out.getChannel();
+                    MappedByteBuffer mappedBuffer = inChannel.map(FileChannel.MapMode.READ_ONLY,
0, inChannel.size());
+                    outChannel.write(mappedBuffer);
+
+                    inChannel.close();
+                    outChannel.close();
+                } catch (FileNotFoundException e) {
+                    Trace.trace(Trace.SEVERE, "can't find file " + sourceFile, e);
+                    throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"can't find file "
+                            + sourceFile, e));
+                } catch (IOException e) {
+                    Trace.trace(Trace.SEVERE, "can't copy file " + sourceFile, e);
+                    throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"can't copy file "
+                            + sourceFile, e));
                     }
                     break;
                 }
@@ -836,11 +819,11 @@ abstract public class GeronimoServerBeha
         wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
     }
 
-    private List convertCPEntryToMemento(List cpEntryList) {
+    private List<String> convertCPEntryToMemento(List<IRuntimeClasspathEntry>
cpEntryList) {
         List<String> list = new ArrayList<String>(cpEntryList.size());
-        Iterator iterator = cpEntryList.iterator();
+        Iterator<IRuntimeClasspathEntry> iterator = cpEntryList.iterator();
         while (iterator.hasNext()) {
-            IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator.next();
+            IRuntimeClasspathEntry entry = iterator.next();
             try {
                 list.add(entry.getMemento());
             } catch (CoreException e) {
@@ -945,7 +928,7 @@ abstract public class GeronimoServerBeha
     }
 
     public MBeanServerConnection getServerConnection() throws Exception {
-        Map map = new HashMap();
+        Map<String, Object> map = new HashMap<String, Object>();
         String user = getGeronimoServer().getAdminID();
         String password = getGeronimoServer().getAdminPassword();
         String port = getGeronimoServer().getRMINamingPort();

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=1071657&r1=1071656&r2=1071657&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
Thu Feb 17 15:51:01 2011
@@ -302,23 +302,24 @@ abstract public class GeronimoServerDele
         if (contextRoot != null) {
             try {
                 String host = getServer().getHost();
-                String url = "http://" + host;
+                StringBuilder urlSB = new StringBuilder("http://");
+                urlSB.append(host);
                 int port = Integer.parseInt(getHTTPPort());
                 port = ServerMonitorManager.getInstance().getMonitoredPort(getServer(), port,
"web");
                 if (port != 80) {
-                    url += ":" + port;
+                    urlSB.append(":").append(port);
                 }
 
                 String moduleId = contextRoot;
                 if (!moduleId.startsWith("/")) {
-                    url += "/";
+                    urlSB.append("/");
                 }
-                url += moduleId;
+                urlSB.append(moduleId);
 
-                if (!url.endsWith("/")) {
-                    url += "/";
+                if (!moduleId.endsWith("/")) {
+                    urlSB.append("/");
                 }
-
+                String url = urlSB.toString();
                 Trace.tracePoint("Exit ", "GeronimoServerDelegate.getModuleRootURL", new
URL(url));
                 return new URL(url);
             } catch (Exception e) {
@@ -361,9 +362,18 @@ abstract public class GeronimoServerDele
 
     @Override
     public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
-        Trace.tracePoint("Enter", "GeronimoServerDelegate.saveConfiguration", monitor);
+        Trace.tracePoint("Enter", "GeronimoServerDelegate.v30.saveConfiguration", monitor);
         super.saveConfiguration(monitor);
-        Trace.tracePoint("Leave", "GeronimoServerDelegate.saveConfiguration", monitor);
+        Trace.tracePoint("Leave", "GeronimoServerDelegate.v30.saveConfiguration", monitor);
+    }
+    
+    
+
+    @Override
+    public void configurationChanged() {
+        Trace.tracePoint("Enter", "GeronimoServerDelegate.v30.configurationChanged");
+        super.configurationChanged();
+        Trace.tracePoint("Leave", "GeronimoServerDelegate.v30.configurationChanged");
     }
 
     // 
@@ -703,23 +713,11 @@ abstract public class GeronimoServerDele
     }
 
     public Set<String> getVMArgsSet() {
-        boolean karafShell = isKarafShell();
-        List<String> parmStrings = getKarafShellArgs(karafShell);
-        Set<String> parms = new HashSet<String>(parmStrings.size());
-        for (String parm : parmStrings) {
-            parms.add(parm);
-        }
-        return parms;
+        return new HashSet<String>(getKarafShellArgs(isKarafShell()));
     }
 
     public Set<String> getVMArgsNotSet() {
-        boolean karafShell = isKarafShell();
-        List<String> parmStrings = getKarafShellArgs(!karafShell);
-        Set<String> notParms = new HashSet<String>(parmStrings.size());
-        for (String parm : parmStrings) {
-            notParms.add(parm);
-        }
-        return notParms;
+        return new HashSet<String>(getKarafShellArgs(!isKarafShell()));
     }
 
     // 
@@ -884,22 +882,21 @@ abstract public class GeronimoServerDele
      * @return 
      */
     private IModule[] doGetParentModules(IModule module) {
-        Trace.tracePoint("Entry", "GeronimoServerDelegate.doGetParentModules", module);
+        Trace.tracePoint("Entry", "GeronimoServerDelegate.v30.doGetParentModules", module);
 
         ArrayList<IModule> parents = new ArrayList<IModule>();
         parents.addAll(getApplicationModules(module));
 
         // also check to see if the module is a utility module for a stand-alone
         // web module
-        IModule[] wars = J2EEUtil.getWebModules(module, null);
-        for (int i = 0; i < wars.length; i++) {
-            if (getApplicationModules(wars[i]).isEmpty()) {
-                parents.add(wars[i]);
+        for (IModule war : J2EEUtil.getWebModules(module, null)) {
+            if (getApplicationModules(war).isEmpty()) {
+                parents.add(war);
             }
         }
-
-        Trace.tracePoint("Exit ", "GeronimoServerDelegate.doGetParentModules", (IModule[])
parents.toArray(new IModule[parents.size()]));
-        return (IModule[]) parents.toArray(new IModule[parents.size()]);
+        IModule[] modules = (IModule[]) parents.toArray(new IModule[parents.size()]);
+        Trace.tracePoint("Exit ", "GeronimoServerDelegate.v30.doGetParentModules", modules);
+        return modules;
     }
 
 



Mime
View raw message