[323542] Need to be able to use labels for server status/state other than the existing ones.
[322397] The entire module cache is destroyed if a publisher modified modules.
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Publisher.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Publisher.java
index f125d75..0dbb618 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Publisher.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Publisher.java
@@ -125,11 +125,11 @@
 				IServerWorkingCopy workingCopy = (IServerWorkingCopy)server;
 				server = (Server) workingCopy.getOriginal();
 			}
-			final List moduleList = (List)getDelegate().getTaskModel().getObject(TaskModel.TASK_MODULES);
+			final List<IModule[]> moduleList = getDelegate().getModifiedModules();
 			if (moduleList != null) {
-				final Iterator moduleIterator = moduleList.iterator();
+				final Iterator<IModule[]> moduleIterator = moduleList.iterator();
 				while (moduleIterator.hasNext()) {
-					IModule[] module = (IModule[]) moduleIterator.next();
+					IModule[] module = moduleIterator.next();
 					if (module != null) {
 						Trace.trace(Trace.FINEST, "rebuilding cache for module: " + module[module.length - 1]);
 						server.getServerPublishInfo().rebuildCache(module);
@@ -165,7 +165,7 @@
 		}
 		catch (Exception e) {
 			Trace.trace(Trace.SEVERE, "Error calling delegate " + toString(), e);
-			resultStatus = new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, "Error in delegate", e); // TODO
+			resultStatus = new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, "Error in delegate", e);
 		}
 		finally {
 			if (changeSchedulingRules) {
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/PublisherDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/PublisherDelegate.java
index 564b322..a8368c1 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/PublisherDelegate.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/PublisherDelegate.java
@@ -10,9 +10,12 @@
  *******************************************************************************/
 package org.eclipse.wst.server.core.model;
 
+import java.util.List;
+
 import org.eclipse.core.runtime.*;
 import org.eclipse.core.runtime.jobs.ISchedulingRule;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.TaskModel;
 /**
  * An operation that will be executed during publishing. 
@@ -114,4 +117,16 @@
 
 		return false;
 	}
+
+	/**
+	 * Accessor to acquire the list of {@link IModule} entries that were modified by the publisher.  By default, it will
+	 * return all modules published to the server
+	 * 
+	 * @return An array of {@link IModule} entries that were modified by the publisher
+	 * @since 3.2
+	 */
+	public List<IModule[]> getModifiedModules() {
+
+		return (List<IModule[]>) this.model.getObject(TaskModel.TASK_MODULES);
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.properties b/plugins/org.eclipse.wst.server.ui/plugin.properties
index 5a019ac..c876eda 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.properties
+++ b/plugins/org.eclipse.wst.server.ui/plugin.properties
@@ -17,6 +17,7 @@
 extensionPointServerImages=Server Images
 extensionPointWizardFragments=Wizard Fragments
 extensionPointInitialSelectionProvider=Initial Selection Provider
+extensionPointServerLabelProvider=Server Label Provider
 extensionPointAudio=Audio
 extensionPointServerCreationWizardPageExtension=Server Creation Wizard Page Extension
 extensionPointServerEditorOverviewPageExtension=Server Editor Overview Page Modifier
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 3e094c8..9baca0e 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -12,6 +12,7 @@
   <extension-point id="serverToolTip" name="%extensionPointServerToolTip" schema="schema/serverToolTip.exsd"/>
   <extension-point id="serverCreationWizardPageExtension" name="%extensionPointServerCreationWizardPageExtension" schema="schema/serverCreationWizardPageExtension.exsd"/>
   <extension-point id="serverEditorOverviewPageModifier" name="%extensionPointServerEditorOverviewPageExtension" schema="schema/serverEditorOverviewPageModifier.exsd"/>
+  <extension-point id="serverLabelProvider" name="%serverLabelProvider" schema="schema/serverLabelProvider.exsd"/>
 
 <extension point="org.eclipse.ui.newWizards">
   <category
diff --git a/plugins/org.eclipse.wst.server.ui/schema/serverLabelProvider.exsd b/plugins/org.eclipse.wst.server.ui/schema/serverLabelProvider.exsd
new file mode 100644
index 0000000..51fe81c
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/schema/serverLabelProvider.exsd
@@ -0,0 +1,133 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.server.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.wst.server.ui" id="serverLabelProvider" name="Server Label Provider"/>
+      </appInfo>
+      <documentation>
+         This extension point provides a way to customize the text label for a particular server type
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="serverLabelProvider" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="serverLabelProvider">
+      <annotation>
+         <appInfo>
+            <meta.element labelAttribute="name"/>
+         </appInfo>
+      </annotation>
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  specifies a unique identifier for this extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  specifies the fully qualified name of the Java class that extends &lt;samp&gt;org.eclipse.wst.server.ui.internal.provisional.AbstractServerLabelProvider&lt;/samp&gt;. The class must have a public 0-arg constructor.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.wst.server.ui.internal.provisional.AbstractServerLabelProvider:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="serverTypes" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The Server Types that this Server Label Provider will respond to. A comma separate list can be provider for more than one Server Type
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         3.2.2
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         &lt;b&gt;This extension point is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.&lt;/b&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2010 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made 
+available under the terms of the Eclipse Public License v1.0 which accompanies 
+this distribution, and is available at 
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
index 53794e1..40b12c1 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
@@ -10,12 +10,7 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
+import java.util.*;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -25,10 +20,14 @@
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.wizard.WizardDialog;
-
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.*;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
 import org.eclipse.wst.server.core.*;
 import org.eclipse.wst.server.core.internal.*;
-import org.eclipse.wst.server.ui.internal.Trace;
 import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
 import org.eclipse.wst.server.core.util.PublishAdapter;
 import org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier;
@@ -36,26 +35,14 @@
 import org.eclipse.wst.server.ui.internal.editor.IServerEditorInput;
 import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore;
 import org.eclipse.wst.server.ui.internal.editor.ServerEditorInput;
+import org.eclipse.wst.server.ui.internal.provisional.AbstractServerLabelProvider;
 import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
 import org.eclipse.wst.server.ui.internal.viewers.InitialSelectionProvider;
 import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
 import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.*;
 import org.eclipse.wst.server.ui.wizard.ServerCreationWizardPageExtension;
 import org.eclipse.wst.server.ui.wizard.WizardFragment;
-
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
 import org.osgi.framework.BundleContext;
 /**
  * The server UI plugin class.
@@ -95,7 +82,12 @@
 	
 	// Cached copy of all server editor UI modifiers
 	private static List<ServerEditorOverviewPageModifier> serverEditorOverviewPageModifier;
-
+	
+	// Cached copy of server state label provider
+	private static HashMap<String,AbstractServerLabelProvider> serverLabelProviders;
+	// Create a default server state label provider
+	private static AbstractServerLabelProvider defaultServerLabelProvider = new AbstractServerLabelProvider();
+	
 	// cached initial selection provider
 	private static InitialSelectionProvider selectionProvider;
 
@@ -227,6 +219,9 @@
 		super.start(context);
 		
 		ServerCore.addServerLifecycleListener(serverLifecycleListener);
+
+		// preload the server state label providers for faster UI response
+		loadServerLabelProvider();
 		
 		InitializeJob job = new InitializeJob();
 		job.schedule();
@@ -723,6 +718,26 @@
 		return selectionProvider;
 	}
 
+ 	/**
+	 * Returns the server label provider. There is always a server label provider for a server type
+	 *
+	 * @return the server label provider, if one is provider by the adopter otherwise it returns a default one
+	 */
+	public static AbstractServerLabelProvider getServerLabelProvider(String serverTypeId) {
+		if (serverLabelProviders == null)
+			loadServerLabelProvider();
+		
+		AbstractServerLabelProvider serverLabelProvider = serverLabelProviders.get(serverTypeId);
+		
+		// If there isn't one defined by an adopter, then bound the defaultServerLabelProvider to the list
+		if (serverLabelProvider == null){
+			serverLabelProvider = defaultServerLabelProvider;
+			serverLabelProviders.put(serverTypeId, serverLabelProvider);
+		}
+		
+		return serverLabelProvider; 
+	}
+
 	/**
 	 * Returns the list of server creation wizard modifier.
 	 *
@@ -745,7 +760,7 @@
 			loadServerEditorOverviewPageModifiers();
 		return serverEditorOverviewPageModifier;
 	}
-	
+
 	/**
 	 * Load the Server creation wizard page modifiers.
 	 */
@@ -802,6 +817,42 @@
 		Trace.trace(Trace.CONFIG, "-<- Done loading .serverEditorOverviewPageModifier extension point -<-");
 	}
 	
+	/**
+	 * Load the Server Label Providers. If there is two implemented for a ServerType the adopters ServerLabelProviders
+	 * will be ignored an a default will be returned
+	 */
+	private static synchronized void loadServerLabelProvider() {
+		if (serverLabelProviders != null)
+			return;
+		
+		Trace.trace(Trace.CONFIG, "->- Loading .serverLabelProvider extension point ->-");
+		serverLabelProviders = new HashMap<String,AbstractServerLabelProvider>();
+		IExtensionRegistry registry = Platform.getExtensionRegistry();
+		IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "serverLabelProvider");
+		
+		for (IConfigurationElement curConfigElement: cf) {
+			// load the extension in a safe enviroment. If there are NPEs or missconfigurations they will be caught by try/catch
+			String[] exServerTypes = ServerPlugin.tokenize(curConfigElement.getAttribute("serverTypes"), ",");
+			for (String exServerType : exServerTypes) {
+				try {
+					if (serverLabelProviders.containsKey(exServerType)){
+						// if a key is already bound for the same serverType, it means that more than one adopters is providing
+						// a ServerLabelProvider, since we don't know which one to use. We will default back to the WTP behaviour
+						Trace.trace(Trace.WARNING, "More that one .serverLabelProvider found - ignoring");
+						serverLabelProviders.put(exServerType, defaultServerLabelProvider);
+					}
+					else{
+						AbstractServerLabelProvider exClass = (AbstractServerLabelProvider)curConfigElement.createExecutableExtension("class");
+						Trace.trace(Trace.CONFIG, "  Loaded .serverLabelProvider: " + curConfigElement.getAttribute("id") + ", loaded class=" + exClass);
+						serverLabelProviders.put(exServerType, exClass); 
+					}
+				} catch (Throwable t) {
+					Trace.trace(Trace.SEVERE, "  Could not load .serverLabelProvider: " + curConfigElement.getAttribute("id"), t);
+				}
+			}
+		}		
+		Trace.trace(Trace.CONFIG, "-<- Done loading .serverLabelProvider extension point -<-");
+	}	
 	
 	/**
 	 * Load the initial selection provider.
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java
index e50ccc7..7a6c9cb 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java
@@ -19,9 +19,8 @@
 import org.eclipse.wst.server.core.IServerType;
 import org.eclipse.wst.server.core.internal.Server;
 import org.eclipse.wst.server.ui.ServerUICore;
-import org.eclipse.wst.server.ui.internal.ImageResource;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.*;
+import org.eclipse.wst.server.ui.internal.provisional.AbstractServerLabelProvider;
 import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
 import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
 
@@ -96,10 +95,23 @@
 				ImageResource.getImage(server.getServerType().getId());
 	}
 	
+	/**
+	 * Find the ServerLabelProvider for this server type and provide a label. If none are found
+	 * a default server label provider will be provided
+	 * 
+	 * @param server
+	 * @return
+	 */
 	public static String getServerStateLabel(IServer server) {
-		return server == null ? null : 
-			server.getServerType() == null ? null : 
-				getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
+		if (server == null || server.getServerType() == null)
+			return null;
+				
+		String stateLabel;
+		
+		AbstractServerLabelProvider labelProvider= ServerUIPlugin.getServerLabelProvider(server.getServerType().getId());
+		stateLabel =  labelProvider.getServerStateLabel(server);
+		
+		return stateLabel;
 	}
 
 	public static String getStateLabel(IServerType serverType, int state, String mode) {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/AbstractServerLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/AbstractServerLabelProvider.java
new file mode 100644
index 0000000..76f7084
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/AbstractServerLabelProvider.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal.provisional;
+
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.cnf.ServerDecorator;
+
+/**
+ * A default or parent class that provides the default labels: Start, Stop, Starting, etc..
+ * 
+ * @author arvera
+ *
+ */
+public class AbstractServerLabelProvider{
+
+	/**
+	 * Based on a server return the server state label to display in the UI
+	 * @param server
+	 * @return String
+	 */
+	public String getServerStateLabel(IServer server) {
+		if (server == null || server.getServerType() == null)
+			return null;
+		
+		return ServerDecorator.getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
+	}
+
+}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
index 205aa73..a80369f 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
@@ -12,6 +12,7 @@
 
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.wst.server.core.IServer;
@@ -21,10 +22,10 @@
 import org.eclipse.wst.server.ui.internal.ImageResource;
 import org.eclipse.wst.server.ui.internal.Messages;
 import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.cnf.ServerDecorator;
 import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
 import org.eclipse.wst.server.ui.internal.viewers.BaseCellLabelProvider;
 import org.eclipse.wst.server.ui.internal.viewers.ServerTreeContentProvider;
-import org.eclipse.swt.graphics.Image;
 /**
  * Server table label provider.
  */
@@ -263,13 +264,14 @@
 	 * @param server org.eclipse.wst.server.core.IServer
 	 */
 	protected String getServerStateLabel(IServer server) {
-		return getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
+		return ServerDecorator.getServerStateLabel(server);
 	}
 
 	/**
 	 * Returns a string representing the given state.
 	 *
 	 * @return java.lang.String
+	 * @deprecated
 	 */
 	protected String getStateLabel(IServerType serverType, int state, String mode) {
 		return UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode, count);