geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r414657 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core: GeronimoServerRuntimeTargetHandler.java internal/Messages.java internal/Messages.properties
Date Thu, 15 Jun 2006 19:20:21 GMT
Author: sppatel
Date: Thu Jun 15 12:20:20 2006
New Revision: 414657

URL: http://svn.apache.org/viewvc?rev=414657&view=rev
Log:
remove dependency on server definition, simplefy classpath provider

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerRuntimeTargetHandler.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerRuntimeTargetHandler.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerRuntimeTargetHandler.java?rev=414657&r1=414656&r2=414657&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerRuntimeTargetHandler.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerRuntimeTargetHandler.java
Thu Jun 15 12:20:20 2006
@@ -15,185 +15,54 @@
  */
 package org.apache.geronimo.st.core;
 
-import java.io.File;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
+import org.apache.geronimo.st.core.internal.Messages;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jst.server.generic.core.internal.GenericServerRuntimeTargetHandler;
-import org.eclipse.jst.server.generic.core.internal.ServerTypeDefinitionUtil;
-import org.eclipse.jst.server.generic.servertype.definition.ArchiveType;
-import org.eclipse.jst.server.generic.servertype.definition.Classpath;
-import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime;
+import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
 import org.eclipse.wst.server.core.IRuntime;
 
-public class GeronimoServerRuntimeTargetHandler extends
-		GenericServerRuntimeTargetHandler {
-
-	private static final String EXTENSION_RUNTIME_ACCESS = "discouragedRuntimeAccess";
-
-	String cachedArchiveString = null;
-	IClasspathEntry[] cachedClasspath = null;
-	private static Map map;
-	private IPath runtimeLoc;
-	private String runtimeTypeId;
-
-	static {
-		loadExtensions();
-	}
-
-	private static synchronized void loadExtensions() {
-		map = new HashMap();
-		IExtensionRegistry registry = Platform.getExtensionRegistry();
-		IConfigurationElement[] cf = registry.getConfigurationElementsFor(Activator.PLUGIN_ID,
EXTENSION_RUNTIME_ACCESS);
-		for (int i = 0; i < cf.length; i++) {
-			IConfigurationElement element = cf[i];
-			if ("restriction".equals(element.getName())) {
-				String runtimeId = element.getAttribute("id");
-				if (runtimeId != null) {
-					IConfigurationElement[] children = element.getChildren();
-					for (int j = 0; j < children.length; j++) {
-						String path = children[j].getAttribute("value");
-						if (path != null) {
-							Collection c = (Collection) map.get(runtimeId);
-							if (c == null) {
-								c = new ArrayList();
-								map.put(runtimeId, c);
-							}
-							c.add(new Path(path));
-						}
-					}
-				}
-			}
-
+public class GeronimoServerRuntimeTargetHandler extends RuntimeClasspathProviderDelegate
{
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate#getClasspathContainerLabel(org.eclipse.wst.server.core.IRuntime)
+	 */
+	public String getClasspathContainerLabel(IRuntime runtime) {
+		String version = runtime.getRuntimeType().getVersion();
+		if(version.equals("1.0")) {
+			return Messages.target10runtime;
+		} else if(version.equals("1.1")) {
+			return Messages.target11runtime;
 		}
+		return Messages.target11runtime;
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jst.server.generic.core.internal.GenericServerRuntimeTargetHandler#resolveClasspathContainer(org.eclipse.wst.server.core.IRuntime)
 	 */
 	public IClasspathEntry[] resolveClasspathContainer(IRuntime runtime) {
-		this.runtimeTypeId = runtime.getRuntimeType().getId();
 		return getServerClassPathEntry(runtime);
 	}
 
 	public IClasspathEntry[] getServerClassPathEntry(IRuntime runtime) {
-		this.runtimeLoc = runtime.getLocation();
-		ServerRuntime serverDefinition = ServerTypeDefinitionUtil.getServerTypeDefinition(runtime);
-		String ref = serverDefinition.getProject().getClasspathReference();
-		Classpath cp = serverDefinition.getClasspath(ref);
-		List archives = cp.getArchive();
-
-		// It's expensive to keep searching directories, so try to cache the
-		// result
-		IClasspathEntry[] savedClasspath = getCachedClasspathFor(serverDefinition, archives);
-		if (savedClasspath != null)
-			return savedClasspath;
-
-		Iterator archiveIter = archives.iterator();
-		ArrayList entryList = new ArrayList();
-		while (archiveIter.hasNext()) {
-			ArchiveType archive = (ArchiveType) archiveIter.next();
-			String item = serverDefinition.getResolver().resolveProperties(archive.getPath());
-			IPath path = new Path(item);
-			File file = path.toFile();
-			if (file.isDirectory()) {
-				boolean discourageAccess = isAccessDiscouraged(path);
-				File[] list = file.listFiles();
-				for (int i = 0; i < list.length; i++) {
-					if (!list[i].isDirectory()) {
-						Path p = new Path(list[i].getAbsolutePath());
-						if (!discourageAccess)
-							discourageAccess = isAccessDiscouraged(p);
-						addLibEntry(entryList, p, discourageAccess);
-					}
-				}
-			} else {
-				addLibEntry(entryList, path, isAccessDiscouraged(path));
-			}
-		}
-
-		IClasspathEntry[] classpath = (IClasspathEntry[]) entryList.toArray(new IClasspathEntry[entryList.size()]);
-		setCachedClasspath(classpath);
-
-		return classpath;
-	}
-
-	private boolean isAccessDiscouraged(IPath path) {
-		Collection c = (Collection) map.get(runtimeTypeId);
-		if (c == null || c.isEmpty())
-			return false;
-
-		Iterator i = c.iterator();
-		while (i.hasNext()) {
-			IPath xPath = (IPath) i.next();
-			if (path.toFile().isDirectory()
-					&& runtimeLoc.append(xPath).isPrefixOf(path)) {
-				return true;
-			} else if (runtimeLoc.append(xPath).equals(path)) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	private void addLibEntry(ArrayList entryList, IPath path,
-			boolean discourageAccess) {
-		IClasspathEntry entry = null;
-		if (discourageAccess) {
-			IAccessRule rule = JavaCore.newAccessRule(new Path("**"), IAccessRule.K_DISCOURAGED);
-			IAccessRule rules[] = new IAccessRule[] { rule };
-			entry = JavaCore.newLibraryEntry(path, null, null, rules, new IClasspathAttribute[] {},
false);
-		} else {
-			entry = JavaCore.newLibraryEntry(path, null, null);
+		
+		List list = new ArrayList();
+		IPath path = runtime.getLocation().append("lib");
+		addLibraryEntries(list, path.toFile(), true);
+		
+		String version = runtime.getRuntimeType().getVersion();
+		
+		if(version.equals("1.0")) {
+			IPath specPath = runtime.getLocation().append("repository/org.apache.geronimo.specs/jars/");
+			addLibraryEntries(list, specPath.toFile(), false);
+		} else if(version.equals("1.1")) {
+			IPath specPath = runtime.getLocation().append("repository/org/apache/geronimo/specs/geronimo-j2ee_1.4_spec/1.1/geronimo-j2ee_1.4_spec-1.1.jar");
+			list.add(JavaCore.newLibraryEntry(specPath, null, null));
 		}
-		entryList.add(entry);
-	}
-
-	private IClasspathEntry[] getCachedClasspathFor(
-			ServerRuntime serverDefinition, List archives) {
-
-		// Need to iterate through the list, and expand the variables (in case
-		// they have changed)
-		// The simplest approach is to construct/cache a string for this
-		// That will still save the overhead of going to the filesystem
-
-		StringBuffer buffer = new StringBuffer();
-		Iterator archiveIter = archives.iterator();
-		while (archiveIter.hasNext()) {
-			ArchiveType archive = (ArchiveType) archiveIter.next();
-			String item = serverDefinition.getResolver().resolveProperties(archive.getPath());
-			buffer.append(item);
-			buffer.append(File.pathSeparatorChar);
-		}
-
-		String archiveString = buffer.toString();
-
-		if (cachedArchiveString != null
-				&& cachedArchiveString.equals(archiveString))
-			return cachedClasspath;
-
-		// This is a cache miss - ensure the data is null (to be safe), but save
-		// the key (archiveString) now
-		// The data will be set once it's calculated
-		cachedClasspath = null;
-		cachedArchiveString = archiveString;
-		return null;
-	}
-
-	private void setCachedClasspath(IClasspathEntry[] classpath) {
-		cachedClasspath = classpath;
+		
+		return (IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]);
 	}
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java?rev=414657&r1=414656&r2=414657&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
Thu Jun 15 12:20:20 2006
@@ -32,5 +32,8 @@
 	public static String UNDEPLOY_FAIL;
 	public static String REDEPLOY_FAIL;
 	public static String DM_CONNECTION_FAIL;
+	
+	public static String target10runtime;
+	public static String target11runtime;
 
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties?rev=414657&r1=414656&r2=414657&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
Thu Jun 15 12:20:20 2006
@@ -3,4 +3,7 @@
 STOP_FAIL=Stopping of configuration failed.  See log for details.
 UNDEPLOY_FAIL=Undeploy of configuration failed.  See log for details.
 REDEPLOY_FAIL=Redeploy of configuration failed.  See log for details.
-DM_CONNECTION_FAIL=Connection to deployment manager failed.  See log for details.
\ No newline at end of file
+DM_CONNECTION_FAIL=Connection to deployment manager failed.  See log for details.
+
+target10runtime=Geronimo v1.0 Runtime
+target11runtime=Geronimo v1.1 Runtime
\ No newline at end of file



Mime
View raw message