Author: rob.stryker(a)jboss.com
Date: 2007-06-28 23:39:52 -0400 (Thu, 28 Jun 2007)
New Revision: 2209
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/model/ServerProcessModel.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TimeoutPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java
Log:
Removed server process model and all references to it.
Now only a reference to the running server process is kept.
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/model/ServerProcessModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/model/ServerProcessModel.java 2007-06-29
03:16:02 UTC (rev 2208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/model/ServerProcessModel.java 2007-06-29
03:39:52 UTC (rev 2209)
@@ -1,201 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerLifecycleListener;
-import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.ide.eclipse.as.core.server.JBossServer;
-import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-
-public class ServerProcessModel implements IServerLifecycleListener {
-
- private static ServerProcessModel instance;
-
- /**
- * There is a singleton instance of the ServerProcessModel.
- * @return
- */
- public static ServerProcessModel getDefault() {
- if( instance == null ) {
- instance = new ServerProcessModel();
- }
- return instance;
- }
-
- /**
- * Static method to check if all of some process array are terminated.
- * @param processes
- * @return
- */
- public static boolean allProcessesTerminated(IProcess[] processes) {
- for( int i = 0; i < processes.length; i++ ) {
- if( !(processes[i].isTerminated())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Will map server ID's to a server process entity.
- * Each server has it's own entity instance.
- */
- private HashMap map;
-
- public ServerProcessModel() {
- map = new HashMap();
- initialize();
- }
-
- private void initialize() {
- ServerCore.addServerLifecycleListener(this);
- JBossServer[] servers = ServerConverter.getAllJBossServers();
- for( int i = 0; i < servers.length; i++ ) {
- getModel(servers[i].getServer().getId(), true);
- }
- }
-
-
- /**
- * Each JBoss Server instance has it's own sub-model
- * @param key
- * @return
- */
- public ServerProcessModelEntity getModel(String key) {
- return getModel(key, false);
- }
-
-
- private ServerProcessModelEntity getModel(String key, boolean create) {
- Object o = map.get(key);
- if( o == null ) {
- if( !create ) return null;
- o = new ServerProcessModelEntity(key);
- map.put(key, (ServerProcessModelEntity)o);
- }
- return ((ServerProcessModelEntity)o);
- }
-
- public ServerProcessModelEntity[] getModels() {
- ArrayList list = new ArrayList();
- Iterator i = map.keySet().iterator();
- while(i.hasNext()) {
- list.add(map.get(i.next()));
- }
- ServerProcessModelEntity[] models = new ServerProcessModelEntity[list.size()];
- list.toArray(models);
- return models;
- }
-
- /**
- * Completely shut down all JBoss Servers, as well as all
- * start, stop, and twiddle launches associated with them.
- */
- public void terminateAllProcesses() {
- Iterator i = map.values().iterator();
- ServerProcessModelEntity entity;
- while(i.hasNext()) {
- entity = (ServerProcessModelEntity)i.next();
- entity.clearAll();
- }
- }
-
- public class ServerProcessModelEntity {
-
- private String serverId;
- private HashMap processMap; // <String type, ArrayList processes>
- public ServerProcessModelEntity(String key) {
- this.serverId = key;
- processMap = new HashMap(3);
- processMap.put(JBossServerLaunchConfiguration.START, new ArrayList());
- processMap.put(JBossServerLaunchConfiguration.STOP, new ArrayList());
- processMap.put(JBossServerLaunchConfiguration.TWIDDLE, new ArrayList());
- }
- public String getServerId() {
- return serverId;
- }
-
- public void add( IProcess[] processes, String processType, ILaunchConfiguration config
) {
- ArrayList pds = (ArrayList)processMap.get(processType);
- for( int i = 0; i < processes.length; i++ ) {
- pds.add(processes[i]);
- }
- }
-
- public void terminateProcesses(String type) {
- IProcess[] proc = getProcesses(type);
- for( int i = 0; i < proc.length; i++ ) {
- try {
- proc[i].terminate();
- } catch( Exception e ) {
- }
- }
- }
- public IProcess[] getProcesses(String type) {
- ArrayList list = (ArrayList)processMap.get(type);
- if( list != null )
- return (IProcess[]) list.toArray(new IProcess[list.size()]);
- return new IProcess[0];
- }
-
- public void clearAll() {
- ArrayList list;
- IProcess proc;
- for( Iterator i = processMap.values().iterator(); i.hasNext();) {
- list = (ArrayList)i.next();
- for( Iterator j = list.iterator(); j.hasNext();) {
- try {
- proc = (IProcess)j.next();
- proc.terminate();
- } catch( DebugException de ) {}
- j.remove();
- }
- }
- }
- }
-
-
-
- public void serverAdded(IServer server) {
- if( ServerConverter.getJBossServer(server) != null ) {
- getModel(server.getId(), true);
- }
- }
-
- public void serverChanged(IServer server) {
- }
-
- public void serverRemoved(IServer server) {
- if( ServerConverter.getJBossServer(server) != null ) {
- map.remove(server.getId());
- }
- }
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TimeoutPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TimeoutPoller.java 2007-06-29
03:16:02 UTC (rev 2208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TimeoutPoller.java 2007-06-29
03:39:52 UTC (rev 2209)
@@ -24,21 +24,17 @@
import java.util.Date;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel;
import org.jboss.ide.eclipse.as.core.runtime.server.IServerStatePoller;
-// Wait 10 seconds, then say it's at it's expected state
+// Wait 15 seconds, then say it's at it's expected state
public class TimeoutPoller implements IServerStatePoller {
- private PollThread pollThread;
private boolean expectedState;
private long endTime;
- private IServer server;
int timeout = -1;
public void beginPolling(IServer server, boolean expectedState, PollThread pt) {
- this.server = server;
this.expectedState = expectedState;
this.endTime = new Date().getTime() + getTimeout();
}
@@ -60,10 +56,5 @@
}
public void cleanup() {
- if( !expectedState ) {
- ServerProcessModel.getDefault().getModel(server.getId()).clearAll();
- }
}
-
-
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java 2007-06-29
03:16:02 UTC (rev 2208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java 2007-06-29
03:39:52 UTC (rev 2209)
@@ -36,11 +36,8 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.model.EventLogModel;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel.ServerProcessModelEntity;
import org.jboss.ide.eclipse.as.core.runtime.server.IServerStatePoller;
-import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.TwiddleLauncher;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
@@ -159,13 +156,6 @@
}
public void cleanup() {
- ServerProcessModelEntity ent =
ServerProcessModel.getDefault().getModel(server.getId());
- if( expectedState == SERVER_UP) {
- ent.terminateProcesses(JBossServerLaunchConfiguration.TWIDDLE);
- } else {
- ent.terminateProcesses(JBossServerLaunchConfiguration.TWIDDLE);
- ent.terminateProcesses(JBossServerLaunchConfiguration.STOP);
- }
}
public class PollingSecurityException extends PollingException {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java 2007-06-29
03:16:02 UTC (rev 2208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java 2007-06-29
03:39:52 UTC (rev 2209)
@@ -33,7 +33,6 @@
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.model.EventLogModel;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.runtime.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.runtime.server.polling.PollThread;
@@ -41,33 +40,22 @@
import org.jboss.ide.eclipse.as.core.server.stripped.DeployableServerBehavior;
public class JBossServerBehavior extends DeployableServerBehavior {
- public static final String LAUNCH_CONFIG_DEFAULT_CLASSPATH =
"__JBOSS_SERVER_BEHAVIOR_LAUNCH_CONFIG_DEFAULT_CLASSPATH__";
-
-
private PollThread pollThread = null;
-
+ protected transient IProcess process;
public JBossServerBehavior() {
super();
}
public void stop(boolean force) {
- if( force ) {
+ int state = getServer().getServerState();
+ if( force || process.isTerminated() || state == IServer.STATE_STOPPED) {
forceStop();
return;
}
- // If the server's already terminated via processes, just abort
- IProcess[] startProcesses =
- ServerProcessModel.getDefault().getModel(getServer().getId()).getProcesses(JBossServerLaunchConfiguration.START);
- if( ServerProcessModel.allProcessesTerminated(startProcesses)) {
- forceStop();
- return;
- }
-
// if we're starting up or shutting down and they've tried again,
// then force it to stop.
- int state = getServer().getServerState();
- if( state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING || state ==
IServer.STATE_STOPPED) {
+ if( state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING ) {
pollThread.cancel();
forceStop();
return;
@@ -91,9 +79,10 @@
forceStop(true);
}
protected void forceStop(boolean addEvent) {
- // just terminate the processes. All of them
+ // just terminate the process.
try {
- ServerProcessModel.getDefault().getModel(getServer().getId()).clearAll();
+ if( process != null )
+ process.terminate();
process = null;
setServerStopped();
if( addEvent ) {
@@ -117,7 +106,6 @@
}
- protected transient IProcess process;
protected transient IDebugEventSetListener processListener;
public void setProcess(final IProcess newProcess) {
if (process != null)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java 2007-06-29
03:16:02 UTC (rev 2208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java 2007-06-29
03:39:52 UTC (rev 2209)
@@ -48,8 +48,6 @@
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.ServerType;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel.ServerProcessModelEntity;
public class JBossServerLaunchConfiguration extends
AbstractJavaLaunchConfigurationDelegate {
@@ -221,19 +219,15 @@
IProcess[] processes = new IProcess[0];
JBossServerBehavior jbossServerBehavior = getServerBehavior(configuration);
String serverID = jbossServerBehavior.getServer().getId();
- ServerProcessModelEntity processModel =
ServerProcessModel.getDefault().getModel(serverID);
if( action.equals(START)) {
processes = launchConfiguration(configuration, launch, monitor, mode);
- processModel.add(processes, action, configuration);
jbossServerBehavior.setProcess(processes[0]);
jbossServerBehavior.serverStarting();
} else if( action.equals(STOP)) {
processes = launchConfiguration(configuration, launch, monitor, mode);
- processModel.add(processes, action, configuration);
jbossServerBehavior.serverStopping();
} else if( action.equals(TWIDDLE)) {
processes = launchConfiguration(configuration, launch, monitor, mode);
- processModel.add(processes, action, configuration);
}
} catch( Exception e ) {
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IStatus.ERROR, "Error launching twiddle", e));
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java 2007-06-29
03:16:02 UTC (rev 2208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java 2007-06-29
03:39:52 UTC (rev 2209)
@@ -34,7 +34,6 @@
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.model.ServerProcessModel.ServerProcessModelEntity;
public class TwiddleLauncher {