[476374] New Server Wizard - Implement auto caching of downloadable
server adapters
diff --git a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
index 18955a8..fcd7531 100644
--- a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.server.core; singleton:=true
-Bundle-Version: 1.7.0.qualifier
+Bundle-Version: 1.8.0.qualifier
 Bundle-Activator: org.eclipse.wst.server.core.internal.ServerPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.core/pom.xml b/plugins/org.eclipse.wst.server.core/pom.xml
index e6e6ce9..02154b0 100644
--- a/plugins/org.eclipse.wst.server.core/pom.xml
+++ b/plugins/org.eclipse.wst.server.core/pom.xml
@@ -22,6 +22,6 @@
 

   <groupId>org.eclipse.webtools.servertools</groupId>

   <artifactId>org.eclipse.wst.server.core</artifactId>

-  <version>1.7.0-SNAPSHOT</version>

+  <version>1.8.0-SNAPSHOT</version>

   <packaging>eclipse-plugin</packaging>

 </project>

diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java
index fbbe050..635a5db 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,7 +10,9 @@
  **********************************************************************/
 package org.eclipse.wst.server.core;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResourceDelta;
@@ -42,6 +44,7 @@
 	//	cached copy of all server and configuration types
 	private static List<IServerType> serverTypes;
 	private static List<IServerType> DAServerTypes;
+	private static List<IRuntimeType> DARuntimeTypes;
 
 	private static IRegistryChangeListener registryListener;
 
@@ -169,6 +172,18 @@
 	}
 	
 	/**
+	 * @since 1.8
+	 */
+	public static IRuntimeType[] getDownloadableRuntimeTypes(IProgressMonitor monitor){
+		if (DARuntimeTypes == null || DARuntimeTypes.isEmpty())
+			loadDARuntimeTypes(monitor);
+		IRuntimeType[] runtimesTypes2 = new IRuntimeType[DARuntimeTypes.size()];
+		DARuntimeTypes.toArray(runtimesTypes2);
+		
+		return runtimesTypes2;
+	}
+	
+	/**
 	 * @since 1.7
 	 */
 	public static void resetDownloadableServers(){
@@ -284,6 +299,27 @@
 		DAServerTypes.addAll(createProxyServers(monitor));
 		
 	}
+	
+	/**
+	 * Load the server types.
+	 */
+	private static synchronized void loadDARuntimeTypes(IProgressMonitor monitor) {
+		DARuntimeTypes = new ArrayList<IRuntimeType>();
+		
+		// fetch from site and add
+		DARuntimeTypes.addAll(createProxyRuntimeTypes(monitor));
+		
+	}
+
+	private static List<RuntimeTypeWithServerProxy> createProxyRuntimeTypes(IProgressMonitor monitor){
+		List<ServerProxy> serverProxyList = Discovery.getExtensionsWithServer(monitor);
+		List<RuntimeTypeWithServerProxy> serverTypeProxyList = new ArrayList<RuntimeTypeWithServerProxy>();
+		for (Iterator iterator = serverProxyList.iterator(); iterator.hasNext();) {
+			ServerProxy serverProxy = (ServerProxy) iterator.next();
+			serverTypeProxyList.add(new RuntimeTypeWithServerProxy(serverProxy.getRuntimeType(), new ServerTypeProxy(serverProxy)));
+		}
+		return serverTypeProxyList;
+	}
 
 	private static List<ServerTypeProxy> createProxyServers(IProgressMonitor monitor){
 		List<ServerProxy> serverProxyList = Discovery.getExtensionsWithServer(monitor);
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeTypeWithServerProxy.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeTypeWithServerProxy.java
new file mode 100644
index 0000000..3f2a87a
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/RuntimeTypeWithServerProxy.java
@@ -0,0 +1,101 @@
+/*******************************************************************************

+ * Copyright (c) 2016 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.core.internal;

+

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.wst.server.core.IModuleType;

+import org.eclipse.wst.server.core.IRuntimeType;

+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;

+import org.eclipse.wst.server.discovery.RuntimeProxy;

+/**

+ * @since 1.7

+ * 

+ */

+public class RuntimeTypeWithServerProxy implements IRuntimeType {

+	private String runtimTypeId;

+	private String name;

+	private String vendor;

+	private String description;

+	private ServerTypeProxy serverTypeProxy;

+

+	public RuntimeTypeWithServerProxy(String id, String name, String description, String vendor) {

+		super();

+		this.runtimTypeId = id;

+		this.name = name;

+		this.description = description;

+		this.vendor = vendor;

+	}

+	public RuntimeTypeWithServerProxy(RuntimeProxy runtimeProxy, ServerTypeProxy server) {

+		super();

+		this.runtimTypeId = runtimeProxy.getId();

+		this.name = runtimeProxy.getName();

+		this.description = runtimeProxy.getDescription();

+		this.vendor = runtimeProxy.getVendor();

+		this.serverTypeProxy = server;

+	}

+

+	/**

+	 * 

+	 * @return the id

+	 */

+	public String getId() {

+		return runtimTypeId;

+	}

+

+	/**

+	 * 

+	 * @return the name

+	 */

+	public String getName() {

+		return name;

+	}

+

+	/**

+	 * 

+	 * @return the description

+	 */

+	public String getDescription() {

+		return description;

+	}

+	

+	public String getVendor() {

+		return vendor;

+	}

+	

+	public String getVersion() {

+		return "";

+	}

+

+	/**

+	 * Return the supported module types.

+	 * 

+	 * @return an array of module types

+	 */

+	public IModuleType[] getModuleTypes() {

+		return null;

+	}

+	

+	public boolean canCreate() {

+		return false;

+	}

+

+	public IRuntimeWorkingCopy createRuntime(String id, IProgressMonitor monitor) {

+		return null;

+	}

+

+	public String toString() {

+		return "RuntimeType[" + getId() + ", " + getName() + "]";

+	}

+	public ServerTypeProxy getServerTypeProxy() {

+		return serverTypeProxy;

+	}

+	

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.discovery/META-INF/MANIFEST.MF
index 0a76940..19bb9cc 100644
--- a/plugins/org.eclipse.wst.server.discovery/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.discovery/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
 Bundle-Name: %bundleName
 Bundle-Vendor: %bundleVendor
 Bundle-SymbolicName: org.eclipse.wst.server.discovery;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
 Bundle-Activator: org.eclipse.wst.server.discovery.internal.Activator
 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0)",
  org.eclipse.ui;bundle-version="[3.5.0,4.0)",
diff --git a/plugins/org.eclipse.wst.server.discovery/pom.xml b/plugins/org.eclipse.wst.server.discovery/pom.xml
index cbdf6ae..2d5f3d4 100644
--- a/plugins/org.eclipse.wst.server.discovery/pom.xml
+++ b/plugins/org.eclipse.wst.server.discovery/pom.xml
@@ -22,6 +22,6 @@
 

   <groupId>org.eclipse.webtools.servertools</groupId>

   <artifactId>org.eclipse.wst.server.discovery</artifactId>

-  <version>1.1.0-SNAPSHOT</version>

+  <version>1.2.0-SNAPSHOT</version>

   <packaging>eclipse-plugin</packaging>

 </project>

diff --git a/plugins/org.eclipse.wst.server.discovery/serverAdapterSitesDetails.xml b/plugins/org.eclipse.wst.server.discovery/serverAdapterSitesDetails.xml
index 847d9c1..981de2b 100644
--- a/plugins/org.eclipse.wst.server.discovery/serverAdapterSitesDetails.xml
+++ b/plugins/org.eclipse.wst.server.discovery/serverAdapterSitesDetails.xml
@@ -1,98 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<?serverAdapter version="2"?>

+<!-- cached file as part of org.eclipse.wst.server.discovery version 1.1.0  -->

+

 <extensionDetails>

 	<feature

 		uri="http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/updates/bluemixAdapter/mars/"

 		id="com.ibm.cftools.wtp.serveradapter.feature.feature.group" name="IBM Bluemix Tools Server Adapter"

 		description="Cloud Tools for IBM Bluemix" provider="IBM"

-		version="1.0.0.v20150801_1001" serverId="com.ibm.cftools.server"/>

+		version="1.0.0.v20150801_1001" serverId="com.ibm.cftools.server" runtime-vendor="IBM"></feature>

 	<feature

 		uri="http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/updates/libertyAdapter/mars/"

 		id="com.ibm.ws.st.tools.base.feature.group"

 		name="WebSphere Application Server Liberty Profile Tools"

 		description="Tools for developing and administering WebSphere Application Server Liberty Profile"

-		provider="IBM" version="1.0.400.v20150617_2241" serverId="com.ibm.ws.st.server.wlp">

+		provider="IBM" version="1.0.400.v20150617_2241"

+		serverId="com.ibm.ws.st.server.wlp" runtime-vendor="IBM">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.v10.feature.feature.group" name="Geronimo v1.0 Server Adapter"

-		description="This feature provides the WTP Server Adapter and additional development tools for Apache Geronimo."

-		provider="Apache" version="2.0.0">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.v10.feature.feature.group"

+		name="Geronimo v1.0 Server Adapter"

+		description="This feature provides the WTP Server Adapter and additional development tools for Apache Software Foundation Geronimo."

+		provider="Apache Software Foundation" version="2.0.0" runtime-vendor="Apache">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.v22.feature.feature.group" name="Geronimo v2.2 Server Adapter"

-		description="This feature provides the WTP Server Adapters and additional development tools for the Apache Geronimo v2.0, v2.1 and v2.2 servers."

-		provider="Apache" version="2.2.1">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.v22.feature.feature.group"

+		name="Geronimo v2.2 Server Adapter"

+		description="This feature provides the WTP Server Adapters and additional development tools for the Apache Software Foundation Geronimo v2.0, v2.1 and v2.2 servers."

+		provider="Apache Software Foundation" version="2.2.1" runtime-vendor="Apache">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.feature.feature.group" name="Geronimo Core Feature"

-		description="This feature provides core support required for the WTP Server Adapter for specific versions of the Apache Geronimo server."

-		provider="Apache" version="2.1.1">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.feature.feature.group"

+		name="Geronimo Core Feature"

+		description="This feature provides core support required for the WTP Server Adapter for specific versions of the Apache Software Foundation Geronimo server."

+		provider="Apache Software Foundation" version="2.1.1" runtime-vendor="Apache">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.v30.feature.feature.group" name="Geronimo v3.0 Server Adapter"

-		description="This feature provides the WTP Server Adapters and additional development tools for the Apache Geronimo v1.1, v2.0, v2.1, v2.2, and v3.0 servers."

-		provider="Apache" version="3.0.1">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.v30.feature.feature.group"

+		name="Geronimo v3.0 Server Adapter"

+		description="This feature provides the WTP Server Adapters and additional development tools for the Apache Software Foundation Geronimo v1.1, v2.0, v2.1, v2.2, and v3.0 servers."

+		provider="Apache Software Foundation" version="3.0.1" runtime-vendor="Apache">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.v11.feature.feature.group" name="Geronimo v1.1.x Server Adapter"

-		description="This feature provides the WTP Server Adapter and additional development tools for Apache Geronimo."

-		provider="Apache" version="2.0.0">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.v11.feature.feature.group"

+		name="Geronimo v1.1.x Server Adapter"

+		description="This feature provides the WTP Server Adapter and additional development tools for Apache Software Foundation Geronimo."

+		provider="Apache Software Foundation" version="2.0.0" runtime-vendor="Apache">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.v21.feature.feature.group" name="Geronimo v2.1 Server Adapter"

-		description="This feature provides the WTP Server Adapters and additional development tools for the Apache Geronimo v2.0 and v2.1 servers."

-		provider="Apache" version="2.1.8">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.v21.feature.feature.group"

+		name="Geronimo v2.1 Server Adapter"

+		description="This feature provides the WTP Server Adapters and additional development tools for the Apache Software Foundation Geronimo v2.0 and v2.1 servers."

+		provider="Apache Software Foundation" version="2.1.8" runtime-vendor="Apache">

 	</feature>

-	<feature

-		uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

-		id="org.apache.geronimo.v20.feature.feature.group" name="Geronimo v2.0 Server Adapter"

-		description="This feature provides the WTP Server Adapter and additional development tools for the Apache Geronimo v2.0 server."

-		provider="Apache" version="2.1.2">

+	<feature uri="http://www.apache.org/dist/geronimo/eclipse/updates/"

+		id="org.apache.geronimo.v20.feature.feature.group"

+		name="Geronimo v2.0 Server Adapter"

+		description="This feature provides the WTP Server Adapter and additional development tools for the Apache Software Foundation Geronimo v2.0 server."

+		provider="Apache Software Foundation" version="2.1.2" runtime-vendor="Apache">

 	</feature>

 	<feature

 		uri="http://master.dl.sourceforge.net/project/sapnweclipse/updates/"

-		id="com.sap.netweaver.porta.ide.eclipse.feature.feature.group" name="SAP NetWeaver Server Adapter"

+		id="com.sap.netweaver.porta.ide.eclipse.feature.feature.group"

+		name="SAP NetWeaver Server Adapter"

 		description="Server adapter for the SAP NetWeaver Application Server. Supports J2EE 1.4 and Java EE 5 modules."

-		provider="SAP" version="0.7.2.201006211643">

+		provider="SAP AG" version="0.7.2.201006211643" runtime-vendor="SAP">

 	</feature>

-	<feature

-		uri="http://jope.ow2.org/update/jope/"

+	<feature uri="http://jope.ow2.org/update/jope/"

 		id="org.ow2.jonas.wtp.adapter.feature.group" name="Jonas WTP Adapter"

 		description="JOPE (JOnAS Plugin for Eclipse) is an open source JOnAS plugin for Eclipse."

-		provider="OW2" version="5.1.2">

+		provider="OW2" version="5.1.2" runtime-vendor="OW2">

 	</feature>

-	<feature

-		uri="http://www.caucho.com/eclipse/"

-		id="com.caucho.resin.eclipse.feature.group" name="Resin (Java EE Web Profile) Server"

+	<feature uri="http://www.caucho.com/eclipse/"

+		id="com.caucho.resin.eclipse.feature.group"

+		name="Resin (Java EE Web Profile) Server"

 		description="Resin Eclipse Plugin based on WebTools Generic Server."

-		provider="Resin" version="4.0.27">

+		provider="Caucho Technology, Inc." version="4.0.27" runtime-vendor="Resin">

 	</feature>

 	<feature

 		uri="http://download.jboss.org/jbosstools/updates/webtools/mars/"

-		id="org.jboss.ide.eclipse.as.feature.feature.group" name="JBoss AS, WildFly, &amp; EAP Server Tools"

+		id="org.jboss.ide.eclipse.as.feature.feature.group"

+		name="JBoss AS, WildFly, &amp; EAP Server Tools"

 		description="Provides WTP server adapters for JBoss installations. These adapters are capable of deployment and providing classpaths for projects. Zipped or exploded deployments, JMX integration, and other extensions are included."

-		provider="Red Hat JBoss Middleware" version="3.1.0.Beta2-v20150723-0026-B29">

+		provider="JBoss by Red Hat"

+		version="3.1.0.Beta2-v20150723-0026-B29" runtime-vendor="Red Hat JBoss Middleware">

 	</feature>

-	<feature

-		uri="http://download.oracle.com/otn_software/oepe/mars/"

-		id="oracle.eclipse.tools.cloud.feature.group" name="Oracle Cloud Tools"

+	<feature uri="http://download.oracle.com/otn_software/oepe/mars/"

+		id="oracle.eclipse.tools.cloud.feature.group"

+		name="Oracle Cloud Tools"

 		description="Additional tools for developing Oracle Cloud applications."

-		provider="Oracle" version="8.2.0.201507100122">

+		provider="Oracle" version="8.2.0.201507100122" runtime-vendor="Oracle">

 	</feature>

-	<feature

-		uri="http://download.oracle.com/otn_software/oepe/mars/"

-		id="oracle.eclipse.tools.weblogic.feature.group" name="Oracle WebLogic Server Tools"

+	<feature uri="http://download.oracle.com/otn_software/oepe/mars/"

+		id="oracle.eclipse.tools.weblogic.feature.group"

+		name="Oracle WebLogic Server Tools"

 		description="Tools for developing applications for Oracle WebLogic Server (versions 12.1.x, 10.3.x, 10.0 and 9.2)."

-		provider="Oracle" version="8.2.0.201507100122">

+		provider="Oracle" version="8.2.0.201507100122" runtime-vendor="Oracle">

 	</feature>

-	<feature

-		uri="http://download.oracle.com/otn_software/oepe/mars/"

-		id="oracle.eclipse.tools.glassfish.feature.group" name="GlassFish Tools"

+	<feature uri="http://download.oracle.com/otn_software/oepe/mars/"

+		id="oracle.eclipse.tools.glassfish.feature.group"

+		name="GlassFish Tools"

 		description="Tools for developing applications for GlassFish."

-		provider="Oracle" version="8.2.0.201507100122">

+		provider="Oracle" version="8.2.0.201507100122" runtime-vendor="Oracle">

 	</feature>

 </extensionDetails>
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/Discovery.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/Discovery.java
index 1d8d5a2..dbc2cdb 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/Discovery.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/Discovery.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -16,6 +16,7 @@
 import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.discovery.internal.DiscoveryPreferences;
 import org.eclipse.wst.server.discovery.internal.ExtensionUtility;
 
 public class Discovery {
@@ -64,4 +65,25 @@
 	public static void refreshServerAdapters(IProgressMonitor monitor) {
 		ExtensionUtility.refreshServerAdapters(monitor);
 	}
+	
+	/**
+	 * @since 1.2
+	 */
+	public static String getLastUpdatedDate(){
+		return DiscoveryPreferences.getInstance().getCacheLastUpdatedDate();
+	}
+	
+	/**
+	 * @since 1.2
+	 */
+	public static int  getCacheUpdateFrequency(){
+		return DiscoveryPreferences.getInstance().getCacheFrequency();
+	}
+	
+	/**
+	 * @since 1.2
+	 */
+	public static void  setCacheUpdateFrequency(int frequency){
+		DiscoveryPreferences.getInstance().setCacheFrequency(frequency);
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/DiscoveryPreferences.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/DiscoveryPreferences.java
new file mode 100644
index 0000000..00589a5
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/DiscoveryPreferences.java
@@ -0,0 +1,84 @@
+/*******************************************************************************

+ * Copyright (c) 2016 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.discovery.internal;

+

+import org.eclipse.core.runtime.Preferences;

+/**

+ * Helper class that stores preference information for Discovery.

+ */

+public class DiscoveryPreferences {

+

+	private static final String PREF_CACHE_FREQUENCY = "cache-frequency";

+	private static final String PREF_CACHE_LAST_UPDATED_DATE = "cache-lastUpdatedDate";

+

+	private Preferences preferences;

+

+	private static DiscoveryPreferences instance;

+

+	/**

+	 * ServerUIPreference constructor comment.

+	 */

+	private DiscoveryPreferences() {

+		super();

+		preferences = Activator.getDefault().getPluginPreferences();

+		setDefaults();

+	}

+

+	public static DiscoveryPreferences getInstance() {

+		if (instance == null)

+			instance = new DiscoveryPreferences();

+		return instance;

+	}

+

+	private void setDefaults() {

+		preferences.setDefault(PREF_CACHE_FREQUENCY, 2);

+		preferences.setDefault(PREF_CACHE_LAST_UPDATED_DATE, Messages.cacheUpdate_Never);

+	}

+

+	

+	

+	/**

+	 * Returns the frequency for cache update.

+	 * 

+	 * @return String

+	 */

+	public int getCacheFrequency() {

+		return preferences.getInt(PREF_CACHE_FREQUENCY);

+	}

+

+	/**

+	 * Sets the frequency for cache update.

+	 *

+	 * @param frequency - 0-Manual, 1-Fortnightly, 2-Monthly and 3-Quarterly 

+	 */

+	public void setCacheFrequency(int frequency) {

+		preferences.setValue(PREF_CACHE_FREQUENCY, frequency);

+		Activator.getDefault().savePluginPreferences();

+	}

+

+	/**

+	 * Returns the cache last updated date.

+	 * 

+	 * @return String

+	 */

+	public String getCacheLastUpdatedDate() {

+		return preferences.getString(PREF_CACHE_LAST_UPDATED_DATE);

+	}

+	

+	/**

+	 * Sets the last updated cache date

+	 *

+	 */

+	public void setCacheLastUpdatedDate(String lastUpdateDate) {

+		preferences.setValue(PREF_CACHE_LAST_UPDATED_DATE, lastUpdateDate);

+		Activator.getDefault().savePluginPreferences();

+	}

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java
index bb6c71e..574ed48 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -14,6 +14,8 @@
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 import org.eclipse.core.runtime.*;
@@ -36,8 +38,11 @@
 import org.eclipse.wst.server.discovery.RuntimeProxy;
 import org.eclipse.wst.server.discovery.ServerProxy;
 import org.eclipse.wst.server.discovery.internal.model.*;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
+import org.w3c.dom.Comment;
+import org.w3c.dom.ProcessingInstruction;
 
 public class ExtensionUtility {
 	private static final String SERVER_ADAPTER_SITES_DETAILS = "serverAdapterSitesDetails.xml";
@@ -46,11 +51,14 @@
     private static List<ServerProxy> serverExtension = new ArrayList<ServerProxy>();
     private static HashMap<String, Extension>extensionMap = new HashMap<String, Extension>();
     private static HashMap<String, ErrorMessage> extensionMapError = new HashMap<String, ErrorMessage>();
+    private static Object cacheFileLock = new Object();
 	
     
     private static List<IServerExtension> getExtensionUpdateSitesDetails(URL url, Extension[] extnList) throws CoreException {InputStream in = null;
 		try {
-			in = url.openStream();
+			synchronized (cacheFileLock) {
+				in = url.openStream();
+			}
 		} catch (Exception e) {
 			Trace.trace(Trace.SEVERE, "Could not load URL " + url);
 		}
@@ -59,44 +67,87 @@
 			throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Could not load extension details", null));
 	
 		try {
-			IMemento memento = XMLMemento.loadMemento(in);
+			IMemento memento ;
+			synchronized (cacheFileLock) {
+				memento = XMLMemento.loadMemento(in);
+			}
 			List<IServerExtension> list = new ArrayList<IServerExtension>();
 			IMemento children[] = memento.getChildren("feature");
 
 			if (extnList != null){
-				XMLMemento newMemento = XMLMemento.createWriteRoot("extensionDetails");
-
+				ProcessingInstruction processInstrn = ((XMLMemento)memento).getProcessingInstruction();
+				Bundle bundle = Activator.getDefault().getBundle();
+				//String dateString = new Date(System.currentTimeMillis()).toString();
+				DateFormat df = new SimpleDateFormat("EEE MMM dd yyyy kk:mm:ss zzz", Locale.ENGLISH);
+				Date date = new Date(System.currentTimeMillis());
+				String dateString = df.format(date);
+				String comment ="Generated by " + bundle.getSymbolicName() + " " + bundle.getVersion() + " on " + 	dateString	;
+				XMLMemento newMemento = null;
+				if (processInstrn == null)
+					newMemento = XMLMemento.createWriteRoot("extensionDetails", "serverAdapter", "version=\"2\"", comment);
+				else
+					 newMemento = XMLMemento.createWriteRoot("extensionDetails", processInstrn.getTarget(), processInstrn.getData(), comment);
+				
 				for (int j = 0; j < extnList.length; j++) {
 					IMemento childMemento = newMemento.createChild("feature");
-					childMemento.putString("provider", extnList[j].getProvider());
-					for (int i = 0; i < children.length; i++) {
-						if (children[i].getString("id").equals(extnList[j].getId())){
-							childMemento.putString("provider", children[i].getString("provider"));
-							if(extnList[j].getServerId() != null){
-								childMemento.putString("serverId", extnList[j].getServerId());
-							}
-							else if (children[i].getString("serverId") != null)
-								childMemento.putString("serverId", children[i].getString("serverId"));
-							
-							break;
-						}
-					}
-
+					String vendor = extnList[j].getRuntimeVendor();
+					String serverId = extnList[j].getServerId();
 					childMemento.putString("id", extnList[j].getId());
 					childMemento.putString("description", extnList[j].getDescription());
 					childMemento.putString("name", extnList[j].getName());
 					childMemento.putString("uri", extnList[j].getURI());
 					childMemento.putString("version", extnList[j].getVersion().toString());
+					childMemento.putString("provider", extnList[j].getProvider());
+					childMemento.putString("serverId", serverId );
+
+					for (int i = 0; i < children.length; i++) {
+						if (children[i].getString("id").equals(extnList[j].getId())){
+							// if vendor detail not provided by site, the provider detail in cache will not be updated to avoid mismatch of runtime vendor nodes
+							if (vendor == null || (vendor != null && vendor.length() == 0)) {
+								childMemento.putString("provider", children[i].getString("provider"));
+								childMemento.putString("vendor", children[i].getString("runtime-vendor"));
+							}
+							else
+								childMemento.putString("vendor", vendor);
+
+							// use the cache data if sites have not provided the data
+							if ((serverId == null || (serverId != null && serverId.length() ==0)))
+								childMemento.putString("serverId", children[i].getString("serverId"));
+							else
+								childMemento.putString("serverId",serverId);
+							
+							break;
+						}
+					}
+
+					
 					ExtensionProxy item = new ExtensionProxy(childMemento.getString("id"), childMemento.getString("name"), childMemento.getString("description"), 
-							childMemento.getString("provider"), childMemento.getString("uri"), childMemento.getString("version"), childMemento.getString("serverId"));
+							childMemento.getString("provider"), childMemento.getString("uri"), childMemento.getString("version"), childMemento.getString("serverId"), childMemento.getString("vendor"));
 						list.add(item);
 				}
-				newMemento.saveToFile(url.toURI().getPath());
+				synchronized (cacheFileLock) {
+					newMemento.saveToFile(url.toURI().getPath());
+				}
+				DiscoveryPreferences.getInstance().setCacheLastUpdatedDate(dateString.trim());
 			}
 			else{
+				ProcessingInstruction processInstrn = ((XMLMemento)memento).getProcessingInstruction();
+				if (processInstrn != null && processInstrn.getNextSibling() instanceof Comment){
+					Comment comment = (Comment)processInstrn.getNextSibling();
+					String commentText = comment.getTextContent();
+					int index = commentText.indexOf(" on ");
+					if (index == -1)
+						DiscoveryPreferences.getInstance().setCacheLastUpdatedDate(Messages.cacheUpdate_Never);
+					else {
+						String dateString = commentText.substring(index+3);
+						DiscoveryPreferences.getInstance().setCacheLastUpdatedDate(dateString);
+					}
+				}
+				else
+					DiscoveryPreferences.getInstance().setCacheLastUpdatedDate(Messages.cacheUpdate_Never);
 				for (int i = 0; i < children.length; i++) {
 					ExtensionProxy item = new ExtensionProxy(children[i].getString("id"), children[i].getString("name"), children[i].getString("description"), 
-						children[i].getString("provider"), children[i].getString("uri"), children[i].getString("version"), children[i].getString("serverId"));
+						children[i].getString("provider"), children[i].getString("uri"), children[i].getString("version"), children[i].getString("serverId"), children[i].getString("vendor"));
 					list.add(item);
 				}
 			}
@@ -242,7 +293,7 @@
 	private static File getConfigDir() throws IOException, URISyntaxException {
 		Location cfgLoc = Platform.getConfigurationLocation();
 		URL cfgDataUrl = cfgLoc.getDataArea(Activator.PLUGIN_ID);
-		return new File(cfgDataUrl.toExternalForm());
+		return new File(cfgDataUrl.getFile());
 	}
 	
 	private static void printLog(String msg, Exception ex) {
@@ -333,7 +384,11 @@
 	}
 	
 	private static ServerProxy createServerProxy(ExtensionProxy newFeature){
-		RuntimeProxy runtimeProxy = new RuntimeProxy("com.eclipse.runtime.proxy", newFeature.getName(), newFeature.getDescription(), newFeature.getProvider());
+		String runtimeVendor = newFeature.getRuntimeVendor();
+		if (runtimeVendor == null || (runtimeVendor!= null && runtimeVendor.length() == 0)){
+			runtimeVendor = newFeature.getProvider();
+		}
+		RuntimeProxy runtimeProxy = new RuntimeProxy("com.eclipse.runtime.proxy", newFeature.getName(), newFeature.getDescription(), runtimeVendor);
 		ServerProxy serverProxy = new ServerProxy("com.eclipse.server.proxy", newFeature.getName(), newFeature.getDescription(),  runtimeProxy, newFeature.getId(), newFeature.getURI(), newFeature.getServerId());
 		return serverProxy;
 	}
@@ -619,12 +674,16 @@
 	}
 	
 	public static void refreshServerAdapters(IProgressMonitor monitor){
+		getExtensionsWithServer(monitor);
 		try {
 			Extension[] extnList = getAllExtensions(SERVER_ADAPTER_ID, null, monitor);
-			getExtensionUpdateSitesDetails(extnList);
-			serverExtension = new ArrayList<ServerProxy>();
+			if (extnList != null && extnList.length >0) {
+				getExtensionUpdateSitesDetails(extnList);
+				serverExtension = new ArrayList<ServerProxy>();
+			}
 		} catch (CoreException e) {
 			Trace.trace(Trace.SEVERE, "Could not refresh server adapter list.");
 		}
 	}
+
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.java
index a20a715..45dea7f 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -33,6 +33,7 @@
 	public static String validateInstall;
 	public static String validateInstallError;
 	public static String fetchingRepositoryFailure;
+	public static String cacheUpdate_Never;
 
 	static {
 		NLS.initializeMessages(Activator.PLUGIN_ID + ".internal.Messages", Messages.class);
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.properties b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.properties
index 8a057f0..e4fb9fc 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.properties
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/Messages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2008,2015 IBM Corporation and others.
+# Copyright (c) 2008, 2016 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
@@ -27,4 +27,5 @@
 fetchingRepository=Fetching from Repository
 validateInstall=Validating requirements for install
 validateInstallError=Selected Server cannot be installed. Check Error log for details
-fetchingRepositoryFailure=Could not fetch the details
\ No newline at end of file
+fetchingRepositoryFailure=Could not fetch the details
+cacheUpdate_Never=Never
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/XMLMemento.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/XMLMemento.java
index 31595b1..ad357c2 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/XMLMemento.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/XMLMemento.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -38,6 +38,7 @@
 public final class XMLMemento implements IMemento {
 	private Document factory;
 	private Element element;
+	private ProcessingInstruction processInstrn;
 
 	/**
 	 * Answer a memento for the document and element.  For simplicity
@@ -69,8 +70,19 @@
 			DocumentBuilder parser = factory.newDocumentBuilder();
 			document = parser.parse(new InputSource(in));
 			Node node = document.getFirstChild();
-			if (node instanceof Element)
-				return new XMLMemento(document, (Element) node);
+			ProcessingInstruction newPI = null;
+			if (node instanceof ProcessingInstruction){
+				newPI = (ProcessingInstruction)node;
+				node = node.getNextSibling();
+				if (node instanceof Comment)
+					node = node.getNextSibling();
+			}
+			if (node instanceof Element){
+				XMLMemento memento = new XMLMemento(document, (Element) node);
+				if (newPI != null)
+					memento.setProcessingInstruction(newPI);
+				return memento;
+			}
 		} catch (Exception e) {
 			// ignore
 		} finally {
@@ -101,6 +113,30 @@
 		}
 	}
 	
+	/**
+	 * Answer a root memento for writing a document.
+	 * 
+	 * @param type a type
+	 * @param target a processingInstruction target
+	 * @param data a processingInstruction data
+	 * @return a memento
+	 */
+	public static XMLMemento createWriteRoot(String type, String target, String data, String commentString) {
+		Document document;
+		try {
+			document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+			ProcessingInstruction newProcessInstrn = document.createProcessingInstruction(target, data);
+			document.appendChild(newProcessInstrn);
+			Comment comment =document.createComment(commentString);
+			document.appendChild(comment);
+			Element element = document.createElement(type);
+			document.appendChild(element);
+			return new XMLMemento(document, element);            
+		} catch (ParserConfigurationException e) {
+			throw new Error(e);
+		}
+	}
+	
 	/*
 	 * @see IMemento
 	 */
@@ -387,4 +423,12 @@
            textNode.setData(data);
        }
    }
+   
+   public ProcessingInstruction getProcessingInstruction(){
+	   return processInstrn;
+   }
+   
+   protected void setProcessingInstruction(ProcessingInstruction processInstrn){
+	   this.processInstrn = processInstrn;
+   }
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java
index 806ebdc..f070e57 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -162,4 +162,8 @@
 	public String getServerId() {
 		return iu.getProperty("serverId", null);
 	}
+	
+	public String getRuntimeVendor() {
+		return iu.getProperty("vendor", null);
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/ExtensionProxy.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/ExtensionProxy.java
index 55cc4de..a571ae1 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/ExtensionProxy.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/ExtensionProxy.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2015 IBM Corporation and others.

+ * Copyright (c) 2015, 2016 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

@@ -23,9 +23,10 @@
 	private String uri;

 	private String version;

 	private String serverId;

+	private String vendor;

 

 

-	public ExtensionProxy(String id, String name, String description, String provider, String uri, String version, String serverId) {

+	public ExtensionProxy(String id, String name, String description, String provider, String uri, String version, String serverId, String vendor) {

 		this.id= id;

 		this.name= name;

 		this.description= description;

@@ -33,6 +34,7 @@
 		this.uri = uri;

 		this.version = version;

 		this.serverId = serverId;

+		this.vendor = vendor;

 	}

 

 	public String getName() {

@@ -66,5 +68,9 @@
 	public String getServerId() {

 		return serverId;

 	}

+	

+	public String getRuntimeVendor() {

+		return vendor;

+	}

 

 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/IServerExtension.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/IServerExtension.java
index 9df509d..c7ab166 100644
--- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/IServerExtension.java
+++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/IServerExtension.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2015 IBM Corporation and others.

+ * Copyright (c) 2015, 2016 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

@@ -24,4 +24,6 @@
 	public String getURI() ;

 	

 	public Version getVersion() ;

+	

+	public String getRuntimeVendor() ;

 }

diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 9925b80..5b10725 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -637,6 +637,13 @@
 			icon="icons/obj16/server.gif"
 			typeIds="com.eclipse.server.proxy" />
 	</extension>
+<extension point="org.eclipse.wst.server.ui.serverImages">
+		<image 
+			id="com.eclipse.wst.server.downloadableserver.image" 
+			icon="icons/obj16/server.gif"
+			typeIds="com.eclipse.runtime.proxy" />
+	</extension>	
+	
 <extension point="org.eclipse.wst.server.ui.wizardFragments">
 	<fragment
 		id="com.eclipse.wst.server.downloadableserver"
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ICacheUpdateListener.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ICacheUpdateListener.java
new file mode 100644
index 0000000..ff8e084
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ICacheUpdateListener.java
@@ -0,0 +1,17 @@
+/*******************************************************************************

+ * Copyright (c) 2016 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;

+

+public interface ICacheUpdateListener {

+	public void start();

+	public void done();

+

+}

diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java
index 064a0fb..3871dd2 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,9 +10,23 @@
  **********************************************************************/
 package org.eclipse.wst.server.ui;
 
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.discovery.Discovery;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ProgressUtil;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
 /**
  * Server UI utility methods.
  * <p>
@@ -73,4 +87,88 @@
 	public static boolean showNewServerWizard(Shell shell, String typeId, String versionId, String serverTypeId) {
 		return ServerUIPlugin.showNewServerWizard(shell, typeId, versionId, serverTypeId);
 	}
-}
\ No newline at end of file
+	
+	
+	public static Job refreshServerNode(final boolean userInitiated){
+		class RefreshJob extends Job{
+			public RefreshJob() {
+				super(Messages.jobRefreshingServerAdapter);
+			}
+			
+			public boolean belongsTo(Object family) {
+				return "org.eclipse.wst.server.ui.family".equals(family);
+			}
+			protected IStatus run(IProgressMonitor monitor) {
+				monitor = ProgressUtil.getMonitorFor(monitor);
+				monitor.beginTask("", 1000);
+				refreshButtonText = Messages.cacheUpdate_refreshing;
+				if (cacheUpdateJobListener != null)
+					cacheUpdateJobListener.start();
+				Discovery.refreshServerAdapters(ProgressUtil.getSubMonitorFor(monitor, 500));
+				monitor.worked(700);
+				refreshButtonText = Messages.cacheUpdate_refreshNow;
+				if (cacheUpdateJobListener!= null)
+					cacheUpdateJobListener.done();
+				if (monitor.isCanceled())
+					return Status.CANCEL_STATUS;
+				ServerCore.resetDownloadableServers();
+				monitor.worked(900);
+				return Status.OK_STATUS;
+			}
+		}
+		if (!userInitiated){
+			int cacheFrequency = ServerUIPlugin.getPreferences().getCacheFrequency();
+			if (cacheFrequency == 0 /*Manual*/){
+				// User will explicitly refresh
+				return null;
+			}
+			String dateString = Discovery.getLastUpdatedDate();
+
+			DateFormat df = new SimpleDateFormat("EEE MMM dd yyyy kk:mm:ss zzz", Locale.ENGLISH);
+			try {
+				Date lastUpDatedDate = ((dateString == null) || (dateString.equals(Messages.cacheUpdate_never)))
+						? new Date(0) : df.parse(dateString.trim());
+				Date currentDate = new Date(System.currentTimeMillis());
+				Calendar cal = Calendar.getInstance();
+				cal.setTime(lastUpDatedDate);
+				switch(cacheFrequency){
+				case 1: //daily
+					cal.add(Calendar.DATE, 1); // add 1 day
+					if (cal.getTime().after(currentDate))
+						return null;
+					break;
+				case 2: //weekly
+					cal.add(Calendar.DATE, 7); // add 7 days
+					if (cal.getTime().after(currentDate))
+						return null;
+					break;
+				case 3: //monthly
+					cal.add(Calendar.MONTH, 1); // add 1 Month
+					if (cal.getTime().after(currentDate))
+						return null;
+					break;
+				case 4: //quarterly
+					cal.add(Calendar.MONTH, 3); // add 3 Months
+					if (cal.getTime().after(currentDate))
+						return null;
+					break;
+				}
+			} catch (ParseException e) {
+				// The last updated date is malformed. Continue further to do a refresh.
+			}
+		}
+
+		RefreshJob job = new RefreshJob();
+		job.schedule();
+		job.setPriority(Job.SHORT);
+		return job;
+
+	}
+	
+	public static String refreshButtonText = Messages.cacheUpdate_refreshNow;
+	static ICacheUpdateListener cacheUpdateJobListener;
+	
+	public static void setListener(ICacheUpdateListener listener){
+		cacheUpdateJobListener = listener;
+	}
+}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
index 599bf39..b472f6f 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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
@@ -373,8 +373,19 @@
 	public static String downLoadableAdapterDescription;
 	public static String errorTitle;
 	public static String jobRefreshingServerAdapter;
-	public static String refreshButton;
-
+	
+	public static String cacheFrequency_manual;
+	public static String cacheFrequency_weekly;
+	public static String cacheFrequency_monthly;
+	public static String cacheFrequency_quarterly;
+	public static String cacheFrequency_daily;
+	public static String cacheUpdate_boxTitle;
+	public static String cacheUpdate_refreshNow;
+	public static String cacheUpdate_refreshing;
+	public static String cacheUpdate_never;
+	public static String cacheUpdate_frequencyLabel;
+	public static String cacheUpdate_lastUpdatedOn;	
+	
 	static {
 		NLS.initializeMessages(ServerUIPlugin.PLUGIN_ID + ".internal.Messages", Messages.class);
 	}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
index 078f962..1f9c9e3 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2004, 2015 IBM Corporation and others.
+# Copyright (c) 2004, 2016 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
@@ -368,7 +368,7 @@
 
 # installable server composite
 installableServerCompTree=Select the &server support to install:
-installableServerLink=Show additional server adapters
+installableServerLink=Show downloadable server adapters
 installableServerLocal=Examining local configuration
 installableServerSearching=Searching {0}
 
@@ -520,4 +520,15 @@
 downLoadableAdapterDescription=Click Next to download and install
 errorTitle=Error
 jobRefreshingServerAdapter=Refreshing server adapter list
-refreshButton=Refresh
\ No newline at end of file
+
+cacheFrequency_manual=Manual
+cacheFrequency_weekly=Weekly
+cacheFrequency_monthly=Monthly
+cacheFrequency_quarterly=Quarterly
+cacheFrequency_daily=Daily
+cacheUpdate_boxTitle=Downloadable server adapters cache update policy
+cacheUpdate_refreshNow=&Refresh Now
+cacheUpdate_lastUpdatedOn=Last updated on: 
+cacheUpdate_frequencyLabel=Update cache frequency:
+cacheUpdate_refreshing=Refreshing ...
+cacheUpdate_never=Never
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java
index dc23338..34c5ab4 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,19 +10,24 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal;
 
+
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.*;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.eclipse.wst.server.core.internal.ServerPreferences;
+import org.eclipse.wst.server.discovery.Discovery;
+import org.eclipse.wst.server.ui.ICacheUpdateListener;
+import org.eclipse.wst.server.ui.ServerUIUtil;
 /**
  * The preference page that holds server properties.
  */
@@ -31,6 +36,9 @@
 	protected ServerUIPreferences uiPreferences;
 
 	protected Button showOnActivity;
+	protected Button refreshNow;
+	protected Text updateTime;
+	protected Combo updateCacheFrequencyCombo;
 
 	/**
 	 * ServerPreferencesPage constructor comment.
@@ -72,10 +80,97 @@
 		showOnActivity.setSelection(uiPreferences.getShowOnActivity());
 		whs.setHelp(showOnActivity, ContextIds.PREF_GENERAL_SHOW_ON_ACTIVITY);
 		
+		Label label = new Label(composite, SWT.NONE);
+		data = new GridData();
+		data.horizontalSpan = 3;
+		label.setLayoutData(data);
+				
+		Group cacheGroup = new Group(composite, SWT.NONE);
+		cacheGroup.setText(Messages.cacheUpdate_boxTitle);
+		layout = new GridLayout();
+		layout.numColumns = 3;
+		cacheGroup.setLayout(layout);
+		data = new GridData(GridData.FILL_HORIZONTAL);
+		data.horizontalSpan = 3;
+		cacheGroup.setLayoutData(data);
+		Label updateCacheLabel = new Label(cacheGroup, SWT.NONE);
+		updateCacheLabel.setText(Messages.cacheUpdate_frequencyLabel);
+
+		
+		updateCacheFrequencyCombo = new Combo(cacheGroup, SWT.READ_ONLY);
+		String[] frequency = new String[5];
+		frequency[0] = Messages.cacheFrequency_manual;
+		frequency[1] = Messages.cacheFrequency_daily;
+		frequency[2] = Messages.cacheFrequency_weekly;
+		frequency[3] = Messages.cacheFrequency_monthly;
+		frequency[4] = Messages.cacheFrequency_quarterly;
+		
+		updateCacheFrequencyCombo.setItems(frequency);
+			
+		int cacheFrequency = uiPreferences.getCacheFrequency();
+		updateCacheFrequencyCombo.select(cacheFrequency);
+		
+		refreshNow = new Button(cacheGroup, SWT.PUSH);
+		data = new GridData(GridData.HORIZONTAL_ALIGN_END);
+		refreshNow.setLayoutData(data);
+		String refreshButtonText = ServerUIUtil.refreshButtonText;
+		ServerUIUtil.setListener(new UpdateJobChangeListener());
+		if (refreshButtonText.equals(Messages.cacheUpdate_refreshNow))
+			refreshNow.setEnabled(true);
+		else
+			refreshNow.setEnabled(false);
+		refreshNow.setText(refreshButtonText);
+		
+		refreshNow.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				refreshNow.setEnabled(false);
+				updateRefreshText(Messages.cacheUpdate_refreshing);
+				updateJob = ServerUIUtil.refreshServerNode(true);
+			}
+		});
+		
+		Label lastUpdatedLabel = new Label(cacheGroup, SWT.NONE);
+		lastUpdatedLabel.setText(Messages.cacheUpdate_lastUpdatedOn);
+		updateTime = new Text(cacheGroup, SWT.READ_ONLY);
+		updateTime.setText(Discovery.getLastUpdatedDate());
 		Dialog.applyDialogFont(composite);
 		
+		
 		return composite;
 	}
+	Job updateJob = null;
+	
+	private class UpdateJobChangeListener implements ICacheUpdateListener {
+		public UpdateJobChangeListener() {
+		}
+		public void start(){
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					 if (refreshNow != null && !refreshNow.isDisposed()){
+						 refreshNow.setText(Messages.cacheUpdate_refreshing);
+						 refreshNow.setEnabled(false);
+					 }
+				}
+			});
+		}
+
+		public void done() {
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					 if (refreshNow != null && !refreshNow.isDisposed()){
+						 refreshNow.setEnabled(true);
+						 refreshNow.setText(Messages.cacheUpdate_refreshNow);
+						 updateTime.setText(Discovery.getLastUpdatedDate());
+					 }
+				}
+			});
+
+		}
+
+	}
+	public void updateRefreshText(String refreshText){
+		refreshNow.setText(refreshText);
+	}
 
 	/**
 	 * Initializes this preference page using the passed workbench.
@@ -91,6 +186,7 @@
 	 */
 	protected void performDefaults() {
 		showOnActivity.setSelection(uiPreferences.getDefaultShowOnActivity());
+		updateCacheFrequencyCombo.select(/*Weekly*/2);
 		
 		super.performDefaults();
 	}
@@ -100,7 +196,11 @@
 	 */
 	public boolean performOk() {
 		uiPreferences.setShowOnActivity(showOnActivity.getSelection());
-		
+		uiPreferences.setCacheFrequency(updateCacheFrequencyCombo.getSelectionIndex());
 		return true;
 	}
+	
+	public void dispose(){
+		ServerUIUtil.setListener(null);
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java
index 9f948cd..6234e5b 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -31,6 +31,8 @@
 	private static final String PREF_CREATE_SERVER_WITH_RUNTIME = "create-server";
 	private static final String PREF_PUBLISH_ON_ADD_REMOVE = "publish-on-add-remove";
 	private static final String PREF_EXT_ADAPTER = "external-adapter";
+	private static final String PREF_CACHE_FREQUENCY = "cache-frequency";
+	private static final String PREF_CACHE_LAST_UPDATED_DATE = "cache-lastUpdatedDate";
 
 	public static final byte SAVE_EDITORS_ALWAYS = 2;
 	public static final byte SAVE_EDITORS_NEVER = 0;
@@ -85,6 +87,7 @@
 		preferences.setDefault(PREF_CREATE_SERVER_WITH_RUNTIME, false);
 		preferences.setDefault(PREF_PUBLISH_ON_ADD_REMOVE, true);
 		preferences.setDefault(PREF_EXT_ADAPTER, true);
+		preferences.setDefault(PREF_CACHE_FREQUENCY, 2);
 	}
 
 	/**
@@ -393,4 +396,42 @@
 		preferences.setValue(PREF_EXT_ADAPTER, b);
 		ServerUIPlugin.getInstance().savePluginPreferences();
 	}
+	
+	/**
+	 * Returns the frequency for cache update.
+	 * 
+	 * @return String
+	 */
+	public int getCacheFrequency() {
+		return preferences.getInt(PREF_CACHE_FREQUENCY);
+	}
+
+	/**
+	 * Sets the frequency for cache update.
+	 *
+	 * @param frequency - 0-Manual, 1-Fortnightly, 2-Monthly and 3-Quarterly 
+	 */
+	public void setCacheFrequency(int frequency) {
+		preferences.setValue(PREF_CACHE_FREQUENCY, frequency);
+		ServerUIPlugin.getInstance().savePluginPreferences();
+	}
+
+	/**
+	 * Returns the cache last updated date.
+	 * 
+	 * @return String
+	 */
+	public String getPrefCacheLastUpdatedDate() {
+		return preferences.getString(PREF_CACHE_LAST_UPDATED_DATE);
+	}
+	
+	/**
+	 * Sets the frequency for cache update.
+	 *
+	 * @param frequency - 0-Manual, 1-Fortnightly, 2-Monthly and 3-Quarterly 
+	 */
+	public void setPrefCacheLastUpdatedDate(int frequency) {
+		preferences.setValue(PREF_CACHE_FREQUENCY, frequency);
+		ServerUIPlugin.getInstance().savePluginPreferences();
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java
index 93ac173..9b44fb7 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -24,6 +24,7 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.*;
 import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.wst.server.ui.ServerUIUtil;
 import org.eclipse.wst.server.ui.internal.Messages;
 import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
 /**
@@ -35,7 +36,6 @@
 	protected Label description;
 	protected Button showAdapters;
 	protected Link prefLink;
-	protected Button refreshButton;
 	protected AbstractTreeContentProvider contentProvider;
 	
 
@@ -92,15 +92,6 @@
 			});
 			if (getDetailsLink()){
 				prefLink.setEnabled(!ServerUIPlugin.getPreferences().getExtAdapter());
-				refreshButton = new Button(comp, SWT.PUSH);
-				refreshButton.setText(Messages.refreshButton);
-				refreshButton.setEnabled(ServerUIPlugin.getPreferences().getExtAdapter());
-				refreshButton.addSelectionListener(new SelectionAdapter() {
-					public void widgetSelected(SelectionEvent e) {
-						refreshButton.setEnabled(false);
-						refreshServerNode();
-					}
-				});
 			}
 		}
 		
@@ -233,11 +224,11 @@
 	protected void handleShowAdapterSelection(boolean selection){
 		showAdapters.setSelection(selection);
 		prefLink.setEnabled(!selection);
-		refreshButton.setEnabled(selection);
 		downloadAdaptersSelectionChanged(selection);
 	}
 
 	protected void deferInitialization() {
+		ServerUIUtil.refreshServerNode(false);
 		Job job = new Job(Messages.jobInitializingServersView) {
 			public IStatus run(final IProgressMonitor monitor) {
 				Display.getDefault().asyncExec(new Runnable() {
@@ -271,12 +262,4 @@
 		
 	}
 	
-	protected void enableRefresh(){
-		if ( !showAdapters.isDisposed() && showAdapters.getSelection() )
-			refreshButton.setEnabled(true);
-	}
-	
-	protected void disableRefresh(){
-		refreshButton.setEnabled(false);
-	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java
index a7bcd29..6682638 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -11,15 +11,12 @@
 package org.eclipse.wst.server.ui.internal.viewers;
 
 import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.SWTException;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
-
 import org.eclipse.wst.server.core.IRuntimeType;
 import org.eclipse.wst.server.discovery.Discovery;
 import org.eclipse.wst.server.ui.internal.Messages;
 import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.Trace;
 /**
  * 
  */
@@ -86,17 +83,7 @@
 		super.setVisible(visible);
 		if (visible && initialSelection) {
 			initialSelection = false;
-			if (contentProvider.getInitialSelection() != null) {
-				try {
-					getDisplay().asyncExec(new Runnable() {
-						public void run() {
-							treeViewer.setSelection(new StructuredSelection(contentProvider.getInitialSelection()), true);
-						}
-					});
-				} catch (SWTException e) {
-					Trace.trace(Trace.STRING_INFO, "Failed to set the default selection on the runtime type tree.", e);
-				}
-			}
+			deferInitialization();
 		}
 	}
 
@@ -141,4 +128,8 @@
 			closeWizard(this);
 		}
 	}
+	
+	protected boolean getDetailsLink() {
+		return true;
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java
index d2de6aa..6185cd8 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2014 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -11,9 +11,14 @@
 package org.eclipse.wst.server.ui.internal.viewers;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.ServerCore;
 import org.eclipse.wst.server.core.ServerUtil;
 import org.eclipse.wst.server.core.internal.RuntimeType;
 /**
@@ -71,4 +76,39 @@
 		}
 		elements = list.toArray();
 	}
+	
+	protected void deferredAdapterInitialize(final TreeViewer treeViewer, IProgressMonitor monitor) {
+		List<TreeElement> list = new ArrayList<TreeElement>();
+		IRuntimeType[] runtimeTypes = ServerCore.getDownloadableRuntimeTypes(monitor);
+		if (runtimeTypes != null) {
+			int size = runtimeTypes.length;
+			for (int i = 0; i < size; i++) {
+				IRuntimeType runtimeType = runtimeTypes[i];
+				try {
+					if (!((RuntimeType)runtimeType).supportsManualCreation()) {
+						// Hide this runtime type from the list.
+						continue;
+					}
+				} catch (Exception e) {
+					// Do nothing since all IRuntimeType should be instance of RuntimeType.
+				}
+				
+				TreeElement ele = getOrCreate(list, runtimeType.getVendor());
+				ele.contents.add(runtimeType);
+				elementToParentMap.put(runtimeType, ele);
+			}
+		}
+		if (list.size() >0) {
+			List<Object> newList = new ArrayList<Object>();
+			newList.addAll(Arrays.asList(elements));
+			newList.addAll(list);
+			elements = newList.toArray();
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					if (!treeViewer.getTree().isDisposed())
+						treeViewer.refresh("root");
+				}
+			});
+		}
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java
index c973c6b..7046659 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,10 +10,12 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.viewers;
 
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.ui.internal.ImageResource;
 import org.eclipse.jface.viewers.ILabelDecorator;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy;
+import org.eclipse.wst.server.ui.internal.DefaultServerImageDescriptor;
+import org.eclipse.wst.server.ui.internal.ImageResource;
 /**
  * Runtime type label provider.
  */
@@ -39,7 +41,16 @@
 	 */
 	protected Image getImageImpl(Object element) {
 		IRuntimeType runtimeType = (IRuntimeType) element;
-		return ImageResource.getImage(runtimeType.getId());
+		Image image = ImageResource.getImage(runtimeType.getId());
+		DefaultServerImageDescriptor dsid = null;
+		if (element instanceof RuntimeTypeWithServerProxy) {
+			Image image1 = ImageResource.getImage(ImageResource.IMG_DOWN_ARROW);
+			dsid = new DefaultServerImageDescriptor(image, image1);
+			dsid.setFlags(DefaultServerImageDescriptor.BOTTOM_RIGHT);
+			image = dsid.createImage();
+		}
+
+		return image;
 	}
 
 	/**
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java
index 288e34b..e9c8a4a 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,20 +10,13 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.viewers;
 
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.viewers.*;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.wst.server.core.IModuleType;
 import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.ServerCore;
 import org.eclipse.wst.server.discovery.Discovery;
 import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ProgressUtil;
 import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
 /**
  * 
@@ -170,102 +163,5 @@
 			closeWizard(this);
 		}
 	}
-
-	protected void refreshServerNode(){
-		class RefreshJob extends Job{
-			public RefreshJob() {
-				super(Messages.jobRefreshingServerAdapter);
-			}
-			
-			public boolean belongsTo(Object family) {
-				return "org.eclipse.wst.server.ui.family".equals(family);
-			}
-			protected IStatus run(IProgressMonitor monitor) {
-				monitor = ProgressUtil.getMonitorFor(monitor);
-				monitor.beginTask("", 1000);
-				Display.getDefault().asyncExec(new Runnable() {
-					public void run() {
-						contentProvider.fillTree();
-						refresh("root");
-						if (contentProvider.getInitialSelection() != null && !treeViewer.getTree().isDisposed()){
-							treeViewer.setSelection(new StructuredSelection(contentProvider.getInitialSelection()), true);
-						}
-					}
-				});
-				monitor.worked(200);
-				if (monitor.isCanceled())
-					return Status.CANCEL_STATUS;
-				Discovery.refreshServerAdapters(ProgressUtil.getSubMonitorFor(monitor, 500));
-				monitor.worked(700);
-				if (monitor.isCanceled())
-					return Status.CANCEL_STATUS;
-				ServerCore.resetDownloadableServers();
-				final IProgressMonitor finalMonitor = monitor;
-				Display.getDefault().asyncExec(new Runnable() {
-					public void run() {
-
-							if (ServerUIPlugin.getPreferences().getExtAdapter()){
-								handleShowAdapters(ProgressUtil.getSubMonitorFor(finalMonitor, 200));
-							}
-					}
-				});
-				monitor.worked(900);
-				Display.getDefault().asyncExec(new Runnable() {
-				public void run() {
-							enableRefresh();
-						}
-					});
-				return Status.OK_STATUS;
-			}
-			
-		}
-		RefreshJob job = new RefreshJob();
-		job.setUser(true);
-		job.schedule();
-		job.setPriority(Job.SHORT);
-		/*Job job = new Job(Messages.jobRefreshingServerAdapter) {
-			@SuppressWarnings("restriction")
-			@Override
-			public IStatus run(IProgressMonitor monitor) {
-				monitor = ProgressUtil.getMonitorFor(monitor);
-				monitor.beginTask("", 1000);
-				Display.getDefault().asyncExec(new Runnable() {
-					public void run() {
-						contentProvider.fillTree();
-						refresh("root");
-						if (contentProvider.getInitialSelection() != null && !treeViewer.getTree().isDisposed()){
-							treeViewer.setSelection(new StructuredSelection(contentProvider.getInitialSelection()), true);
-						}
-					}
-				});
-				monitor.worked(200);
-				if (monitor.isCanceled())
-					return Status.CANCEL_STATUS;
-				Discovery.refreshServerAdapters(ProgressUtil.getSubMonitorFor(monitor, 500));
-				monitor.worked(700);
-				if (monitor.isCanceled())
-					return Status.CANCEL_STATUS;
-				ServerCore.resetDownloadableServers();
-				final IProgressMonitor finalMonitor = monitor;
-				Display.getDefault().asyncExec(new Runnable() {
-					public void run() {
-
-							if (ServerUIPlugin.getPreferences().getExtAdapter()){
-								handleShowAdapters(ProgressUtil.getSubMonitorFor(finalMonitor, 200));
-							}
-					}
-				});
-				monitor.worked(900);
-				Display.getDefault().asyncExec(new Runnable() {
-				public void run() {
-							enableRefresh();
-						}
-					});
-				return Status.OK_STATUS;
-			}
-			
-		};*/
-		
-
-	}
+	
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java
index d97650f..04664f0 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -91,7 +91,7 @@
 
 
 	protected boolean include(IServerType serverType) {
-		if (serverType instanceof ServerTypeProxy)
+		if (serverType != null && serverType instanceof ServerTypeProxy)
 			return true;
 		if (serverTypeId != null && !serverType.getId().startsWith(serverTypeId))
 			return false;
@@ -147,16 +147,18 @@
 			int size = serverTypes.length;
 			for (int i = 0; i < size; i++) {
 				IServerType serverType = serverTypes[i];
-				try {
-					IRuntimeType runtimeType = serverType.getRuntimeType();
-					TreeElement ele = getOrCreate(list, runtimeType.getVendor());
-					if (!compareServers(ele.contents, (ServerTypeProxy)serverType)){
-						ele.contents.add(serverType);
-						elementToParentMap.put(serverType, ele);
-					}
-				} catch (Exception e) {
-					if (Trace.WARNING) {
-						Trace.trace(Trace.STRING_WARNING, "Error in server configuration content provider", e);
+				if (include(serverType)){
+					try {
+						IRuntimeType runtimeType = serverType.getRuntimeType();
+						TreeElement ele = getOrCreate(list, runtimeType.getVendor());
+						if (!compareServers(ele.contents, (ServerTypeProxy)serverType)){
+							ele.contents.add(serverType);
+							elementToParentMap.put(serverType, ele);
+						}
+					} catch (Exception e) {
+						if (Trace.WARNING) {
+							Trace.trace(Trace.STRING_WARNING, "Error in server configuration content provider", e);
+						}
 					}
 				}
 			}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
index 2aaa32f..5b9f2a6 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2012 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,23 +10,21 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.wizard.fragment;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
 import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
 import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
 import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
 import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.internal.wizard.page.NewRuntimeComposite;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
 import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
 /**
  * 
  */
@@ -76,21 +74,28 @@
 		if (getTaskModel() == null)
 			return;
 		
-		IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+		Object runtime =  getTaskModel().getObject(TaskModel.TASK_RUNTIME);
 		if (runtime == null)
 			return;
-		
-		WizardFragment sub = getWizardFragment(runtime.getRuntimeType().getId());
+		WizardFragment sub = null;
+		if (runtime instanceof IRuntimeWorkingCopy)
+		 sub = getWizardFragment(((RuntimeWorkingCopy)runtime).getRuntimeType().getId());
+		else if (runtime instanceof RuntimeTypeWithServerProxy)
+			sub = getWizardFragment(((RuntimeTypeWithServerProxy)runtime).getId());
 		if (sub != null)
 			list.add(sub);
 		
-		IServerWorkingCopy server = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
-		if (server != null) {
+		Object serverObj =  getTaskModel().getObject(TaskModel.TASK_SERVER);
+		if (serverObj != null && serverObj instanceof IServerWorkingCopy) {
+			IServerWorkingCopy server = (IServerWorkingCopy)serverObj;
 			if (server.getServerType().hasServerConfiguration() && server instanceof ServerWorkingCopy) {
 				ServerWorkingCopy swc = (ServerWorkingCopy) server;
 				try {
-					if (runtime.getLocation() != null && !runtime.getLocation().isEmpty())
-						swc.importRuntimeConfiguration(runtime, null);
+					if (runtime instanceof IRuntimeWorkingCopy){
+						RuntimeWorkingCopy runtimeWorkingCopy = (RuntimeWorkingCopy)runtime;
+						if (runtimeWorkingCopy.getLocation() != null && !runtimeWorkingCopy.getLocation().isEmpty())
+							swc.importRuntimeConfiguration(runtimeWorkingCopy, null);
+					}
 				} catch (CoreException ce) {
 					// ignore
 				}
@@ -135,4 +140,10 @@
 		}
 		return false;
 	}	
+	
+
+	public void exit() {
+		comp.refreshExtension();
+		
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java
index c8d69d0..016f9f6 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2012 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 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
@@ -10,33 +10,36 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.wizard.page;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.IWorkbenchHelpSystem;
-import org.eclipse.wst.server.core.*;
-import org.eclipse.wst.server.ui.internal.ContextIds;
-import org.eclipse.wst.server.ui.internal.ImageResource;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.SWTUtil;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.Trace;
-import org.eclipse.wst.server.ui.internal.viewers.RuntimeTypeComposite;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.internal.*;
+import org.eclipse.wst.server.discovery.Discovery;
+import org.eclipse.wst.server.discovery.ErrorMessage;
+import org.eclipse.wst.server.ui.internal.*;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.internal.viewers.RuntimeTypeComposite;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
 /**
  * 
  */
@@ -106,11 +109,33 @@
 			}
 		});
 	}
-
+	boolean success ;
 	protected void handleSelection(IRuntimeType runtimeType) {
+		wizard.setMessage(null, IMessageProvider.NONE);
 		if (runtimeType == null)
 			runtime = null;
 		else {
+			if (runtimeType instanceof RuntimeTypeWithServerProxy){
+				success = false;
+				final RuntimeTypeWithServerProxy runtimeTypeFinal = (RuntimeTypeWithServerProxy)runtimeType;
+				try {
+					wizard.run(true, true, new IRunnableWithProgress() {
+						
+						public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+							success = showDownloadableServerWizard(runtimeTypeFinal, monitor);
+					}
+					});
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				} catch (InvocationTargetException e) {
+					e.printStackTrace();
+				}
+				if (!success){
+					return;
+					
+				}
+				wizard.update();
+			}
 			try {
 				runtime = null;
 				runtime = cache.get(runtimeType);
@@ -122,15 +147,40 @@
 					runtime = runtimeType.createRuntime(null, null);
 					if (runtime != null)
 						cache.put(runtimeType, runtime);
+					else if (runtimeType instanceof RuntimeTypeWithServerProxy){
+						serverType = ((RuntimeTypeWithServerProxy)runtimeType).getServerTypeProxy();
+						runtime = new RuntimeWorkingCopy(new RuntimeProxy((RuntimeTypeProxy)(serverType.getRuntimeType())));
+					}
 				} catch (Exception e) {
 					// ignore
 				}
 			}
 		}
-		serverType = getCompatibleServerType(runtimeType);
+		if (! (runtimeType instanceof RuntimeTypeWithServerProxy))
+				serverType = getCompatibleServerType(runtimeType);
 		handleServer();
 	}
 
+	protected boolean showDownloadableServerWizard(RuntimeTypeWithServerProxy runtimeType, IProgressMonitor monitor) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				wizard.setMessage(Messages.downLoadableAdapterDescription, IMessageProvider.INFORMATION);
+			}
+		});
+		
+		serverType = runtimeType.getServerTypeProxy();
+		WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(serverType.getRuntimeType().getId());
+		if (fragment2 == null)
+			return false;
+		TaskModel fragmentTaskModel = fragment2.getTaskModel();
+		if (fragmentTaskModel == null)
+			fragmentTaskModel = new TaskModel();
+		fragmentTaskModel.putObject(TaskModel.TASK_EXTENSION, runtimeType.getServerTypeProxy().getExtension());
+		fragmentTaskModel.putObject(TaskModel.TASK_RUNTIME, serverType.getRuntimeType());
+		fragmentTaskModel.putObject(TaskModel.TASK_SERVER, serverType);
+		fragment2.setTaskModel(fragmentTaskModel);
+		return true;
+	}
 	protected void handleServer() {
 		boolean option = false;
 		if (serverType != null && serverType.hasRuntime())
@@ -140,9 +190,10 @@
 		if (option && createServer.getSelection()) {
 			IServerWorkingCopy server = getServer();
 			taskModel.putObject(TaskModel.TASK_SERVER, server);
-		} else
+		} else if (!(serverType instanceof ServerTypeProxy))
 			taskModel.putObject(TaskModel.TASK_SERVER, null);
-		
+		else
+			taskModel.putObject(TaskModel.TASK_SERVER, serverType);
 		taskModel.putObject(TaskModel.TASK_RUNTIME, runtime);
 		wizard.update();
 	}
@@ -215,4 +266,50 @@
 		}
 		return true;
 	}
+	
+	public boolean refreshExtension(){
+		if (!(serverType instanceof ServerTypeProxy))
+			return true;
+		final ServerTypeProxy finalServerType = (ServerTypeProxy)serverType;
+		try {
+			wizard.run(true, true, new IRunnableWithProgress() {
+				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+					ErrorMessage errorMsg = Discovery.refreshExtension(finalServerType.getExtension(), finalServerType.getURI(), monitor);
+					if (errorMsg != null){
+						final ErrorMessage errorMsgFinal = errorMsg;
+						Display.getDefault().asyncExec(new Runnable() {
+							public void run() {
+								wizard.setMessage(errorMsgFinal.getErrorTitle(), IMessageProvider.ERROR);
+								WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getRuntimeType().getId());
+								if (fragment2 != null){
+									TaskModel fragmentTaskModel = fragment2.getTaskModel();
+									fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE, errorMsgFinal.getErrorDescription());
+									fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.ERROR));
+								}
+								wizard.update();
+							}
+						});
+					}
+					else{
+						WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getRuntimeType().getId());
+						if (fragment2 != null){
+							TaskModel fragmentTaskModel = fragment2.getTaskModel();
+							fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE, Discovery.getLicenseText(finalServerType.getExtension()));
+							fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.NONE));
+						}
+					}
+				}
+			});
+		} catch (InvocationTargetException e) {
+			if (Trace.WARNING) {
+				Trace.trace(Trace.STRING_WARNING, "Error refreshing extension", e);
+			}
+		} catch (InterruptedException e) {
+			if (Trace.WARNING) {
+				Trace.trace(Trace.STRING_WARNING, "Error refreshing extension", e);
+			}
+		}
+		
+		return true;
+	}
 }
\ No newline at end of file