diff options
Diffstat (limited to 'plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal')
30 files changed, 0 insertions, 3190 deletions
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntime.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntime.java deleted file mode 100644 index 5cb3cef48..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntime.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.jst.server.core.internal; - -import org.eclipse.core.runtime.*; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.IVMInstallType; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.model.RuntimeDelegate; -/** - * - */ -public class GenericRuntime extends RuntimeDelegate implements IGenericRuntime, IGenericRuntimeWorkingCopy { - protected static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id"; - protected static final String PROP_VM_INSTALL_ID = "vm-install-id"; - - /** - * Create a new generic runtime. - */ - public GenericRuntime() { - // do nothing - } - - protected String getVMInstallTypeId() { - return getAttribute(PROP_VM_INSTALL_TYPE_ID, (String)null); - } - - protected String getVMInstallId() { - return getAttribute(PROP_VM_INSTALL_ID, (String)null); - } - - /** - * Returns <code>true</code> if the runtime is using the default JRE. - * - * @return <code>true</code> if the runtime is using the default JRE, - * and <code>false</code> otherwise - */ - public boolean isUsingDefaultJRE() { - return getVMInstallTypeId() == null; - } - - /** - * @see IGenericRuntime#getVMInstall() - */ - public IVMInstall getVMInstall() { - if (getVMInstallTypeId() == null) - return JavaRuntime.getDefaultVMInstall(); - try { - IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId()); - IVMInstall[] vmInstalls = vmInstallType.getVMInstalls(); - int size = vmInstalls.length; - String id = getVMInstallId(); - for (int i = 0; i < size; i++) { - if (id.equals(vmInstalls[i].getId())) - return vmInstalls[i]; - } - } catch (Exception e) { - // ignore - } - return null; - } - - /** - * @see RuntimeDelegate#validate() - */ - public IStatus validate() { - IStatus status = super.validate(); - if (!status.isOK()) - return status; - - IRuntime runtime = getRuntime(); - - IPath path = runtime.getLocation(); - if (!path.toFile().exists()) - return new Status(IStatus.ERROR, JavaServerPlugin.PLUGIN_ID, 0, Messages.errorLocation, null); - else if (getVMInstall() == null) - return new Status(IStatus.ERROR, JavaServerPlugin.PLUGIN_ID, 0, Messages.errorJRE, null); - else - return Status.OK_STATUS; - } - - /** - * @see IGenericRuntimeWorkingCopy#setVMInstall(IVMInstall) - */ - public void setVMInstall(IVMInstall vmInstall) { - if (vmInstall == null) { - setVMInstall(null, null); - } else - setVMInstall(vmInstall.getVMInstallType().getId(), vmInstall.getId()); - } - - protected void setVMInstall(String typeId, String id) { - if (typeId == null) - setAttribute(PROP_VM_INSTALL_TYPE_ID, (String)null); - else - setAttribute(PROP_VM_INSTALL_TYPE_ID, typeId); - - if (id == null) - setAttribute(PROP_VM_INSTALL_ID, (String)null); - else - setAttribute(PROP_VM_INSTALL_ID, id); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeClasspathProvider.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeClasspathProvider.java deleted file mode 100644 index c8f5cf9fa..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeClasspathProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.jst.server.core.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate; - -import org.eclipse.wst.server.core.IRuntime; -/** - * - */ -public class GenericRuntimeClasspathProvider extends RuntimeClasspathProviderDelegate { - /** (non-Javadoc) - * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IProject, IRuntime) - */ - public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) { - IPath installPath = runtime.getLocation(); - - if (installPath == null) - return new IClasspathEntry[0]; - - List list = new ArrayList(); - addLibraryEntries(list, installPath.toFile(), false); - return (IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeUtil.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeUtil.java deleted file mode 100644 index 82dc4882e..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.server.core.internal; - -import org.eclipse.wst.server.core.IRuntime; -/** - * Utility methods for the generic J2EE runtime. - */ -public class GenericRuntimeUtil { - protected static final String RUNTIME_TYPE_ID = "org.eclipse.jst.server.core.runtimeType"; - - /** - * Cannot create GenericRuntimeUtil - use static methods. - */ - private GenericRuntimeUtil() { - // can't create - } - - /** - * Returns <code>true</code> if the given runtime is a generic J2EE runtime, and - * <code>false</code> otherwise. The runtime may not be null. - * - * @param runtime - * @return <code>true</code> if - */ - public static boolean isGenericJ2EERuntime(IRuntime runtime) { - if (runtime == null) - throw new IllegalArgumentException(); - - return (runtime.getRuntimeType() != null && - runtime.getRuntimeType().getId().startsWith(RUNTIME_TYPE_ID)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntime.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntime.java deleted file mode 100644 index 1c509c414..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntime.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.server.core.internal; - -import org.eclipse.jst.server.core.IJavaRuntime; -/** - * - */ -public interface IGenericRuntime extends IJavaRuntime { - // no additional methods -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntimeWorkingCopy.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntimeWorkingCopy.java deleted file mode 100644 index 0133c5c51..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntimeWorkingCopy.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.server.core.internal; - -import org.eclipse.jdt.launching.IVMInstall; -/** - * - */ -public interface IGenericRuntimeWorkingCopy extends IGenericRuntime { - /** - * Set the VM install (installed JRE) that this runtime is using. - * Use <code>null</code> to use the Eclipse default JRE. - * - * @param vmInstall the VM install to use - */ - public void setVMInstall(IVMInstall vmInstall); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IMemento.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IMemento.java deleted file mode 100644 index 820e0a644..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IMemento.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.jst.server.core.internal; - -import java.util.List; -/** - * Interface to a memento used for saving the important state of an object - * in a form that can be persisted in the file system. - * <p> - * Mementos were designed with the following requirements in mind: - * <ol> - * <li>Certain objects need to be saved and restored across platform sessions. - * </li> - * <li>When an object is restored, an appropriate class for an object might not - * be available. It must be possible to skip an object in this case.</li> - * <li>When an object is restored, the appropriate class for the object may be - * different from the one when the object was originally saved. If so, the - * new class should still be able to read the old form of the data.</li> - * </ol> - * </p> - * <p> - * Mementos meet these requirements by providing support for storing a - * mapping of arbitrary string keys to primitive values, and by allowing - * mementos to have other mementos as children (arranged into a tree). - * A robust external storage format based on XML is used. - * </p><p> - * The key for an attribute may be any alpha numeric value. However, the - * value of <code>TAG_ID</code> is reserved for internal use. - * </p><p> - * This interface is not intended to be implemented by clients. - * </p> - */ -public interface IMemento { - /** - * Special reserved key used to store the memento id - * (value <code>"org.eclipse.ui.id"</code>). - * - * @see #getId - */ - public static final String TAG_ID = "IMemento.internal.id"; //$NON-NLS-1$ - - /** - * Creates a new child of this memento with the given type. - * <p> - * The <code>getChild</code> and <code>getChildren</code> methods - * are used to retrieve children of a given type. - * </p> - * - * @param type the type - * @return a new child memento - * @see #getChild - * @see #getChildren - */ - public IMemento createChild(String type); - - /** - * Creates a new child of this memento with the given type and id. - * The id is stored in the child memento (using a special reserved - * key, <code>TAG_ID</code>) and can be retrieved using <code>getId</code>. - * <p> - * The <code>getChild</code> and <code>getChildren</code> methods - * are used to retrieve children of a given type. - * </p> - * - * @param type the type - * @param id the child id - * @return a new child memento with the given type and id - * @see #getId - */ - public IMemento createChild(String type, String id); - - /** - * Returns the first child with the given type id. - * - * @param type the type id - * @return the first child with the given type - */ - public IMemento getChild(String type); - - /** - * Returns all children with the given type id. - * - * @param type the type id - * @return the list of children with the given type - */ - public IMemento[] getChildren(String type); - - /** - * Returns the floating point value of the given key. - * - * @param key the key - * @return the value, or <code>null</code> if the key was not found or was found - * but was not a floating point number - */ - public Float getFloat(String key); - - /** - * Returns the id for this memento. - * - * @return the memento id, or <code>null</code> if none - * @see #createChild(java.lang.String,java.lang.String) - */ - public String getId(); - - /** - * Returns the name for this memento. - * - * @return the memento name, or <code>null</code> if none - * @see #createChild(java.lang.String,java.lang.String) - */ - public String getName(); - - /** - * Returns the integer value of the given key. - * - * @param key the key - * @return the value, or <code>null</code> if the key was not found or was found - * but was not an integer - */ - public Integer getInteger(String key); - - /** - * Returns the string value of the given key. - * - * @param key the key - * @return the value, or <code>null</code> if the key was not found or was found - * but was not an integer - */ - public String getString(String key); - - /** - * Returns the boolean value of the given key. - * - * @param key the key - * @return the value, or <code>null</code> if the key was not found or was found - * but was not a boolean - */ - public Boolean getBoolean(String key); - - /** - * Return the list of names. - * - * @return a possibly empty list of names - */ - public List getNames(); - - /** - * Sets the value of the given key to the given floating point number. - * - * @param key the key - * @param value the value - */ - public void putFloat(String key, float value); - - /** - * Sets the value of the given key to the given integer. - * - * @param key the key - * @param value the value - */ - public void putInteger(String key, int value); - - /** - * Sets the value of the given key to the given boolean value. - * - * @param key the key - * @param value the value - */ - public void putBoolean(String key, boolean value); - - /** - * Copy the attributes and children from <code>memento</code> - * to the receiver. - * - * @param memento the IMemento to be copied. - */ - public void putMemento(IMemento memento); - - /** - * Sets the value of the given key to the given string. - * - * @param key the key - * @param value the value - */ - public void putString(String key, String value); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EELaunchableClient.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EELaunchableClient.java deleted file mode 100644 index 4f1829295..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EELaunchableClient.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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.jst.server.core.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.jst.server.core.JndiLaunchable; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.model.ClientDelegate; -/** - * - */ -public class J2EELaunchableClient extends ClientDelegate { - /* - * @see ClientDelegate#supports(ILaunchable) - */ - public boolean supports(IServer server, Object launchable, String launchMode) { - return (launchable instanceof JndiLaunchable); - } - - /* - * @see ClientDelegate#launch(ILaunchable) - */ - public IStatus launch(IServer server, Object launchable, String launchMode, ILaunch launch) { - Trace.trace(Trace.FINEST, "JNDI client launched"); - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EEUtil.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EEUtil.java deleted file mode 100644 index 25d7de0f5..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EEUtil.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.server.core.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.server.core.IEnterpriseApplication; -import org.eclipse.jst.server.core.IJ2EEModule; -import org.eclipse.jst.server.core.IWebModule; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.ServerUtil; -/** - * Utility class for dealing with J2EE modules. - */ -public class J2EEUtil { - private static final String EAR_MODULE = "jst.ear"; - private static final String WEB_MODULE = "jst.web"; - - /** - * Returns the enterprise applications that the module is contained within. - * - * @param module a J2EE module - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return a possibly empty array of enterprise applications - */ - public static IModule[] getEnterpriseApplications(IJ2EEModule module, IProgressMonitor monitor) { - List list = new ArrayList(); - IModule[] modules = ServerUtil.getModules(EAR_MODULE); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - IModule module2 = modules[i]; - IEnterpriseApplication ear = (IEnterpriseApplication) module2.loadAdapter(IEnterpriseApplication.class, monitor); - if (ear != null) { - IModule[] modules2 = ear.getModules(); - if (modules2 != null) { - int size2 = modules2.length; - for (int j = 0; j < size2; j++) { - if (module.equals(modules2[j].loadAdapter(IJ2EEModule.class, monitor))) - list.add(module2); - } - } - } - } - } - - IModule[] ears = new IModule[list.size()]; - list.toArray(ears); - return ears; - } - - /** - * Returns the enterprise applications that the module is contained within. - * - * @param module a J2EE module or utility module - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return a possibly empty array of enterprise applications - */ - public static IModule[] getEnterpriseApplications(IModule module, IProgressMonitor monitor) { - List list = new ArrayList(); - IModule[] modules = ServerUtil.getModules(EAR_MODULE); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - IModule module2 = modules[i]; - IEnterpriseApplication ear = (IEnterpriseApplication) module2.loadAdapter(IEnterpriseApplication.class, monitor); - if (ear != null) { - IModule[] modules2 = ear.getModules(); - if (modules2 != null) { - int size2 = modules2.length; - for (int j = 0; j < size2; j++) { - if (module.equals(modules2[j])) - list.add(module2); - } - } - } - } - } - - IModule[] ears = new IModule[list.size()]; - list.toArray(ears); - return ears; - } - - /** - * Returns the web modules that the utility module is contained within. - * - * @param module a utility module - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return a possibly empty array of web modules - */ - public static IModule[] getWebModules(IModule module, IProgressMonitor monitor) { - List list = new ArrayList(); - IModule[] modules = ServerUtil.getModules(WEB_MODULE); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - IModule module2 = modules[i]; - IWebModule web = (IWebModule) module2.loadAdapter(IWebModule.class, monitor); - if (web != null) { - IModule[] modules2 = web.getModules(); - if (modules2 != null) { - int size2 = modules2.length; - for (int j = 0; j < size2; j++) { - if (module.equals(modules2[j])) - list.add(module2); - } - } - } - } - } - - IModule[] webs = new IModule[list.size()]; - list.toArray(webs); - return webs; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JRERuntimeComponentProvider.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JRERuntimeComponentProvider.java deleted file mode 100644 index 4394b4d14..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JRERuntimeComponentProvider.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.jst.server.core.internal; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.IVMInstall2; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.jst.server.core.IJavaRuntime; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion; -import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.internal.Runtime; - -public class JRERuntimeComponentProvider extends RuntimeComponentProviderDelegate { - public static final String CLASSPATH = "classpath"; - - private Map vmCache = new HashMap(); - - class VMInstallCache { - // cached attributes - IVMInstall vmInstall; - String jvmver; - - // caching validation - int timestamp; - File location; - } - - public List getRuntimeComponents(IRuntime runtime) { - // define JRE component - IJavaRuntime javaRuntime = (IJavaRuntime) runtime.loadAdapter(IJavaRuntime.class, null); - if (javaRuntime != null) { - VMInstallCache cache = (VMInstallCache) vmCache.get(runtime.getId()); - if (cache != null) { - if (cache.timestamp != ((Runtime) runtime).getTimestamp()) - cache = null; - if (cache != null && cache.location != null && cache.vmInstall != null && !cache.location.equals(cache.vmInstall.getInstallLocation())) - cache = null; - } - - if (cache == null) { - cache = new VMInstallCache(); - cache.timestamp = ((Runtime) runtime).getTimestamp(); - cache.vmInstall = javaRuntime.getVMInstall(); - - if (cache.vmInstall != null) { - if (cache.vmInstall instanceof IVMInstall2) { - IVMInstall2 vmInstall2 = (IVMInstall2) cache.vmInstall; - if (vmInstall2 != null) - cache.jvmver = vmInstall2.getJavaVersion(); - } - cache.location = cache.vmInstall.getInstallLocation(); - } - vmCache.put(runtime.getId(), cache); - } - - IVMInstall vmInstall = cache.vmInstall; - String jvmver = cache.jvmver; - - String vmInstallName; - if (vmInstall != null) - vmInstallName = vmInstall.getName(); - else - vmInstallName = "Unknown"; - - IRuntimeComponentVersion rcv = null; - if (vmInstall == null) { - // JRE couldn't be found - assume 6.0 for now - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("6.0"); - } else if (jvmver == null) { - Trace.trace(Trace.WARNING, "Could not determine VM version for: " + vmInstallName); - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("6.0"); - } else if (jvmver.startsWith("1.3")) - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("1.3"); - else if (jvmver.startsWith("1.4")) - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("1.4"); - else if (jvmver.startsWith("1.5") || jvmver.startsWith("5.0")) - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("5.0"); - else if (jvmver.startsWith("1.6") || jvmver.startsWith("6.0")) - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("6.0"); - else { - Trace.trace(Trace.WARNING, "Invalid Java version: " + vmInstallName + ", " + jvmver); - rcv = RuntimeManager.getRuntimeComponentType("standard.jre").getVersion("6.0"); - } - - if (rcv != null) { - Map properties = new HashMap(3); - String name = "-"; - if (vmInstallName != null) - name = vmInstallName; - properties.put("name", name); - - StringBuffer buf = new StringBuffer(); - buf.append("JRE "); - buf.append(rcv.getVersionString()); - buf.append(": "); - buf.append(name); - properties.put("type", buf.toString()); - - if (vmInstall == null) { - // no classpath - } else if (vmInstall == null || javaRuntime.isUsingDefaultJRE()) - properties.put(CLASSPATH, new Path(JavaRuntime.JRE_CONTAINER).toPortableString()); - else - properties.put(CLASSPATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString()); - - List list = new ArrayList(); - list.add(RuntimeManager.createRuntimeComponent(rcv, properties)); - return list; - } - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JavaServerPlugin.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JavaServerPlugin.java deleted file mode 100644 index 958de355a..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JavaServerPlugin.java +++ /dev/null @@ -1,366 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.jst.server.core.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.VMRunnerConfiguration; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeLifecycleListener; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; -import org.osgi.framework.BundleContext; -/** - * The main server tooling plugin class. - */ -public class JavaServerPlugin extends Plugin { - /** - * Java server plugin id - */ - public static final String PLUGIN_ID = "org.eclipse.jst.server.core"; - - // singleton instance of this class - private static JavaServerPlugin singleton; - - // cached copy of all runtime classpath providers - private static List runtimeClasspathProviders; - - // cached copy of all server profilers - private static List serverProfilers; - - // runtime listener - private static IRuntimeLifecycleListener runtimeListener; - - /** - * Create the JavaServerPlugin. - */ - public JavaServerPlugin() { - super(); - singleton = this; - } - - /** - * Returns the singleton instance of this plugin. - * - * @return a singleton instance - */ - public static JavaServerPlugin getInstance() { - return singleton; - } - - /** - * @see Plugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - - runtimeListener = new IRuntimeLifecycleListener() { - public void runtimeAdded(IRuntime runtime) { - handleRuntimeChange(runtime, 0); - } - - public void runtimeChanged(IRuntime runtime) { - handleRuntimeChange(runtime, 1); - } - - public void runtimeRemoved(IRuntime runtime) { - handleRuntimeChange(runtime, 2); - } - }; - - ServerCore.addRuntimeLifecycleListener(runtimeListener); - } - - /** - * @see Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context2) throws Exception { - ServerCore.removeRuntimeLifecycleListener(runtimeListener); - super.stop(context2); - } - - /** - * Handle a runtime change by potentially updating the classpath container. - * - * @param runtime a runtime - */ - protected void handleRuntimeChange(final IRuntime runtime, final int act) { - if (runtime == null) - throw new IllegalArgumentException(); - - Trace.trace(Trace.FINEST, "Possible runtime change: " + runtime); - - if (runtime.getRuntimeType() == null) - return; - - final RuntimeClasspathProviderWrapper rcpw = findRuntimeClasspathProvider(runtime.getRuntimeType()); - if (rcpw != null && (rcpw.hasRuntimeClasspathChanged(runtime) || act != 1)) { - final IPath serverContainerPath = new Path(RuntimeClasspathContainer.SERVER_CONTAINER) - .append(rcpw.getId()).append(runtime.getId()); - - class RebuildRuntimeReferencesJob extends Job { - public RebuildRuntimeReferencesJob() { - super(NLS.bind(Messages.updateClasspathContainers, runtime.getName())); - } - - public boolean belongsTo(Object family) { - return ServerUtil.SERVER_JOB_FAMILY.equals(family); - } - - public IStatus run(IProgressMonitor monitor) { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - if (projects != null) { - int size = projects.length; - for (int i = 0; i < size; i++) { - if (projects[i].isAccessible()) { - try { - if (!projects[i].isNatureEnabled(JavaCore.NATURE_ID)) - continue; - - IJavaProject javaProject = JavaCore.create(projects[i]); - - boolean found = false; - IClasspathEntry[] ce = javaProject.getRawClasspath(); - for (int j = 0; j < ce.length; j++) { - if (ce[j].getEntryKind() == IClasspathEntry.CPE_CONTAINER) { - if (serverContainerPath.isPrefixOf(ce[j].getPath())) - found = true; - } - } - - Trace.trace(Trace.FINEST, "Classpath change on: " + projects[i] + " " + found); - - if (found) { - IRuntime runtime2 = runtime; - if (act == 2) - runtime2 = null; - RuntimeClasspathContainer container = new RuntimeClasspathContainer(projects[i], - serverContainerPath, rcpw, runtime2, runtime.getId()); - JavaCore.setClasspathContainer(serverContainerPath, new IJavaProject[] { javaProject }, - new IClasspathContainer[] {container}, null); - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not update classpath container", e); - } - } - } - } - - return Status.OK_STATUS; - } - } - RebuildRuntimeReferencesJob job = new RebuildRuntimeReferencesJob(); - job.schedule(); - } - } - - /** - * Convenience method for logging. - * - * @param status a status - */ - private static void log(IStatus status) { - getInstance().getLog().log(status); - } - - public static void logWarning(String msg) { - log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.OK, msg, null)); - } - - /** - * Returns an array of all known runtime classpath provider instances. - * <p> - * A new array is returned on each call, so clients may store or modify the - * result. - * </p> - * - * @return a possibly-empty array of runtime classpath provider instances - * {@link RuntimeClasspathProviderWrapper} - */ - public static RuntimeClasspathProviderWrapper[] getRuntimeClasspathProviders() { - if (runtimeClasspathProviders == null) - loadRuntimeClasspathProviders(); - - RuntimeClasspathProviderWrapper[] rth = new RuntimeClasspathProviderWrapper[runtimeClasspathProviders.size()]; - runtimeClasspathProviders.toArray(rth); - return rth; - } - - /** - * Returns the runtime classpath provider that supports the given runtime type, or <code>null</code> - * if none. This convenience method searches the list of known runtime - * classpath providers ({@link #getRuntimeClasspathProviders()}) for the one with - * a matching runtime type. - * The runtimeType may not be null. - * - * @param runtimeType a runtime type - * @return the runtime classpath provider instance, or <code>null</code> if - * there is no runtime classpath provider that supports the given id - */ - public static RuntimeClasspathProviderWrapper findRuntimeClasspathProvider(IRuntimeType runtimeType) { - if (runtimeType == null) - throw new IllegalArgumentException(); - - if (runtimeClasspathProviders == null) - loadRuntimeClasspathProviders(); - - Iterator iterator = runtimeClasspathProviders.iterator(); - while (iterator.hasNext()) { - RuntimeClasspathProviderWrapper runtimeClasspathProvider = (RuntimeClasspathProviderWrapper) iterator.next(); - if (runtimeClasspathProvider.supportsRuntimeType(runtimeType)) - return runtimeClasspathProvider; - } - return null; - } - - /** - * Returns the runtime classpath provider that supports the given runtime type id, - * or <code>null</code> if none. This convenience method searches the list of known - * runtime classpath providers ({@link #getRuntimeClasspathProviders()}) for the one - * with a matching runtime type id. The id may not be null. - * - * @param id a runtime type id - * @return the runtime classpath provider instance, or <code>null</code> if - * there is no runtime classpath provider that supports the given id - */ - public static RuntimeClasspathProviderWrapper findRuntimeClasspathProviderBySupport(String id) { - if (id == null) - throw new IllegalArgumentException(); - - if (runtimeClasspathProviders == null) - loadRuntimeClasspathProviders(); - - Iterator iterator = runtimeClasspathProviders.iterator(); - while (iterator.hasNext()) { - RuntimeClasspathProviderWrapper runtimeClasspathProvider = (RuntimeClasspathProviderWrapper) iterator.next(); - if (runtimeClasspathProvider.supportsRuntimeType(id)) - return runtimeClasspathProvider; - } - return null; - } - - /** - * Returns the runtime classpath provider with the given id, or <code>null</code> - * if none. This convenience method searches the list of known runtime - * classpath providers ({@link #getRuntimeClasspathProviders()}) for the one with - * a matching runtime classpath provider id ({@link RuntimeClasspathProviderWrapper#getId()}). - * The id may not be null. - * - * @param id the runtime classpath provider id - * @return the runtime classpath provider instance, or <code>null</code> if - * there is no runtime classpath provider with the given id - */ - public static RuntimeClasspathProviderWrapper findRuntimeClasspathProvider(String id) { - if (id == null) - throw new IllegalArgumentException(); - - if (runtimeClasspathProviders == null) - loadRuntimeClasspathProviders(); - - Iterator iterator = runtimeClasspathProviders.iterator(); - while (iterator.hasNext()) { - RuntimeClasspathProviderWrapper runtimeClasspathProvider = (RuntimeClasspathProviderWrapper) iterator.next(); - if (id.equals(runtimeClasspathProvider.getId())) - return runtimeClasspathProvider; - } - return null; - } - - /** - * Load the runtime classpath providers. - */ - private static synchronized void loadRuntimeClasspathProviders() { - if (runtimeClasspathProviders != null) - return; - Trace.trace(Trace.CONFIG, "->- Loading .runtimeClasspathProviders extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(JavaServerPlugin.PLUGIN_ID, "runtimeClasspathProviders"); - - int size = cf.length; - List list = new ArrayList(size); - for (int i = 0; i < size; i++) { - try { - list.add(new RuntimeClasspathProviderWrapper(cf[i])); - Trace.trace(Trace.CONFIG, " Loaded runtimeClasspathProviders: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load runtimeClasspathProviders: " + cf[i].getAttribute("id"), t); - } - } - runtimeClasspathProviders = list; - - Trace.trace(Trace.CONFIG, "-<- Done loading .runtimeClasspathProviders extension point -<-"); - } - - /** - * Returns an array of all known server profiler instances. - * <p> - * A new array is returned on each call, so clients may store or modify the result. - * </p> - * - * @return a possibly-empty array of server profiler instances - * {@link ServerProfiler} - */ - public static ServerProfiler[] getServerProfilers() { - if (serverProfilers == null) - loadServerProfilers(); - - ServerProfiler[] sp = new ServerProfiler[serverProfilers.size()]; - serverProfilers.toArray(sp); - return sp; - } - - /** - * Load the server profilers. - */ - private static synchronized void loadServerProfilers() { - if (serverProfilers != null) - return; - Trace.trace(Trace.CONFIG, "->- Loading .serverProfilers extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(JavaServerPlugin.PLUGIN_ID, "serverProfilers"); - - int size = cf.length; - List list = new ArrayList(size); - for (int i = 0; i < size; i++) { - try { - list.add(new ServerProfiler(cf[i])); - Trace.trace(Trace.CONFIG, " Loaded serverProfiler: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load serverProfiler: " + cf[i].getAttribute("id"), t); - } - } - serverProfilers = list; - - Trace.trace(Trace.CONFIG, "-<- Done loading .serverProfilers extension point -<-"); - } - - public static void configureProfiling(ILaunch launch, IVMInstall vmInstall, VMRunnerConfiguration vmConfig, IProgressMonitor monitor) throws CoreException { - ServerProfiler[] sp = JavaServerPlugin.getServerProfilers(); - if (sp == null || sp.length == 0) - throw new CoreException(new Status(IStatus.ERROR, JavaServerPlugin.PLUGIN_ID, 0, Messages.errorNoProfiler, null)); - - sp[0].process(launch, vmInstall, vmConfig, monitor); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/LaunchConfigurationUtil.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/LaunchConfigurationUtil.java deleted file mode 100644 index 6b94bbef2..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/LaunchConfigurationUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.server.core.internal; -/** - * - */ -public class LaunchConfigurationUtil { - /** - * Gets the classpath from the launch configuration of the given server. - * If create is false, it will return null if there is no launch configuration - * (i.e. the server has not been run before) If create is true, it will create - * a launch configuration if one does not exist. - * - * @param server - * @param create - * @param monitor a progress monitor - * @return an array containing runtime classpath entries - * @throws CoreException - */ - /*public static IRuntimeClasspathEntry[] getClasspath(IServer server, boolean create, IProgressMonitor monitor) throws CoreException { - ILaunchConfiguration config = server.getLaunchConfiguration(create, monitor); - if (config == null) - return null; - - return JavaRuntime.computeUnresolvedRuntimeClasspath(config); - }*/ - - /** - * Sets the classpath on the given server's launch configuration. - * - * @param server - * @param classpath - * @throws CoreException - */ - /*public static void setClasspath(IServer server, IRuntimeClasspathEntry[] classpath, IProgressMonitor monitor) throws CoreException { - ILaunchConfiguration config = server.getLaunchConfiguration(true, monitor); - ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false); - - List mementos = new ArrayList(classpath.length); - for (int i = 0; i < classpath.length; i++) { - IRuntimeClasspathEntry entry = classpath[i]; - mementos.add(entry.getMemento()); - } - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, mementos); - wc.doSave(); - }*/ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java deleted file mode 100644 index 0bfeeeb23..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.jst.server.core.internal; - -import org.eclipse.osgi.util.NLS; -/** - * Translated messages. - */ -public class Messages extends NLS { - public static String errorLocation; - public static String errorJRE; - public static String classpathContainerDescription; - public static String classpathContainer; - public static String classpathContainerUnbound; - - public static String copyingTask; - public static String deletingTask; - public static String errorCopyingFile; - public static String errorCreatingZipFile; - public static String errorDelete; - public static String errorRename; - public static String errorReading; - public static String updateClasspathContainers; - public static String errorNoRuntime; - public static String errorFacet; - public static String errorDeleting; - public static String errorNotADirectory; - public static String errorMkdir; - - public static String artifactServlet; - public static String artifactEJB; - public static String artifactJNDI; - public static String artifactCactusTest; - - public static String canModifyModules; - public static String errorNoProfiler; - public static String errorPublish; - public static String httpPort; - public static String errorPortInUse; - - static { - NLS.initializeMessages(JavaServerPlugin.PLUGIN_ID + ".internal.Messages", Messages.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties deleted file mode 100644 index 76c6ce48b..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################### -# Copyright (c) 2004, 2007 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 -############################################################################### - -classpathContainerDescription=Server Library -classpathContainer={0} [{1}] -classpathContainerUnbound={0} [{1}] (unbound) - -errorLocation=Invalid location. -errorJRE=Invalid JRE. - -copyingTask=Copying from {0} to {1} -deletingTask=Deleting {0} -errorCopyingFile=Error copying file {0}: {1} -errorCreatingZipFile=Error creating zip file {0}: {1} -errorDelete=Could not delete previous copy, which may be locked by another process. -errorRename=Could not replace with temp file {0}. -errorReading=Error reading file {0} -errorNoRuntime=Cannot verify facets because there is no runtime associated with the server. -errorFacet=Project facet {0} version {1} is not supported. -errorDeleting=Could not delete {0}. May be locked by another process. -errorNotADirectory=Could not delete {0} since it is not a directory. -errorMkdir=Could not create directory {0}. - -updateClasspathContainers=Updating classpath container for {0} - -artifactServlet=Servlet {0} -artifactEJB=EJB {0} -artifactJNDI=JNDI {0} -artifactCactusTest=Cactus test {0} - -canModifyModules=Web module can be added to the server. -errorNoProfiler=Could not launch in profiling mode because no profilers are configured. -errorPublish=An error occured during publishing. -httpPort=HTTP Port -errorPortInUse=Port {0} required by {1} is already in use. The server may already be running in another process, or a system process may be using the port. \ - To start this server you will need to stop the other process or change the port number(s).
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProgressUtil.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProgressUtil.java deleted file mode 100644 index 55bbe1c03..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProgressUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.server.core.internal; - -import org.eclipse.core.runtime.*; -/** - * Progress Monitor utility. - */ -public class ProgressUtil { - /** - * ProgressUtil constructor comment. - */ - private ProgressUtil() { - super(); - } - - /** - * Return a valid progress monitor. - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @return org.eclipse.core.runtime.IProgressMonitor - */ - public static IProgressMonitor getMonitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - return monitor; - } - - /** - * Return a sub-progress monitor with the given amount on the - * current progress monitor. - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @param ticks int - * @return org.eclipse.core.runtime.IProgressMonitor - */ - public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks); - } - - /** - * Return a sub-progress monitor with the given amount on the - * current progress monitor. - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @param ticks a number of ticks - * @param style a style - * @return org.eclipse.core.runtime.IProgressMonitor - */ - public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks, int style) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks, style); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java deleted file mode 100644 index 1e409b755..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.jst.server.core.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.osgi.util.NLS; - -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -/** - * - */ -public class RuntimeClasspathContainer implements IClasspathContainer { - /** - * The server container id. - */ - public static final String SERVER_CONTAINER = JavaServerPlugin.PLUGIN_ID + ".container"; - - private IPath path; - private RuntimeClasspathProviderWrapper delegate; - private IRuntime runtime; - private String runtimeId; - private IProject project; - - /** - * Create a new runtime classpath container. - * - * @param path - * @param delegate - * @param runtime - * @deprecated should use the constructor that accepts a project - */ - public RuntimeClasspathContainer(IPath path, RuntimeClasspathProviderWrapper delegate, IRuntime runtime) { - this.path = path; - this.delegate = delegate; - this.runtime = runtime; - } - - /** - * Create a new runtime classpath container. - * - * @param project - * @param path - * @param delegate - * @param runtime - * @param runtimeId - */ - public RuntimeClasspathContainer(IProject project, IPath path, RuntimeClasspathProviderWrapper delegate, IRuntime runtime, String runtimeId) { - this.project = project; - this.path = path; - this.delegate = delegate; - this.runtime = runtime; - this.runtimeId = runtimeId; - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries() - */ - public IClasspathEntry[] getClasspathEntries() { - IClasspathEntry[] entries = null; - if (delegate != null && runtime != null) - entries = delegate.resolveClasspathContainerImpl(project, runtime); - - if (entries == null) - return new IClasspathEntry[0]; - - return entries; - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getDescription() - */ - public String getDescription() { - if (runtime != null) { - IRuntimeType runtimeType = runtime.getRuntimeType(); - if (runtimeType != null) - return NLS.bind(Messages.classpathContainer, runtimeType.getName(), runtime.getName()); - } - return NLS.bind(Messages.classpathContainerUnbound, Messages.classpathContainerDescription, runtimeId); - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getKind() - */ - public int getKind() { - return IClasspathContainer.K_APPLICATION; - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getPath() - */ - public IPath getPath() { - return path; - } - - public boolean equals(Object obj) { - if (!(obj instanceof RuntimeClasspathContainer)) - return false; - - RuntimeClasspathContainer rcc = (RuntimeClasspathContainer) obj; - if (delegate != null && !delegate.equals(rcc.delegate)) - return false; - - if (runtime == null && rcc.runtime != null) - return false; - - if (runtime != null && !runtime.equals(rcc.runtime)) - return false; - - if (runtimeId != null && !runtimeId.equals(rcc.runtimeId)) - return false; - - if (project == null && rcc.project != null) - return false; - - if (project != null && !project.equals(rcc.project)) - return false; - - if (path != null && !path.equals(rcc.path)) - return false; - - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java deleted file mode 100644 index abf5bcb3e..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.jst.server.core.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jdt.core.*; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; -/** - * - */ -public class RuntimeClasspathContainerInitializer extends ClasspathContainerInitializer { - /** (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public void initialize(IPath containerPath, IJavaProject project) throws CoreException { - if (containerPath.segmentCount() > 0) { - if (containerPath.segment(0).equals(RuntimeClasspathContainer.SERVER_CONTAINER)) { - RuntimeClasspathProviderWrapper delegate = null; - IRuntime runtime = null; - String runtimeId = null; - if (containerPath.segmentCount() > 2) { - delegate = JavaServerPlugin.findRuntimeClasspathProvider(containerPath.segment(1)); - - runtimeId = containerPath.segment(2); - if (runtimeId != null) - runtime = ServerCore.findRuntime(runtimeId); - } - RuntimeClasspathContainer container = new RuntimeClasspathContainer(project.getProject(), containerPath, delegate, runtime, runtimeId); - JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project}, new IClasspathContainer[] {container}, null); - } - } - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public String getDescription(IPath containerPath, IJavaProject project) { - return Messages.classpathContainerDescription; - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { - return true; - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathContainer) - */ - public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { - if (containerPath.segmentCount() > 0) { - if (containerPath.segment(0).equals(RuntimeClasspathContainer.SERVER_CONTAINER)) { - RuntimeClasspathProviderWrapper delegate = null; - IRuntime runtime = null; - if (containerPath.segmentCount() > 2) { - delegate = JavaServerPlugin.findRuntimeClasspathProvider(containerPath.segment(1)); - String runtimeId = containerPath.segment(2); - if (runtimeId != null) - runtime = ServerCore.findRuntime(runtimeId); - delegate.requestClasspathContainerUpdate(runtime, containerSuggestion.getClasspathEntries()); - //JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, - // new IClasspathContainer[] { containerSuggestion }, new NullProgressMonitor()); - updateClasspath(runtime, containerPath, containerSuggestion); - } - } - } - } - - public static void updateClasspath(final IRuntime runtime, final IPath containerPath, final IClasspathContainer containerSuggestion) { - class UpdateClasspathJob extends Job { - public UpdateClasspathJob() { - super(NLS.bind(Messages.updateClasspathContainers, runtime.getName())); - } - - public boolean belongsTo(Object family) { - return ServerUtil.SERVER_JOB_FAMILY.equals(family); - } - - public IStatus run(IProgressMonitor monitor) { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - List list = new ArrayList(); - if (projects != null) { - int size = projects.length; - for (int i = 0; i < size; i++) { - if (projects[i].isAccessible()) { - try { - if (!projects[i].isNatureEnabled(JavaCore.NATURE_ID)) - continue; - - IJavaProject javaProject = JavaCore.create(projects[i]); - - boolean found = false; - IClasspathEntry[] ce = javaProject.getRawClasspath(); - for (int j = 0; j < ce.length; j++) { - if (ce[j].getEntryKind() == IClasspathEntry.CPE_CONTAINER) { - if (containerPath.isPrefixOf(ce[j].getPath())) - found = true; - } - } - - Trace.trace(Trace.FINEST, "Classpath change on: " + projects[i] + " " + found); - - if (found) - list.add(javaProject); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not update classpath container", e); - } - } - } - } - - int size = list.size(); - if (size > 0) { - IJavaProject[] javaProjects = new IJavaProject[size]; - list.toArray(javaProjects); - IClasspathContainer[] containers = new IClasspathContainer[size]; - for (int i = 0; i < size; i++) - containers[i] = containerSuggestion; - - try { - JavaCore.setClasspathContainer(containerPath, javaProjects, containers, monitor); - } catch (JavaModelException jme) { - return jme.getStatus(); - } - } - - return Status.OK_STATUS; - } - } - UpdateClasspathJob job = new UpdateClasspathJob(); - job.schedule(); - } - - /** (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public Object getComparisonID(IPath containerPath, IJavaProject project) { - if (containerPath == null) - return null; - - return containerPath.toPortableString(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProvider.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProvider.java deleted file mode 100644 index 86aafe98f..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2007 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - * IBM Corporation - Support for all server types - ******************************************************************************/ -package org.eclipse.jst.server.core.internal; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.common.project.facet.core.IClasspathProvider; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent; -/** - * - */ -public class RuntimeClasspathProvider implements IClasspathProvider { - private static final IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet("jst.web"); - private static final IProjectFacet EJB_FACET = ProjectFacetsManager.getProjectFacet("jst.ejb"); - private static final IProjectFacet EAR_FACET = ProjectFacetsManager.getProjectFacet("jst.ear"); - private static final IProjectFacet UTILITY_FACET = ProjectFacetsManager.getProjectFacet("jst.utility"); - private static final IProjectFacet CONNECTOR_FACET = ProjectFacetsManager.getProjectFacet("jst.connector"); - private static final IProjectFacet APP_CLIENT_FACET = ProjectFacetsManager.getProjectFacet("jst.appclient"); - - private IRuntimeComponent rc; - - public RuntimeClasspathProvider(IRuntimeComponent rc) { - this.rc = rc; - } - - public List getClasspathEntries(IProjectFacetVersion fv) { - IProjectFacet pf = fv.getProjectFacet(); - if (pf == null) - return null; - - if (pf.equals(WEB_FACET) || pf.equals(EJB_FACET) || pf.equals(EAR_FACET) || - pf.equals(UTILITY_FACET) || pf.equals(CONNECTOR_FACET) || pf.equals(APP_CLIENT_FACET)) { - String runtimeTypeId = rc.getProperty("type-id"); - String runtimeId = rc.getProperty("id"); - if (runtimeTypeId == null || runtimeId == null) - return null; - RuntimeClasspathProviderWrapper rcpw = JavaServerPlugin.findRuntimeClasspathProviderBySupport(runtimeTypeId); - if (rcpw != null) { - IPath path = new Path(RuntimeClasspathContainer.SERVER_CONTAINER); - path = path.append(rcpw.getId()).append(runtimeId); - IClasspathEntry cpentry = JavaCore.newContainerEntry(path); - return Collections.singletonList(cpentry); - } - } - - return null; - } - - public static final class Factory implements IAdapterFactory { - private static final Class[] ADAPTER_TYPES = { IClasspathProvider.class }; - - public Object getAdapter(Object adaptable, Class adapterType) { - IRuntimeComponent rc = (IRuntimeComponent) adaptable; - return new RuntimeClasspathProvider(rc); - } - - public Class[] getAdapterList() { - return ADAPTER_TYPES; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProviderWrapper.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProviderWrapper.java deleted file mode 100644 index 40f78b979..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProviderWrapper.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.jst.server.core.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate; -import org.eclipse.wst.server.core.*; -/** - * - */ -public class RuntimeClasspathProviderWrapper { - private IConfigurationElement element; - private RuntimeClasspathProviderDelegate delegate; - - /** - * Create a new runtime target handler. - * - * @param element a configuration element - */ - public RuntimeClasspathProviderWrapper(IConfigurationElement element) { - super(); - this.element = element; - } - - protected IConfigurationElement getElement() { - return element; - } - - /** - * - * @return the id - */ - public String getId() { - return element.getAttribute("id"); - } - - /** - * Returns the order. - * - * @return the order - */ - public int getOrder() { - try { - String o = element.getAttribute("order"); - return Integer.parseInt(o); - } catch (NumberFormatException e) { - return -1; - } - } - - public String[] getRuntimeTypeIds() { - try { - List list = new ArrayList(); - StringTokenizer st = new StringTokenizer(element.getAttribute("runtimeTypeIds"), ","); - while (st.hasMoreTokens()) { - String str = st.nextToken(); - if (str != null && str.length() > 0) - list.add(str.trim()); - } - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not parse runtime type ids: " + element); - return null; - } - } - - /** - * Returns true if the given server resource type (given by the - * id) can be opened with this editor. This result is based on - * the result of the getServerResources() method. - * - * @param runtimeType a runtime type - * @return boolean - */ - public boolean supportsRuntimeType(IRuntimeType runtimeType) { - if (runtimeType == null) - return false; - return supportsRuntimeType(runtimeType.getId()); - } - - /** - * Returns true if the given server resource type (given by the - * id) can be opened with this editor. This result is based on - * the result of the getServerResources() method. - * - * @param id a runtime type id - * @return boolean - */ - public boolean supportsRuntimeType(String id) { - if (id == null || id.length() == 0) - return false; - - String[] s = getRuntimeTypeIds(); - if (s == null) - return false; - - int size = s.length; - for (int i = 0; i < size; i++) { - if (s[i].endsWith("*")) { - if (id.length() >= s[i].length() && id.startsWith(s[i].substring(0, s[i].length() - 1))) - return true; - } else if (id.equals(s[i])) - return true; - } - return false; - } - - /* - * Loads the delegate class. - */ - public RuntimeClasspathProviderDelegate getDelegate() { - if (delegate == null) { - try { - delegate = (RuntimeClasspathProviderDelegate) element.createExecutableExtension("class"); - delegate.initialize(getId()); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create delegate " + toString() + ": " + t.getMessage()); - } - } - return delegate; - } - - /* - * @see RuntimeClasspathProviderDelegate#resolveClasspathContainerImpl(IProject, IRuntime) - */ - public IClasspathEntry[] resolveClasspathContainerImpl(IProject project, IRuntime runtime) { - if (runtime == null) - return null; - try { - return getDelegate().resolveClasspathContainerImpl(project, runtime); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate " + toString() + ": " + e.getMessage()); - } - return null; - } - - /* - * @see RuntimeClasspathProviderDelegate#requestClasspathContainerUpdate(IRuntime, IClasspathEntry[]) - */ - public void requestClasspathContainerUpdate(IRuntime runtime, IClasspathEntry[] entries) { - if (runtime == null) - return; - try { - getDelegate().requestClasspathContainerUpdate(runtime, entries); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate " + toString() + ": " + e.getMessage()); - } - } - - /* - * @see RuntimeClasspathProviderDelegate#hasRuntimeClasspathChanged(IRuntime) - */ - public boolean hasRuntimeClasspathChanged(IRuntime runtime) { - if (runtime == null) - return false; - try { - return getDelegate().hasRuntimeClasspathChanged(runtime); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate " + toString() + ": " + e.getMessage()); - } - return false; - } - - public String toString() { - return "RuntimeClasspathProviderWrapper[" + getId() + "]"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderDelegate.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderDelegate.java deleted file mode 100644 index 968e4dd46..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderDelegate.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.jst.server.core.internal; - -import org.eclipse.wst.server.core.internal.facets.RuntimeFacetComponentProviderDelegate; -/** - * A runtime component provider can provide additional runtime components for a facet runtime. - * This provider is scoped by runtime type and may provide components for multiple - * runtime instances. - * <p> - * This abstract class is intended to be extended only by clients - * to extend the <code>internalRuntimeComponentProviders</code> extension point. - * </p> - * <p> - * <b>Provisional API:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - * @plannedfor 2.0 - */ -public abstract class RuntimeComponentProviderDelegate extends RuntimeFacetComponentProviderDelegate { - // nothing added -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderWrapper.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderWrapper.java deleted file mode 100644 index dc10d0533..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderWrapper.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 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.jst.server.core.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -/** - * - */ -public class RuntimeComponentProviderWrapper { - private IConfigurationElement element; - private RuntimeComponentProviderDelegate delegate; - - /** - * Create a new runtime component handler. - * - * @param element a configuration element - */ - public RuntimeComponentProviderWrapper(IConfigurationElement element) { - super(); - this.element = element; - } - - protected IConfigurationElement getElement() { - return element; - } - - /** - * - * @return the id - */ - public String getId() { - return element.getAttribute("id"); - } - - public String[] getRuntimeTypeIds() { - try { - List list = new ArrayList(); - StringTokenizer st = new StringTokenizer(element.getAttribute("runtimeTypeIds"), ","); - while (st.hasMoreTokens()) { - String str = st.nextToken(); - if (str != null && str.length() > 0) - list.add(str.trim()); - } - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not parse runtime type ids: " + element); - return null; - } - } - - /** - * Returns true if the given server resource type (given by the - * id) can be opened with this editor. This result is based on - * the result of the getServerResources() method. - * - * @param runtimeType a runtime type - * @return boolean - */ - public boolean supportsRuntimeType(IRuntimeType runtimeType) { - if (runtimeType == null) - return false; - String id = runtimeType.getId(); - if (id == null || id.length() == 0) - return false; - - String[] s = getRuntimeTypeIds(); - if (s == null) - return false; - - int size = s.length; - for (int i = 0; i < size; i++) { - if (s[i].endsWith("*")) { - if (id.length() >= s[i].length() && id.startsWith(s[i].substring(0, s[i].length() - 1))) - return true; - } else if (id.equals(s[i])) - return true; - } - return false; - } - - /* - * Loads the delegate class. - */ - protected RuntimeComponentProviderDelegate getDelegate() { - if (delegate == null) { - try { - delegate = (RuntimeComponentProviderDelegate) element.createExecutableExtension("class"); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create delegate " + toString() + ": " + t.getMessage()); - } - } - return delegate; - } - - /* - * @see RuntimeFacetComponentProviderDelegate#getRuntimeComponents(IRuntime) - */ - public List getComponents(IRuntime runtime) { - if (runtime == null) - return null; - try { - return getDelegate().getRuntimeComponents(runtime); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate " + toString() + ": " + e.getMessage()); - } - return null; - } - - public String toString() { - return "RuntimeComponentProviderWrapper[" + getId() + "]"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeFacetMapping.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeFacetMapping.java deleted file mode 100644 index ea829a8a7..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeFacetMapping.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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.jst.server.core.internal; - -import org.eclipse.core.runtime.IConfigurationElement; -/** - * - */ -public class RuntimeFacetMapping { - private IConfigurationElement element; - - /** - * Create a new runtime facet mapping. - * - * @param element a configuration element - */ - public RuntimeFacetMapping(IConfigurationElement element) { - super(); - this.element = element; - } - - /** - * - * @return the id - */ - public String getId() { - return element.getAttribute("id"); - } - - /** - * - * @return the id - */ - public String getRuntimeTypeId() { - return element.getAttribute("runtimeTypeId"); - } - - /** - * - * @return the id - */ - public String getVersion() { - return element.getAttribute("version"); - } - - /** - * - * @return the id - */ - public String getRuntimeComponent() { - return element.getAttribute("runtime-component"); - } - - public String toString() { - return "RuntimeFacetMapping[" + getId() + "]"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ServerProfiler.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ServerProfiler.java deleted file mode 100644 index e9f1ecccd..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ServerProfiler.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.jst.server.core.internal; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.VMRunnerConfiguration; -import org.eclipse.jst.server.core.ServerProfilerDelegate; -/** - * - */ -public class ServerProfiler { - private IConfigurationElement element; - private ServerProfilerDelegate delegate; - - /** - * Create a new server profiler. - * - * @param element a configuration element - */ - public ServerProfiler(IConfigurationElement element) { - super(); - this.element = element; - } - - /** - * - * @return the id - */ - public String getId() { - return element.getAttribute("id"); - } - - /** - * - * @return the name - */ - public String getName() { - return element.getAttribute("name"); - } - - /* - * Loads the delegate class. - */ - protected ServerProfilerDelegate getDelegate() { - if (delegate == null) { - if (element.getAttribute("class") == null) - return null; - try { - delegate = (ServerProfilerDelegate) element.createExecutableExtension("class"); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create delegate " + toString() + ": " + t.getMessage()); - } - } - return delegate; - } - - /** - * @deprecated Switch to new API via TODO - * @return the VM args - */ - public String getVMArgs() { - return null; - } - - public void process(ILaunch launch, IVMInstall vmInstall, VMRunnerConfiguration vmConfig, IProgressMonitor monitor) { - try { - ServerProfilerDelegate del = getDelegate(); - if (del != null) - del.process(launch, vmInstall, vmConfig, monitor); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create delegate " + toString() + ": " + t.getMessage()); - } - } - - public String toString() { - return "ServerProfiler[" + getId() + "]"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/StandardJreClasspathProvider.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/StandardJreClasspathProvider.java deleted file mode 100644 index adb515608..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/StandardJreClasspathProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - * IBM Corporation - Cleanup - ******************************************************************************/ -package org.eclipse.jst.server.core.internal; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.common.project.facet.core.IClasspathProvider; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent; -/** - * - */ -public final class StandardJreClasspathProvider implements IClasspathProvider { - private static final IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet("jst.java"); - - private IRuntimeComponent rc; - - public StandardJreClasspathProvider(IRuntimeComponent rc) { - this.rc = rc; - } - - public List getClasspathEntries(IProjectFacetVersion fv) { - if (fv.getProjectFacet() == JAVA_FACET) { - String s = rc.getProperty(JRERuntimeComponentProvider.CLASSPATH); - if (s == null || s.length() == 0) - return null; - - IClasspathEntry cpentry = JavaCore.newContainerEntry(new Path(s)); - return Collections.singletonList(cpentry); - } - - return null; - } - - public static final class Factory implements IAdapterFactory { - private static final Class[] ADAPTER_TYPES = { IClasspathProvider.class }; - - public Object getAdapter(Object adaptable, Class adapterType) { - IRuntimeComponent rc = (IRuntimeComponent) adaptable; - return new StandardJreClasspathProvider(rc); - } - - public Class[] getAdapterList() { - return ADAPTER_TYPES; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Trace.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Trace.java deleted file mode 100644 index 224c64d9d..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Trace.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.jst.server.core.internal; -/** - * Helper class to route trace output. - */ -public class Trace { - /** - * Config tracing - */ - public static final byte CONFIG = 0; - /** - * Warning tracing - */ - public static final byte WARNING = 1; - /** - * Severe tracing - */ - public static final byte SEVERE = 2; - /** - * Finest tracing - */ - public static final byte FINEST = 3; - - public static final byte PUBLISHING = 4; - - /** - * Trace constructor comment. - */ - private Trace() { - super(); - } - - /** - * Trace the given text. - * - * @param level trace level - * @param s String - */ - public static void trace(byte level, String s) { - Trace.trace(level, s, null); - } - - /** - * Trace the given message and exception. - * - * @param level trace level - * @param s String - * @param t Throwable - */ - public static void trace(byte level, String s, Throwable t) { - if (!JavaServerPlugin.getInstance().isDebugging()) - return; - - System.out.println(JavaServerPlugin.PLUGIN_ID + " " + s); - if (t != null) - t.printStackTrace(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/XMLMemento.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/XMLMemento.java deleted file mode 100644 index 35110972a..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/XMLMemento.java +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.jst.server.core.internal; - -import java.io.*; -import java.util.*; - -import org.w3c.dom.*; -import org.xml.sax.*; - -import javax.xml.parsers.*; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -/** - * A Memento is a class independent container for persistence - * info. It is a reflection of 3 storage requirements. - * - * 1) We need the ability to persist an object and restore it. - * 2) The class for an object may be absent. If so we would - * like to skip the object and keep reading. - * 3) The class for an object may change. If so the new class - * should be able to read the old persistence info. - * - * We could ask the objects to serialize themselves into an - * ObjectOutputStream, DataOutputStream, or Hashtable. However - * all of these approaches fail to meet the second requirement. - * - * Memento supports binary persistance with a version ID. - */ -public final class XMLMemento implements IMemento { - private Document factory; - private Element element; - - /** - * Answer a memento for the document and element. For simplicity - * you should use createReadRoot and createWriteRoot to create the initial - * mementos on a document. - */ - private XMLMemento(Document doc, Element el) { - factory = doc; - element = el; - } - - /** - * @see IMemento#createChild(String) - */ - public IMemento createChild(String type) { - Element child = factory.createElement(type); - element.appendChild(child); - return new XMLMemento(factory, child); - } - - /** - * @see IMemento#createChild(String, String) - */ - public IMemento createChild(String type, String id) { - Element child = factory.createElement(type); - child.setAttribute(TAG_ID, id); - element.appendChild(child); - return new XMLMemento(factory, child); - } - - /** - * Create a Document from a Reader and answer a root memento for reading - * a document. - */ - protected static XMLMemento createReadRoot(InputStream in) { - Document document = null; - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder parser = factory.newDocumentBuilder(); - document = parser.parse(new InputSource(in)); - Node node = document.getFirstChild(); - if (node instanceof Element) - return new XMLMemento(document, (Element) node); - } catch (Exception e) { - // ignore - } finally { - try { - in.close(); - } catch (Exception e) { - // ignore - } - } - return null; - } - - /** - * Answer a root memento for writing a document. - * - * @param type a type - * @return a memento - */ - public static XMLMemento createWriteRoot(String type) { - Document document; - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - Element element = document.createElement(type); - document.appendChild(element); - return new XMLMemento(document, element); - } catch (ParserConfigurationException e) { - throw new Error(e); - } - } - - /* - * @see IMemento - */ - public IMemento getChild(String type) { - // Get the nodes. - NodeList nodes = element.getChildNodes(); - int size = nodes.getLength(); - if (size == 0) - return null; - - // Find the first node which is a child of this node. - for (int nX = 0; nX < size; nX ++) { - Node node = nodes.item(nX); - if (node instanceof Element) { - Element element2 = (Element)node; - if (element2.getNodeName().equals(type)) - return new XMLMemento(factory, element2); - } - } - - // A child was not found. - return null; - } - - /* - * @see IMemento - */ - public IMemento [] getChildren(String type) { - // Get the nodes. - NodeList nodes = element.getChildNodes(); - int size = nodes.getLength(); - if (size == 0) - return new IMemento[0]; - - // Extract each node with given type. - ArrayList list = new ArrayList(size); - for (int nX = 0; nX < size; nX ++) { - Node node = nodes.item(nX); - if (node instanceof Element) { - Element element2 = (Element)node; - if (element2.getNodeName().equals(type)) - list.add(element2); - } - } - - // Create a memento for each node. - size = list.size(); - IMemento [] results = new IMemento[size]; - for (int x = 0; x < size; x ++) { - results[x] = new XMLMemento(factory, (Element)list.get(x)); - } - return results; - } - - /** - * Return the contents of this memento as a byte array. - * - * @return byte[] - * @throws IOException if anything goes wrong - */ - public byte[] getContents() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - save(out); - return out.toByteArray(); - } - - /** - * Returns an input stream for writing to the disk with a local locale. - * - * @return java.io.InputStream - * @throws IOException if anything goes wrong - */ - public InputStream getInputStream() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - save(out); - return new ByteArrayInputStream(out.toByteArray()); - } - - /* - * @see IMemento - */ - public Float getFloat(String key) { - Attr attr = element.getAttributeNode(key); - if (attr == null) - return null; - String strValue = attr.getValue(); - try { - return new Float(strValue); - } catch (NumberFormatException e) { - return null; - } - } - - /* - * @see IMemento - */ - public String getId() { - return element.getAttribute(TAG_ID); - } - - /* - * @see IMemento - */ - public String getName() { - return element.getNodeName(); - } - - /* - * @see IMemento - */ - public Integer getInteger(String key) { - Attr attr = element.getAttributeNode(key); - if (attr == null) - return null; - String strValue = attr.getValue(); - try { - return new Integer(strValue); - } catch (NumberFormatException e) { - return null; - } - } - - /* - * @see IMemento - */ - public String getString(String key) { - Attr attr = element.getAttributeNode(key); - if (attr == null) - return null; - return attr.getValue(); - } - - public List getNames() { - NamedNodeMap map = element.getAttributes(); - int size = map.getLength(); - List list = new ArrayList(); - for (int i = 0; i < size; i++) { - Node node = map.item(i); - String name = node.getNodeName(); - list.add(name); - } - return list; - } - - /** - * Loads a memento from the given filename. - * - * @param filename java.lang.String - * @exception java.io.IOException - * @return a memento - */ - public static IMemento loadMemento(String filename) throws IOException { - InputStream in = null; - try { - in = new BufferedInputStream(new FileInputStream(filename)); - return XMLMemento.createReadRoot(in); - } finally { - try { - if (in != null) - in.close(); - } catch (Exception e) { - // ignore - } - } - } - - /* - * @see IMemento - */ - private void putElement(Element element2) { - NamedNodeMap nodeMap = element2.getAttributes(); - int size = nodeMap.getLength(); - for (int i = 0; i < size; i++){ - Attr attr = (Attr)nodeMap.item(i); - putString(attr.getName(),attr.getValue()); - } - - NodeList nodes = element2.getChildNodes(); - size = nodes.getLength(); - for (int i = 0; i < size; i ++) { - Node node = nodes.item(i); - if (node instanceof Element) { - XMLMemento child = (XMLMemento)createChild(node.getNodeName()); - child.putElement((Element)node); - } - } - } - - /* - * @see IMemento - */ - public void putFloat(String key, float f) { - element.setAttribute(key, String.valueOf(f)); - } - - /* - * @see IMemento - */ - public void putInteger(String key, int n) { - element.setAttribute(key, String.valueOf(n)); - } - - /* - * @see IMemento - */ - public void putMemento(IMemento memento) { - XMLMemento xmlMemento = (XMLMemento) memento; - putElement(xmlMemento.element); - } - - /* - * @see IMemento - */ - public void putString(String key, String value) { - if (value == null) - return; - element.setAttribute(key, value); - } - - /** - * Save this Memento to a Writer. - * - * @param os an output stream - * @throws IOException if anything goes wrong - */ - public void save(OutputStream os) throws IOException { - Result result = new StreamResult(os); - Source source = new DOMSource(factory); - try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); - transformer.transform(source, result); - } catch (Exception e) { - throw (IOException) (new IOException().initCause(e)); - } - } - - /** - * Saves the memento to the given file. - * - * @param filename java.lang.String - * @exception java.io.IOException - */ - public void saveToFile(String filename) throws IOException { - FileOutputStream w = null; - try { - w = new FileOutputStream(filename); - save(w); - } catch (IOException e) { - throw e; - } catch (Exception e) { - throw new IOException(e.getLocalizedMessage()); - } finally { - if (w != null) { - try { - w.close(); - } catch (Exception e) { - // ignore - } - } - } - } - - /* - * @see IMemento#getBoolean(String) - */ - public Boolean getBoolean(String key) { - Attr attr = element.getAttributeNode(key); - if (attr == null) - return null; - String strValue = attr.getValue(); - if ("true".equalsIgnoreCase(strValue)) - return new Boolean(true); - return new Boolean(false); - } - - /* - * @see IMemento#putBoolean(String, boolean) - */ - public void putBoolean(String key, boolean value) { - element.setAttribute(key, value ? "true" : "false"); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchable.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchable.java deleted file mode 100644 index de2f44725..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchable.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import java.net.URL; -/** - * - */ -public class CactusLaunchable { - private String fProjectname; - private String fClassName; - private String fTestName; - private URL fCactusURL; - - public CactusLaunchable(String projectName, String className, String testName, URL cactusURL) { - fProjectname = projectName; - fClassName = className; - fTestName = testName; - fCactusURL = cactusURL; - } - - public String getTestClassName() { - return fClassName; - } - - public String getTestName() { - return fTestName; - } - - public String getProjectName() { - return fProjectname; - } - - public URL getCactusURL() { - return fCactusURL; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchableAdapterDelegate.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchableAdapterDelegate.java deleted file mode 100644 index 028f6fc20..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchableAdapterDelegate.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import java.net.MalformedURLException; -import java.net.URL; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jst.server.core.internal.Trace; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.model.IURLProvider; -import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate; -/** - * - */ -public class CactusLaunchableAdapterDelegate extends LaunchableAdapterDelegate { - public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException { - if (moduleArtifact instanceof WebTestableResource) { - WebTestableResource resource = (WebTestableResource) moduleArtifact; - URL url = ((IURLProvider) server.getAdapter(IURLProvider.class)) - .getModuleRootURL(resource.getModule()); - - String urlString = url.toString(); - if (urlString.endsWith("/")) { - try { - url = new URL(urlString.substring(0, urlString.length() - 1)); - } catch (MalformedURLException e) { - Trace.trace(Trace.SEVERE, "Error getting launchable", e); - return null; - } - } - return new CactusLaunchable(resource.getProjectName(), - resource.getClassName(), resource.getTestName(), url); - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusModuleArtifactAdapterDelegate.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusModuleArtifactAdapterDelegate.java deleted file mode 100644 index 162b3418f..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusModuleArtifactAdapterDelegate.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.server.core.internal.Trace; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; -/** - * - */ -public class CactusModuleArtifactAdapterDelegate extends ModuleArtifactAdapterDelegate { - private static final String SERVLET_TEST_CASE_TYPE = "org.apache.cactus.ServletTestCase"; - - private static final String SUITE_METHOD = "suite"; - - private static final String TEST_CLASS_NAME = "junit.framework.Test"; - - public IModuleArtifact getModuleArtifact(Object obj) { - String methodName = ""; - if (obj instanceof IMethod) { - IMethod method = (IMethod) obj; - methodName = method.getElementName(); - obj = method.getCompilationUnit(); - } - if (obj instanceof IAdaptable) { - IResource resource = (IResource) ((IAdaptable) obj).getAdapter(IResource.class); - String testClassName = getClassNameForType(resource, SERVLET_TEST_CASE_TYPE); - String projectName = resource.getProject().getName(); - if (testClassName != null) { - return new WebTestableResource(getModule(resource.getProject()), false, - projectName, testClassName, methodName); - } - } - return null; - } - - public static String getClassNameForType(IResource resource, String superType) { - if (resource == null) - return null; - try { - IProject project = resource.getProject(); - IPath path = resource.getFullPath(); - if (!project.hasNature(JavaCore.NATURE_ID) || path == null) - return null; - - IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID); - if (!javaProject.isOpen()) - javaProject.open(new NullProgressMonitor()); - - // output location may not be on classpath - IPath outputPath = javaProject.getOutputLocation(); - if (outputPath != null - && "class".equals(path.getFileExtension()) && outputPath.isPrefixOf(path)) { //$NON-NLS-1$ - int count = outputPath.segmentCount(); - path = path.removeFirstSegments(count); - } - - // remove initial part of classpath - IClasspathEntry[] classPathEntry = javaProject.getResolvedClasspath(true); - if (classPathEntry != null) { - int size = classPathEntry.length; - for (int i = 0; i < size; i++) { - IPath classPath = classPathEntry[i].getPath(); - if (classPath.isPrefixOf(path)) { - int count = classPath.segmentCount(); - path = path.removeFirstSegments(count); - i += size; - } - } - } - - // get java element - IJavaElement javaElement = javaProject.findElement(path); - IType[] types = getTypes(javaElement); - if (types != null) { - int size2 = types.length; - for (int i = 0; i < size2; i++) { - if (hasSuperclass(types[i], superType) || hasSuiteMethod(types[i])) - return types[i].getFullyQualifiedName(); - } - } - return null; - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Unexpected exception: " + e); - return null; - } - } - - private static boolean hasSuiteMethod(IType type) throws JavaModelException { - IMethod[] methods = type.getMethods(); - int size = methods.length; - for (int i = 0; i < size; i++) { - IMethod method = methods[i]; - if (method.getParameterNames().length == 0 && method.getElementName().equals(SUITE_METHOD)) { - String returnType = getFullyQualifiedTypeForMangledType(method.getReturnType(), type); - if (TEST_CLASS_NAME.equals(returnType)) { - return true; - } - } - } - return false; - } - - private static IType[] getTypes(IJavaElement element) { - try { - if (element.getElementType() != IJavaElement.COMPILATION_UNIT) - return null; - return ((ICompilationUnit) element).getAllTypes(); - } catch (Exception e) { - return null; - } - } - - public static boolean hasSuperclass(IType type, String superClassName) { - try { - ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null); - IType[] superClasses = hierarchy.getAllSuperclasses(type); - int size = superClasses.length; - for (int i = 0; i < size; i++) { - if (superClassName.equals(superClasses[i].getFullyQualifiedName())) //$NON-NLS-1$ - return true; - } - return false; - } catch (Exception e) { - return false; - } - } - - protected static IModule getModule(IProject project) { - IModule deployable = null; - Iterator iterator = Arrays.asList(ServerUtil.getModules("jst.web")).iterator(); - while (iterator.hasNext()) { - Object next = iterator.next(); - if (next instanceof IModule) { - deployable = (IModule) next; - if (deployable.getProject().equals(project)) - return deployable; - } - } - return null; - } - - private static String getFullyQualifiedTypeForMangledType(String type, - IType declaringType) throws JavaModelException { - type = Signature.toString(type); - return getFullyQualifiedTypeForType(type, declaringType); - } - - private static String getFullyQualifiedTypeForType(String type, IType declaringType) - throws JavaModelException { - String[][] resolvedTypes = declaringType.resolveType(type); - // Are there legit cases where this would not be the case? We might need to check - // for this and bomb out if the type cannot be unambigiously resolved - if (resolvedTypes.length != 1) - Trace.trace(Trace.WARNING, "The type cannot be unambigiously resolved. Need to handle this case"); - String[] resolvedType = resolvedTypes[0]; - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < resolvedType.length - 1; i++) { - buffer.append(resolvedType[i]); - buffer.append('.'); - } - - buffer.append(resolvedType[resolvedType.length - 1]); - - return buffer.toString(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/ServletTestCasePropertyTester.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/ServletTestCasePropertyTester.java deleted file mode 100644 index d73704d2a..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/ServletTestCasePropertyTester.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.server.core.internal.Trace; -/** - * - */ -public class ServletTestCasePropertyTester extends PropertyTester { - public static final String PROPERTY_IS_SERVLET_TEST_CASE = "isServletTestCase"; - private static final String TEST_SUPERCLASS_NAME = "org.apache.cactus.ServletTestCase"; - - public boolean test(Object receiver, String method, Object[] args, Object expectedValue) { - IJavaElement javaElement = null; - if (receiver instanceof IAdaptable) { - javaElement = (IJavaElement) ((IAdaptable) receiver).getAdapter(IJavaElement.class); - } - if (javaElement != null) { - if (!javaElement.exists()) { - return false; - } - } - if (javaElement instanceof IJavaProject - || javaElement instanceof IPackageFragmentRoot - || javaElement instanceof IPackageFragment) { - return true; - } - if (javaElement != null) { - if (PROPERTY_IS_SERVLET_TEST_CASE.equals(method)) { //$NON-NLS-1$ - return isServletTestCase(javaElement); - } - } - return false; - } - - private boolean isServletTestCase(IJavaElement element) { - IType testType = null; - - try { - if (element instanceof ICompilationUnit) { - ICompilationUnit cu = (ICompilationUnit) element; - testType = cu.getType(Signature.getQualifier(cu.getElementName())); - } else if (element instanceof IClassFile) - testType = ((IClassFile) element).getType(); - else if (element instanceof IType) - testType = (IType) element; - else if (element instanceof IMember) - testType = ((IMember) element).getDeclaringType(); - - if (testType != null && testType.exists() && isTestOrSuite(testType)) - return true; - } catch (JavaModelException e) { - Trace.trace(Trace.SEVERE, "Error checking isServlet", e); - } - return false; - } - - /** - * - * @param testType - * @return true if the type is a test, false otherwise - */ - private boolean isTestOrSuite(IType testType) throws JavaModelException { - IType[] types = testType.newSupertypeHierarchy(null).getAllSuperclasses(testType); - for (int i = 0; i < types.length; i++) { - if (types[i].getFullyQualifiedName().equals(TEST_SUPERCLASS_NAME)) { - return true; - } - } - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java deleted file mode 100644 index 9e6873aeb..000000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import org.eclipse.jst.server.core.internal.Messages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleArtifactDelegate; - -public class WebTestableResource extends ModuleArtifactDelegate { - private boolean fServletIsConfigured; - private String fClassName; - private String fTestName; - private String fProjectName; - - public WebTestableResource(IModule module, boolean servletIsConfigured, - String projectName, String className, String testName) { - super(module); - fServletIsConfigured = servletIsConfigured; - fClassName = className; - fTestName = testName; - fProjectName = projectName; - } - - public WebTestableResource() { - super(); - } - - public String getProjectName() { - return fProjectName; - } - - public boolean isServletConfigured() { - return fServletIsConfigured; - } - - public String getClassName() { - return fClassName; - } - - public String getTestName() { - return fTestName; - } - - /* - * @see ModuleArtifactDelegate#getName() - */ - public String getName() { - return NLS.bind(Messages.artifactCactusTest, fTestName); - } - - /* - * @see ModuleArtifactDelegate#deserialize(String) - */ - public void deserialize(String s) { - int ind = s.indexOf("//"); - super.deserialize(s.substring(0, ind)); - s = s.substring(ind+2); - ind = s.indexOf("//"); - fProjectName = s.substring(0, ind); - - s = s.substring(ind+2); - ind = s.indexOf("//"); - fClassName = s.substring(0, ind); - - if ('T' == s.charAt(ind+2)) - fServletIsConfigured = true; - else - fServletIsConfigured = false; - fTestName = s.substring(ind+3); - } - - /* - * @see ModuleArtifactDelegate#serialize() - */ - public String serialize() { - StringBuffer sb = new StringBuffer(super.serialize()); - sb.append("//"); - sb.append(fProjectName); - sb.append("//"); - sb.append(fClassName); - sb.append("//"); - if (fServletIsConfigured) - sb.append("T"); - else - sb.append("F"); - sb.append(fTestName); - return sb.toString(); - } -}
\ No newline at end of file |