org.apache.lenya.ac.file
Class FileItemManager

java.lang.Object
  extended by org.apache.lenya.ac.file.FileItemManager
Direct Known Subclasses:
FileGroupManager, FileIPRangeManager, FileRoleManager, FileUserManager

public abstract class FileItemManager
extends java.lang.Object

Abstract superclass for classes that manage items loaded from configuration files.


Nested Class Summary
static class FileItemManager.DirectoryChangeNotifier
          Helper class to observe a directory for changes.
 
Field Summary
static java.lang.String PATH
           
 
Constructor Summary
protected FileItemManager(java.io.File configurationDirectory)
          Create a new ItemManager
 
Method Summary
 void add(Item item)
          Add an Item to this manager
 void addItemManagerListener(ItemManagerListener listener)
          Attaches an item manager listener to this item manager.
 boolean contains(Item item)
          Returns if the ItemManager contains an object.
 java.io.File getConfigurationDirectory()
          Get the directory where the items are located.
protected  java.io.FileFilter getFileFilter()
          Get a file filter which filters for files containing items.
 Item getItem(java.lang.String id)
          Returns an item for a given ID.
protected  java.lang.String getItemClass(org.apache.avalon.framework.configuration.Configuration config)
          Returns the class name of an item.
protected  org.apache.avalon.framework.configuration.Configuration getItemConfiguration(java.io.File file)
          Loads teh configuration of an item from a file.
 Item[] getItems()
          get all items
protected abstract  java.lang.String getSuffix()
          Returns the file extension to be used.
protected  Item loadItem(java.io.File file)
          Loads an item from a file.
protected  void loadItems()
          Reloads the items if an item was changed / added / removed.
protected  void notifyAdded(Item item)
          Notifies the listeners that an item was added.
protected  void notifyRemoved(Item item)
          Notifies the listeners that an item was removed.
 void remove(Item item)
          Remove an item from this manager
protected  void removeItem(java.io.File file)
           
 void removeItemManagerListener(ItemManagerListener listener)
          Removes an item manager listener from this item manager.
 void update(Item newItem)
          Update an item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH

public static final java.lang.String PATH
Constructor Detail

FileItemManager

protected FileItemManager(java.io.File configurationDirectory)
                   throws AccessControlException
Create a new ItemManager

Parameters:
configurationDirectory - where the items are fetched from
Throws:
AccessControlException - if the item manager cannot be instantiated
Method Detail

loadItems

protected void loadItems()
                  throws AccessControlException
Reloads the items if an item was changed / added / removed.

Throws:
AccessControlException - when something went wrong.

loadItem

protected Item loadItem(java.io.File file)
                 throws AccessControlException
Loads an item from a file.

Parameters:
file - The file.
Returns:
An item.
Throws:
AccessControlException - when something went wrong.

getItemClass

protected java.lang.String getItemClass(org.apache.avalon.framework.configuration.Configuration config)
                                 throws AccessControlException
Returns the class name of an item.

Parameters:
config - The item configuration.
Returns:
The class name.
Throws:
AccessControlException - when something went wrong.

getItemConfiguration

protected org.apache.avalon.framework.configuration.Configuration getItemConfiguration(java.io.File file)
                                                                                throws AccessControlException
Loads teh configuration of an item from a file.

Parameters:
file - The file.
Returns:
A configuration.
Throws:
AccessControlException - when something went wrong.

removeItem

protected void removeItem(java.io.File file)

getItem

public Item getItem(java.lang.String id)
Returns an item for a given ID.

Parameters:
id - The id.
Returns:
An item.

getItems

public Item[] getItems()
get all items

Returns:
an array of items

add

public void add(Item item)
         throws AccessControlException
Add an Item to this manager

Parameters:
item - to be added
Throws:
AccessControlException - when the notification threw this exception.

remove

public void remove(Item item)
            throws AccessControlException
Remove an item from this manager

Parameters:
item - to be removed
Throws:
AccessControlException - when the notification threw this exception.

update

public void update(Item newItem)
            throws AccessControlException
Update an item.

Parameters:
newItem - The new version of the item.
Throws:
AccessControlException - when the notification threw this exception.

contains

public boolean contains(Item item)
Returns if the ItemManager contains an object.

Parameters:
item - The object.
Returns:
A boolean value.

getConfigurationDirectory

public java.io.File getConfigurationDirectory()
Get the directory where the items are located.

Returns:
a File

getFileFilter

protected java.io.FileFilter getFileFilter()
Get a file filter which filters for files containing items.

Returns:
a FileFilter

getSuffix

protected abstract java.lang.String getSuffix()
Returns the file extension to be used.

Returns:
A string.

addItemManagerListener

public void addItemManagerListener(ItemManagerListener listener)
Attaches an item manager listener to this item manager.

Parameters:
listener - An item manager listener.

removeItemManagerListener

public void removeItemManagerListener(ItemManagerListener listener)
Removes an item manager listener from this item manager.

Parameters:
listener - An item manager listener.

notifyAdded

protected void notifyAdded(Item item)
                    throws AccessControlException
Notifies the listeners that an item was added.

Parameters:
item - The item that was added.
Throws:
AccessControlException - if an error occurs.

notifyRemoved

protected void notifyRemoved(Item item)
                      throws AccessControlException
Notifies the listeners that an item was removed.

Parameters:
item - The item that was removed.
Throws:
AccessControlException - if an error occurs.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.