Author: ptahchiev Date: Sun Mar 9 10:35:03 2008 New Revision: 635311 URL: http://svn.apache.org/viewvc?rev=635311&view=rev Log: Final modification on the Eclipse integration so that it can work, also removed some log messages.
Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/pom.xml jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/assemble/main-bin.xml jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/common/LibraryHelper.java jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/containers/jetty/JettyContainerManager.java jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/CactusLaunchConfiguration.java jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/JettyCactusLaunchConfiguration.java jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactifyActionDelegate.java jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPlugin.java jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPreferences.java Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/pom.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/pom.xml?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/pom.xml (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/pom.xml Sun Mar 9 10:35:03 2008 @@ -255,6 +255,21 @@ <artifactId>org.mortbay.jetty</artifactId> <version>5.1.9</version> </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>jasper-compiler</artifactId> + <version>4.1.30</version> + </dependency> + <dependency> + <groupId>tomcat</groupId> + <artifactId>jasper-runtime</artifactId> + <version>4.1.30</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jsp-api</artifactId> + <version>2.0</version> + </dependency> </dependencies> <build> <plugins> Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/assemble/main-bin.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/assemble/main-bin.xml?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/assemble/main-bin.xml (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/assemble/main-bin.xml Sun Mar 9 10:35:03 2008 @@ -28,6 +28,10 @@ <include>httpunit:httpunit:jar</include> <include>junit:junit:jar</include> <include>log4j:log4j:jar</include> + <include>jsp</include> + <include>tomcat:jasper-compiler:jar</include> + <include>tomcat:jasper-runtime:jar</include> + <include>javax.servlet:jsp-api:jar</include> </includes> <unpack>false</unpack> </dependencySet> Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/common/LibraryHelper.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/common/LibraryHelper.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/common/LibraryHelper.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/common/LibraryHelper.java Sun Mar 9 10:35:03 2008 @@ -1,186 +1,183 @@ -/* - * ======================================================================== - * - * Copyright 2001-2003 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ======================================================================== - */ -package org.apache.cactus.eclipse.runner.common; - -import java.io.File; - -import org.apache.cactus.eclipse.runner.ui.CactusPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.JavaCore; - -/** - * Helper class for library access. - * - * @version $Id: LibraryHelper.java 238816 2004-02-29 16:36:46Z vmassol $ - */ -public class LibraryHelper -{ - /** - * Returns an array of jar paths contained - * in the given directory. - * @param theDirectory the directory to list jars from - * @return an array of jar paths - */ - private static IPath[] getJarPathArray(File theDirectory) - { - File[] files = theDirectory.listFiles(new JarFilenameFilter()); - IPath[] result = new IPath[files.length]; - for (int i = 0; i < files.length; i++) - { - result[i] = new Path(files[i].getAbsolutePath()); - } - return result; - } - - /** - * @return an IPath array of the jar files in client lib directory - */ - private static IPath[] getClientJarPathArray() - { - File clientLibDir = getClientLibPath().toFile(); - return getJarPathArray(clientLibDir); - } - - /** - * @return an IPath array of the jar files in client lib directory - */ - private static IPath[] getCommonJarPathArray() - { - File commmonLibDir = getCommonLibPath().toFile(); - return getJarPathArray(commmonLibDir); - } - - /** - * @return an array of IClasspathEntry contained in the client dir - */ - public static IClasspathEntry[] getClientEntries() - { - IPath[] clientJars = getClientJarPathArray(); - IClasspathEntry[] result = new IClasspathEntry[clientJars.length]; - for (int i = 0; i < clientJars.length; i++) - { - result[i] = getIClasspathEntry(clientJars[i]); - } - return result; - } - - /** - * @return an array of IClasspathEntry contained in the common dir - */ - public static IClasspathEntry[] getCommonEntries() - { - IPath[] commonJars = getCommonJarPathArray(); - IClasspathEntry[] result = new IClasspathEntry[commonJars.length]; - for (int i = 0; i < commonJars.length; i++) - { - result[i] = getIClasspathEntry(commonJars[i]); - } - return result; - } - - /** - * @return an array of IClasspathEntry contained in the common dir - */ - public static IClasspathEntry[] getClientSideEntries() - { - IClasspathEntry[] clientEntries = getClientEntries(); - IClasspathEntry[] commonEntries = getCommonEntries(); - return concatenateEntries(clientEntries, commonEntries); - } - - /** - * Concatenate two IClasspathEntry arrays. - * - * @param theArray1 the first array - * @param theArray2 the second array - * @return an IClasspathEntry array containing the first array - * followed by the second one - */ - public static IClasspathEntry[] concatenateEntries( - IClasspathEntry[] theArray1, IClasspathEntry[] theArray2) - { - IClasspathEntry[] newArray = - new IClasspathEntry[theArray1.length + theArray2.length]; - System.arraycopy(theArray1, 0, newArray, 0, theArray1.length); - System.arraycopy( - theArray2, - 0, - newArray, - theArray1.length, - theArray2.length); - return newArray; - } - - /** - * @return the path to the library directory - */ - public static IPath getLibPath() - { - CactusPlugin thePlugin = CactusPlugin.getDefault(); - String plPath = ""; - //URL antLibURL = thePlugin.getDefault().find(new Path(CACTUS_LIBRARY_PATH)); - - //We have to replace the underscore because our jar is generated with Maven, and - //Maven places dashes as a delimiter, between the version and the artifactId. - try { - plPath = JavaCore.getClasspathVariable("ECLIPSE_HOME").toFile().toURL().getPath()+ - CactusPlugin.getDefault().getDescriptor().getInstallURL().getFile().replaceAll("plugin","plugins").replaceAll("_", "-"); - } catch(Exception ex) { - CactusPlugin.log(ex); - } - return new Path(plPath.concat(CactusPlugin.CACTUS_LIBRARY_PATH)); - } - - /** - * @return the path to the client library directory - */ - private static IPath getClientLibPath() - { - return getLibPath().append(CactusPlugin.CACTUS_CLIENT_LIBRARY_PATH); - } - - /** - * @return the path to the common library directory - */ - private static IPath getCommonLibPath() - { - return getLibPath().append(CactusPlugin.CACTUS_COMMON_LIBRARY_PATH); - } - - /** - * @param thePath path to convert to an IClasspathEntry - * @return the IClasspathEntry built from the given path - */ - public static IClasspathEntry getIClasspathEntry(IPath thePath) - { - return JavaCore.newLibraryEntry(thePath, null, null); - } - - /** - * @param thePath path to convert to an IClasspathEntry - * @return the IClasspathEntry built from the given path - */ - public static IClasspathEntry getIClasspathEntry(String thePath) - { - return getIClasspathEntry(new Path(thePath)); - } -} +/* + * ======================================================================== + * + * Copyright 2001-2003 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ======================================================================== + */ +package org.apache.cactus.eclipse.runner.common; + +import java.io.File; +import java.io.IOException; + +import org.apache.cactus.eclipse.runner.ui.CactusPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.JavaCore; + +/** + * Helper class for library access. + * + * @version $Id: LibraryHelper.java 238816 2004-02-29 16:36:46Z vmassol $ + */ +public class LibraryHelper +{ + /** + * Returns an array of jar paths contained + * in the given directory. + * @param theDirectory the directory to list jars from + * @return an array of jar paths + */ + private static IPath[] getJarPathArray(File theDirectory) + { + File[] files = theDirectory.listFiles(new JarFilenameFilter()); + IPath[] result = new IPath[files.length]; + for (int i = 0; i < files.length; i++) + { + result[i] = new Path(files[i].getAbsolutePath()); + } + return result; + } + + /** + * @return an IPath array of the jar files in client lib directory + */ + private static IPath[] getClientJarPathArray() + { + File clientLibDir = getClientLibPath().toFile(); + return getJarPathArray(clientLibDir); + } + + /** + * @return an IPath array of the jar files in client lib directory + */ + private static IPath[] getCommonJarPathArray() + { + File commmonLibDir = getCommonLibPath().toFile(); + return getJarPathArray(commmonLibDir); + } + + /** + * @return an array of IClasspathEntry contained in the client dir + */ + public static IClasspathEntry[] getClientEntries() + { + IPath[] clientJars = getClientJarPathArray(); + IClasspathEntry[] result = new IClasspathEntry[clientJars.length]; + for (int i = 0; i < clientJars.length; i++) + { + result[i] = getIClasspathEntry(clientJars[i]); + } + return result; + } + + /** + * @return an array of IClasspathEntry contained in the common dir + */ + public static IClasspathEntry[] getCommonEntries() + { + IPath[] commonJars = getCommonJarPathArray(); + IClasspathEntry[] result = new IClasspathEntry[commonJars.length]; + for (int i = 0; i < commonJars.length; i++) + { + result[i] = getIClasspathEntry(commonJars[i]); + } + return result; + } + + /** + * @return an array of IClasspathEntry contained in the common dir + */ + public static IClasspathEntry[] getClientSideEntries() + { + IClasspathEntry[] clientEntries = getClientEntries(); + IClasspathEntry[] commonEntries = getCommonEntries(); + return concatenateEntries(clientEntries, commonEntries); + } + + /** + * Concatenate two IClasspathEntry arrays. + * + * @param theArray1 the first array + * @param theArray2 the second array + * @return an IClasspathEntry array containing the first array + * followed by the second one + */ + public static IClasspathEntry[] concatenateEntries( + IClasspathEntry[] theArray1, IClasspathEntry[] theArray2) + { + IClasspathEntry[] newArray = + new IClasspathEntry[theArray1.length + theArray2.length]; + System.arraycopy(theArray1, 0, newArray, 0, theArray1.length); + System.arraycopy( + theArray2, + 0, + newArray, + theArray1.length, + theArray2.length); + return newArray; + } + + /** + * @return the path to the library directory + */ + public static IPath getLibPath() + { + CactusPlugin thePlugin = CactusPlugin.getDefault(); + + try { + return new Path(Platform.asLocalURL(thePlugin.getBundle().getEntry("/" +CactusPlugin.CACTUS_LIBRARY_PATH)).getPath()); + } catch(IOException ex) { + CactusPlugin.log(ex); // throwing an exception would be preferable + } + return new Path(CactusPlugin.CACTUS_LIBRARY_PATH); + } + + /** + * @return the path to the client library directory + */ + private static IPath getClientLibPath() + { + return getLibPath().append(CactusPlugin.CACTUS_CLIENT_LIBRARY_PATH); + } + + /** + * @return the path to the common library directory + */ + private static IPath getCommonLibPath() + { + return getLibPath().append(CactusPlugin.CACTUS_COMMON_LIBRARY_PATH); + } + + /** + * @param thePath path to convert to an IClasspathEntry + * @return the IClasspathEntry built from the given path + */ + public static IClasspathEntry getIClasspathEntry(IPath thePath) + { + return JavaCore.newLibraryEntry(thePath, null, null); + } + + /** + * @param thePath path to convert to an IClasspathEntry + * @return the IClasspathEntry built from the given path + */ + public static IClasspathEntry getIClasspathEntry(String thePath) + { + return getIClasspathEntry(new Path(thePath)); + } +} Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/containers/jetty/JettyContainerManager.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/containers/jetty/JettyContainerManager.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/containers/jetty/JettyContainerManager.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/containers/jetty/JettyContainerManager.java Sun Mar 9 10:35:03 2008 @@ -1,173 +1,172 @@ -/* - * ======================================================================== - * - * Copyright 2001-2003 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ======================================================================== - */ -package org.apache.cactus.eclipse.runner.containers.jetty; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; - -import org.apache.cactus.eclipse.runner.containers.IContainerManager; -import org.apache.cactus.eclipse.runner.ui.CactusPlugin; -import org.apache.cactus.eclipse.runner.ui.CactusPreferences; -import org.apache.cactus.eclipse.webapp.internal.WarBuilder; -import org.apache.cactus.eclipse.webapp.internal.Webapp; -import org.apache.cactus.eclipse.webapp.internal.ui.WebappPlugin; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Copy; -import org.apache.tools.ant.types.FileSet; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IJavaProject; - -/** - * Implementation of IContainerManager for the Jetty container. - * - * @version $Id: JettyContainerManager.java 238816 2004-02-29 16:36:46Z vmassol $ - */ -public class JettyContainerManager implements IContainerManager -{ - - /** - * The name of the path to the Jetty webapp - */ - private static final String JETTY_WEBAPP_PATH = "jetty.webapp"; - - /** - * The name of the jspRedirector.jsp file - */ - private static final String JSPREDIRECTOR_PATH = - "C:/eclipse/plugins/org.apache.cactus.eclipse.runner-1.8.0/lib/confs/jspRedirector.jsp"; - - /** - * Directory containg the web application for Jetty - */ - private File jettyWebappDir = - new File( - CactusPreferences.getTempDir() - + File.separator - + JETTY_WEBAPP_PATH); - /** - * @see IContainerManager#prepare(org.eclipse.jdt.core.IJavaProject) - */ - public void prepare(IJavaProject theJavaProject) - { - try - { - cactifyWebapp(theJavaProject); - } - catch (CoreException e) - { - CactusPlugin.log("Failed"+e.getMessage()); - } - } - - /** - * @see IContainerManager#tearDown() - */ - public void tearDown() - { - //WarBuilder.delete(jettyWebappDir); - } - - /** - * @param theJavaProject the project to cactify - * @throws CoreException if the cactification could not occur - */ - private void cactifyWebapp(IJavaProject theJavaProject) - throws CoreException - { - WarBuilder.delete(jettyWebappDir); - jettyWebappDir.mkdir(); - copyCactusWebappResources(jettyWebappDir); - Webapp webapp = WebappPlugin.getWebapp(theJavaProject); - CactusPlugin.log("Webapp"+ webapp.toString()); - webapp.init(); - File webappDir = webapp.getAbsoluteDir(); - CactusPlugin.log("Webapp.dir"+webappDir.getAbsolutePath()); - if (webappDir != null && webappDir.exists()) - { - copyContents(webappDir, jettyWebappDir); - } - } - - /** - * Copies Cactus webapp resources (jspredirector.jsp) to the given - * directory - * @param theDir the directory to copy resources to - * @throws CoreException if we cannot copy the resources - */ - private void copyCactusWebappResources(File theDir) throws CoreException - { - Project antProject = new Project(); - antProject.init(); - Copy copy = new Copy(); - copy.setProject(antProject); - copy.setTodir(theDir); - CactusPlugin thePlugin = CactusPlugin.getDefault(); - URL jspRedirectorURL = null; - try{ - jspRedirectorURL = new URL("file://"+JSPREDIRECTOR_PATH); - } catch(MalformedURLException mde) { - throw CactusPlugin.createCoreException( - "CactusLaunch.message.prepare.error.plugin.file", - " : " + mde.getMessage(), - null); - } - if (jspRedirectorURL == null) - { - throw CactusPlugin.createCoreException( - "CactusLaunch.message.prepare.error.plugin.file", - " : " + JSPREDIRECTOR_PATH, - null); - } - CactusPlugin.log(jspRedirectorURL.getPath()); - File jspRedirector = new File(jspRedirectorURL.getPath()); - FileSet fileSet = new FileSet(); - fileSet.setFile(jspRedirector); - copy.addFileset(fileSet); - copy.execute(); - } - - /** - * copies files from a directory to another directory - * @param theSourceDir directory to copy files from - * @param theTargetDir directory to copy files to - */ - private void copyContents(File theSourceDir, File theTargetDir) - { - Project antProject = new Project(); - antProject.init(); - Copy copy = new Copy(); - copy.setProject(antProject); - copy.setTodir(theTargetDir); - FileSet fileSet = new FileSet(); - fileSet.setDir(theSourceDir); - copy.addFileset(fileSet); - copy.execute(); - } - - /** - * @return the path name element of the web application directory - */ - public static String getJettyWebappPath() - { - return JETTY_WEBAPP_PATH; - } -} +/* + * ======================================================================== + * + * Copyright 2001-2003 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ======================================================================== + */ +package org.apache.cactus.eclipse.runner.containers.jetty; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +import org.apache.cactus.eclipse.runner.containers.IContainerManager; +import org.apache.cactus.eclipse.runner.ui.CactusPlugin; +import org.apache.cactus.eclipse.runner.ui.CactusPreferences; +import org.apache.cactus.eclipse.webapp.internal.WarBuilder; +import org.apache.cactus.eclipse.webapp.internal.Webapp; +import org.apache.cactus.eclipse.webapp.internal.ui.WebappPlugin; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Copy; +import org.apache.tools.ant.types.FileSet; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.core.IJavaProject; + +/** + * Implementation of IContainerManager for the Jetty container. + * + * @version $Id: JettyContainerManager.java 238816 2004-02-29 16:36:46Z vmassol $ + */ +public class JettyContainerManager implements IContainerManager +{ + + /** + * The name of the path to the Jetty webapp + */ + private static final String JETTY_WEBAPP_PATH = "jetty.webapp"; + + /** + * The name of the jspRedirector.jsp file + */ + private static final Path JSPREDIRECTOR_PATH = + new Path("/lib/confs/jspRedirector.jsp"); + + /** + * Directory containg the web application for Jetty + */ + private File jettyWebappDir = + new File( + CactusPreferences.getTempDir() + + File.separator + + JETTY_WEBAPP_PATH); + /** + * @see IContainerManager#prepare(org.eclipse.jdt.core.IJavaProject) + */ + public void prepare(IJavaProject theJavaProject) + { + try + { + cactifyWebapp(theJavaProject); + } + catch (CoreException e) + { + CactusPlugin.log("Failed"+e.getMessage()); + } + } + + /** + * @see IContainerManager#tearDown() + */ + public void tearDown() + { + //WarBuilder.delete(jettyWebappDir); + } + + /** + * @param theJavaProject the project to cactify + * @throws CoreException if the cactification could not occur + */ + private void cactifyWebapp(IJavaProject theJavaProject) + throws CoreException + { + WarBuilder.delete(jettyWebappDir); + jettyWebappDir.mkdir(); + copyCactusWebappResources(jettyWebappDir); + Webapp webapp = WebappPlugin.getWebapp(theJavaProject); + webapp.init(); + File webappDir = webapp.getAbsoluteDir(); + if (webappDir != null && webappDir.exists()) + { + copyContents(webappDir, jettyWebappDir); + } + } + + /** + * Copies Cactus webapp resources (jspredirector.jsp) to the given + * directory + * @param theDir the directory to copy resources to + * @throws CoreException if we cannot copy the resources + */ + private void copyCactusWebappResources(File theDir) throws CoreException + { + Project antProject = new Project(); + antProject.init(); + Copy copy = new Copy(); + copy.setProject(antProject); + copy.setTodir(theDir); + CactusPlugin thePlugin = CactusPlugin.getDefault(); + URL jspRedirectorURL = thePlugin.find(JSPREDIRECTOR_PATH); + if (jspRedirectorURL == null) + { + throw CactusPlugin.createCoreException( + "CactusLaunch.message.prepare.error.plugin.file", + " : " + JSPREDIRECTOR_PATH, + null); + } + try{ + jspRedirectorURL = Platform.asLocalURL(jspRedirectorURL); + } catch(IOException e) { + throw CactusPlugin.createCoreException( + "CactusLaunch.message.prepare.error.plugin.file", + " : " + e.getMessage(), + null); + } + CactusPlugin.log(jspRedirectorURL.getPath()); + File jspRedirector = new File(jspRedirectorURL.getPath()); + FileSet fileSet = new FileSet(); + fileSet.setFile(jspRedirector); + copy.addFileset(fileSet); + copy.execute(); + } + + /** + * copies files from a directory to another directory + * @param theSourceDir directory to copy files from + * @param theTargetDir directory to copy files to + */ + private void copyContents(File theSourceDir, File theTargetDir) + { + Project antProject = new Project(); + antProject.init(); + Copy copy = new Copy(); + copy.setProject(antProject); + copy.setTodir(theTargetDir); + FileSet fileSet = new FileSet(); + fileSet.setDir(theSourceDir); + copy.addFileset(fileSet); + copy.execute(); + } + + /** + * @return the path name element of the web application directory + */ + public static String getJettyWebappPath() + { + return JETTY_WEBAPP_PATH; + } +} Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/CactusLaunchConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/CactusLaunchConfiguration.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/CactusLaunchConfiguration.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/CactusLaunchConfiguration.java Sun Mar 9 10:35:03 2008 @@ -20,6 +20,7 @@ package org.apache.cactus.eclipse.runner.launcher; import java.net.URL; +import java.util.Iterator; import java.util.List; import java.util.Vector; @@ -136,14 +137,12 @@ try { CactusPlugin.getContainerManager(true).prepare(javaProject); - CactusPlugin.log("Preapred successfully!!!!!!!!!!!!!!!!!!"); Display.getDefault().asyncExec(new Runnable() { public void run() { try { - CactusPlugin.log("After this breaks."); CactusLaunchConfiguration.super.launch( cactusConfig, theMode, @@ -315,7 +314,6 @@ { return; } - CactusPlugin.log("Test run ended"); try { CactusPlugin.getContainerManager(false).tearDown(); Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/JettyCactusLaunchConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/JettyCactusLaunchConfiguration.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/JettyCactusLaunchConfiguration.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/launcher/JettyCactusLaunchConfiguration.java Sun Mar 9 10:35:03 2008 @@ -96,10 +96,7 @@ private IClasspathEntry[] getJettyClasspath() throws CoreException, MalformedURLException { CactusPlugin thePlugin = CactusPlugin.getDefault(); - //CactusPlugin.log("Just here:"+LibraryHelper.getLibPath().toString()); - - //URL libURL = thePlugin.find(LibraryHelper.getLibPath()); - + IPath libURL = LibraryHelper.getLibPath(); if (libURL == null) @@ -145,7 +142,7 @@ + VM_ARG_SEPARATOR; } cactusVMArgs += "-Dcactus.initializer=" - + "org.apache.cactus.extension.jetty.JettyInitializer"; + + "org.apache.cactus.extension.jetty.JettyTestSetup"; return cactusVMArgs; } @@ -174,10 +171,8 @@ private IClasspathEntry[] getLibrariesPaths( IPluginDescriptor theDescriptor, String thePackagePrefix) throws MalformedURLException { - CactusPlugin.log("PPrefix"+thePackagePrefix); Vector result = new Vector(); URL root = new URL(("file://"+JavaCore.getClasspathVariable("ECLIPSE_HOME").toFile().toURL().getPath()+theDescriptor.getInstallURL().getPath()).replaceAll("plugin","plugins")); - CactusPlugin.log("Root"+root.getPath()); ILibrary[] libraries = theDescriptor.getRuntimeLibraries(); for (int i = 0; i < libraries.length; i++) @@ -194,7 +189,6 @@ result.add( LibraryHelper.getIClasspathEntry( Platform.asLocalURL(url).getPath())); - CactusPlugin.log("Added"); } catch (IOException e) { @@ -215,9 +209,6 @@ */ private boolean isContained(String thePackagePrefix, ILibrary theCurrentLib) { - - //CactusPlugin.log("Path of the lib:"+theCurrentLib.getPath().toString()); - String[] prefixes = theCurrentLib.getPackagePrefixes(); if(prefixes==null || prefixes.length==0) { //CactusPlugin.log("lib: "+theCurrentLib.getPath().toString()+" is not"); Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactifyActionDelegate.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactifyActionDelegate.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactifyActionDelegate.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactifyActionDelegate.java Sun Mar 9 10:35:03 2008 @@ -1,199 +1,199 @@ -/* - * ======================================================================== - * - * Copyright 2001-2003 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ======================================================================== - */ -package org.apache.cactus.eclipse.runner.ui; - -import java.io.File; -import java.util.Vector; - -import org.apache.cactus.eclipse.runner.common.JarFilenameFilter; -import org.eclipse.core.internal.resources.Project; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Action delegate to cactify a project. - * - * @version $Id: CactifyActionDelegate.java 238816 2004-02-29 16:36:46Z vmassol $ - */ -public class CactifyActionDelegate implements IObjectActionDelegate -{ - /** - * The project selected by the user - */ - private IJavaProject selectedProject; - - /** - * The active part - */ - private IWorkbenchPart part; - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction theAction, IWorkbenchPart theTargetPart) - { - this.part = theTargetPart; - } - - /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction theAction) - { - if (part != null && selectedProject != null) - { - CactusPlugin thePlugin = CactusPlugin.getDefault(); - String libPath = ""; - try { - libPath = JavaCore.getClasspathVariable("ECLIPSE_HOME").toFile().toURL().getPath()+ - CactusPlugin.getDefault().getDescriptor().getInstallURL().getFile().replaceAll("plugin","plugins").replaceAll("_", "-").concat(CactusPlugin.CACTUS_LIBRARY_PATH); - } catch (Exception ex) { - CactusPlugin.log(ex); - } - - File commonLibDir = new File(libPath.concat(CactusPlugin.CACTUS_COMMON_LIBRARY_PATH)); - File clientLibDir = new File(libPath.concat(CactusPlugin.CACTUS_CLIENT_LIBRARY_PATH)); - CactusPlugin.log(libPath); - IClasspathEntry[] commonEntries = - getLibClassPathEntries(commonLibDir); - IClasspathEntry[] clientEntries = - getLibClassPathEntries(clientLibDir); - IClasspathEntry[] allNewEntries = - new IClasspathEntry[commonEntries.length - + clientEntries.length]; - System.arraycopy( - commonEntries, - 0, - allNewEntries, - 0, - commonEntries.length); - System.arraycopy( - clientEntries, - 0, - allNewEntries, - commonEntries.length, - clientEntries.length); - try - { - - IClasspathEntry[] existingEntries = - selectedProject.getRawClasspath(); - selectedProject.setRawClasspath( - merge(existingEntries, allNewEntries), - null); - } - catch (Exception e) - { - CactusPlugin.displayErrorMessage( - CactusMessages.getString("Cactify.message.error"), - e.getMessage(), - null); - } - } - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction theAction, ISelection theSelection) - { - selectedProject = null; - if (theSelection instanceof IStructuredSelection) - { - IStructuredSelection structuredSelection = - (IStructuredSelection) theSelection; - if (structuredSelection.size() == 1) - { - Object selectedResource = structuredSelection.getFirstElement(); - if (selectedResource instanceof org.eclipse.core.internal.resources.Project) - { - Project project = (Project) selectedResource; - selectedProject = JavaCore.create(project); - } - } - } - } - - /** - * Returns a list of entries of jars files contained - * in the given directory. - * @param theDirectory the directory to list jars from - * @return an array of jar entries - */ - private IClasspathEntry[] getLibClassPathEntries(File theDirectory) - { - File[] jarFiles = theDirectory.listFiles(new JarFilenameFilter()); - IClasspathEntry[] result = new IClasspathEntry[jarFiles.length]; - for (int i = 0; i < jarFiles.length; i++) - { - File currentJarFile = jarFiles[i]; - result[i] = - JavaCore.newLibraryEntry( - new Path(currentJarFile.getAbsolutePath()), - null, - null); - } - return result; - } - /** - * @param theFirstArray an array of classpath entries - * @param theSecondArray an array of classpath entries - * @return the fusion of the two given arrays - */ - private static IClasspathEntry[] merge( - IClasspathEntry[] theFirstArray, - IClasspathEntry[] theSecondArray) - { - - Vector result = new Vector(); - for (int i = 0; i < theFirstArray.length; i++) - { - result.add(theFirstArray[i]); - } - for (int i = 0; i < theSecondArray.length; i++) - { - IClasspathEntry currentEntry = theSecondArray[i]; - boolean entryAlreadyExists = false; - for (int j = 0; j < theFirstArray.length; j++) - { - IClasspathEntry comparedEntry = theFirstArray[j]; - if (comparedEntry.getPath().equals(currentEntry.getPath())) - { - entryAlreadyExists = true; - break; - } - } - if (!entryAlreadyExists) - { - result.add(currentEntry); - } - } - return (IClasspathEntry[]) result.toArray( - new IClasspathEntry[result.size()]); - } -} +/* + * ======================================================================== + * + * Copyright 2001-2003 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ======================================================================== + */ +package org.apache.cactus.eclipse.runner.ui; + +import java.io.File; +import java.util.Vector; + +import org.apache.cactus.eclipse.runner.common.JarFilenameFilter; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Action delegate to cactify a project. + * + * @version $Id: CactifyActionDelegate.java 238816 2004-02-29 16:36:46Z vmassol $ + */ +public class CactifyActionDelegate implements IObjectActionDelegate +{ + /** + * The project selected by the user + */ + private IJavaProject selectedProject; + + /** + * The active part + */ + private IWorkbenchPart part; + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction theAction, IWorkbenchPart theTargetPart) + { + this.part = theTargetPart; + } + + /** + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction theAction) + { + if (part != null && selectedProject != null) + { + CactusPlugin thePlugin = CactusPlugin.getDefault(); + File commonLibDir = null; + File clientLibDir = null; + + try { + commonLibDir = new File(Platform.asLocalURL(thePlugin.getBundle().getEntry("/" +CactusPlugin.CACTUS_LIBRARY_PATH +"/" +CactusPlugin.CACTUS_COMMON_LIBRARY_PATH)).getPath()); + clientLibDir = new File(Platform.asLocalURL(thePlugin.getBundle().getEntry("/" +CactusPlugin.CACTUS_LIBRARY_PATH +"/" +CactusPlugin.CACTUS_CLIENT_LIBRARY_PATH)).getPath()); + } catch (Exception ex) { + CactusPlugin.log(ex); + } + + IClasspathEntry[] commonEntries = + getLibClassPathEntries(commonLibDir); + IClasspathEntry[] clientEntries = + getLibClassPathEntries(clientLibDir); + IClasspathEntry[] allNewEntries = + new IClasspathEntry[commonEntries.length + + clientEntries.length]; + System.arraycopy( + commonEntries, + 0, + allNewEntries, + 0, + commonEntries.length); + System.arraycopy( + clientEntries, + 0, + allNewEntries, + commonEntries.length, + clientEntries.length); + try + { + + IClasspathEntry[] existingEntries = + selectedProject.getRawClasspath(); + selectedProject.setRawClasspath( + merge(existingEntries, allNewEntries), + null); + } + catch (Exception e) + { + CactusPlugin.displayErrorMessage( + CactusMessages.getString("Cactify.message.error"), + e.getMessage(), + null); + } + } + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction theAction, ISelection theSelection) + { + selectedProject = null; + if (theSelection instanceof IStructuredSelection) + { + IStructuredSelection structuredSelection = + (IStructuredSelection) theSelection; + if (structuredSelection.size() == 1) + { + Object selectedResource = structuredSelection.getFirstElement(); + if (selectedResource instanceof org.eclipse.core.internal.resources.Project) + { + Project project = (Project) selectedResource; + selectedProject = JavaCore.create(project); + } + } + } + } + + /** + * Returns a list of entries of jars files contained + * in the given directory. + * @param theDirectory the directory to list jars from + * @return an array of jar entries + */ + private IClasspathEntry[] getLibClassPathEntries(File theDirectory) + { + File[] jarFiles = theDirectory.listFiles(new JarFilenameFilter()); + IClasspathEntry[] result = new IClasspathEntry[jarFiles.length]; + for (int i = 0; i < jarFiles.length; i++) + { + File currentJarFile = jarFiles[i]; + result[i] = + JavaCore.newLibraryEntry( + new Path(currentJarFile.getAbsolutePath()), + null, + null); + } + return result; + } + /** + * @param theFirstArray an array of classpath entries + * @param theSecondArray an array of classpath entries + * @return the fusion of the two given arrays + */ + private static IClasspathEntry[] merge( + IClasspathEntry[] theFirstArray, + IClasspathEntry[] theSecondArray) + { + + Vector result = new Vector(); + for (int i = 0; i < theFirstArray.length; i++) + { + result.add(theFirstArray[i]); + } + for (int i = 0; i < theSecondArray.length; i++) + { + IClasspathEntry currentEntry = theSecondArray[i]; + boolean entryAlreadyExists = false; + for (int j = 0; j < theFirstArray.length; j++) + { + IClasspathEntry comparedEntry = theFirstArray[j]; + if (comparedEntry.getPath().equals(currentEntry.getPath())) + { + entryAlreadyExists = true; + break; + } + } + if (!entryAlreadyExists) + { + result.add(currentEntry); + } + } + return (IClasspathEntry[]) result.toArray( + new IClasspathEntry[result.size()]); + } +} Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPlugin.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPlugin.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPlugin.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPlugin.java Sun Mar 9 10:35:03 2008 @@ -253,7 +253,6 @@ } if (CactusPreferences.getJetty()) { - CactusPlugin.log("Using Jetty..."); containerManager = new JettyContainerManager(); return containerManager; } Modified: jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPreferences.java URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPreferences.java?rev=635311&r1=635310&r2=635311&view=diff ============================================================================== --- jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPreferences.java (original) +++ jakarta/cactus/trunk/integration/eclipse/org.apache.cactus.eclipse.runner/src/main/java/org/apache/cactus/eclipse/runner/ui/CactusPreferences.java Sun Mar 9 10:35:03 2008 @@ -83,7 +83,6 @@ .append("/") .append(store.getString(CONTEXT_URL_PATH)); String result = buf.toString(); - CactusPlugin.log("Cactus preference : ContextURL = [" + result + "]"); return result; } @@ -95,8 +94,6 @@ { IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore(); int result = store.getInt(CONTEXT_URL_PORT); - CactusPlugin.log( - "Cactus preference : ContextURLPort = [" + result + "]"); return result; } @@ -108,8 +105,6 @@ { IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore(); String result = store.getString(CONTEXT_URL_PATH); - CactusPlugin.log( - "Cactus preference : ContextURLPath = [" + result + "]"); return result; } @@ -121,7 +116,6 @@ { IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore(); String result = store.getString(TEMP_DIR); - CactusPlugin.log("Cactus preference : TempDir = [" + result + "]"); return result; } @@ -133,8 +127,6 @@ { IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore(); String result = store.getString(theContainerId); - CactusPlugin.log( - "Cactus preference : " + theContainerId + "= [" + result + "]"); return result; } @@ -145,7 +137,6 @@ { IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore(); boolean result = store.getBoolean(JETTY); - CactusPlugin.log("Cactus preference : Jetty = [" + result + "]"); return result; } @@ -156,7 +147,6 @@ { IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore(); String result = store.getString(JETTY_XML); - CactusPlugin.log("Cactus preference : jetty.xml = [" + result + "]"); return result; } @@ -178,8 +168,6 @@ } } - CactusPlugin.log( - "Cactus preference : ContainerHomes = [" + containerHomes + "]"); return containerHomes; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]