|
Eclipse Platform Release 3.2 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.runtime.spi.RegistryStrategy
This is the basic registry strategy. It describes how the registry does logging, message translation, extra start/stop processing, event scheduling, caching, and debugging.
In this strategy:
System.out
;'%'/;
This class can be used without OSGi running.
This class can be overridden and/or instantiated by clients.
Note: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Constructor Summary | |
---|---|
RegistryStrategy(File[] storageDirs,
boolean[] cacheReadOnly)
Constructor for this default registry strategy. |
Method Summary | |
---|---|
boolean |
cacheLazyLoading()
Specifies if lazy cache loading is used. |
boolean |
cacheUse()
Specifies if the extension registry should use cache to store registry data between invocations. |
Object |
createExecutableExtension(RegistryContributor contributor,
String className,
String overridenContributorName)
Creates an executable extension. |
boolean |
debug()
Override this method to specify debug requirements to the registry. |
boolean |
debugRegistryEvents()
Override this method to specify debug requirements for the registry event processing. |
long |
getContainerTimestamp()
This method is called as a part of the registry cache validation. |
long |
getContributionsTimestamp()
This method is called as a part of the registry cache validation. |
int |
getLocationsLength()
Returns the number of possible cache locations for this registry. |
File |
getStorage(int index)
Returns the possible registry cache location identified by the index. |
SAXParserFactory |
getXMLParser()
Returns the parser used by the registry to parse descriptions of extension points and extensions. |
boolean |
isCacheReadOnly(int index)
Returns the read-only status of the registry cache location. |
void |
log(IStatus status)
Override this method to provide customized logging functionality to the registry. |
void |
onStart(IExtensionRegistry registry)
Override this method to provide additional processing performed when the registry is created and started. |
void |
onStop(IExtensionRegistry registry)
Override this method to provide additional processing to be performed just before the registry is stopped. |
static IStatus |
processChangeEvent(Object[] listeners,
Map deltas,
Object registry)
This method performs actual processing of the registry change event. |
void |
scheduleChangeEvent(Object[] listeners,
Map deltas,
Object registry)
Override this method to customize scheduling of an extension registry event. |
String |
translate(String key,
ResourceBundle resources)
Translates key using the supplied resource bundle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RegistryStrategy(File[] storageDirs, boolean[] cacheReadOnly)
The strategy sequentially checks the array of storage directories to
discover the location of the registry cache formed by previous invocations of the extension
registry. Once found, the location is used to store registry cache. If this value
is null
then caching of the registry content is disabled.
The cache read-only array is an array the same length as the storage directory array.
It contains boolean values indicating whether or not each storage directory is read-only.
If the value at an index is true
then the location at the corresponding index
in the storage directories array is read-only; if false
then the cache location
is read-write. The array can be null
if the storageDirs
parameter
is null
.
storageDirs
- array of file system directories, or null
cacheReadOnly
- array of read only attributes, or null
Method Detail |
public final int getLocationsLength()
public final File getStorage(int index)
index
- index of the possible registry location
public final boolean isCacheReadOnly(int index)
index
- the index of the possible registry location
true
if the location is read only and
false
if the location is read/writepublic void log(IStatus status)
This method writes a message to System.out
in the following format:
[Error|Warning|Log]: Main error message [Error|Warning|Log]: Child error message 1 ... [Error|Warning|Log]: Child error message N
status
- the status to logpublic String translate(String key, ResourceBundle resources)
null
.
The default translation routine assumes that keys are prefixed with '%'. If no resource bundle is present, the key itself (without leading '%') is returned. There is no decoding for the leading '%%'.
key
- message key to be translatedresources
- resource bundle, or null
null
public void onStart(IExtensionRegistry registry)
super.onStart()
at the beginning of the processing.
registry
- the extension registry being startedpublic void onStop(IExtensionRegistry registry)
super.onStop()
at the end of the processing.
registry
- the extension registry being stoppedpublic Object createExecutableExtension(RegistryContributor contributor, String className, String overridenContributorName) throws CoreException
This method receives the contributor of the executable extension and, possibly,
an optional contributor name if specified by the executable extension. The overridden
contributor name might be null
.
In this implementation registry attempts to instantiate the class specified via
the class name (must not be null
) using standard Java reflection mechanism.
This method assumes that such class has a default constructor with no arguments.
contributor
- the contributor of this executable extensionclassName
- the name of the class to be instantiatedoverridenContributorName
- the contributor to be used, or null
if not specified
null
CoreException
- if there was a problem creating the executable extensionIConfigurationElement.createExecutableExtension(String)
,
IExecutableExtension
public void scheduleChangeEvent(Object[] listeners, Map deltas, Object registry)
RegistryStrategy.processChangeEvent(listeners, deltas, registry);
In the default implementation, the method registry events are executed in a queue on a separate thread (i.e. asynchronously, sequentially).
listeners
- the list of active listeners (thread safe); may not be null
deltas
- the registry deltas (thread safe); may not be null
registry
- the extension registry (NOT thread safe); may not be null
public static final IStatus processChangeEvent(Object[] listeners, Map deltas, Object registry)
null
if an unexpected registry type was encountered.
listeners
- the list of active listeners; may not be null
deltas
- the extension registry deltas; may not be null
registry
- the extension registry; may not be null
null
public boolean debug()
false
indicating that debug functionality
is turned off.
Note that in a general case the extension registry plug-in doesn't depend on OSGI and therefore cannot use Eclipse .options files to discover debug options.
true
if debug logging and validation should be performed and
false
otherwisepublic boolean debugRegistryEvents()
false
indicating that
debug of the registry events is turned off.
Note that in a general case the extension registry plug-in doesn't depend on OSGI and therefore cannot use Eclipse .options files to discover debug options.
true
if debug logging and validation of the registry events
should be performed and false
otherwisepublic boolean cacheUse()
The default implementation enables caching returning true
.
true
if the cache should be used and false
otherwisepublic boolean cacheLazyLoading()
The default implementation specifies that lazy cache loading is going to be used
and therefore returns true
.
true
if lazy cache loading is used and false
otherwisepublic long getContainerTimestamp()
The method produces a number that corresponds to the current state of the data stored by the container. Increment the stamp if the data stored in the container has been updated so that the data cached by the registry is no longer valid. For instance, in Eclipse addition or removal of a bundle results in the number returned by this method being incremented. As a result, if a bundle that contributed plugin.xml into the extension registry was modified, the state doesn't match the state stored in the registry cache. In this case the cache content becomes invalid and the registry needs to be re-created from the original data.
Generally, treat this number as a hash code for the data stored in the registry. It stays the same as long as the registry content is not changing. It becomes a different number as the registry content gets modified.
Return 0 to indicate that state verification is not required.
public long getContributionsTimestamp()
The method calculates a number describing time when the contributions cached by the registry were last modified. For instance, in the Eclipse registry this number is calculated as a function of the time when plugin.xml files have been modified. If the number is not the same as the number stored in the cache, it means that plugin.xml file(s) have been updated and the cached information is no longer valid.
Generally, treat this number as a hash code for the time of modifications of contributions stored in the registry. It stays the same as long as the contributions aren't changing. It becomes a different number when contributions are modified.
Return 0 to indicate that no time stamp verification is required.
public SAXParserFactory getXMLParser()
null
.
IExtensionRegistry.addContribution(java.io.InputStream, IContributor, boolean, String, ResourceBundle, Object)
|
Eclipse Platform Release 3.2 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.