KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > spi > RegistryContributor


1 /*******************************************************************************
2  * Copyright (c) 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.spi;
12
13 import org.eclipse.core.runtime.IContributor;
14
15 /**
16  * This class describes a registry contributor which is an entity that supplies information
17  * to the extension registry. Depending on the registry strategy, contributor might delegate
18  * some of its functionality to a "host" contributor. For instance, OSGi registry strategy
19  * uses "host" contributor to delegate some functionality from fragments to plug-ins.
20  * <p>
21  * This class can be instantiated by the registry Service Providers.
22  * </p><p>
23  * This class can be used without OSGi running.
24  * </p><p>
25  * This class can not be extended.
26  * </p><p>
27  * <b>Note:</b> This class/interface is part of an interim API that is still under
28  * development and expected to change significantly before reaching stability.
29  * It is being made available at this early stage to solicit feedback from pioneering
30  * adopters on the understanding that any code that uses this API will almost certainly
31  * be broken (repeatedly) as the API evolves.
32  * </p>
33  * @since org.eclipse.equinox.registry 3.2
34  */

35 public final class RegistryContributor implements IContributor {
36
37     /**
38      * Actual ID of the contributor (e.g., "12"). IDs are expected to be unique in the workspace.
39      */

40     private String JavaDoc actualContributorId;
41
42     /**
43      * Actual name of the contributor (e.g., "org.eclipse.core.runtime.fragment").
44      */

45     private String JavaDoc actualContributorName;
46
47     /**
48      * ID associated with the entity "in charge" of the contributor (e.g., "1"). IDs are expected
49      * to be unique in the workspace. If contributor does not rely on a host, this value should be
50      * the same as the actual contributor ID.
51      */

52     private String JavaDoc hostId;
53
54     /**
55      * Name of the entity "in charge" of the contributor (e.g. "org.eclipse.core.runtime").
56      * If contributor does not rely on a host, this value should be the same as the actual
57      * contributor name.
58      */

59     private String JavaDoc hostName;
60
61     /**
62      * Constructor for the registry contributor.
63      * <p>
64      * The actual ID is a string identifier for the contributor (e.g., "12") and is expected
65      * to be unique within the workspace. The actual ID of the contributor must not
66      * be <code>null</code>.
67      * </p><p>
68      * The actual name is the name associated with the contributor
69      * (e.g., "org.eclipse.core.runtime.fragment"). The actual name of the contributor must
70      * not be <code>null</code>.
71      * </p><p>
72      * The host ID is the identifier associated with the entity "in charge" of the contributor
73      * (e.g., "1"). IDs are expected to be unique in the workspace. If contributor does not
74      * rely on a host, then <code>null</code> should be used as the host ID.
75      * </p><p>
76      * The host name is the name of the entity "in charge" of the contributor
77      * (e.g., "org.eclipse.core.runtime"). If contributor does not rely on a host, then
78      * <code>null</code> should be used as the host name.
79      * </p><p>
80      * There should be 1-to-1 mapping between the contributor and the contibutor ID.
81      * The IDs (either actual or host) can not be re-used in the same registry.
82      * For example, if ID of 12 was used to identify contributorA, the ID of 12 can not
83      * be used to identify contributorB or a host for the contributorC.
84      * </p>
85      * @param actualId contributor identifier
86      * @param actualName name of the contributor
87      * @param hostId id associated with the host, or <code>null</code>
88      * @param hostName name of the host, or <code>null</code>
89      */

90     public RegistryContributor(String JavaDoc actualId, String JavaDoc actualName, String JavaDoc hostId, String JavaDoc hostName) {
91         this.actualContributorId = actualId;
92         this.actualContributorName = actualName;
93         if (hostId != null) {
94             this.hostId = hostId;
95             this.hostName = hostName;
96         } else {
97             this.hostId = actualId;
98             this.hostName = actualName;
99         }
100     }
101
102     /**
103      * Provides actual ID associated with the registry contributor (e.g., "12"). IDs are expected
104      * to be unique in the workspace.
105      *
106      * @return actual ID of the registry contributor
107      */

108     public String JavaDoc getActualId() {
109         return actualContributorId;
110     }
111
112     /**
113      * Provides actual name of the registry contributor (e.g., "org.eclipe.core.runtime.fragment").
114      *
115      * @return actual name of the registry contributor
116      */

117     public String JavaDoc getActualName() {
118         return actualContributorName;
119     }
120
121     /**
122      * Provides ID associated with the entity "in charge" of the contributor (e.g., "1"). IDs are expected
123      * to be unique in the workspace. If contributor does not rely on a host, this value should be
124      * the same as the actual contributor ID.
125      *
126      * @return id of the registry contributor
127      */

128     public String JavaDoc getId() {
129         return hostId;
130     }
131
132     /**
133      * Provides name of the entity "in charge" of the contributor (e.g., "org.eclipse.core.runtime").
134      * If contributor does not rely on a host, this value should be the same as the actual contributor name.
135      *
136      * @return name of the registry contributor
137      */

138     public String JavaDoc getName() {
139         return hostName;
140     }
141
142     /* (non-Javadoc)
143      * @see java.lang.Object#toString()
144      */

145     public String JavaDoc toString() {
146         return actualContributorName + "[" + actualContributorId + "]"; //$NON-NLS-1$ //$NON-NLS-2$
147
}
148 }
149
Popular Tags