diff options
Diffstat (limited to 'plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core')
3 files changed, 0 insertions, 356 deletions
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java deleted file mode 100644 index 0bf71ed45..000000000 --- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. 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: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.internal.core.util; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IRegistryChangeListener; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.server.generic.core.internal.CorePlugin; -/** - * Utilities for handling the extension points. - * - * @author Gorkem Ercan - */ -public class ExtensionPointUtil { - /** - * serverdefinition extension id - */ - public static final String SERVERDEFINITION_EXTENSION_ID = "serverdefinition"; //$NON-NLS-1$ - public static final String RUNTIMEDEFINITION_EXTENSION_ID = "runtimedefinition"; //$NON-NLS-1$ - private static final String GENERICPUBLISHER_EXTENSION_ID = "genericpublisher"; //$NON-NLS-1$ - private static final String EXTENSION_SERVER_TYPE = "serverTypes";//$NON-NLS-1$ - - /** - * Returns serverdefinition extensions - * @return serverdefinition Extensions - */ - public static IExtension[] getGenericServerDefinitionExtensions(){ - return getExtensions(CorePlugin.PLUGIN_ID+"."+SERVERDEFINITION_EXTENSION_ID); //$NON-NLS-1$ - } - - /** - * Returns runtimedefinition extensions - * @return runtimedefinition Extensions - */ - public static IExtension[] getGenericServerRuntimeDefinitionExtensions(){ - return getExtensions(CorePlugin.PLUGIN_ID+"."+RUNTIMEDEFINITION_EXTENSION_ID); //$NON-NLS-1$ - } - - /** - * Returns publisher extensions - * @return genericpublisher extensions - */ - public static IExtension[] getGenericPublisherExtension(){ - return getExtensions(CorePlugin.PLUGIN_ID+"."+GENERICPUBLISHER_EXTENSION_ID); //$NON-NLS-1$ - } - - private static IExtension[] getExtensions(String extensionId){ - IExtensionPoint extensionPoint=getExtensionPoint(extensionId); - IExtension[] extensions = extensionPoint.getExtensions(); - return extensions; - } - - private static IExtensionPoint getExtensionPoint(String id) - { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint= registry.getExtensionPoint(id); - return extensionPoint; - } - - - /** - * Returns the configuration elements - * - * @param extension - * @return configurationElements - */ - public static IConfigurationElement[] getConfigurationElements(IExtension extension){ - return extension!=null?extension.getConfigurationElements():null; - } - - /** - * Add listener to extension registry. - * @param listener - */ - public static void addRegistryListener(IRegistryChangeListener listener){ - IExtensionRegistry registry = Platform.getExtensionRegistry(); - registry.addRegistryChangeListener(listener, CorePlugin.PLUGIN_ID); - } - /** - * Retrieves the list of servers with the given launch configuration ID. - * Returns an empty array if there is none. - * @param launchConfigId - * @return - */ - public static String[] getServerTypesFromLaunchConfig(String launchConfigId){ - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor("org.eclipse.wst.server.core", EXTENSION_SERVER_TYPE); //$NON-NLS-1$ - ArrayList<String> list = new ArrayList<String>(); - for( int i = 0; i < cf.length; i++ ) - { - String id = cf[i].getAttribute( "launchConfigId" ); //$NON-NLS-1$ - if (id != null && id.equals( launchConfigId )) - { - list.add( cf[i].getAttribute( "id" ) ); //$NON-NLS-1$ - } - - } - return list.toArray(new String[list.size()]); - - } -} diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/FileUtil.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/FileUtil.java deleted file mode 100644 index b61051aa6..000000000 --- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/FileUtil.java +++ /dev/null @@ -1,124 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. 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: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.internal.core.util; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; - -/** - * Utilities for file operations. - * - * @author Gorkem Ercan - */ -public class FileUtil { - - - - /** - * Returns a resolved equivalent of url, use with the - * platform relative urls - * - * @param url - * @return URL - */ - public static URL resolveURL(URL url){ - try{ - return FileLocator.resolve(url); - }catch(IOException e){ - //ignore - } - return null; - } - - - - /** - * Create a temporary file - * @param name - * @param dir - * @return file - */ - public static File createTempFile(String name, String dir){ - if(name==null || dir == null) - return null; - - File temp=null; - String filePath; - filePath = name.replace('/', File.separatorChar); - if (filePath.startsWith(File.separator)) - filePath = filePath.substring(1); - temp = new File(dir, filePath); - verifyPath(temp,true); - temp.deleteOnExit(); - return temp; - - } - - /** - * Copies a file - * @param input - * @param output - * @throws IOException - */ - public static void copy(InputStream input, OutputStream output) throws IOException{ - byte[] buf = new byte[4096]; - int len = input.read(buf); - while(len!=-1){ - output.write(buf,0,len); - len= input.read(buf); - } - } - - private static void verifyPath(File path, boolean isFile) { - // if we are expecting a file back off 1 path element - if (isFile) { - if (path.getAbsolutePath().endsWith(File.separator)) { - // make sure this is a file - path = path.getParentFile(); - isFile = false; - } - } - // already exists ... just return - if (path.exists()) - return; - // does not exist ... ensure parent exists - File parent = path.getParentFile(); - verifyPath(parent, false); - // ensure directories are made. Mark files or directories for deletion - if (!isFile) - path.mkdir(); - path.deleteOnExit(); - } - - /** - * Resolves a URL to a file. - * - * @param url - * @return file - */ - public static File resolveFile(URL url){ - try { - URL resolvedUrl = resolveURL(url); - URI uri = new URI(resolvedUrl.getProtocol(), resolvedUrl.getHost(),resolvedUrl.getPath(), resolvedUrl.getQuery()); - return new File(uri); - } - catch (URISyntaxException e) { - //ignore - } - return null; - } -} diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ServerRuntimeMergeUtil.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ServerRuntimeMergeUtil.java deleted file mode 100644 index 30db9e722..000000000 --- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ServerRuntimeMergeUtil.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (c) 2006 Cape Clear Software. 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 - */ -package org.eclipse.jst.server.generic.internal.core.util; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jst.server.generic.servertype.definition.Classpath; -import org.eclipse.jst.server.generic.servertype.definition.Property; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; - -/** - * Combines a runtimedef files - * - * - properties - * - classpaths - * - * entries with a serverdef, if the serverdef does not already have - * them - contains check is done by id. - * - * @author <a href="mailto:david.black@capeclear.com">David Black</a> - */ -public class ServerRuntimeMergeUtil { - - /** - * Combines a runtime definition and a server definition - * into a single logical <code>ServerRuntime</code>. - * - * @param serverdef - * @param runtimedef - * @return serverdef - */ - public static ServerRuntime combine(ServerRuntime serverdef, ServerRuntime runtimedef) { - /** - * Add properties from runtimedef to serverdef if not already present, - * this ensures that: - * - * (1) while we are affecting the cached copy of serverdef, it is always - * required to be combined with its runtimedef (if there is one), and - * we check that the property has not already been added - * - * (2) serverdef properties can override runtimedef properties - */ - List properties = runtimedef.getProperty(); - if (properties != null) { - Iterator iter = properties.iterator(); - while (iter.hasNext()) { - Property prop = (Property) iter.next(); - addPropertyIfNotPresent(serverdef.getProperty(), prop); - } - } - - /** - * Add classpaths from runtimedef to serverdef if not already present, - * this ensures that: - * - * (1) while we are affecting the cached copy of serverdef, it is always - * required to be combined with its runtimedef (if there is one), and - * we check that the classpath has not already been added (by id) - * - * (2) serverdef classpath can override runtimedef classpath by id - */ - List classpaths = runtimedef.getClasspath(); - if (classpaths != null) { - Iterator iter = classpaths.iterator(); - while (iter.hasNext()) { - Classpath classpath = (Classpath)iter.next(); - addClasspathIfNotPresent(serverdef.getClasspath(), classpath); - } - } - - return serverdef; - } - - @SuppressWarnings("unchecked") - private static void addClasspathIfNotPresent(List classpaths, Classpath classpath) { - if (!containsClasspath(classpaths, classpath.getId())) { - classpaths.add(classpath); - } - } - - private static boolean containsClasspath(List properties, String id) { - boolean found = false; - Iterator iter = properties.iterator(); - while (iter.hasNext()) { - Classpath classpath = (Classpath) iter.next(); - if (classpath.getId().equals(id)) { - found = true; - break; - } - } - return found; - } - - @SuppressWarnings("unchecked") - private static void addPropertyIfNotPresent(List properties, Property prop) { - if (!containsProperty(properties, prop.getId())) { - properties.add(prop); - } - } - - private static boolean containsProperty(List properties, String id) { - boolean found = false; - Iterator iter = properties.iterator(); - while (iter.hasNext()) { - Property prop = (Property) iter.next(); - if (prop.getId().equals(id)) { - found = true; - break; - } - } - return found; - } - -} |