KickJava   Java API By Example, From Geeks To Geeks.

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


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

43 public interface IExtension {
44     /**
45      * Returns all configuration elements declared by this extension.
46      * These elements are a direct reflection of the configuration
47      * markup supplied in the manifest (<code>plugin.xml</code>)
48      * file for the plug-in that declares this extension.
49      * Returns an empty array if this extension does not declare any
50      * configuration elements.
51      *
52      * @return the configuration elements declared by this extension
53      * @throws InvalidRegistryObjectException if this extension is no longer valid
54      */

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

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

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

115     public IContributor getContributor() throws InvalidRegistryObjectException;
116
117     /**
118      * Returns the unique identifier of the extension point
119      * to which this extension should be contributed.
120      *
121      * @return the unique identifier of the relevant extension point
122      * @throws InvalidRegistryObjectException if this extension is no longer valid
123      */

124     public String JavaDoc getExtensionPointUniqueIdentifier() throws InvalidRegistryObjectException;
125
126     /**
127      * Returns a displayable label for this extension.
128      * Returns the empty string if no label for this extension
129      * is specified in the plug-in manifest file.
130      * <p> Note that any translation specified in the plug-in manifest
131      * file is automatically applied.
132      * <p>
133      *
134      * @return a displayable string label for this extension,
135      * possibly the empty string
136      * @throws InvalidRegistryObjectException if this extension is no longer valid
137      */

138     public String JavaDoc getLabel() throws InvalidRegistryObjectException;
139
140     /**
141      * Returns the simple identifier of this extension, or <code>null</code>
142      * if this extension does not have an identifier.
143      * This identifier is specified in the plug-in manifest (<code>plugin.xml</code>)
144      * file as a non-empty string containing no period characters
145      * (<code>'.'</code>) and must be unique within the namespace.
146      *
147      * @return the simple identifier of the extension (e.g. <code>"main"</code>)
148      * or <code>null</code>
149      * @throws InvalidRegistryObjectException if this extension is no longer valid
150      */

151     public String JavaDoc getSimpleIdentifier() throws InvalidRegistryObjectException;
152
153     /**
154      * Returns the unique identifier of this extension, or <code>null</code>
155      * if this extension does not have an identifier.
156      * If available, this identifier is unique within the plug-in registry, and
157      * is composed of the namespace where this extension
158      * was declared and this extension's simple identifier.
159      *
160      * @return the unique identifier of the extension
161      * (e.g. <code>"com.example.acme.main"</code>), or <code>null</code>
162      * @throws InvalidRegistryObjectException if this extension is no longer valid
163      */

164     public String JavaDoc getUniqueIdentifier() throws InvalidRegistryObjectException;
165
166     /* (non-javadoc)
167      * @see Object#equals(java.lang.Object)
168      */

169     public boolean equals(Object JavaDoc o);
170
171     /**
172      * Returns whether this extension object is valid.
173      *
174      * @return <code>true</code> if the object is valid, and <code>false</code>
175      * if it is no longer valid
176      * @since 3.1
177      */

178     public boolean isValid();
179 }
180
Popular Tags