[282466] Axis2: Support for Axis2 1.5
diff --git a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/constant/Axis2Constants.java b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/constant/Axis2Constants.java
index 6b3e882..38396f4 100644
--- a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/constant/Axis2Constants.java
+++ b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/constant/Axis2Constants.java
@@ -15,6 +15,7 @@
  * 20080521   231098 sandakith@wso2.com - Lahiru Sandakith, Fix for Axis2 1.4 dependency chenge
  * 20080604   193371 samindaw@wso2.com - Saminda Wijeratne, creating a function to validate services.xml
  * 20091207   192005 samindaw@wso2.com - merge the web.xml to have axis2 welcome file defined
+ * 20100308	  282466 samindaw@wso2.com - Saminda Wijeratne, support for axis2 1.5
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.core.constant;
 
@@ -93,7 +94,8 @@
         "annogen",
         "backport-util",
         "mex-impl",
-        "mail"
+        "mail",
+        "httpcore"
 	};
 }	
 	
diff --git a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/FacetContainerUtils.java b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/FacetContainerUtils.java
index 9333b7c..980c16c 100644
--- a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/FacetContainerUtils.java
+++ b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/FacetContainerUtils.java
@@ -18,6 +18,7 @@
  * 20070612   192047 kathy@ca.ibm.com   - Kathy Chan
  * 20070813   196173  sandakith@wso2.com - Lahiru Sandakith, Fix 196173, DWP custom location fix
  * 20070824   200515 sandakith@wso2.com - Lahiru Sandakith, NON-NLS move to seperate file
+ * 20100308	  282466 samindaw@wso2.com - Saminda Wijeratne, support for axis2 1.5
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.core.utils;
 
@@ -182,5 +183,34 @@
 		return FileUtils.addNodesToURL(deployedWSDLURLpath, deployedWSDLURLParts)+"?wsdl";
 	}
 	
+	public static String getAxis2WebContainerLibPath(IProject project){
+		return getAxis2WebContainerLibPath(FacetContainerUtils.pathToWebProjectContainer(
+				project.toString()));
+	}
+	
+	public static String getAxis2WebContainerLibPath(String webcontainerPath){
+		return FileUtils.addAnotherNodeToPath(getAxis2WebContainerWEB_INFPath(webcontainerPath),
+				Axis2Constants.DIR_LIB);
+	}
+	
+	public static String getAxis2WebContainerwebinfClassPath(IProject project){
+		return getAxis2WebContainerwebinfClassPath(FacetContainerUtils.pathToWebProjectContainer(
+				project.toString()));
+	}
+	
+	public static String getAxis2WebContainerwebinfClassPath(String webcontainerPath){
+		return FileUtils.addAnotherNodeToPath(getAxis2WebContainerWEB_INFPath(webcontainerPath),
+				Axis2Constants.DIR_CLASSES);
+	}
+	
+	public static String getAxis2WebContainerRepositoryPath(String webcontainerPath){
+		return FileUtils.addAnotherNodeToPath(getAxis2WebContainerWEB_INFPath(webcontainerPath),
+				Axis2Constants.DIR_SERVICES);
+	}
+	
+	public static String getAxis2WebContainerWEB_INFPath(String webcontainerPath){
+		return  FileUtils.addAnotherNodeToPath(webcontainerPath,Axis2Constants.DIR_WEB_INF);
+	}
+	
 	
 }
diff --git a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/Axis2WebservicesServerCommand.java b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/Axis2WebservicesServerCommand.java
index 76c5673..f8d6618 100644
--- a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/Axis2WebservicesServerCommand.java
+++ b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/Axis2WebservicesServerCommand.java
@@ -20,6 +20,7 @@
  * 20071011   205972 sandakith@wso2.com - Lahiru Sandakith, Axis2 Libraries License files fix
  * 20080528   186429 sandakith@wso2.com - Lahiru Sandakith, Axis2 webapp jsp's validation fix
  * 20080616   237363 samindaw@wso2.com - Saminda Wijeratne, get ResourceContext from environment instead of preference
+ * 20100308	  282466 samindaw@wso2.com - Saminda Wijeratne, support for axis2 1.5
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.facet.commands;
 
@@ -120,12 +121,8 @@
 		List<String> includeList = new ArrayList<String>();
 		contentCopyUtils.updateCheckList(loadIncludeListWithAxis2Libs(libPath.toOSString(),
 				includeList));
-		String[] nodes = {Axis2Constants.DIR_WEB_INF,Axis2Constants.DIR_LIB};
 		status = contentCopyUtils.copyDirectoryRecursivelyIntoWorkspace(
-				libPath.toOSString(), 
-				FileUtils.addNodesToPath(
-						FacetContainerUtils.pathToWebProjectContainer(project.toString()), 
-						nodes), 
+				libPath.toOSString(), FacetContainerUtils.getAxis2WebContainerLibPath(project), 
 				monitor,
 				true
 		);
diff --git a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/MergeWEBXMLCommand.java b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/MergeWEBXMLCommand.java
index eb1f6a6..08a3ad4 100644
--- a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/MergeWEBXMLCommand.java
+++ b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/commands/MergeWEBXMLCommand.java
@@ -13,6 +13,7 @@
  * 20060515   115225 sengpl@ca.ibm.com - Seng Phung-Lu
  * 20070606   177421 sandakith@wso2.com - fix web.xml wiped out when Axis2 facet
  * 20091207   192005 samindaw@wso2.com - merge the web.xml to have axis2 welcome file defined
+ * 20100308	  282466 samindaw@wso2.com - Saminda Wijeratne, support for axis2 1.5
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.facet.commands;
 
@@ -40,6 +41,9 @@
 import org.eclipse.jst.javaee.web.WebFactory;
 import org.eclipse.jst.javaee.web.WelcomeFileList;
 import org.eclipse.jst.ws.axis2.core.constant.Axis2Constants;
+import org.eclipse.jst.ws.axis2.core.utils.FacetContainerUtils;
+import org.eclipse.jst.ws.axis2.core.utils.FileUtils;
+import org.eclipse.jst.ws.axis2.facet.utils.Axis2RuntimeUtils;
 import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
 import org.eclipse.wst.common.environment.IEnvironment;
 import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
@@ -112,12 +116,13 @@
 		ServletDescriptor sd = new ServletDescriptor();
 		sd._name = "AxisAdminServlet"; //$NON-NLS-1$
 		sd._displayName = "Apache-Axis Admin Servlet Web Admin"; //$NON-NLS-1$
-		sd._className = "org.apache.axis2.transport.http.AxisAdminServlet"; //$NON-NLS-1$
+		sd._className = Axis2RuntimeUtils.getAxis2ServletAdminClass(serverProject); 
 		sd._mappings = new String[] { "/axis2-admin/*"	}; //$NON-NLS-1$
 		sd._loadOnStartup = new Integer(100);
 		return sd;
 	}
 
+
 	public IStatus addServlet(IProject webProject, ServletDescriptor servletDescriptor,
 																			WebApp webapp) {
 		try {
diff --git a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/utils/Axis2RuntimeUtils.java b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/utils/Axis2RuntimeUtils.java
index c6ebdb9..fd8773b 100644
--- a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/utils/Axis2RuntimeUtils.java
+++ b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/facet/utils/Axis2RuntimeUtils.java
@@ -16,6 +16,7 @@
  * 20070516   183147 sandakith@wso2.com - Lahiru Sandakith Fix for the persisting DBCS paths
  * 20070523   174876 sandakith@wso2.com - Lahiru Sandakith, Persist Preferences inside Framework
  * 20070824   200515 sandakith@wso2.com - Lahiru Sandakith, NON-NLS move to seperate file
+ * 20100308	  282466 samindaw@wso2.com - Saminda Wijeratne, support for axis2 1.5
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.facet.utils;
 
@@ -32,6 +33,9 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.Project;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
@@ -39,6 +43,7 @@
 import org.eclipse.jst.ws.axis2.core.context.Axis2EmitterContext;
 import org.eclipse.jst.ws.axis2.core.plugin.WebServiceAxis2CorePlugin;
 import org.eclipse.jst.ws.axis2.core.utils.Axis2CoreUtils;
+import org.eclipse.jst.ws.axis2.core.utils.FacetContainerUtils;
 import org.eclipse.jst.ws.axis2.core.utils.FileUtils;
 
 public class Axis2RuntimeUtils {
@@ -196,6 +201,42 @@
 	public static void setOutputPath(String outputPath) {
 		Axis2RuntimeUtils.outputPath = outputPath;
 	}
-
+	
+	public static String getAxis2ServletAdminClass(IProject project){
+		String[] classNames=new String[]{"org.apache.axis2.transport.http.AxisAdminServlet" ,
+				"org.apache.axis2.webapp.AxisAdminServlet"};//$NON-NLS-1$
+		String defaultClassName=classNames[0];
+		String selectedClassName=null;
+		String axis2WCLibPath = FacetContainerUtils.getAxis2WebContainerLibPath(project);
+		File libFolder = new File(axis2WCLibPath);
+		File[] libs = libFolder.listFiles();
+		AntClassLoader antClassLoader = new AntClassLoader();
+		antClassLoader.setParentFirst(false);
+		org.apache.tools.ant.types.Path path = new org.apache.tools.ant.types.Path(new Project());
+		path.setPath(FacetContainerUtils.getAxis2WebContainerwebinfClassPath(project));
+		for (File lib : libs) {
+			if (lib.getName().toLowerCase().endsWith(".jar")){
+				path.setPath(lib.getAbsolutePath());
+				antClassLoader.setClassPath(path);
+				for(String className:classNames){
+					try{
+						Class.forName(className, false, antClassLoader);
+						selectedClassName=className;
+					}catch (NoClassDefFoundError e1){
+						if (!e1.getMessage().contains(className) && !e1.getCause().getMessage().contains(className)) //dependent class is not found
+							selectedClassName=className;
+						//class not found
+					}catch(Exception e){
+						//the class is not found
+					}
+					if (selectedClassName!=null) break;
+				}
+			}
+			if (selectedClassName!=null) break;
+		}
+		antClassLoader.cleanup();
+		if (selectedClassName==null) selectedClassName=defaultClassName;
+		return selectedClassName;
+	}
 		    
 }
diff --git a/bundles/org.eclipse.jst.ws.axis2.creation.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.axis2.creation.core/META-INF/MANIFEST.MF
index 7851917..ef177a7 100644
--- a/bundles/org.eclipse.jst.ws.axis2.creation.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.axis2.creation.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %PLUGIN_NAME
 Bundle-SymbolicName: org.eclipse.jst.ws.axis2.creation.core
-Bundle-Version: 1.0.105.qualifier
+Bundle-Version: 1.0.106.qualifier
 Bundle-Activator: org.eclipse.jst.ws.axis2.creation.core.plugin.WebServiceAxis2CreationCorePlugin
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.core.runtime,
diff --git a/bundles/org.eclipse.jst.ws.axis2.creation.core/src/org/eclipse/jst/ws/axis2/creation/core/command/Axis2WebservicesServerCommand.java b/bundles/org.eclipse.jst.ws.axis2.creation.core/src/org/eclipse/jst/ws/axis2/creation/core/command/Axis2WebservicesServerCommand.java
index 97c6c7d..c05c508 100644
--- a/bundles/org.eclipse.jst.ws.axis2.creation.core/src/org/eclipse/jst/ws/axis2/creation/core/command/Axis2WebservicesServerCommand.java
+++ b/bundles/org.eclipse.jst.ws.axis2.creation.core/src/org/eclipse/jst/ws/axis2/creation/core/command/Axis2WebservicesServerCommand.java
@@ -15,18 +15,16 @@
  * 20070813   196173  sandakith@wso2.com - Lahiru Sandakith, Fix 196173, DWP custom location fix
  * 20070824   200515 sandakith@wso2.com - Lahiru Sandakith, NON-NLS move to seperate file
  * 20080616   237363 samindaw@wso2.com - Saminda Wijeratne, get ResourceContext from environment instead of preference
+ * 20100308	  282466 samindaw@wso2.com - Saminda Wijeratne, support for axis2 1.5
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.creation.core.command;
 
-import java.io.File;
-
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jst.ws.axis2.consumption.core.utils.ContentCopyUtils;
-import org.eclipse.jst.ws.axis2.core.constant.Axis2Constants;
 import org.eclipse.jst.ws.axis2.core.utils.FacetContainerUtils;
 import org.eclipse.jst.ws.axis2.core.utils.FileUtils;
 import org.eclipse.jst.ws.axis2.creation.core.data.DataModel;
@@ -52,34 +50,18 @@
 		IEnvironment environment = getEnvironment();
 		IStatusHandler statusHandler = environment.getStatusHandler();	
 
-		String webContainerDirString = FacetContainerUtils.pathToWebProjectContainer(
-				model.getWebProjectName());
+
 
 		ContentCopyUtils contentCopyUtils = new ContentCopyUtils(getEnvironment());
 		
 		//Check for the server status
 		if (model.getServerStatus()){
-			if (scenario == WebServiceScenario.BOTTOMUP){
-				//Import the tempory webservices directory according to the Resources API of eclipse 
+			if (scenario == WebServiceScenario.BOTTOMUP || scenario == WebServiceScenario.TOPDOWN){
+				String webContainerDirString = FacetContainerUtils.pathToWebProjectContainer(
+						model.getWebProjectName());
+				String repositoryString = FacetContainerUtils.getAxis2WebContainerRepositoryPath(
+						webContainerDirString); 
 				String webserviceTempDirString = model.getPathToWebServicesTempDir();
-				String repositoryString = webContainerDirString 
-				+ File.separator + Axis2Constants.DIR_WEB_INF 
-				+ File.separator + Axis2Constants.DIR_SERVICES;
-				//Copy the existing services to the repository
-				status = contentCopyUtils.copyDirectoryRecursivelyIntoWorkspace(
-											webserviceTempDirString, 
-											repositoryString, 
-											monitor, 
-											statusHandler);
-				FileUtils.deleteDirectories(webserviceTempDirString);
-
-
-			}else if (scenario == WebServiceScenario.TOPDOWN){
-				//Do topdown
-				String webserviceTempDirString = model.getPathToWebServicesTempDir();
-				String repositoryString = webContainerDirString 
-				+ File.separator + Axis2Constants.DIR_WEB_INF 
-				+ File.separator + Axis2Constants.DIR_SERVICES;
 				//Copy the existing services to the repository
 				status = contentCopyUtils.copyDirectoryRecursivelyIntoWorkspace(
 											webserviceTempDirString,