geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bjr...@apache.org
Subject svn commit: r725733 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/ org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/
Date Thu, 11 Dec 2008 16:25:14 GMT
Author: bjreed
Date: Thu Dec 11 08:25:14 2008
New Revision: 725733

URL: http://svn.apache.org/viewvc?rev=725733&view=rev
Log:
minor imporvements for GeronimoServerPlugin.  Also fixed random null pointer error and tabs
in Activator.java

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/Activator.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/Activator.java?rev=725733&r1=725732&r2=725733&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/Activator.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/Activator.java
Thu Dec 11 08:25:14 2008
@@ -30,83 +30,85 @@
  */
 public class Activator extends Plugin {
 
-	// The plug-in ID
-	public static final String PLUGIN_ID = "org.apache.geronimo.st.core";
+    // The plug-in ID
+    public static final String PLUGIN_ID = "org.apache.geronimo.st.core";
 
-	// The shared instance
-	private static Activator plugin;
+    // The shared instance
+    private static Activator plugin;
 
-	/**
-	 * The constructor
-	 */
-	public Activator() {
-		plugin = this;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
-	 */
-	public void start(BundleContext context) throws Exception {
-		super.start(context);
-		ServerCore.addServerLifecycleListener(new IServerLifecycleListener() {
-			public void serverAdded(IServer server) {
-				triggerStartUpdateServerTask(server);
-			}
-
-			public void serverChanged(IServer server) {
-				
-			}
-
-			public void serverRemoved(IServer server) {
-			}
-		});
-		IServer[] servers = ServerCore.getServers();
-		for(int i = 0; i < servers.length; i++) {
-			triggerStartUpdateServerTask(servers[i]);
-		}
-	}
-
-	private void triggerStartUpdateServerTask(IServer server) {
-		GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) server.getAdapter(GeronimoServerBehaviourDelegate.class);
-		if (delegate == null) {
-			delegate = (GeronimoServerBehaviourDelegate) server.loadAdapter(GeronimoServerBehaviourDelegate.class,
null);
-		}
-		if (delegate != null) {
-			delegate.startUpdateServerStateTask();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
-	 */
-	public void stop(BundleContext context) throws Exception {
-		IServer[] servers = ServerCore.getServers();
-		for(int i = 0; i < servers.length; i++) {
-			GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) servers[i].getAdapter(GeronimoServerBehaviourDelegate.class);
-			if(delegate != null) {
-				delegate.stopUpdateServerStateTask();
-			}
-		}
-		ModuleArtifactMapper.getInstance().save();
-		super.stop(context);
-		plugin = null;
-	}
-
-	/**
-	 * Returns the shared instance
-	 * 
-	 * @return the shared instance
-	 */
-	public static Activator getDefault() {
-		return plugin;
-	}
-
-	public static void log(int severity, String message, Throwable throwable) {
-		plugin.getLog().log(new Status(severity, PLUGIN_ID, 0, message, throwable));
-	}
+    /**
+     * The constructor
+     */
+    public Activator() {
+        plugin = this;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+     */
+    public void start(BundleContext context) throws Exception {
+        super.start(context);
+        ServerCore.addServerLifecycleListener(new IServerLifecycleListener() {
+            public void serverAdded(IServer server) {
+                triggerStartUpdateServerTask(server);
+            }
+
+            public void serverChanged(IServer server) {
+
+            }
+
+            public void serverRemoved(IServer server) {
+            }
+        });
+        IServer[] servers = ServerCore.getServers();
+        for(int i = 0; i < servers.length; i++) {
+            triggerStartUpdateServerTask(servers[i]);
+        }
+    }
+
+    private void triggerStartUpdateServerTask(IServer server) {
+        GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) server.getAdapter(GeronimoServerBehaviourDelegate.class);
+        if (delegate == null) {
+            delegate = (GeronimoServerBehaviourDelegate) server.loadAdapter(GeronimoServerBehaviourDelegate.class,
null);
+        }
+        if (delegate != null) {
+            delegate.startUpdateServerStateTask();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+     */
+    public void stop(BundleContext context) throws Exception {
+        IServer[] servers = ServerCore.getServers();
+        for(int i = 0; i < servers.length; i++) {
+            GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate)
servers[i].getAdapter(GeronimoServerBehaviourDelegate.class);
+            if(delegate != null) {
+                delegate.stopUpdateServerStateTask();
+            }
+        }
+        ModuleArtifactMapper.getInstance().save();
+        super.stop(context);
+        plugin = null;
+    }
+
+    /**
+     * Returns the shared instance
+     *
+     * @return the shared instance
+     */
+    public static Activator getDefault() {
+        return plugin;
+    }
+
+    public static void log(int severity, String message, Throwable throwable) {
+        if (plugin != null && plugin.getLog() != null) {
+            plugin.getLog().log(new Status(severity, PLUGIN_ID, 0, message, throwable));
+        }
+    }
 
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java?rev=725733&r1=725732&r2=725733&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java
Thu Dec 11 08:25:14 2008
@@ -34,7 +34,6 @@
 import java.util.jar.Manifest;
 import java.util.List;
 import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
 
 import javax.management.MBeanServerConnection;
 import javax.xml.bind.JAXBElement;
@@ -286,21 +285,44 @@
 
         Artifact artifact = Artifact.create(configId);
         String filename = createDirectoryStructure (localRepoDir, artifact);
-        filename = addFilename (filename, artifact);
+        File outputDir = new File (filename);
 
-        ConfigurationManager mgr = getConfigurationManager();
-        FileOutputStream outputStream = new FileOutputStream(filename);
         File serverArtifact = new File(getArtifactLocation (artifact));
-        ZipOutputStream out = new ZipOutputStream(outputStream);
-        byte[] buf = new byte[10240];
-        writeToZip(serverArtifact, out, "", buf);
-        out.closeEntry();
-        out.finish();
-        out.flush();
+        writeToDirectory(serverArtifact, outputDir);
 
         Trace.tracePoint("Exit", "GeronimoServerPluginManager.exportCAR");
     }
 
+    private void writeToDirectory(File inputDir, File outputDir) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.writeToZip", inputDir);
+
+        outputDir.mkdirs();
+        File[] all = inputDir.listFiles();
+        for (File file : all) {
+            if (file.isDirectory()) {
+                String oDir = outputDir.getAbsolutePath() + File.separator + file.getName();
+                File temp = new File (oDir);
+                writeToDirectory(file, temp);
+            } else {
+                File entry = new File(outputDir + File.separator + file.getName());
+                FileOutputStream out = new FileOutputStream (entry);
+                FileInputStream in = new FileInputStream(file);
+                byte[] buf = new byte[10240];
+                int count;
+                try {
+                    while ((count = in.read(buf, 0, buf.length)) > -1) {
+                        out.write(buf, 0, count);
+                    }
+                } finally {
+                    in.close();
+                    out.flush();
+                    out.close();
+                }
+            }
+        }
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.writeToZip");
+    }
+
     public void updatePluginList (String localRepoDir, PluginType metadata) throws Exception
{
         Trace.tracePoint("Entry", "GeronimoServerPluginManager.updatePluginList", localRepoDir,
metadata);
 
@@ -551,8 +573,9 @@
     }
 
     private String getArtifactLocation (Artifact artifact) {
-        String temp = server.getRuntime().getLocation().toOSString() + "/repository/";
-        temp += artifact.getGroupId().replaceAll("[.]", "/") + "/" + artifact.getArtifactId()
+ "/" + artifact.getVersion() + "/";
+        String ch = File.separator;
+        String temp = server.getRuntime().getLocation().toOSString() + ch + "repository"
+ ch;
+        temp += artifact.getGroupId().replaceAll("[.]", ch) + ch + artifact.getArtifactId()
+ ch + artifact.getVersion() + ch;
         return temp;
     }
     
@@ -577,38 +600,6 @@
 
         return fileName;
     }
-
-    private void writeToZip(File dir, ZipOutputStream out, String prefix, byte[] buf) throws
Exception {
-        Trace.tracePoint("Entry", "GeronimoServerPluginManager.writeToZip", dir);
-
-        File[] all = dir.listFiles();
-        for (File file : all) {
-            if (file.isDirectory()) {
-                writeToZip(file, out, prefix + file.getName() + "/", buf);
-            } else {
-                ZipEntry entry = new ZipEntry(prefix + file.getName());
-                out.putNextEntry(entry);
-                writeToZipStream(file, out, buf);
-            }
-        }
-        Trace.tracePoint("Exit", "GeronimoServerPluginManager.writeToZip");
-    }
-
-    private void writeToZipStream(File file, OutputStream out, byte[] buf) throws Exception
{
-        Trace.tracePoint("Entry", "GeronimoServerPluginManager.writeToZipStream", file);
-
-        FileInputStream in = new FileInputStream(file);
-        int count;
-        try {
-            while ((count = in.read(buf, 0, buf.length)) > -1) {
-                out.write(buf, 0, count);
-            }
-        } finally {
-            in.close();
-        }
-
-        Trace.tracePoint("Exit", "GeronimoServerPluginManager.writeToZipStream", file);
-    }
     
     private ConfigurationManager getConfigurationManager () {
         Trace.tracePoint("Entry", "GeronimoServerPluginManager.getConfigurationManager");
@@ -631,7 +622,7 @@
         }
         if (kernel != null) {
             Trace.tracePoint("Exit", "GeronimoServerPluginManager.getConfigurationManager");
-            return ConfigurationUtil.getConfigurationManager(kernel);
+            return ConfigurationUtil.getEditableConfigurationManager(kernel);
         }
 
         Trace.tracePoint("Exit", "GeronimoServerPluginManager.getConfigurationManager");
@@ -692,7 +683,7 @@
     public boolean validatePlugin (PluginType plugin) {
         Trace.tracePoint("Entry", "GeronimoServerPluginManager.validatePlugin", plugin);
 
-        boolean valid = false;
+        boolean valid = true;
         String serverVersion = null;
         GeronimoRuntimeDelegate rd = (GeronimoRuntimeDelegate)server.getRuntime().getAdapter(GeronimoRuntimeDelegate.class);
         if (rd == null)
@@ -704,6 +695,7 @@
         // check the Geronimo and JVM versions for validity
         PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
         if (metadata.getGeronimoVersion().size() > 0) {
+            valid = false;
             for (String gerVersion : metadata.getGeronimoVersion()) {
                 valid = gerVersion.equals(serverVersion);
                 if (valid) {
@@ -715,9 +707,10 @@
             Trace.tracePoint("Exit", "GeronimoServerPluginManager.validatePlugin", valid);
             return valid;
         }
-        valid = false;
+
         String jvmSystem = System.getProperty("java.version");
         if (metadata.getJvmVersion().size() > 0) {
+            valid = false;
             for (String jvmVersion : metadata.getJvmVersion()) {
                 valid = jvmSystem.startsWith(jvmVersion);
                 if (valid) {
@@ -761,7 +754,7 @@
             List<PluginType> toInstall = new ArrayList<PluginType>();
             for (PluginType metadata : pluginList) {
                 try {
-                    validatePlugin(metadata);
+                    //validatePlugin(metadata);
                     verifyPrerequisites(metadata);
 
                     PluginArtifactType instance = metadata.getPluginArtifact().get(0);
@@ -803,6 +796,9 @@
                     //for (Artifact artifact : artifacts) {
                         if (!configManager.isRunning(artifact)) {
                             if (!configManager.isLoaded(artifact)) {
+                                File serverArtifact = new File(getArtifactLocation (artifact));
+                                File localDir = new File (createDirectoryStructure(localRepoDir,
artifact));
+                                writeToDirectory(localDir, serverArtifact);
                                 configManager.loadConfiguration(artifact);
                             }
                             configManager.startConfiguration(artifact);



Mime
View raw message