Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54683 Details for
Bug 163444
Associate access restrictions with execution environments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
access-rules.patch (text/plain), 31.37 KB, created by
Darin Wright
on 2006-11-28 19:05:50 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2006-11-28 19:05:50 EST
Size:
31.37 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug.tests >Index: tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java,v >retrieving revision 1.5 >diff -u -r1.5 ClasspathContainerTests.java >--- tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java 26 Oct 2006 20:11:49 -0000 1.5 >+++ tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java 29 Nov 2006 00:03:18 -0000 >@@ -98,7 +98,7 @@ > IVMInstall newVM = def.getVMInstallType().findVMInstall(vmId); > assertNotNull("Failed to create new VM", newVM); > >- JREContainer container = new JREContainer(newVM, containerPath); >+ JREContainer container = new JREContainer(newVM, containerPath, getJavaProject()); > JREContainerInitializer initializer = new JREContainerInitializer(); > // store the current library settings > LibraryLocation[] originalLibs = JavaRuntime.getLibraryLocations(newVM); >#P org.eclipse.jdt.debug.ui >Index: ui/org/eclipse/jdt/internal/debug/ui/launcher/SelectSystemLibraryQuickFix.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/SelectSystemLibraryQuickFix.java,v >retrieving revision 1.13 >diff -u -r1.13 SelectSystemLibraryQuickFix.java >--- ui/org/eclipse/jdt/internal/debug/ui/launcher/SelectSystemLibraryQuickFix.java 18 Jul 2006 19:33:10 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/debug/ui/launcher/SelectSystemLibraryQuickFix.java 29 Nov 2006 00:03:20 -0000 >@@ -12,7 +12,7 @@ > > > import java.lang.reflect.InvocationTargetException; >-import com.ibm.icu.text.MessageFormat; >+ > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; >@@ -33,6 +33,8 @@ > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.ui.PlatformUI; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * Quick fix to select an alternate JRE for a project. > */ >@@ -96,7 +98,7 @@ > project.setRawClasspath(classpath, monitor); > newBinding = newPath; > } >- JavaCore.setClasspathContainer(unboundPath, new IJavaProject[] {project}, new IClasspathContainer[] {new JREContainer(vm, newBinding)}, monitor); >+ JavaCore.setClasspathContainer(unboundPath, new IJavaProject[] {project}, new IClasspathContainer[] {new JREContainer(vm, newBinding, project)}, monitor); > } catch (CoreException e) { > throw new InvocationTargetException(e); > } >Index: ui/org/eclipse/jdt/internal/debug/ui/launcher/RuntimeClasspathEntryLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/RuntimeClasspathEntryLabelProvider.java,v >retrieving revision 1.38 >diff -u -r1.38 RuntimeClasspathEntryLabelProvider.java >--- ui/org/eclipse/jdt/internal/debug/ui/launcher/RuntimeClasspathEntryLabelProvider.java 8 May 2006 20:35:08 -0000 1.38 >+++ ui/org/eclipse/jdt/internal/debug/ui/launcher/RuntimeClasspathEntryLabelProvider.java 29 Nov 2006 00:03:20 -0000 >@@ -13,7 +13,6 @@ > > > import java.io.File; >-import com.ibm.icu.text.MessageFormat; > > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IResource; >@@ -40,6 +39,8 @@ > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.model.WorkbenchLabelProvider; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * Label provider for runtime classpath entries. > */ >@@ -186,7 +187,7 @@ > if (path.segmentCount() > 0 && path.segment(0).equals(JavaRuntime.JRE_CONTAINER)) { > IVMInstall vm = JavaRuntime.getVMInstall(path); > if (vm != null) { >- JREContainer container = new JREContainer(vm, path); >+ JREContainer container = new JREContainer(vm, path, project); > return container.getDescription(); > } > } >#P org.eclipse.jdt.launching >Index: launching/org/eclipse/jdt/internal/launching/JREContainerInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JREContainerInitializer.java,v >retrieving revision 1.39 >diff -u -r1.39 JREContainerInitializer.java >--- launching/org/eclipse/jdt/internal/launching/JREContainerInitializer.java 10 May 2006 16:25:11 -0000 1.39 >+++ launching/org/eclipse/jdt/internal/launching/JREContainerInitializer.java 29 Nov 2006 00:03:22 -0000 >@@ -52,7 +52,7 @@ > IVMInstall vm = resolveVM(containerPath); > JREContainer container = null; > if (vm != null) { >- container = new JREContainer(vm, containerPath); >+ container = new JREContainer(vm, containerPath, project); > } > JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project}, new IClasspathContainer[] {container}, null); > } >Index: launching/org/eclipse/jdt/internal/launching/JREContainer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JREContainer.java,v >retrieving revision 1.21 >diff -u -r1.21 JREContainer.java >--- launching/org/eclipse/jdt/internal/launching/JREContainer.java 8 May 2006 20:39:12 -0000 1.21 >+++ launching/org/eclipse/jdt/internal/launching/JREContainer.java 29 Nov 2006 00:03:22 -0000 >@@ -12,7 +12,6 @@ > > > import java.net.URL; >-import com.ibm.icu.text.MessageFormat; > import java.util.ArrayList; > import java.util.HashMap; > import java.util.List; >@@ -23,12 +22,16 @@ > import org.eclipse.jdt.core.IClasspathAttribute; > 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.IVMInstallChangedListener; > import org.eclipse.jdt.launching.JavaRuntime; > import org.eclipse.jdt.launching.LibraryLocation; > import org.eclipse.jdt.launching.PropertyChangeEvent; >+import org.eclipse.jdt.launching.environments.IExecutionEnvironment; >+ >+import com.ibm.icu.text.MessageFormat; > > /** > * JRE Container - resolves a classpath container variable to a JRE >@@ -46,6 +49,11 @@ > private IPath fPath = null; > > /** >+ * The project this container is for >+ */ >+ private IJavaProject fProject = null; >+ >+ /** > * Cache of classpath entries per VM install. Cleared when a VM changes. > */ > private static Map fgClasspathEntries = null; >@@ -53,12 +61,15 @@ > private static IAccessRule[] EMPTY_RULES = new IAccessRule[0]; > > /** >- * Returns the classpath entries associated with the given VM. >+ * Returns the classpath entries associated with the given VM >+ * in the context of the given path and project. > * > * @param vm >+ * @param containerPath the container path resolution is for >+ * @param project project the resolution is for > * @return classpath entries > */ >- private static IClasspathEntry[] getClasspathEntries(IVMInstall vm) { >+ private static IClasspathEntry[] getClasspathEntries(IVMInstall vm, IPath containerPath, IJavaProject project) { > if (fgClasspathEntries == null) { > fgClasspathEntries = new HashMap(10); > // add a listener to clear cached value when a VM changes or is removed >@@ -83,25 +94,37 @@ > } > IClasspathEntry[] entries = (IClasspathEntry[])fgClasspathEntries.get(vm); > if (entries == null) { >- entries = computeClasspathEntries(vm); >+ entries = computeClasspathEntries(vm, containerPath, project); > fgClasspathEntries.put(vm, entries); > } > return entries; > } > > /** >- * Computes the classpath entries associated with a VM - one entry per library. >+ * Computes the classpath entries associated with a VM - one entry per library >+ * in the context of the given path and project. > * > * @param vm >+ * @param containerPath the container path the resolution is for >+ * @param project the project the resolution is for. > * @return classpath entries > */ >- private static IClasspathEntry[] computeClasspathEntries(IVMInstall vm) { >+ private static IClasspathEntry[] computeClasspathEntries(IVMInstall vm, IPath containerPath, IJavaProject project) { > LibraryLocation[] libs = vm.getLibraryLocations(); > boolean overrideJavaDoc = false; > if (libs == null) { > libs = JavaRuntime.getLibraryLocations(vm); > overrideJavaDoc = true; > } >+ String id = JavaRuntime.getExecutionEnvironmentId(containerPath); >+ IAccessRule[][] rules = null; >+ if (id != null) { >+ // compute access rules for execution environment >+ IExecutionEnvironment environment = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(id); >+ if (environment != null) { >+ rules = environment.getAccessRules(vm, libs, project); >+ } >+ } > List entries = new ArrayList(libs.length); > for (int i = 0; i < libs.length; i++) { > if (!libs[i].getSystemLibraryPath().isEmpty()) { >@@ -123,28 +146,35 @@ > } else { > attributes = new IClasspathAttribute[]{JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toExternalForm())}; > } >- entries.add(JavaCore.newLibraryEntry(libs[i].getSystemLibraryPath(), sourcePath, rootPath, EMPTY_RULES, attributes, false)); >+ IAccessRule[] libRules = null; >+ if (rules != null) { >+ libRules = rules[i]; >+ } else { >+ libRules = EMPTY_RULES; >+ } >+ entries.add(JavaCore.newLibraryEntry(libs[i].getSystemLibraryPath(), sourcePath, rootPath, libRules, attributes, false)); > } > } > return (IClasspathEntry[])entries.toArray(new IClasspathEntry[entries.size()]); > } > > /** >- * Constructs a JRE classpath conatiner on the given VM install >+ * Constructs a JRE classpath container on the given VM install > * > * @param vm vm install - cannot be <code>null</code> > * @param path container path used to resolve this JRE > */ >- public JREContainer(IVMInstall vm, IPath path) { >+ public JREContainer(IVMInstall vm, IPath path, IJavaProject project) { > fVMInstall = vm; > fPath = path; >+ fProject = project; > } > > /** > * @see IClasspathContainer#getClasspathEntries() > */ > public IClasspathEntry[] getClasspathEntries() { >- return getClasspathEntries(fVMInstall); >+ return getClasspathEntries(fVMInstall, getPath(), fProject); > } > > /** >Index: schema/executionEnvironments.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/schema/executionEnvironments.exsd,v >retrieving revision 1.4 >diff -u -r1.4 executionEnvironments.exsd >--- schema/executionEnvironments.exsd 24 May 2006 20:04:00 -0000 1.4 >+++ schema/executionEnvironments.exsd 29 Nov 2006 00:03:22 -0000 >@@ -15,6 +15,7 @@ > <sequence> > <element ref="environment" minOccurs="0" maxOccurs="unbounded"/> > <element ref="analyzer" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="ruleParticipant" minOccurs="0" maxOccurs="unbounded"/> > </sequence> > <attribute name="point" type="string" use="required"> > <annotation> >@@ -62,6 +63,16 @@ > </appInfo> > </annotation> > </attribute> >+ <attribute name="ruleParticipant" type="string"> >+ <annotation> >+ <documentation> >+ the fully qualified name of a Java class that implements <code>org.eclipse.jdt.launching.environments.IAccessRuleParticipant</code>. When specified, this class is used to create access rules for VM libraries associated with this execution environment during classpath resolution. This participant creates rules first, followed by any <code>ruleParticipants</code> contributed as elements. This attribute was added in the 3.3 release. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.jdt.launching.environments.IAccessRuleParticipant"/> >+ </appInfo> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -87,6 +98,33 @@ > </complexType> > </element> > >+ <element name="ruleParticipant"> >+ <annotation> >+ <documentation> >+ This element was added in the 3.3 release. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ a unique identifier for this rule participant >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ the fully qualified name of a Java class that implements <code>org.eclipse.jdt.launching.environments.IAccessRuleParticipant</code>. When specified, this class is used to create access rules for VM libraries associated with this execution environment during classpath resolution. This participant creates after any <code>ruleParticipant</code> contributed as by an execution environment directly. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.jdt.launching.environments.IAccessRuleParticipant"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ > <annotation> > <appInfo> > <meta.section type="since"/> >@@ -122,7 +160,7 @@ > <meta.section type="implementation"/> > </appInfo> > <documentation> >- PDE (<code>org.eclispe.pde.core</code>) provides definitions and an analyzer for the following execution environments: >+ JDT (<code>org.eclispe.jdt.launching</code>) provides definitions and an analyzer for the following execution environments: > <ul> > <li>OSGi/Minimum-1.0</li> > <li>OSGi/Minimum-1.1</li> >Index: launching/org/eclipse/jdt/launching/environments/IExecutionEnvironment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/environments/IExecutionEnvironment.java,v >retrieving revision 1.6 >diff -u -r1.6 IExecutionEnvironment.java >--- launching/org/eclipse/jdt/launching/environments/IExecutionEnvironment.java 8 May 2006 20:39:13 -0000 1.6 >+++ launching/org/eclipse/jdt/launching/environments/IExecutionEnvironment.java 29 Nov 2006 00:03:22 -0000 >@@ -10,7 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.launching.environments; > >+import org.eclipse.jdt.core.IAccessRule; >+import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.LibraryLocation; > > /** > * An execution environment describes capabilities of >@@ -82,4 +85,18 @@ > * this environment > */ > public void setDefaultVM(IVMInstall vm); >+ >+ /** >+ * Returns a collection of access rules to be applied to the specified VM >+ * libraries for this execution environment in the context of the given project. >+ * An array of access rules is returned for each library specified by >+ * <code>libraries</code>, possibly empty. >+ * >+ * @param vm the vm that access rules are requested for >+ * @param libraries the libraries that access rules are requested for >+ * @param project the project the access rules are requested for or <code>null</code> if none >+ * @return a collection of arrays of access rules - one array per library >+ * @since 3.3 >+ */ >+ public IAccessRule[][] getAccessRules(IVMInstall vm, LibraryLocation[] libraries, IJavaProject project); > } >Index: launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironment.java,v >retrieving revision 1.7 >diff -u -r1.7 ExecutionEnvironment.java >--- launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironment.java 8 May 2006 20:39:13 -0000 1.7 >+++ launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironment.java 29 Nov 2006 00:03:22 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.launching.environments; > >-import com.ibm.icu.text.MessageFormat; > import java.util.ArrayList; > import java.util.HashSet; > import java.util.List; >@@ -20,6 +19,7 @@ > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jdt.core.IAccessRule; > import org.eclipse.jdt.core.IClasspathContainer; > import org.eclipse.jdt.core.IClasspathEntry; > import org.eclipse.jdt.core.IJavaModel; >@@ -29,8 +29,12 @@ > import org.eclipse.jdt.internal.launching.LaunchingPlugin; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.LibraryLocation; >+import org.eclipse.jdt.launching.environments.IAccessRuleParticipant; > import org.eclipse.jdt.launching.environments.IExecutionEnvironment; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * A contributed execution environment. > * >@@ -41,12 +45,17 @@ > private IConfigurationElement fElement; > > /** >- * Set of compatible vms - just the strictly compatible ones >+ * Environment specific rule participant or <code>null</code> if none. >+ */ >+ private IAccessRuleParticipant fRuleParticipant; >+ >+ /** >+ * Set of compatible vm's - just the strictly compatible ones > */ > private Set fStrictlyCompatible = new HashSet(); > > /** >- * All compatible vms >+ * All compatible vm's > */ > private List fCompatibleVMs = new ArrayList(); > >@@ -57,6 +66,10 @@ > > ExecutionEnvironment(IConfigurationElement element) { > fElement = element; >+ String attribute = fElement.getAttribute(EnvironmentsManager.RULE_PARTICIPANT_ELEMENT); >+ if (attribute != null) { >+ fRuleParticipant = new AccessRuleParticipant(fElement); >+ } > } > > private void init() { >@@ -171,4 +184,40 @@ > void initDefaultVM(IVMInstall vm) { > fDefault = vm; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.environments.IExecutionEnvironment#getAccessRules(org.eclipse.jdt.launching.IVMInstall, org.eclipse.jdt.launching.LibraryLocation[], org.eclipse.jdt.core.IJavaProject) >+ */ >+ public IAccessRule[][] getAccessRules(IVMInstall vm, LibraryLocation[] libraries, IJavaProject project) { >+ List[] libLists = new List[libraries.length]; // array of lists of access rules >+ for (int i = 0; i < libLists.length; i++) { >+ libLists[i] = new ArrayList(); >+ } >+ // check primary provider first >+ if (fRuleParticipant != null) { >+ processParticipant(fRuleParticipant, libLists, vm, libraries, project); >+ } >+ // check other participants >+ IAccessRuleParticipant[] participants = EnvironmentsManager.getDefault().getAccessRuleParticipants(); >+ for (int i = 0; i < participants.length; i++) { >+ processParticipant(participants[i], libLists, vm, libraries, project); >+ } >+ IAccessRule[][] allRules = new IAccessRule[libraries.length][]; >+ for (int i = 0; i < libLists.length; i++) { >+ allRules[i] = (IAccessRule[]) libLists[i].toArray(new IAccessRule[libLists[i].size()]); >+ } >+ return allRules; >+ } >+ >+ private void processParticipant(IAccessRuleParticipant participant, List[] collect, IVMInstall vm, LibraryLocation[] libraries, IJavaProject project) { >+ // TODO: use safe runnables >+ IAccessRule[][] accessRules = participant.getAccessRules(this, vm, libraries, project); >+ for (int i = 0; i < accessRules.length; i++) { >+ IAccessRule[] libRules = accessRules[i]; >+ List list = collect[i]; >+ for (int j = 0; j < libRules.length; j++) { >+ list.add(libRules[j]); >+ } >+ } >+ } > } >Index: launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java,v >retrieving revision 1.12 >diff -u -r1.12 EnvironmentsManager.java >--- launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java 21 Jun 2006 19:31:40 -0000 1.12 >+++ launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java 29 Nov 2006 00:03:22 -0000 >@@ -12,7 +12,6 @@ > > import java.io.ByteArrayInputStream; > import java.io.IOException; >-import com.ibm.icu.text.MessageFormat; > import java.util.ArrayList; > import java.util.Collection; > import java.util.HashMap; >@@ -38,6 +37,7 @@ > import org.eclipse.jdt.launching.PropertyChangeEvent; > import org.eclipse.jdt.launching.VMStandin; > import org.eclipse.jdt.launching.environments.CompatibleEnvironment; >+import org.eclipse.jdt.launching.environments.IAccessRuleParticipant; > import org.eclipse.jdt.launching.environments.IExecutionEnvironment; > import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; > import org.w3c.dom.Document; >@@ -46,6 +46,8 @@ > import org.w3c.dom.NodeList; > import org.xml.sax.SAXException; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * Utility class for execution environments. > * >@@ -53,6 +55,21 @@ > */ > public class EnvironmentsManager implements IExecutionEnvironmentsManager, IVMInstallChangedListener, IPropertyChangeListener { > >+ /** >+ * Extension configuration element name. >+ */ >+ private static final String ANALYZER_ELEMENT = "analyzer"; //$NON-NLS-1$ >+ >+ /** >+ * Extension configuration element name. >+ */ >+ static final String ENVIRONMENT_ELEMENT = "environment"; //$NON-NLS-1$ >+ >+ /** >+ * Extension configuration element name. >+ */ >+ static final String RULE_PARTICIPANT_ELEMENT = "ruleParticipant"; //$NON-NLS-1$ >+ > private static EnvironmentsManager fgManager = null; > > /** >@@ -66,6 +83,11 @@ > private List fEnvironments = null; > > /** >+ * List of access rule participants >+ */ >+ private List fRuleParticipants = null; >+ >+ /** > * Map of environments keyed by id > */ > private Map fEnvironmentsMap = null; >@@ -133,6 +155,17 @@ > return (IExecutionEnvironment[]) fEnvironments.toArray(new IExecutionEnvironment[fEnvironments.size()]); > } > >+ /** >+ * Returns all access rule participants that are not specific to an execution environment. >+ * >+ * @return all access rule participants that are not specific to an execution environment. >+ * @since 3.3 >+ */ >+ public synchronized IAccessRuleParticipant[] getAccessRuleParticipants() { >+ initializeExtensions(); >+ return (IAccessRuleParticipant[]) fRuleParticipants.toArray(new IAccessRuleParticipant[fRuleParticipants.size()]); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager#getEnvironment(java.lang.String) > */ >@@ -157,12 +190,13 @@ > IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchingPlugin.ID_PLUGIN, JavaRuntime.EXTENSION_POINT_EXECUTION_ENVIRONMENTS); > IConfigurationElement[] configs= extensionPoint.getConfigurationElements(); > fEnvironments = new ArrayList(); >+ fRuleParticipants = new ArrayList(); > fEnvironmentsMap = new HashMap(configs.length); > fAnalyzers = new HashMap(configs.length); > for (int i = 0; i < configs.length; i++) { > IConfigurationElement element = configs[i]; > String name = element.getName(); >- if (name.equals("environment")) { //$NON-NLS-1$ >+ if (name.equals(ENVIRONMENT_ELEMENT)) { > String id = element.getAttribute("id"); //$NON-NLS-1$ > if (id == null) { > LaunchingPlugin.log(MessageFormat.format("Execution environment must specify \"id\" attribute. Contributed by {0}.", new String[]{element.getContributor().getName()})); //$NON-NLS-1$ >@@ -171,13 +205,20 @@ > fEnvironments.add(env); > fEnvironmentsMap.put(id, env); > } >- } else if (name.equals("analyzer")) { //$NON-NLS-1$ >+ } else if (name.equals(ANALYZER_ELEMENT)) { > String id = element.getAttribute("id"); //$NON-NLS-1$ > if (id == null) { > LaunchingPlugin.log(MessageFormat.format("Execution environment analyzer must specify \"id\" attribute. Contributed by {0}", new String[]{element.getContributor().getName()})); //$NON-NLS-1$ > } else { > fAnalyzers.put(id, new Analyzer(element)); > } >+ } else if (name.equals(RULE_PARTICIPANT_ELEMENT)) { >+ String id = element.getAttribute("id"); //$NON-NLS-1$ >+ if (id == null) { >+ LaunchingPlugin.log(MessageFormat.format("Execution environment rule participant must specify \"id\" attribute. Contributed by {0}", new String[]{element.getContributor().getName()})); //$NON-NLS-1$ >+ } else { >+ fRuleParticipants.add(new AccessRuleParticipant(element)); >+ } > } > } > } >Index: launching/org/eclipse/jdt/internal/launching/environments/AccessRuleParticipant.java >=================================================================== >RCS file: launching/org/eclipse/jdt/internal/launching/environments/AccessRuleParticipant.java >diff -N launching/org/eclipse/jdt/internal/launching/environments/AccessRuleParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ launching/org/eclipse/jdt/internal/launching/environments/AccessRuleParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.environments; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.jdt.core.IAccessRule; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.internal.launching.LaunchingPlugin; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.LibraryLocation; >+import org.eclipse.jdt.launching.environments.IAccessRuleParticipant; >+import org.eclipse.jdt.launching.environments.IExecutionEnvironment; >+ >+/** >+ * Proxy to an access rule participant for an execution environment. >+ * >+ * @since 3.3 >+ */ >+class AccessRuleParticipant implements IAccessRuleParticipant { >+ >+ private IConfigurationElement fElement; >+ >+ private IAccessRuleParticipant fDelegate; >+ >+ /** >+ * Constructs a proxy to a rule participant contributed with the >+ * given configuration element. The element may be an >+ * <code>executionEnvironment</code> element or a <code>ruleParticipant</code> >+ * extension. >+ * >+ * @param element >+ */ >+ AccessRuleParticipant(IConfigurationElement element) { >+ fElement = element; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.environments.IAccessRuleParticipant#getAccessRules(org.eclipse.jdt.launching.environments.IExecutionEnvironment, org.eclipse.jdt.launching.IVMInstall, org.eclipse.jdt.launching.LibraryLocation[], org.eclipse.jdt.core.IJavaProject) >+ */ >+ public IAccessRule[][] getAccessRules(IExecutionEnvironment environment, IVMInstall vm, LibraryLocation[] libraries, IJavaProject project) { >+ try { >+ return getDelegate().getAccessRules(environment, vm, libraries, project); >+ } catch (CoreException e) { >+ LaunchingPlugin.log(e.getStatus()); >+ } >+ IAccessRule[][] rules = new IAccessRule[libraries.length][]; >+ for (int i = 0; i < rules.length; i++) { >+ rules[i] = new IAccessRule[0]; >+ } >+ return rules; >+ } >+ >+ private IAccessRuleParticipant getDelegate() throws CoreException { >+ if (fDelegate == null) { >+ if (fElement.getName().equals(EnvironmentsManager.ENVIRONMENT_ELEMENT)) { >+ fDelegate = (IAccessRuleParticipant) fElement.createExecutableExtension(EnvironmentsManager.RULE_PARTICIPANT_ELEMENT); >+ } else { >+ fDelegate = (IAccessRuleParticipant) fElement.createExecutableExtension("class"); //$NON-NLS-1$ >+ } >+ } >+ return fDelegate; >+ } >+ >+ /** >+ * Returns the id of this participant. >+ * >+ * @return participant id >+ */ >+ String getId() { >+ if (fElement.getName().equals(EnvironmentsManager.ENVIRONMENT_ELEMENT)) { >+ return fElement.getAttribute(EnvironmentsManager.RULE_PARTICIPANT_ELEMENT); >+ } else { >+ return fElement.getAttribute("id"); >+ } >+ } >+ >+} >Index: launching/org/eclipse/jdt/launching/environments/IAccessRuleParticipant.java >=================================================================== >RCS file: launching/org/eclipse/jdt/launching/environments/IAccessRuleParticipant.java >diff -N launching/org/eclipse/jdt/launching/environments/IAccessRuleParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ launching/org/eclipse/jdt/launching/environments/IAccessRuleParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.launching.environments; >+ >+import org.eclipse.jdt.core.IAccessRule; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.LibraryLocation; >+ >+/** >+ * Builds access rules for an execution environment. Contributed with >+ * an execution environment extension. >+ * <p> >+ * Client contributing an access rule participant may implement this interface. >+ * </p> >+ * @since 3.3 >+ */ >+public interface IAccessRuleParticipant { >+ >+ /** >+ * Returns a collection of access rules to be applied to the specified VM >+ * libraries and execution environment in the context of the given project. >+ * An array of access rules is returned for each library specified by >+ * <code>libraries</code>, possibly empty. >+ * >+ * @param environment the environment that access rules are requested for >+ * @param vm the vm that access rules are requested for >+ * @param libraries the libraries that access rules are requested for >+ * @param project the project the access rules are requested for or <code>null</code> if none >+ * @return a collection of arrays of access rules - one array per library >+ * @since 3.3 >+ */ >+ public IAccessRule[][] getAccessRules(IExecutionEnvironment environment, IVMInstall vm, LibraryLocation[] libraries, IJavaProject project); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 163444
:
54044
| 54683