Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal')
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntime.java111
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeClasspathProvider.java39
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntimeUtil.java41
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntime.java19
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntimeWorkingCopy.java19
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IMemento.java86
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EELaunchableClient.java38
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EEUtil.java214
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JRERuntimeComponentProvider.java34
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JavaServerPlugin.java417
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/LaunchConfigurationUtil.java56
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java53
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties45
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProfilerPreferences.java75
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProgressUtil.java69
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java149
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java164
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProvider.java81
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProviderWrapper.java189
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderDelegate.java33
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderWrapper.java131
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeFacetMapping.java65
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ServerProfiler.java95
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Trace.java106
-rw-r--r--plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/XMLMemento.java246
25 files changed, 0 insertions, 2575 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 264fcaa1d..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/GenericRuntime.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 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();
- String id = getVMInstallId();
- for (IVMInstall vmInst : vmInstalls) {
- if (id.equals(vmInst.getId()))
- return vmInst;
- }
- } 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);
- }
-}
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 862bb642e..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, 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.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<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- addLibraryEntries(list, installPath.toFile(), false);
- return 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 d5fbb11ea..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, 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.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));
- }
-}
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 9a4bd3156..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, 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.jst.server.core.IJavaRuntime;
-/**
- *
- */
-public interface IGenericRuntime extends IJavaRuntime {
- // no additional methods
-}
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 36c19659a..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IGenericRuntimeWorkingCopy.java
+++ /dev/null
@@ -1,19 +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 org.eclipse.jst.server.core.IJavaRuntimeWorkingCopy;
-/**
- *
- */
-public interface IGenericRuntimeWorkingCopy extends IGenericRuntime, IJavaRuntimeWorkingCopy {
- // no new methods
-} \ 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 8c0d1f1d3..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/IMemento.java
+++ /dev/null
@@ -1,86 +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;
-/**
- * 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 {
- /**
- * 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);
-
- /**
- * 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 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);
-
- /**
- * 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 cd6f908a7..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EELaunchableClient.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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) {
- if (Trace.FINEST) {
- Trace.trace(Trace.STRING_FINEST, "JNDI client launched");
- }
- return null;
- }
-}
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 2bbf8e975..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/J2EEUtil.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 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.HashMap;
-import java.util.List;
-import java.util.Map;
-
-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";
-
- private static final IModule[] EMPTY_LIST = new IModule[0];
- private static Map<IModule, List<IModule>> earCache;
- private static Map<IJ2EEModule, List<IModule>> earCache2;
- private static Map<IModule, List<IModule>> webCache;
- protected static String cache;
-
- /**
- * 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) {
- if (shouldUseCache()) {
- List<IModule> list = earCache2.get(module);
- if (list == null)
- return EMPTY_LIST;
- return list.toArray(new IModule[list.size()]);
- }
-
- List<IModule> list = new ArrayList<IModule>();
- IModule[] modules = ServerUtil.getModules(EAR_MODULE);
- if (modules != null) {
- for (IModule module2 : modules) {
- IEnterpriseApplication ear = (IEnterpriseApplication) module2.loadAdapter(IEnterpriseApplication.class, monitor);
- if (ear != null) {
- IModule[] modules2 = ear.getModules();
- if (modules2 != null) {
- for (IModule m : modules2) {
- if (module.equals(m.loadAdapter(IJ2EEModule.class, monitor)))
- list.add(module2);
- }
- }
- }
- }
- }
-
- return list.toArray(new IModule[list.size()]);
- }
-
- /**
- * 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) {
- if (shouldUseCache()) {
- List<IModule> list = earCache.get(module);
- if (list == null)
- return EMPTY_LIST;
- return list.toArray(new IModule[list.size()]);
- }
-
- List<IModule> list = new ArrayList<IModule>();
- IModule[] modules = ServerUtil.getModules(EAR_MODULE);
- if (modules != null) {
- for (IModule module2 : modules) {
- IEnterpriseApplication ear = (IEnterpriseApplication) module2.loadAdapter(IEnterpriseApplication.class, monitor);
- if (ear != null) {
- IModule[] modules2 = ear.getModules();
- if (modules2 != null) {
- for (IModule m : modules2) {
- if (module.equals(m))
- list.add(module2);
- }
- }
- }
- }
- }
-
- return list.toArray(new IModule[list.size()]);
- }
-
- /**
- * 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) {
- if (shouldUseCache()) {
- List<IModule> list = webCache.get(module);
- if (list == null)
- return EMPTY_LIST;
- return list.toArray(new IModule[list.size()]);
- }
-
- List<IModule> list = new ArrayList<IModule>();
- IModule[] modules = ServerUtil.getModules(WEB_MODULE);
- if (modules != null) {
- for (IModule module2 : modules) {
- IWebModule web = (IWebModule) module2.loadAdapter(IWebModule.class, monitor);
- if (web != null) {
- IModule[] modules2 = web.getModules();
- if (modules2 != null) {
- for (IModule m : modules2) {
- if (module.equals(m))
- list.add(module2);
- }
- }
- }
- }
- }
-
- return list.toArray(new IModule[list.size()]);
- }
-
- private static void fillCache(IProgressMonitor monitor) {
- earCache = new HashMap<IModule, List<IModule>>();
- earCache2 = new HashMap<IJ2EEModule, List<IModule>>();
- webCache = new HashMap<IModule, List<IModule>>();
-
- IModule[] modules = ServerUtil.getModules(EAR_MODULE);
- if (modules != null) {
- for (IModule module2 : modules) {
- IEnterpriseApplication ear = (IEnterpriseApplication) module2.loadAdapter(IEnterpriseApplication.class, monitor);
- if (ear != null) {
- IModule[] modules2 = ear.getModules();
- if (modules2 != null) {
- for (IModule mm : modules2) {
- List<IModule> m = earCache.get(mm);
- if (m == null) {
- m = new ArrayList<IModule>(2);
- earCache.put(mm, m);
- }
- m.add(module2);
-
- IJ2EEModule mod = (IJ2EEModule) mm.loadAdapter(IJ2EEModule.class, monitor);
- if (mod != null) {
- m = earCache2.get(mod);
- if (m == null) {
- m = new ArrayList<IModule>(2);
- earCache2.put(mod, m);
- }
- m.add(module2);
- }
- }
- }
- }
- }
- }
-
- modules = ServerUtil.getModules(WEB_MODULE);
- if (modules != null) {
- for (IModule module2 : modules) {
- IWebModule web = (IWebModule) module2.loadAdapter(IWebModule.class, monitor);
- if (web != null) {
- IModule[] modules2 = web.getModules();
- if (modules2 != null) {
- for (IModule mm : modules2) {
- List<IModule> m = webCache.get(mm);
- if (m == null) {
- m = new ArrayList<IModule>(2);
- webCache.put(mm, m);
- }
- m.add(module2);
- }
- }
- }
- }
- }
- }
-
- private static boolean shouldUseCache() {
- String s = System.getProperty("J2EEcache");
- if (s == null || "".equals(s) || "false".equals(s)) {
- webCache = null;
- earCache = null;
- return false;
- }
- if (cache == null || !cache.equals(s)) {
- cache = s;
- fillCache(null);
- }
- return true;
- }
-} \ 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 89afad8e7..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JRERuntimeComponentProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007,2008 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.Collections;
-import java.util.List;
-
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jst.common.project.facet.core.StandardJreRuntimeComponent;
-import org.eclipse.jst.server.core.IJavaRuntime;
-import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
-import org.eclipse.wst.server.core.IRuntime;
-
-public class JRERuntimeComponentProvider extends RuntimeComponentProviderDelegate {
-
- public List<IRuntimeComponent> getRuntimeComponents(IRuntime runtime) {
- // define JRE component
- IJavaRuntime javaRuntime = (IJavaRuntime) runtime.loadAdapter(IJavaRuntime.class, null);
- if (javaRuntime != null) {
- final IVMInstall vmInstall = javaRuntime.getVMInstall();
- final IRuntimeComponent rc = StandardJreRuntimeComponent.create( vmInstall );
- return Collections.singletonList( rc );
- }
- 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 51ba74566..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/JavaServerPlugin.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.Hashtable;
-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.service.debug.DebugOptions;
-import org.eclipse.osgi.service.debug.DebugOptionsListener;
-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<RuntimeClasspathProviderWrapper> runtimeClasspathProviders;
-
- // cached copy of all server profilers
- private static List<ServerProfiler> 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);
-
- // register the debug options listener
- final Hashtable<String, String> props = new Hashtable<String, String>(4);
- props.put(DebugOptions.LISTENER_SYMBOLICNAME, JavaServerPlugin.PLUGIN_ID);
- context.registerService(DebugOptionsListener.class.getName(), new Trace(), props);
- }
-
- /**
- * @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();
-
- if (Trace.FINEST) {
- Trace.trace(Trace.STRING_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) {
- for (IProject project : projects) {
- if (project.isAccessible()) {
- try {
- if (!project.isNatureEnabled(JavaCore.NATURE_ID))
- continue;
-
- IJavaProject javaProject = JavaCore.create(project);
-
- boolean found = false;
- IClasspathEntry[] ce = javaProject.getRawClasspath();
- for (IClasspathEntry cp : ce) {
- if (cp.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
- if (serverContainerPath.isPrefixOf(cp.getPath()))
- found = true;
- }
- }
-
- if (Trace.FINEST) {
- Trace.trace(Trace.STRING_FINEST, "Classpath change on: " + project + " " + found);
- }
-
- if (found) {
- IRuntime runtime2 = runtime;
- if (act == 2)
- runtime2 = null;
- RuntimeClasspathContainer container = new RuntimeClasspathContainer(project,
- serverContainerPath, rcpw, runtime2, runtime.getId());
- JavaCore.setClasspathContainer(serverContainerPath, new IJavaProject[] { javaProject },
- new IClasspathContainer[] {container}, null);
- }
- } catch (Exception e) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_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;
- if (Trace.CONFIG) {
- Trace.trace(Trace.STRING_CONFIG, "->- Loading .runtimeClasspathProviders extension point ->-");
- }
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(JavaServerPlugin.PLUGIN_ID, "runtimeClasspathProviders");
-
- List<RuntimeClasspathProviderWrapper> list = new ArrayList<RuntimeClasspathProviderWrapper>(cf.length);
- for (IConfigurationElement ce : cf) {
- try {
- list.add(new RuntimeClasspathProviderWrapper(ce));
- if (Trace.CONFIG) {
- Trace.trace(Trace.STRING_CONFIG, " Loaded runtimeClasspathProviders: " + ce.getAttribute("id"));
- }
- } catch (Throwable t) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_SEVERE,
- " Could not load runtimeClasspathProviders: " + ce.getAttribute("id"), t);
- }
- }
- }
- runtimeClasspathProviders = list;
-
- if (Trace.CONFIG) {
- Trace.trace(Trace.STRING_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;
- if (Trace.CONFIG) {
- Trace.trace(Trace.STRING_CONFIG, "->- Loading .serverProfilers extension point ->-");
- }
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(JavaServerPlugin.PLUGIN_ID, "serverProfilers");
-
- List<ServerProfiler> list = new ArrayList<ServerProfiler>(cf.length);
- for (IConfigurationElement ce : cf) {
- try {
- list.add(new ServerProfiler(ce));
- if (Trace.CONFIG) {
- Trace.trace(Trace.STRING_CONFIG, " Loaded serverProfiler: " + ce.getAttribute("id"));
- }
- } catch (Throwable t) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_SEVERE, " Could not load serverProfiler: " + ce.getAttribute("id"), t);
- }
- }
- }
- serverProfilers = list;
-
- if (Trace.CONFIG) {
- Trace.trace(Trace.STRING_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));
-
- String id = ProfilerPreferences.getInstance().getServerProfilerId();
- if ( id != null ) {
- for ( int i = 0; i < sp.length; i++ ) {
- if ( sp[i].getId().equals(id) ) {
- sp[i].process(launch, vmInstall, vmConfig, monitor);
- return;
- }
- }
- } else {
- if ( sp.length == 1 ) {
- /* The user has not selected a profiler preference, but there is only one
- * registered so we can just call that
- */
- sp[0].process(launch, vmInstall, vmConfig, monitor);
- } else {
- /* We have more than one profiler registered, but the user has not yet
- * configured their preference so we don't know which one to call. Throw
- * an exception and notify the user must configure the profiler
- * before continuing. */
- throw new CoreException(new Status(IStatus.ERROR, JavaServerPlugin.PLUGIN_ID, 0,
- Messages.noProfilersSelected, null));
- }
- }
- }
-} \ 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 2ffe1686a..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, 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;
-/**
- *
- */
-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();
- }*/
-}
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 2230290e2..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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 canModifyModules;
- public static String errorNoProfiler;
- public static String errorPublish;
- public static String httpPort;
- public static String errorPortInUse;
-
- public static String noProfilersSelected;
-
- 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 b6169140b..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties
+++ /dev/null
@@ -1,45 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2009 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}
-
-noProfilersSelected=A Server Profiler is not selected. Please select a profiler on the Server -> Profilers page in the workbench preferences.
-
-canModifyModules=Web module can be added to the server.
-errorNoProfiler=Could not launch in profiling mode because no profilers are configured.
-errorPublish=An error occurred 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/ProfilerPreferences.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProfilerPreferences.java
deleted file mode 100644
index 5ec278688..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ProfilerPreferences.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 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.Platform;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Helper class which wraps around the preference store so that options related to
- * server profilers can be persisted.
- */
-public class ProfilerPreferences {
-
- private static ProfilerPreferences prefs = null;
- private IPreferencesService prefService;
-
- /* The qualifier (scope) in the preference store */
- private static final String PREF_PROFILER_QUALIFIER = "org.eclipse.jst.server.core.internal.profilers";
- /* The key used to store the selected profiler preference */
- private static final String PREF_SELECTED_PROFILER = "selected-profiler";
-
-
- /**
- * Private Constructor - This should be a singleton class
- */
- private ProfilerPreferences() {
- prefService = Platform.getPreferencesService();
- }
-
- /**
- * Returns an instance of this class
- * @return
- */
- public static ProfilerPreferences getInstance() {
- if ( prefs == null )
- prefs = new ProfilerPreferences();
- return prefs;
- }
-
- /**
- * Sets the profiler to use when profiling on server
- * @param profilerId the id of the server profiler
- */
- public void setServerProfilerId( String profilerId ) {
- Preferences node = new InstanceScope().getNode( PREF_PROFILER_QUALIFIER );
- node.put( PREF_SELECTED_PROFILER, profilerId );
- try {
- node.flush();
- } catch (BackingStoreException e) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_SEVERE, "Could not save server profiler preference", e);
- }
- }
- }
-
- /**
- * Reutns the id of the current server profiler
- * @return the id of the current server profiler
- */
- public String getServerProfilerId() {
- return prefService.getString( PREF_PROFILER_QUALIFIER, PREF_SELECTED_PROFILER, null, null );
- }
-
-}
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 61d99d626..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, 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.*;
-/**
- * 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);
- }
-}
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 bd0c9bc72..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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;
-import org.eclipse.wst.server.core.ServerCore;
-/**
- *
- */
-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;
-
- IRuntime curRuntime = getRuntime();
-
- if (delegate != null && curRuntime != null)
- entries = delegate.resolveClasspathContainerImpl(project, curRuntime);
-
- if (entries == null)
- return new IClasspathEntry[0];
-
- return entries;
- }
-
- private IRuntime getRuntime(){
- if (runtime == null && runtimeId != null) {
- // Make sure the runtime object is initialized.
- runtime = ServerCore.findRuntime(runtimeId);
- }
- return runtime;
- }
-
- /** (non-Javadoc)
- * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
- */
- public String getDescription() {
- IRuntime curRuntime = getRuntime();
-
- if (curRuntime != null) {
- IRuntimeType runtimeType = curRuntime.getRuntimeType();
- if (runtimeType != null)
- return NLS.bind(Messages.classpathContainer, runtimeType.getName(), curRuntime.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;
- }
-}
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 c7b9a1392..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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<IJavaProject> list = new ArrayList<IJavaProject>();
- if (projects != null) {
- for (IProject project : projects) {
- if (project.isAccessible()) {
- try {
- if (!project.isNatureEnabled(JavaCore.NATURE_ID))
- continue;
-
- IJavaProject javaProject = JavaCore.create(project);
-
- boolean found = false;
- IClasspathEntry[] ce = javaProject.getRawClasspath();
- for (IClasspathEntry cp : ce) {
- if (cp.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
- if (containerPath.isPrefixOf(cp.getPath()))
- found = true;
- }
- }
-
- if (Trace.FINEST) {
- Trace.trace(Trace.STRING_FINEST, "Classpath change on: " + project + " " + found);
- }
-
- if (found)
- list.add(javaProject);
- } catch (Exception e) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_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 c581153b5..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2005, 2011 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 static final IProjectFacet WEBFRAGMENT_FACET = ProjectFacetsManager.getProjectFacet("jst.webfragment");
-
- 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) ||
- pf.equals(WEBFRAGMENT_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 c99273631..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeClasspathProviderWrapper.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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.*;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-/**
- *
- */
-public class RuntimeClasspathProviderWrapper {
- private IConfigurationElement element;
- private volatile 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<String> list = new ArrayList<String>();
- 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) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_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;
-
- for (String ss : s) {
- if (ss.endsWith("*")) {
- if (id.length() >= ss.length() && id.startsWith(ss.substring(0, ss.length() - 1)))
- return true;
- } else if (id.equals(ss))
- return true;
- }
- return false;
- }
-
- /*
- * Loads the delegate class.
- */
- public RuntimeClasspathProviderDelegate getDelegate() {
- if (delegate == null) {
- try {
- // Create delegate unsynchronized to avoid possible deadlocks
- RuntimeClasspathProviderDelegate tempDelegate = (RuntimeClasspathProviderDelegate) element.createExecutableExtension("class");
- tempDelegate.initialize(getId());
- // If delegate is not already set, use this delegate
- synchronized (this) {
- if (delegate == null) {
- delegate = tempDelegate;
- }
- }
- } catch (Throwable t) {
- ServerPlugin.logExtensionFailure(toString(), t);
- }
- }
- 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) {
- ServerPlugin.logExtensionFailure(toString(), e);
- }
- return null;
- }
-
- public void requestClasspathContainerUpdate(IRuntime runtime, IClasspathEntry[] entries) {
- if (runtime == null)
- return;
- try {
- getDelegate().requestClasspathContainerUpdate(runtime, entries);
- } catch (Exception e) {
- ServerPlugin.logExtensionFailure(toString(), e);
- }
- }
-
- /*
- * @see RuntimeClasspathProviderDelegate#hasRuntimeClasspathChanged(IRuntime)
- */
- public boolean hasRuntimeClasspathChanged(IRuntime runtime) {
- if (runtime == null)
- return false;
- try {
- return getDelegate().hasRuntimeClasspathChanged(runtime);
- } catch (Exception e) {
- ServerPlugin.logExtensionFailure(toString(), e);
- }
- return false;
- }
-
- public String toString() {
- return "RuntimeClasspathProviderWrapper[" + getId() + "]";
- }
-}
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 edb13aad1..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/RuntimeComponentProviderWrapper.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 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.common.project.facet.core.runtime.IRuntimeComponent;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-/**
- *
- */
-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<String> list = new ArrayList<String>();
- 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) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_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;
-
- for (String ss : s) {
- if (ss.endsWith("*")) {
- if (id.length() >= ss.length() && id.startsWith(ss.substring(0, ss.length() - 1)))
- return true;
- } else if (id.equals(ss))
- return true;
- }
- return false;
- }
-
- /*
- * Loads the delegate class.
- */
- protected RuntimeComponentProviderDelegate getDelegate() {
- if (delegate == null) {
- try {
- delegate = (RuntimeComponentProviderDelegate) element.createExecutableExtension("class");
- } catch (Throwable t) {
- ServerPlugin.logExtensionFailure(toString(), t);
- }
- }
- return delegate;
- }
-
- /*
- * @see RuntimeFacetComponentProviderDelegate#getRuntimeComponents(IRuntime)
- */
- public List<IRuntimeComponent> getComponents(IRuntime runtime) {
- if (runtime == null)
- return null;
- try {
- return getDelegate().getRuntimeComponents(runtime);
- } catch (Exception e) {
- ServerPlugin.logExtensionFailure(toString(), e);
- }
- 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 72cd04537..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, 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;
-/**
- *
- */
-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() + "]";
- }
-}
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 1f0a3c356..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/ServerProfiler.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 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.CoreException;
-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) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_SEVERE, "Could not create delegate " + toString(), t);
- }
- }
- }
- 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) throws CoreException {
- try {
- ServerProfilerDelegate del = getDelegate();
- if (del != null)
- del.process(launch, vmInstall, vmConfig, monitor);
- } catch (CoreException ce) {
- if (Trace.SEVERE) {
- Trace.trace(Trace.STRING_SEVERE, "Could not create delegate " + toString(), ce);
- }
- throw ce;
- }
- }
-
- 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/Trace.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Trace.java
deleted file mode 100644
index ef97d154a..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Trace.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.service.debug.DebugOptionsListener;
-
-/**
- * Helper class to route trace output.
- */
-public class Trace implements DebugOptionsListener {
-
- private static Set<String> logged = new HashSet<String>();
-
- // tracing enablement flags
- public static boolean CONFIG = false;
- public static boolean WARNING = false;
- public static boolean SEVERE = false;
- public static boolean FINEST = false;
- public static boolean PUBLISHING = false;
-
- // tracing levels. One most exist for each debug option
- public final static String STRING_CONFIG = "/config"; //$NON-NLS-1$
- public final static String STRING_FINEST = "/finest"; //$NON-NLS-1$
- public final static String STRING_WARNING = "/warning"; //$NON-NLS-1$
- public final static String STRING_SEVERE = "/severe"; //$NON-NLS-1$
- public final static String STRING_PUBLISHING = "/publishing"; //$NON-NLS-1$
-
- /**
- * Trace constructor. This should never be explicitly called by clients and is used to register this class with the
- * {@link DebugOptions} service.
- */
- public Trace() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.osgi.service.debug.DebugOptionsListener#optionsChanged(org.eclipse.osgi.service.debug.DebugOptions)
- */
- public void optionsChanged(DebugOptions options) {
-
- Trace.CONFIG = options.getBooleanOption(JavaServerPlugin.PLUGIN_ID + Trace.STRING_CONFIG, false);
- Trace.WARNING = options.getBooleanOption(JavaServerPlugin.PLUGIN_ID + Trace.STRING_WARNING, false);
- Trace.SEVERE = options.getBooleanOption(JavaServerPlugin.PLUGIN_ID + Trace.STRING_SEVERE, false);
- Trace.FINEST = options.getBooleanOption(JavaServerPlugin.PLUGIN_ID + Trace.STRING_FINEST, false);
- Trace.PUBLISHING = options.getBooleanOption(JavaServerPlugin.PLUGIN_ID + Trace.STRING_PUBLISHING, false);
- }
-
- /**
- * Trace the given message.
- *
- * @param level
- * The tracing level.
- * @param s
- * The message to trace
- */
- public static void trace(final String level, final String s) {
- Trace.trace(level, s, null);
- }
-
- /**
- * Trace the given message and exception.
- *
- * @param level
- * The tracing level.
- * @param s
- * The message to trace
- * @param t
- * A {@link Throwable} to trace
- */
- public static void trace(final String level, final String s, final Throwable t) {
-
- if (s == null) {
- return;
- }
- if (Trace.STRING_SEVERE.equals(level)) {
- if (!logged.contains(s)) {
- JavaServerPlugin.getInstance().getLog()
- .log(new Status(IStatus.ERROR, JavaServerPlugin.PLUGIN_ID, s, t));
- logged.add(s);
- }
- }
- if (JavaServerPlugin.getInstance().isDebugging()) {
- System.out.println(JavaServerPlugin.PLUGIN_ID + " " + level + " " + 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 119f14ddf..000000000
--- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/XMLMemento.java
+++ /dev/null
@@ -1,246 +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.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);
- }
-
- /**
- * Create a Document from a Reader and answer a root memento for reading
- * a document.
- */
- private 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.
- List<Element> list = new ArrayList<Element>(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, list.get(x));
- }
- return results;
- }
-
- /*
- * @see IMemento
- */
- public String getString(String key) {
- Attr attr = element.getAttributeNode(key);
- if (attr == null)
- return null;
- return attr.getValue();
- }
-
- /**
- * 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
- */
- 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
- */
- private 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
- }
- }
- }
- }
-}

Back to the top