KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > launching > RuntimeClasspathEntryResolver


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.launching;
12
13  
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IConfigurationElement;
16 import org.eclipse.debug.core.ILaunchConfiguration;
17 import org.eclipse.jdt.core.IClasspathEntry;
18 import org.eclipse.jdt.core.IJavaProject;
19 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
20 import org.eclipse.jdt.launching.IRuntimeClasspathEntryResolver;
21 import org.eclipse.jdt.launching.IRuntimeClasspathEntryResolver2;
22 import org.eclipse.jdt.launching.IVMInstall;
23
24 /**
25  * Proxy to a runtime classpath entry resolver extension.
26  */

27 public class RuntimeClasspathEntryResolver implements IRuntimeClasspathEntryResolver2 {
28
29     private IConfigurationElement fConfigurationElement;
30     
31     private IRuntimeClasspathEntryResolver fDelegate;
32     
33     /**
34      * Constructs a new resolver on the given configuration element
35      */

36     public RuntimeClasspathEntryResolver(IConfigurationElement element) {
37         fConfigurationElement = element;
38     }
39     
40     /**
41      * @see IRuntimeClasspathEntryResolver#resolveRuntimeClasspathEntry(IRuntimeClasspathEntry, ILaunchConfiguration)
42      */

43     public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry, ILaunchConfiguration configuration) throws CoreException {
44         return getResolver().resolveRuntimeClasspathEntry(entry, configuration);
45     }
46     
47     /**
48      * Returns the resolver delegate (and creates if required)
49      */

50     protected IRuntimeClasspathEntryResolver getResolver() throws CoreException {
51         if (fDelegate == null) {
52             fDelegate = (IRuntimeClasspathEntryResolver)fConfigurationElement.createExecutableExtension("class"); //$NON-NLS-1$
53
}
54         return fDelegate;
55     }
56     
57     /**
58      * Returns the variable name this resolver is registered for, or <code>null</code>
59      */

60     public String JavaDoc getVariableName() {
61         return fConfigurationElement.getAttribute("variable"); //$NON-NLS-1$
62
}
63     
64     /**
65      * Returns the container id this resolver is registered for, or <code>null</code>
66      */

67     public String JavaDoc getContainerId() {
68         return fConfigurationElement.getAttribute("container"); //$NON-NLS-1$
69
}
70     
71     /**
72      * Returns the runtime classpath entry id this resolver is registered
73      * for,or <code>null</code> if none.
74      */

75     public String JavaDoc getRuntimeClasspathEntryId() {
76         return fConfigurationElement.getAttribute("runtimeClasspathEntryId"); //$NON-NLS-1$
77
}
78
79     /**
80      * @see IRuntimeClasspathEntryResolver#resolveVMInstall(IClasspathEntry)
81      */

82     public IVMInstall resolveVMInstall(IClasspathEntry entry) throws CoreException {
83         return getResolver().resolveVMInstall(entry);
84     }
85
86     /**
87      * @see IRuntimeClasspathEntryResolver#resolveRuntimeClasspathEntry(IRuntimeClasspathEntry, IJavaProject)
88      */

89     public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry, IJavaProject project) throws CoreException {
90         return getResolver().resolveRuntimeClasspathEntry(entry, project);
91     }
92
93     /* (non-Javadoc)
94      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntryResolver2#isVMInstallReference(org.eclipse.jdt.core.IClasspathEntry)
95      */

96     public boolean isVMInstallReference(IClasspathEntry entry) {
97         try {
98             IRuntimeClasspathEntryResolver resolver = getResolver();
99             if (resolver instanceof IRuntimeClasspathEntryResolver2) {
100                 IRuntimeClasspathEntryResolver2 resolver2 = (IRuntimeClasspathEntryResolver2) resolver;
101                 return resolver2.isVMInstallReference(entry);
102             } else {
103                 return resolver.resolveVMInstall(entry) != null;
104             }
105         } catch (CoreException e) {
106             return false;
107         }
108     }
109
110 }
111
Popular Tags