geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r289146 - in /geronimo/devtools/trunk/modules/eclipse-plugin: etc/ plugins/org.apache.geronimo.devtools.eclipse.core/ plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/ plugins/org.apache.geronimo.runti...
Date Thu, 15 Sep 2005 04:51:14 GMT
Author: sppatel
Date: Wed Sep 14 21:51:03 2005
New Revision: 289146

URL: http://svn.apache.org/viewcvs?rev=289146&view=rev
Log:
Fixes to get plugin working on I-driver

Modified:
    geronimo/devtools/trunk/modules/eclipse-plugin/etc/project.properties
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/.options
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/plugin.xml
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/project.xml

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/etc/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/etc/project.properties?rev=289146&r1=289145&r2=289146&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/etc/project.properties (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/etc/project.properties Wed Sep 14 21:51:03
2005
@@ -8,6 +8,8 @@
 geronimo_runtime_version=1.0-M4
 geronimo_spec_version=1.1-rc4
 mx4j_version=3.0.1
+commons_logging_version=1.0.4
+cglib_version=2.1_2
 
 maven.jar.org.eclipse.osgi = ${eclipse.home.plugins}/org.eclipse.osgi_3.1.0.jar
 maven.jar.org.eclipse.core.runtime = ${eclipse.home.plugins}/org.eclipse.core.runtime_3.1.0.jar

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/.options
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/.options?rev=289146&r1=289145&r2=289146&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/.options
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/.options
Wed Sep 14 21:51:03 2005
@@ -1 +1 @@
-org.apache.geronimo.core/debug=true
+org.apache.geronimo.devtools.eclipse.core/debug=true

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java?rev=289146&r1=289145&r2=289146&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java
Wed Sep 14 21:51:03 2005
@@ -68,462 +68,497 @@
 
 public class GeronimoServerBehaviour extends GenericServerBehaviour {
 
-	private final static String DEFAULT_URI = "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";
+    private final static String DEFAULT_URI = "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";
+
+    private final static String J2EE_DEPLOYER_ID = "org/apache/geronimo/RuntimeDeployer";
 
-	private final static String J2EE_DEPLOYER_ID = "org/apache/geronimo/RuntimeDeployer";
-    
     private static final int MAX_TRIES = 10;
-    
-    private static final long TIMEOUT = 100000;
 
-	private DeploymentFactoryManager dfm = null;
+    private static final long TIMEOUT = 100000;
 
-	private DeploymentManager dm = null;
+    private DeploymentFactoryManager dfm = null;
 
-	private IProgressMonitor _monitor = null;
+    private DeploymentManager dm = null;
 
-	private Kernel kernel = null;
+    private IProgressMonitor _monitor = null;
 
-	public GeronimoServerBehaviour() {
-		super();
-	}
-
-	private void discoverDeploymentFactory() {
-
-		try {
-			JarFile deployerJar = new JarFile(getServer().getRuntime().getLocation().append(
-					"/deployer.jar").toFile());
-			java.util.jar.Manifest manifestFile = deployerJar.getManifest();
-			Attributes attributes = manifestFile.getMainAttributes();
-			String key = "J2EE-DeploymentFactory-Implementation-Class";
-			String className = attributes.getValue(key);
-			dfm = DeploymentFactoryManager.getInstance();
-			Class deploymentFactory = Class.forName(className);
-			DeploymentFactory deploymentFactoryInstance = (DeploymentFactory) deploymentFactory
-					.newInstance();
-			dfm.registerDeploymentFactory(deploymentFactoryInstance);
-		} catch (IOException e) {
-			e.printStackTrace();
-		} catch (ClassNotFoundException e) {
-			e.printStackTrace();
-		} catch (InstantiationException e) {
-			e.printStackTrace();
-		} catch (IllegalAccessException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public DeploymentManager getDeploymentManager() throws DeploymentManagerCreationException
{
-
-		if (dm == null) {
-			discoverDeploymentFactory();
-			if (dfm != null) {
-				dm = dfm.getDeploymentManager(DEFAULT_URI, getUserName(), getPassword());
-			} else {
-				DeploymentFactory df = new DeploymentFactoryImpl();
-				dm = df.getDeploymentManager(DEFAULT_URI, getUserName(), getPassword());
-			}
-		}
-		return dm;
-	}
-
-	private String getUserName() {        
-        GeronimoServer server = (GeronimoServer) getServer().getAdapter(GeronimoServer.class);
-		return server.getAdminID();
-	}
+    private Kernel kernel = null;
 
-	private String getPassword() {
-        GeronimoServer server = (GeronimoServer) getServer().getAdapter(GeronimoServer.class);
+    public GeronimoServerBehaviour() {
+        super();
+    }
+
+    private void discoverDeploymentFactory() {
+
+        try {
+            JarFile deployerJar = new JarFile(getServer().getRuntime()
+                    .getLocation().append("/deployer.jar").toFile());
+            java.util.jar.Manifest manifestFile = deployerJar.getManifest();
+            Attributes attributes = manifestFile.getMainAttributes();
+            String key = "J2EE-DeploymentFactory-Implementation-Class";
+            String className = attributes.getValue(key);
+            dfm = DeploymentFactoryManager.getInstance();
+            Class deploymentFactory = Class.forName(className);
+            DeploymentFactory deploymentFactoryInstance = (DeploymentFactory) deploymentFactory
+                    .newInstance();
+            dfm.registerDeploymentFactory(deploymentFactoryInstance);
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public DeploymentManager getDeploymentManager()
+            throws DeploymentManagerCreationException {
+
+        if (dm == null) {
+            discoverDeploymentFactory();
+            if (dfm != null) {
+                dm = dfm.getDeploymentManager(DEFAULT_URI, getUserName(),
+                        getPassword());
+            } else {
+                DeploymentFactory df = new DeploymentFactoryImpl();
+                dm = df.getDeploymentManager(DEFAULT_URI, getUserName(),
+                        getPassword());
+            }
+        }
+        return dm;
+    }
+
+    private String getUserName() {
+        GeronimoServer server = (GeronimoServer) getServer().getAdapter(
+                GeronimoServer.class);
+        return server.getAdminID();
+    }
+
+    private String getPassword() {
+        GeronimoServer server = (GeronimoServer) getServer().getAdapter(
+                GeronimoServer.class);
         return server.getAdminPassword();
-	}
+    }
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#stop(boolean)
-	 */
-	public void stop(boolean force) {       
-	               
-		if (getKernel() != null) {
-            //lets shutdown the kernel so shutdown messages are displayed in the console
view
-			kernel.shutdown();
-		}           
-                
-
-		dm = null;
-		kernel = null;
-        
-		//kill the process
-		super.stop(true);
-	}
-
-	private Kernel getKernel() {
-
-		int tries = MAX_TRIES;
-
-		if (kernel == null) {
-
-			Map map = new HashMap();
-			map.put("jmx.remote.credentials", new String[] { getUserName(), getPassword() });
-			try {
-				JMXServiceURL address = new JMXServiceURL(
-						"service:jmx:rmi://localhost/jndi/rmi:/JMXConnector");
-				do {
-					try {
-
-						JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map);
-						MBeanServerConnection mbServerConnection = jmxConnector
-								.getMBeanServerConnection();
-						kernel = new KernelDelegate(mbServerConnection);
-						Trace.trace(Trace.INFO, "Connected to kernel.");
-						break;
-					} catch (Exception e) {
-						Thread.sleep(3000);
-						tries--;
-						if (tries != 0) {
-                            Trace.trace(Trace.WARNING,"Couldn't connect to kernel.  Trying
again...");
-						} else {
-                            Trace.trace(Trace.SEVERE,"Connection to Geronimo kernel failed.",
e);
-						}
-					}
-				} while (tries > 0);
-			} catch (MalformedURLException e) {
-				e.printStackTrace();
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-
-		return kernel;
-	}
-
-	protected void setServerStarted() {
-
-		boolean started = false;
-
-		try {
-			ObjectName configName = Configuration.getConfigurationObjectName(new URI(
-					J2EE_DEPLOYER_ID));
-
-			for (int tries = MAX_TRIES; tries > 0 && !started; tries--) {
-				try {
-					if (getKernel() != null) {
-						if (kernel.getGBeanState(configName) == 1) {
-							started = true;
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#stop(boolean)
+     */
+    public void stop(boolean force) {
+
+        if (getKernel() != null) {
+            // lets shutdown the kernel so shutdown messages are displayed in
+            // the console view
+            kernel.shutdown();
+        }
+
+        dm = null;
+        kernel = null;
+
+        // kill the process
+        super.stop(true);
+    }
+
+    private Kernel getKernel() {
+
+        int tries = MAX_TRIES;
+
+        if (kernel == null) {
+
+            Map map = new HashMap();
+            map.put("jmx.remote.credentials", new String[] { getUserName(),
+                    getPassword() });
+            try {
+                JMXServiceURL address = new JMXServiceURL(
+                        "service:jmx:rmi://localhost/jndi/rmi:/JMXConnector");
+                do {
+                    try {
+
+                        JMXConnector jmxConnector = JMXConnectorFactory
+                                .connect(address, map);
+                        MBeanServerConnection mbServerConnection = jmxConnector
+                                .getMBeanServerConnection();
+                        kernel = new KernelDelegate(mbServerConnection);
+                        Trace.trace(Trace.INFO, "Connected to kernel.");
+                        break;
+                    } catch (Exception e) {
+                        Thread.sleep(3000);
+                        tries--;
+                        if (tries != 0) {
+                            Trace
+                                    .trace(Trace.WARNING,
+                                            "Couldn't connect to kernel.  Trying again...");
+                        } else {
+                            Trace.trace(Trace.SEVERE,
+                                    "Connection to Geronimo kernel failed.", e);
+                        }
+                    }
+                } while (tries > 0);
+            } catch (MalformedURLException e) {
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return kernel;
+    }
+
+    protected void setServerStarted() {
+
+        boolean started = false;
+
+        try {
+            ObjectName configName = Configuration
+                    .getConfigurationObjectName(new URI(J2EE_DEPLOYER_ID));
+
+            for (int tries = MAX_TRIES; tries > 0 && !started; tries--) {
+                try {
+                    if (getKernel() != null) {
+                        if (kernel.getGBeanState(configName) == 1) {
+                            started = true;
                             setServerState(IServer.STATE_STARTED);
-							Trace.trace(Trace.INFO, "RuntimeDeployer has started.");
-						} else {
-							Trace.trace(Trace.INFO, "RuntimeDeployer has not yet started.");
-						}
-					}
-				} catch (InternalKernelException e) {
-				} catch (GBeanNotFoundException e) {
-				}
-				Thread.sleep(2000);
-			}
-		} catch (MalformedObjectNameException e) {
-			e.printStackTrace();
-		} catch (URISyntaxException e) {
-			e.printStackTrace();
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		
-		if (!started) {
-			Trace.trace(Trace.SEVERE, "Runtime deployer failed to start.");
-		}		
-
-	}
-
-	public void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
-			throws CoreException {                
-
-		_monitor = monitor;
-
-		// Can only publish when the server is running
-		int state = getServer().getServerState();
-		if (state == IServer.STATE_STOPPED || state == IServer.STATE_STOPPING) {
-			throw new CoreException(Status.CANCEL_STATUS);
-		}
-
-		if (state == IServer.STATE_STARTING) {
-			int timeout = 25;
-			while (getServer().getServerState() == IServer.STATE_STARTING) {
-				if (--timeout == 0)
-					throw new CoreException(Status.CANCEL_STATUS);
-				try {
-					Thread.sleep(1000);
-				} catch (InterruptedException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-
-		if (deltaKind == NO_CHANGE) // Temporary workaround for WTP server tools
-			// bug
-			deltaKind = CHANGED;
-
-		if (!(deltaKind == ADDED || deltaKind == REMOVED || deltaKind == CHANGED))
-			return;
-
-		invokeCommand(deltaKind, module[module.length - 1]);
-	}
-
-	class WaitForNotificationThread extends Thread {
-		public void run() {
-			try {
-				sleep(TIMEOUT);
-			} catch (InterruptedException e) {
-			}
-		}
-	}
-
-	class GeronimoDeploymentProgressListener implements ProgressListener {
-
-		private Thread waitThread;
-
-		private CommandType cmd = null;
-
-		private IProject project = null;
-
-		public String lastMessage = null;
-
-		public GeronimoDeploymentProgressListener() {
-			waitThread = new WaitForNotificationThread();
-		}
-
-		public void handleProgressEvent(ProgressEvent event) {
-			String message = DeploymentStatusMessageTranslator.getTranslatedMessage(event, project);
		
-			if (!message.equals(lastMessage)) {
+                            Trace.trace(Trace.INFO,
+                                    "RuntimeDeployer has started.");
+                        } else {
+                            Trace.trace(Trace.INFO,
+                                    "RuntimeDeployer has not yet started.");
+                        }
+                    }
+                } catch (InternalKernelException e) {
+                } catch (GBeanNotFoundException e) {
+                }
+                Thread.sleep(2000);
+            }
+        } catch (MalformedObjectNameException e) {
+            e.printStackTrace();
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+
+        if (!started) {
+            Trace.trace(Trace.SEVERE, "Runtime deployer failed to start.");
+        }
+
+    }
+
+    public void publishModule(int kind, int deltaKind, IModule[] module,
+            IProgressMonitor monitor) throws CoreException {
+
+        _monitor = monitor;
+
+        // Can only publish when the server is running
+        int state = getServer().getServerState();
+        if (state == IServer.STATE_STOPPED || state == IServer.STATE_STOPPING) {
+            throw new CoreException(Status.CANCEL_STATUS);
+        }
+
+        if (state == IServer.STATE_STARTING) {
+            int timeout = 25;
+            while (getServer().getServerState() == IServer.STATE_STARTING) {
+                if (--timeout == 0)
+                    throw new CoreException(Status.CANCEL_STATUS);
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        if (deltaKind == NO_CHANGE) // Temporary workaround for WTP server tools
+            // bug
+            deltaKind = CHANGED;
+
+        if (!(deltaKind == ADDED || deltaKind == REMOVED || deltaKind == CHANGED))
+            return;
+
+        invokeCommand(deltaKind, module[module.length - 1]);
+    }
+
+    class WaitForNotificationThread extends Thread {
+        public void run() {
+            try {
+                sleep(TIMEOUT);
+            } catch (InterruptedException e) {
+            }
+        }
+    }
+
+    class GeronimoDeploymentProgressListener implements ProgressListener {
+
+        private Thread waitThread;
+
+        private CommandType cmd = null;
+
+        private IProject project = null;
+
+        public String lastMessage = null;
+
+        public GeronimoDeploymentProgressListener() {
+            waitThread = new WaitForNotificationThread();
+        }
+
+        public void handleProgressEvent(ProgressEvent event) {
+            String message = DeploymentStatusMessageTranslator
+                    .getTranslatedMessage(event, project);
+            if (!message.equals(lastMessage)) {
                 _monitor.setTaskName(message);
-				Trace.trace(Trace.INFO,message);
-			}
-			lastMessage = message;
-			DeploymentStatus status = event.getDeploymentStatus();
-			if (status.getMessage() != null) {
-				Trace.trace(Trace.INFO,"\t" + status.getMessage());
-				_monitor.subTask(status.getMessage());
-			}
-			if (cmd == null || cmd == status.getCommand()) {
-				if (status.isCompleted() || status.isFailed()) {
-					waitThread.interrupt();
-				}
-			}
-		}
-
-		public void start() {
-			waitThread.start();
-		}
-
-		public void setType(CommandType cmd) {
-			this.cmd = cmd;
-		}
-
-		public Thread getWaitThread() {
-			return waitThread;
-		}
-
-		public void setProject(IProject project) {
-			this.project = project;
-		}
-	}
-
-	private void waitForCompletion(ProgressObject po, GeronimoDeploymentProgressListener listener,
-			CommandType cmd, IProject project) {
-
-		listener.setType(cmd);
-		listener.setProject(project);
-
-		po.addProgressListener(listener);
-
-		try {
-			listener.getWaitThread().join();
-		} catch (InterruptedException e) {
-
-		} finally {
-			po.removeProgressListener(listener);
-		}
-	}
-
-	private void invokeCommand(int deltaKind, IModule module) throws CoreException {
-
-		GeronimoUtils.getConfigId(module); //triggers web dp creation
-
-		//GeronimoUtils.copyDeploymentPlanToDeployable(module); // Temporary
-
-		try {
-			switch (deltaKind) {
-			case ADDED: {
-				doDeploy(module);
-				break;
-			}
-			case CHANGED: {
-				doReploy(module);
-				break;
-			}
-			case REMOVED: {
-				doUndeploy(module);
-				break;
-			}
-			default:
-				throw new IllegalArgumentException();
-			}
-		}  catch (DeploymentManagerCreationException e) {			
-			e.printStackTrace();
-			throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jst.geronimo.core", 0,e.getMessage(),
e));
-		}
-	}
-
-	private void doDeploy(IModule module) throws CoreException, DeploymentManagerCreationException
{
-
-		IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, null);
-
-		Target[] targets = getDeploymentManager().getTargets();
-		File jarFile = createJarFile(j2eeModule.getLocation());
-
-		GeronimoDeploymentProgressListener listener = createAndStartListener();
-
-		ProgressObject po = getDeploymentManager().distribute(targets, jarFile, null);
-		waitForCompletion(po, listener, CommandType.DISTRIBUTE, module.getProject());
-
-		if (po.getDeploymentStatus().isCompleted()) {
-
-			listener = createAndStartListener();
-
-			po = getDeploymentManager().start(po.getResultTargetModuleIDs());
-			waitForCompletion(po, listener, CommandType.START, module.getProject());
-
-			if (po.getDeploymentStatus().isCompleted()) {
-
-			} else if (po.getDeploymentStatus().isFailed()) {
-				// TODO handle fail
-			}
-		} else if (po.getDeploymentStatus().isFailed()) {
-			IStatus status = new Status(IStatus.ERROR, "org.eclipse.jst.geronimo.core", 0, "Distribution
of application failed.  See .log for details.", new Exception(listener.lastMessage));
-			throw new CoreException(status);
-		}
-	}
-
-	private void doReploy(IModule module) throws CoreException, DeploymentManagerCreationException{
-
-		IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, null);
-
-		TargetModuleID id = getTargetModuleID(module);
-		if (id != null) {
-			File jarFile = createJarFile(j2eeModule.getLocation());
-			GeronimoDeploymentProgressListener listener = createAndStartListener();
-			ProgressObject po = getDeploymentManager().redeploy(new TargetModuleID[] { id },
-					jarFile, null);
-			waitForCompletion(po, listener, CommandType.REDEPLOY, module.getProject());
-			if (po.getDeploymentStatus().isCompleted()) {
-
-			} else if (po.getDeploymentStatus().isFailed()) {
-				// TODO handle fail
-			}
-		}
-	}
-
-	private void doUndeploy(IModule module) throws CoreException, DeploymentManagerCreationException
{
-		TargetModuleID id = getTargetModuleID(module);
-		if (id != null) {
-			GeronimoDeploymentProgressListener listener = createAndStartListener();
-			ProgressObject po = getDeploymentManager().undeploy(new TargetModuleID[] { id });
-			waitForCompletion(po, listener, CommandType.UNDEPLOY, module.getProject());
-			if (po.getDeploymentStatus().isCompleted()) {
-
-			} else if (po.getDeploymentStatus().isFailed()) {
-				// TODO handle fail
-			}
-		}
-	}
-
-	private GeronimoDeploymentProgressListener createAndStartListener() {
-		GeronimoDeploymentProgressListener listener = new GeronimoDeploymentProgressListener();
-		listener.start();
-		return listener;
-	}
-
-	// TODO find a better way to get TargetModuleID for IModule
-	private TargetModuleID getTargetModuleID(IModule module) throws DeploymentManagerCreationException
{
-		try {
-			TargetModuleID ids[] = getDeploymentManager().getAvailableModules(
-					GeronimoUtils.getJSR88ModuleType(module), getDeploymentManager().getTargets());
-			if (ids != null) {
-				for (int i = 0; i < ids.length; i++) {
-					if (ids[i].getModuleID().equals(GeronimoUtils.getConfigId(module))) {
-						return ids[i];
-					}
-				}
-			}
-		} catch (IllegalStateException e) {
-			e.printStackTrace();
-		} catch (TargetException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	private File createJarFile(IPath location) {
-
-		try {
-
-			String rootFilename = location.toOSString();
-
-			File rootDir = new File(rootFilename);
-			String zipFilePrefix = rootDir.getName();
-			if (zipFilePrefix.length() < 3)
-				zipFilePrefix += "123";
-			File zipFile = File.createTempFile(zipFilePrefix, null);
-
-			if (zipFile.exists())
-				zipFile.delete();
-
-			FileOutputStream fos = new FileOutputStream(zipFile);
-			JarOutputStream jos = new JarOutputStream(fos);
-
-			addToJar("", rootDir, jos);
-
-			jos.close();
-			fos.close();
-
-			zipFile.deleteOnExit();
-
-			return zipFile;
-
-		} catch (IOException e) {
-			Trace.trace(Trace.SEVERE, "Error creating zip file", e);
-			return null;
-		}
-	}
-
-	private void addToJar(String namePrefix, File dir, JarOutputStream jos) throws IOException
{
-		File[] contents = dir.listFiles();
-		for (int i = 0; i < contents.length; i++) {
-			File f = contents[i];
-			if (f.isDirectory()) {
-				// Recurse into the directory
-				addToJar(namePrefix + f.getName() + "/", f, jos);
-			} else {
-				JarEntry entry = new JarEntry(namePrefix + f.getName());
-				jos.putNextEntry(entry);
-
-				byte[] buffer = new byte[10000];
-				FileInputStream fis = new FileInputStream(f);
-				int bytesRead = 0;
-				while (bytesRead != -1) {
-					bytesRead = fis.read(buffer);
-					if (bytesRead > 0)
-						jos.write(buffer, 0, bytesRead);
-				}
-			}
-		}
-	}
-
-	protected List getPublishClasspath() {
-		String cpRef = getServerDefinition().getStop().getClasspathReference();
-		return serverClasspath(cpRef);
-	}
-
-	public Map getServerInstanceProperties() {
-		return getRuntimeDelegate().getServerInstanceProperties();
-	}
+                Trace.trace(Trace.INFO, message);
+            }
+            lastMessage = message;
+            DeploymentStatus status = event.getDeploymentStatus();
+            if (status.getMessage() != null) {
+                Trace.trace(Trace.INFO, "\t" + status.getMessage());
+                _monitor.subTask(status.getMessage());
+            }
+            if (cmd == null || cmd == status.getCommand()) {
+                if (status.isCompleted() || status.isFailed()) {
+                    waitThread.interrupt();
+                }
+            }
+        }
+
+        public void start() {
+            waitThread.start();
+        }
+
+        public void setType(CommandType cmd) {
+            this.cmd = cmd;
+        }
+
+        public Thread getWaitThread() {
+            return waitThread;
+        }
+
+        public void setProject(IProject project) {
+            this.project = project;
+        }
+    }
+
+    private void waitForCompletion(ProgressObject po,
+            GeronimoDeploymentProgressListener listener, CommandType cmd,
+            IProject project) {
+
+        listener.setType(cmd);
+        listener.setProject(project);
+
+        po.addProgressListener(listener);
+
+        try {
+            listener.getWaitThread().join();
+        } catch (InterruptedException e) {
+        } finally {
+            po.removeProgressListener(listener);
+        }
+    }
+
+    private void invokeCommand(int deltaKind, IModule module)
+            throws CoreException {
+
+        GeronimoUtils.getConfigId(module); // triggers web dp creation
+
+        try {
+
+            switch (deltaKind) {
+            case ADDED: {
+                doDeploy(module);
+                break;
+            }
+            case CHANGED: {
+                doReploy(module);
+                break;
+            }
+            case REMOVED: {
+                doUndeploy(module);
+                break;
+            }
+            default:
+                throw new IllegalArgumentException();
+            }
+        } catch (DeploymentManagerCreationException e) {
+            e.printStackTrace();
+            throw new CoreException(new Status(IStatus.ERROR,
+                    "org.eclipse.jst.geronimo.core", 0, e.getMessage(), e));
+        } finally {
+
+        }
+    }
+
+    private void doDeploy(IModule module) throws CoreException,
+            DeploymentManagerCreationException {
+
+        IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(
+                IJ2EEModule.class, null);
+
+        Target[] targets = getDeploymentManager().getTargets();
+        File jarFile = createJarFile(j2eeModule.getLocation());
+
+        GeronimoDeploymentProgressListener listener = createAndStartListener();
+
+        ProgressObject po = getDeploymentManager().distribute(targets, jarFile,
+                null);
+        waitForCompletion(po, listener, CommandType.DISTRIBUTE, module
+                .getProject());
+
+        if (po.getDeploymentStatus().isCompleted()) {
+            listener = createAndStartListener();
+
+            po = getDeploymentManager().start(po.getResultTargetModuleIDs());
+            waitForCompletion(po, listener, CommandType.START, module
+                    .getProject());
+
+            if (po.getDeploymentStatus().isCompleted()) {
+            } else if (po.getDeploymentStatus().isFailed()) {
+                // TODO handle fail
+            }
+        } else if (po.getDeploymentStatus().isFailed()) {
+            IStatus status = new Status(
+                    IStatus.ERROR,
+                    "org.eclipse.jst.geronimo.core",
+                    0,
+                    "Distribution of application failed.  See .log for details.",
+                    new Exception(listener.lastMessage));
+            throw new CoreException(status);
+        }
+    }
+
+    private void doReploy(IModule module) throws CoreException,
+            DeploymentManagerCreationException {
+
+        IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(
+                IJ2EEModule.class, null);
+
+        TargetModuleID id = getTargetModuleID(module);
+        if (id != null) {
+            File jarFile = createJarFile(j2eeModule.getLocation());
+            GeronimoDeploymentProgressListener listener = createAndStartListener();
+            ProgressObject po = getDeploymentManager().redeploy(
+                    new TargetModuleID[] { id }, jarFile, null);
+            waitForCompletion(po, listener, CommandType.REDEPLOY, module
+                    .getProject());
+            if (po.getDeploymentStatus().isCompleted()) {
+
+            } else if (po.getDeploymentStatus().isFailed()) {
+                // TODO handle fail
+            }
+        }
+    }
+
+    private void doUndeploy(IModule module) throws CoreException,
+            DeploymentManagerCreationException {
+        TargetModuleID id = getTargetModuleID(module);
+        if (id != null) {
+            GeronimoDeploymentProgressListener listener = createAndStartListener();
+            ProgressObject po = getDeploymentManager().undeploy(
+                    new TargetModuleID[] { id });
+            waitForCompletion(po, listener, CommandType.UNDEPLOY, module
+                    .getProject());
+            if (po.getDeploymentStatus().isCompleted()) {
+            } else if (po.getDeploymentStatus().isFailed()) {
+                // TODO handle fail
+            }
+        }
+    }
+
+    private GeronimoDeploymentProgressListener createAndStartListener() {
+        GeronimoDeploymentProgressListener listener = new GeronimoDeploymentProgressListener();
+        listener.start();
+        return listener;
+    }
+
+    // TODO find a better way to get TargetModuleID for IModule
+    private TargetModuleID getTargetModuleID(IModule module)
+            throws DeploymentManagerCreationException {
+        try {
+            TargetModuleID ids[] = getDeploymentManager().getAvailableModules(
+                    GeronimoUtils.getJSR88ModuleType(module),
+                    getDeploymentManager().getTargets());
+            if (ids != null) {
+                for (int i = 0; i < ids.length; i++) {
+                    if (ids[i].getModuleID().equals(
+                            GeronimoUtils.getConfigId(module))) {
+                        return ids[i];
+                    }
+                }
+            }
+        } catch (IllegalStateException e) {
+            e.printStackTrace();
+        } catch (TargetException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private File createJarFile(IPath location) {
+
+        try {
+
+            String rootFilename = location.toOSString();
+
+            File rootDir = new File(rootFilename);
+            String zipFilePrefix = rootDir.getName();
+            if (zipFilePrefix.length() < 3)
+                zipFilePrefix += "123";
+            File zipFile = File.createTempFile(zipFilePrefix, null);
+
+            if (zipFile.exists())
+                zipFile.delete();
+
+            FileOutputStream fos = new FileOutputStream(zipFile);
+            JarOutputStream jos = new JarOutputStream(fos);
+
+            addToJar("", rootDir, jos);
+
+            jos.close();
+            fos.close();
+
+            zipFile.deleteOnExit();
+
+            return zipFile;
+
+        } catch (IOException e) {
+            Trace.trace(Trace.SEVERE, "Error creating zip file", e);
+            return null;
+        }
+    }
+
+    private void addToJar(String namePrefix, File dir, JarOutputStream jos)
+            throws IOException {
+        File[] contents = dir.listFiles();
+        for (int i = 0; i < contents.length; i++) {
+            File f = contents[i];
+            if (f.isDirectory()) {
+                // Recurse into the directory
+                addToJar(namePrefix + f.getName() + "/", f, jos);
+            } else {
+                JarEntry entry = new JarEntry(namePrefix + f.getName());
+                jos.putNextEntry(entry);
+
+                byte[] buffer = new byte[10000];
+                FileInputStream fis = new FileInputStream(f);
+                int bytesRead = 0;
+                while (bytesRead != -1) {
+                    bytesRead = fis.read(buffer);
+                    if (bytesRead > 0)
+                        jos.write(buffer, 0, bytesRead);
+                }
+            }
+        }
+    }
+
+    protected List getPublishClasspath() {
+        String cpRef = getServerDefinition().getStop().getClasspathReference();
+        return serverClasspath(cpRef);
+    }
+
+    public Map getServerInstanceProperties() {
+        return getRuntimeDelegate().getServerInstanceProperties();
+    }
 
 }

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/plugin.xml
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/plugin.xml?rev=289146&r1=289145&r2=289146&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/plugin.xml
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/plugin.xml
Wed Sep 14 21:51:03 2005
@@ -6,10 +6,10 @@
    version="1.0.0"
    provider-name="Apache Software Foundation">
    <runtime>     
-      <library name="lib/geronimo-deploy-jsr88-1.0-SNAPSHOT.jar">
+      <library name="lib/geronimo-deploy-jsr88-1.0-M4.jar">
          <export name="*"/>
       </library>     
-      <library name="lib/geronimo-kernel-1.0-SNAPSHOT.jar">
+      <library name="lib/geronimo-kernel-1.0-M4.jar">
          <export name="*"/>
       </library>     
       <library name="lib/geronimo-spec-j2ee-deployment-1.1-rc4.jar">
@@ -19,6 +19,15 @@
          <export name="*"/>
       </library>
       <library name="lib/mx4j-remote-3.0.1.jar">
+         <export name="*"/>
+      </library>
+      <library name="lib/commons-logging-1.0.4.jar">
+         <export name="*"/>
+      </library> 
+      <library name="lib/cglib-nodep-2.1_2.jar">
+         <export name="*"/>
+      </library>  
+      <library name="lib/geronimo-common-1.0-M4.jar">
          <export name="*"/>
       </library>   
    </runtime>

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/project.xml?rev=289146&r1=289145&r2=289146&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/project.xml
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.runtime.v1/project.xml
Wed Sep 14 21:51:03 2005
@@ -47,6 +47,21 @@
       <artifactId>geronimo-spec-j2ee-deployment</artifactId>
       <version>${geronimo_spec_version}</version>
     </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>${commons_logging_version}</version>
+    </dependency>
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <version>${cglib_version}</version>
+    </dependency>
+    <dependency>
+      <groupId>geronimo</groupId>
+      <artifactId>geronimo-common</artifactId>
+      <version>${geronimo_runtime_version}</version>
+    </dependency>
   </dependencies>
 </project>
 



Mime
View raw message