org.apache.felix.prefs.impl
Class StreamBackingStoreImpl

java.lang.Object
  extended by org.apache.felix.prefs.impl.StreamBackingStoreImpl
All Implemented Interfaces:
BackingStore
Direct Known Subclasses:
DataFileBackingStoreImpl

public abstract class StreamBackingStoreImpl
extends Object
implements BackingStore

This is an abstract implementation of a backing store which uses streams to read/write the preferences and stores a complete preferences tree in a single stream.


Field Summary
protected  BundleContext bundleContext
          The bundle context.
 
Constructor Summary
StreamBackingStoreImpl(BundleContext context)
           
 
Method Summary
protected abstract  void checkAccess()
          This method is invoked to check if the backing store is accessible right now.
protected abstract  OutputStream getOutputStream(PreferencesDescription desc)
          Get the output stream to write the preferences.
protected  boolean hasChanges(PreferencesImpl prefs)
          Has the tree changes?
protected  void read(PreferencesImpl prefs, InputStream is)
          Read the preferences recursively from the input stream.
protected  void readPreferences(PreferencesImpl prefs, InputStream in)
          Load this preferences from an input stream.
 void store(PreferencesImpl prefs)
          Store the current preferences and its children in the backing store.
 void update(PreferencesImpl prefs)
          Update the current preferences and its children from the backing store.
protected  void write(PreferencesImpl prefs, OutputStream os)
          Write the preferences recursively to the output stream.
protected  void writePreferences(PreferencesImpl prefs, OutputStream out)
          Save this preferences to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.felix.prefs.BackingStore
availableBundles, load, loadAll, remove
 

Field Detail

bundleContext

protected final BundleContext bundleContext
The bundle context.

Constructor Detail

StreamBackingStoreImpl

public StreamBackingStoreImpl(BundleContext context)
Method Detail

checkAccess

protected abstract void checkAccess()
                             throws BackingStoreException
This method is invoked to check if the backing store is accessible right now.

Throws:
BackingStoreException

getOutputStream

protected abstract OutputStream getOutputStream(PreferencesDescription desc)
                                         throws IOException
Get the output stream to write the preferences.

Throws:
IOException

store

public void store(PreferencesImpl prefs)
           throws BackingStoreException
Description copied from interface: BackingStore
Store the current preferences and its children in the backing store. The store should check, if the preferences have changed, it should also check all children.

Specified by:
store in interface BackingStore
Parameters:
prefs - The preferences.
Throws:
BackingStoreException
See Also:
BackingStore.store(org.apache.felix.prefs.PreferencesImpl)

hasChanges

protected boolean hasChanges(PreferencesImpl prefs)
Has the tree changes?


update

public void update(PreferencesImpl prefs)
            throws BackingStoreException
Description copied from interface: BackingStore
Update the current preferences and its children from the backing store.

Specified by:
update in interface BackingStore
Throws:
BackingStoreException
See Also:
BackingStore.update(org.apache.felix.prefs.PreferencesImpl)

write

protected void write(PreferencesImpl prefs,
                     OutputStream os)
              throws IOException
Write the preferences recursively to the output stream.

Parameters:
prefs -
os -
Throws:
IOException

read

protected void read(PreferencesImpl prefs,
                    InputStream is)
             throws IOException
Read the preferences recursively from the input stream.

Parameters:
prefs -
is -
Throws:
IOException

readPreferences

protected void readPreferences(PreferencesImpl prefs,
                               InputStream in)
                        throws IOException
Load this preferences from an input stream. Currently the prefs are read from an object input stream and the serialization is done by hand. The changeSet is neither updated nor cleared in order to provide an update/sync functionality. This has to be done at a higher level.

Throws:
IOException

writePreferences

protected void writePreferences(PreferencesImpl prefs,
                                OutputStream out)
                         throws IOException
Save this preferences to an output stream. Currently the prefs are written through an object output stream with handmade serialization of strings. The changeSet is neither updated nor cleared in order to provide an update/sync functionality. This has to be done at a higher level.

Throws:
IOException


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.