KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > IExtensionPoint


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.core.runtime;
12
13 /**
14  * An extension point declared in a plug-in.
15  * Except for the list of extensions plugged in to it, the information
16  * available for an extension point is obtained from the declaring plug-in's
17  * manifest (<code>plugin.xml</code>) file.
18  * <p>
19  * These registry objects are intended for relatively short-term use. Clients that
20  * deal with these objects must be aware that they may become invalid if the
21  * declaring plug-in is updated or uninstalled. If this happens, all methods except
22  * {@link #isValid()} will throw {@link InvalidRegistryObjectException}.
23  * For extension point objects, the most common case is code in a plug-in dealing
24  * with one of the extension points it declares. These extension point objects are
25  * guaranteed to be valid while the plug-in is active. Code in a plug-in that has
26  * declared that it is not dynamic aware (or not declared anything) can also safely
27  * ignore this issue, since the registry would not be modified while it is
28  * active. However, code in a plug-in that declares that it is dynamic aware
29  * must be careful if it access the extension point object of a different plug-in,
30  * because it's at risk if that other plug-in is removed. Similarly,
31  * tools that analyze or display the extension registry are vulnerable.
32  * Client code can pre-test for invalid objects by calling {@link #isValid()},
33  * which never throws this exception. However, pre-tests are usually not sufficient
34  * because of the possibility of the extension point object becoming invalid as a
35  * result of a concurrent activity. At-risk clients must treat
36  * <code>InvalidRegistryObjectException</code> as if it were a checked exception.
37  * Also, such clients should probably register a listener with the extension registry
38  * so that they receive notification of any changes to the registry.
39  * </p><p>
40  * This interface can be used without OSGi running.
41  * </p><p>
42  * This interface is not intended to be implemented by clients.
43  * </p>
44  */

45 public interface IExtensionPoint {
46     /**
47      * Returns all configuration elements from all extensions configured
48      * into this extension point. Returns an empty array if this extension
49      * point has no extensions configured, or none of the extensions
50      * contain configuration elements.
51      *
52      * @return the configuration elements for all extension configured
53      * into this extension point
54      * @throws InvalidRegistryObjectException if this extension point is no longer valid
55      */

56     public IConfigurationElement[] getConfigurationElements() throws InvalidRegistryObjectException;
57
58     /**
59      * Returns the namespace for this extension point. This value can be used
60      * in various global facilities to discover this extension point's provider.
61      *
62      * @return the namespace for this extension point
63      * @throws InvalidRegistryObjectException if this extension point is no longer valid
64      * @see IExtensionRegistry
65      * @since 3.0
66      * @deprecated As namespace is no longer restricted to the contributor name,
67      * use {@link #getNamespaceIdentifier()} to obtain namespace name or {@link #getContributor()}
68      * to get the name of the contributor of this registry element.
69      * <p>
70      * In the past namespace was dictated by the name of the bundle. If bundle <code>org.abc</code>
71      * contributed registry element with Id of <code>MyId</code>, the namespace of
72      * the element was always set to <code>org.abc</code>, producing the qualified name of
73      * <code>org.abc.MyId</code>.
74      * </p><p>
75      * The namespace used to be the same as the bundle name. As a result, the {@link #getNamespace()}
76      * method was used both to obtain the name of the bundle and to obtain the namespace of a registry
77      * element.
78      * </p><p>
79      * Since 3.2, the extension registry allows elements to specify qualified name. The extension point
80      * of the plug-in <code>org.abc</code> could specify <code>org.zzz.MyExtPoint</code> as
81      * an Id. In this case, namespace name is <code>org.zzz</code>, but the contributor
82      * name is <code>org.abc</code>.
83      * </p><p>
84      * (The use of a simple Id is still a preferred way. Whenever possible, specify only the simple
85      * Id and let runtime take care of the rest.)
86      * </p><p>
87      * If your code used the {@link #getNamespace()} to obtain the name of the contributing bundle,
88      * use {@link #getContributor()}. The typical usage pattern here is to find a bundle name to obtain
89      * some information from the corresponding OSGi bundle. For example, deducing the file location
90      * specified as a relative path to the bundle install location would fall into this group.
91      * </p><p>
92      * If your code used the {@link #getNamespace()} to obtain the namespace of the registry element,
93      * use {@link #getNamespaceIdentifier()}. Typically, this is the case when code is trying to process
94      * registry elements belonging to some logical group. For example, processing notifications for all
95      * elements belonging to the <code>org.abc</code> namespace would fall into this category.
96      * </p>
97      */

98     public String JavaDoc getNamespace() throws InvalidRegistryObjectException;
99
100     /**
101      * Returns the namespace name for this extension point.
102      *
103      * @return the namespace name for this extension point
104      * @throws InvalidRegistryObjectException if this extension point is no longer valid
105      * @since org.eclipse.equinox.registry 3.2
106      */

107     public String JavaDoc getNamespaceIdentifier() throws InvalidRegistryObjectException;
108
109     /**
110      * Returns the contributor of this extension point.
111      *
112      * @return the contributor for this extension point
113      * @throws InvalidRegistryObjectException if this extension point is no longer valid
114      * @since org.eclipse.equinox.registry 3.2
115      */

116     public IContributor getContributor() throws InvalidRegistryObjectException;
117
118     /**
119      * Returns the extension with the given unique identifier configured into
120      * this extension point, or <code>null</code> if there is no such extension.
121      * Since an extension might not have an identifier, some extensions
122      * can only be found via the <code>getExtensions</code> method.
123      *
124      * @param extensionId the unique identifier of an extension
125      * (e.g. <code>"com.example.acme.main"</code>).
126      * @return an extension, or <code>null</code>
127      * @throws InvalidRegistryObjectException if this extension point is no longer valid
128      */

129     public IExtension getExtension(String JavaDoc extensionId) throws InvalidRegistryObjectException;
130
131     /**
132      * Returns all extensions configured into this extension point.
133      * Returns an empty array if this extension point has no extensions.
134      *
135      * @return the extensions configured into this extension point
136      * @throws InvalidRegistryObjectException if this extension point is no longer valid
137      */

138     public IExtension[] getExtensions() throws InvalidRegistryObjectException;
139
140     /**
141      * Returns a displayable label for this extension point.
142      * Returns the empty string if no label for this extension point
143      * is specified in the plug-in manifest file.
144      * <p> Note that any translation specified in the plug-in manifest
145      * file is automatically applied.
146      * </p>
147      *
148      * @return a displayable string label for this extension point,
149      * possibly the empty string
150      * @throws InvalidRegistryObjectException if this extension point is no longer valid
151      */

152     public String JavaDoc getLabel() throws InvalidRegistryObjectException;
153
154     /**
155      * Returns reference to the extension point schema. The schema
156      * reference is returned as a URL path relative to the plug-in
157      * installation URL.
158      * Returns the empty string if no schema for this extension point
159      * is specified in the plug-in manifest file.
160      *
161      * @return a relative URL path, or an empty string
162      * @throws InvalidRegistryObjectException if this extension point is no longer valid
163      */

164     public String JavaDoc getSchemaReference() throws InvalidRegistryObjectException;
165
166     /**
167      * Returns the simple identifier of this extension point.
168      * This identifier is a non-empty string containing no
169      * period characters (<code>'.'</code>) and is guaranteed
170      * to be unique within the namespace.
171      *
172      * @return the simple identifier of the extension point (e.g. <code>"builders"</code>)
173      * @throws InvalidRegistryObjectException if this extension point is no longer valid
174      */

175     public String JavaDoc getSimpleIdentifier() throws InvalidRegistryObjectException;
176
177     /**
178      * Returns the unique identifier of this extension point.
179      * This identifier is unique within the plug-in registry, and
180      * is composed of the namespace for this extension point
181      * and this extension point's simple identifier.
182      *
183      *
184      * @return the unique identifier of the extension point
185      * (e.g. <code>"org.eclipse.core.resources.builders"</code>)
186      * @throws InvalidRegistryObjectException if this extension point is no longer valid
187      */

188     public String JavaDoc getUniqueIdentifier() throws InvalidRegistryObjectException;
189
190     /* (non-javadoc)
191      * @see Object#equals(java.lang.Object)
192      */

193     public boolean equals(Object JavaDoc o);
194
195     /**
196      * Returns whether this extension point object is valid.
197      *
198      * @return <code>true</code> if the object is valid, and <code>false</code>
199      * if it is no longer valid
200      * @since 3.1
201      */

202     public boolean isValid();
203 }
204
Popular Tags