org.eclipse.core.runtime.internal.adaptor
Class EclipseStorageHook

java.lang.Object
  extended by org.eclipse.core.runtime.internal.adaptor.EclipseStorageHook
All Implemented Interfaces:
HookConfigurator, StorageHook, KeyedElement

public final class EclipseStorageHook
extends java.lang.Object
implements StorageHook, HookConfigurator


Field Summary
static int HASHCODE
           
static java.lang.String KEY
           
 
Constructor Summary
EclipseStorageHook()
           
 
Method Summary
 void addHooks(HookRegistry hookRegistry)
          Adds hooks to the specified hook registry.
 boolean compare(KeyedElement other)
          Compares this element with a specified element
 void copy(StorageHook storageHook)
          Copies the data from the specified storage hook into this storage hook.
 StorageHook create(BaseData bundledata)
          Creates an uninitialized storage hook for the specified bundledata.
 boolean forgetStartLevelChange(int startlevel)
          Gets called by a base data during BundleData.setStartLevel(int).
 boolean forgetStatusChange(int status)
          Gets called by a base data during BundleData.setStatus(int).
 FrameworkAdaptor getAdaptor()
           
 BaseData getBaseData()
           
 java.lang.String getBuddyList()
           
 java.util.Dictionary getGeneratedManifest()
           
 java.lang.Object getKey()
          Returns the key for this element
 int getKeyHashCode()
          Returns the hash code of the key
 java.lang.String[] getLazyStartExcludes()
           
 java.lang.String[] getLazyStartIncludes()
           
 java.util.Dictionary getManifest(boolean firstLoad)
          Returns the manifest for the data in this storage hook, or null if this hook does not provide the manifest.
 long getManifestTimeStamp()
           
 byte getManifestType()
           
 java.lang.String getPluginClass()
           
 java.lang.String getRegisteredBuddyList()
           
 int getStorageVersion()
          Returns the storage version of this storage hook.
 boolean hasPackageInfo()
           
 void initialize(java.util.Dictionary manifest)
          Initializes this storage hook with the content of the specified bundle manifest.
 boolean isAutoStartable()
          Checks whether this bundle is auto started for all resource/class loads or only for a subset of resource/classloads
 boolean isLazyStart()
           
 StorageHook load(BaseData target, java.io.DataInputStream in)
          Creates a new storage hook and loads the data from the specified input stream into the storage hook.
 boolean matchDNChain(java.lang.String pattern)
          Gets called by a base data during BundleData.matchDNChain(String).
 void save(java.io.DataOutputStream out)
          Saves the data from this storage hook into the specified output stream.
 void validate()
          Validates the data in this storage hook, if the data is invalid then an illegal state exception is thrown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static final java.lang.String KEY

HASHCODE

public static final int HASHCODE
Constructor Detail

EclipseStorageHook

public EclipseStorageHook()
Method Detail

getStorageVersion

public int getStorageVersion()
Description copied from interface: StorageHook
Returns the storage version of this storage hook. This version is used by the storage to check the consistency of cached persistent data. Any time a storage hook changes the format of its persistent data the storage version should be incremented.

Specified by:
getStorageVersion in interface StorageHook
Returns:
the storage version of this storage hook

create

public StorageHook create(BaseData bundledata)
                   throws BundleException
Description copied from interface: StorageHook
Creates an uninitialized storage hook for the specified bundledata. This method is called when a bundle is installed or updated. The returned storage hook will be used for the new contents of the bundle. The returned hook will have its StorageHook.initialize(Dictionary) method called to initialize the storage hook.

Specified by:
create in interface StorageHook
Parameters:
bundledata - a base data the created storage hook will be associated with
Returns:
an uninitialized storage hook
Throws:
BundleException - if any error occurs

initialize

public void initialize(java.util.Dictionary manifest)
                throws BundleException
Description copied from interface: StorageHook
Initializes this storage hook with the content of the specified bundle manifest. This method is called when a bundle is installed or updated.

Specified by:
initialize in interface StorageHook
Parameters:
manifest - the bundle manifest to load into this storage hook
Throws:
BundleException - if any error occurs
See Also:
StorageHook.create(BaseData), StorageHook.copy(StorageHook)

load

public StorageHook load(BaseData target,
                        java.io.DataInputStream in)
                 throws java.io.IOException
Description copied from interface: StorageHook
Creates a new storage hook and loads the data from the specified input stream into the storage hook. This method is called during startup to load all the persistently installed bundles.

It is important that this method and the StorageHook.save(DataOutputStream) method stay in sync. This method must be able to successfully read the data saved by the StorageHook.save(DataOutputStream) method.

Specified by:
load in interface StorageHook
Parameters:
target - a base data the loaded storage hook will be associated with
in - an input stream used to load the storage hook's data from.
Returns:
a loaded storage hook
Throws:
java.io.IOException - if any error occurs
See Also:
StorageHook.save(DataOutputStream)

save

public void save(java.io.DataOutputStream out)
          throws java.io.IOException
Description copied from interface: StorageHook
Saves the data from this storage hook into the specified output stream. This method is called if some persistent data has changed for the bundle.

It is important that this method and the StorageHook.load(BaseData, DataInputStream) method stay in sync. This method must be able to save data which the StorageHook.load(BaseData, DataInputStream) method can ready successfully.

Specified by:
save in interface StorageHook
Parameters:
out - an output stream used to save the storage hook's data from.
Throws:
java.io.IOException - if any error occurs
See Also:
StorageHook.load(BaseData, DataInputStream)

getKeyHashCode

public int getKeyHashCode()
Description copied from interface: KeyedElement
Returns the hash code of the key

Specified by:
getKeyHashCode in interface KeyedElement
Returns:
the hash code of the key

compare

public boolean compare(KeyedElement other)
Description copied from interface: KeyedElement
Compares this element with a specified element

Specified by:
compare in interface KeyedElement
Parameters:
other - the element to compare with
Returns:
returns true if the specified element equals this element

getKey

public java.lang.Object getKey()
Description copied from interface: KeyedElement
Returns the key for this element

Specified by:
getKey in interface KeyedElement
Returns:
the key for this element

isLazyStart

public boolean isLazyStart()

getLazyStartExcludes

public java.lang.String[] getLazyStartExcludes()

getLazyStartIncludes

public java.lang.String[] getLazyStartIncludes()

getBuddyList

public java.lang.String getBuddyList()

hasPackageInfo

public boolean hasPackageInfo()

getPluginClass

public java.lang.String getPluginClass()

getRegisteredBuddyList

public java.lang.String getRegisteredBuddyList()

getManifestTimeStamp

public long getManifestTimeStamp()

getManifestType

public byte getManifestType()

isAutoStartable

public boolean isAutoStartable()
Checks whether this bundle is auto started for all resource/class loads or only for a subset of resource/classloads

Returns:
true if the bundle is auto started; false otherwise

addHooks

public void addHooks(HookRegistry hookRegistry)
Description copied from interface: HookConfigurator
Adds hooks to the specified hook registry.

Specified by:
addHooks in interface HookConfigurator
Parameters:
hookRegistry - the hook registry used to add hooks

getGeneratedManifest

public java.util.Dictionary getGeneratedManifest()
                                          throws BundleException
Throws:
BundleException

getBaseData

public BaseData getBaseData()

copy

public void copy(StorageHook storageHook)
Description copied from interface: StorageHook
Copies the data from the specified storage hook into this storage hook. This method is called when a bundle is updated to copy the data from the original bundle to a new storage hook. Then this storage will be initialized with the new bundle's manifest using the StorageHook.initialize(Dictionary) method.

Specified by:
copy in interface StorageHook
Parameters:
storageHook - the original storage hook to copy data out of.
See Also:
StorageHook.create(BaseData), StorageHook.initialize(Dictionary)

validate

public void validate()
              throws java.lang.IllegalArgumentException
Description copied from interface: StorageHook
Validates the data in this storage hook, if the data is invalid then an illegal state exception is thrown

Specified by:
validate in interface StorageHook
Throws:
java.lang.IllegalArgumentException - if the data is invalid

getAdaptor

public FrameworkAdaptor getAdaptor()

getManifest

public java.util.Dictionary getManifest(boolean firstLoad)
                                 throws BundleException
Description copied from interface: StorageHook
Returns the manifest for the data in this storage hook, or null if this hook does not provide the manifest. Most hooks should return null from this method. This method may be used to provide special handling of manifest loading. For example, to provide a cached manfest or to do automatic manifest generation.

Specified by:
getManifest in interface StorageHook
Parameters:
firstLoad - true if this is the very first time this manifest is being loaded.
Returns:
the manifest for the data in this storage hook, or null if this hook does not provide the manifest
Throws:
BundleException

forgetStatusChange

public boolean forgetStatusChange(int status)
Description copied from interface: StorageHook
Gets called by a base data during BundleData.setStatus(int). A base data will call this method for each configured storage hook it is associated with until one storage hook returns true. If all configured storage hooks return false then the BaseData will be marked dirty and will cause the status to be persistently saved.

Specified by:
forgetStatusChange in interface StorageHook
Parameters:
status - the new status of the base data
Returns:
false if the status is not to be persistently saved; otherwise true is returned

forgetStartLevelChange

public boolean forgetStartLevelChange(int startlevel)
Description copied from interface: StorageHook
Gets called by a base data during BundleData.setStartLevel(int). A base data will call this method for each configured storage hook it is associated with until one storage hook returns true. If all configured storage hooks return false then the BaseData will be marked dirty and will cause the start level to be persistently saved.

Specified by:
forgetStartLevelChange in interface StorageHook
Parameters:
startlevel - the new startlevel of the base data
Returns:
false if the startlevel is not to be persistently saved; otherwise true is returned

matchDNChain

public boolean matchDNChain(java.lang.String pattern)
Description copied from interface: StorageHook
Gets called by a base data during BundleData.matchDNChain(String). A base data will call this method for each configured storage hook it is associated with until one storage hook returns true. If all configured storage hooks return false value then the BaseAdaptor will return false.

Specified by:
matchDNChain in interface StorageHook
Parameters:
pattern - the pattern of distinguished name (DN) chains to match
Returns:
true if the pattern matches. A value of false is returned if bundle signing is not supported.