|
What this is
This file is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
Other links
The source code
/*******************************************************************************
* 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.pde.api.tools.internal;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.launching.EEVMType;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstall2;
import org.eclipse.jdt.launching.IVMInstallChangedListener;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.PropertyChangeEvent;
import org.eclipse.jdt.launching.VMStandin;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.ResolverError;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateHelper;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.IApiProfile;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.ibm.icu.text.MessageFormat;
/**
* Implementation of an API profile.
*
* @since 1.0
*/
public class ApiProfile implements IApiProfile, IVMInstallChangedListener {
/**
* Constant used for controlling tracing in the example class
*/
private static boolean DEBUG = Util.DEBUG;
/**
* Method used for initializing tracing in the example class
*/
public static void setDebug(boolean debugValue) {
DEBUG = debugValue || Util.DEBUG;
}
public static IWorkspaceRoot ROOT;
public static IPath ROOT_LOCATION_PATH;
static {
try {
ROOT = ResourcesPlugin.getWorkspace().getRoot();
ROOT_LOCATION_PATH = ROOT.getLocation();
} catch(IllegalStateException e) {
// ignore
}
}
private IApiComponent[] EMPTY_COMPONENTS = new IApiComponent[0];
/**
* profile name
*/
private String fName;
/**
* OSGi bundle state
*/
private State fState;
/**
* Maps bundle descriptions to components
*/
private Map fComponents = new HashMap();
/**
* Maps component id's to components
*/
private Map fComponentsById = new HashMap();
/**
* Next available bundle id
*/
private long fNextId = 0L;
/**
* Execution environment identifier
*/
private String fExecutionEnvironment;
/**
* Component representing the system library
*/
private IApiComponent fSystemLibraryComponent;
/**
* Whether an execution environment should be automatically resolved
* as API components are added.
*/
private boolean fAutoResolve = false;
/**
* Execution environment status
*/
private IStatus fEEStatus = null;
/**
* Constant to match any value for ws, os, arch.
*/
private AnyValue ANY_VALUE = new AnyValue("*"); //$NON-NLS-1$
/**
* Cache of resolved packages. Map of <packageName> ->
|