com.amazon.carbonado.spi
Class AbstractRepositoryBuilder

java.lang.Object
  extended by com.amazon.carbonado.spi.AbstractRepositoryBuilder
All Implemented Interfaces:
RepositoryBuilder
Direct Known Subclasses:
BDBRepositoryBuilder, IndexedRepositoryBuilder, JDBCRepositoryBuilder, LoggingRepositoryBuilder, MapRepositoryBuilder, ReplicatedRepositoryBuilder

public abstract class AbstractRepositoryBuilder
extends Object
implements RepositoryBuilder

Abstract builder class for opening repositories.

Author:
Don Schneider, Brian S O'Neill

Constructor Summary
protected AbstractRepositoryBuilder()
           
 
Method Summary
 boolean addTriggerFactory(TriggerFactory factory)
          Optionally add a TriggerFactory which will be called upon to create an initial trigger for each Storable type that the Repository supports.
 void assertReady()
          Throw a configuration exception if the configuration is not filled out sufficiently and correctly such that a repository could be instantiated from it.
 Repository build()
          Builds a repository instance.
 void errorCheck(Collection<String> messages)
          This method is called by assertReady, and subclasses must override to perform custom checks.
 Iterable<TriggerFactory> getTriggerFactories()
          Returns all the TriggerFactories which were added.
 boolean removeTriggerFactory(TriggerFactory factory)
          Remove a TriggerFactory which was added earlier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.amazon.carbonado.RepositoryBuilder
build, getName, isMaster, setMaster, setName
 

Constructor Detail

AbstractRepositoryBuilder

protected AbstractRepositoryBuilder()
Method Detail

build

public Repository build()
                 throws ConfigurationException,
                        RepositoryException
Description copied from interface: RepositoryBuilder
Builds a repository instance.

Specified by:
build in interface RepositoryBuilder
Throws:
ConfigurationException - if there is a problem in the builder's configuration
RepositoryException - if there is a general problem opening the repository

addTriggerFactory

public boolean addTriggerFactory(TriggerFactory factory)
Description copied from interface: RepositoryBuilder
Optionally add a TriggerFactory which will be called upon to create an initial trigger for each Storable type that the Repository supports. The primary purpose of this method is to allow decorator repositories the opportunity to register custom persistence code for each Storable.

Specified by:
addTriggerFactory in interface RepositoryBuilder
Returns:
true if TriggerFactory was added, false if TriggerFactory was not added because an equal TriggerFactory is already registered

removeTriggerFactory

public boolean removeTriggerFactory(TriggerFactory factory)
Description copied from interface: RepositoryBuilder
Remove a TriggerFactory which was added earlier.

Specified by:
removeTriggerFactory in interface RepositoryBuilder
Returns:
true if TriggerFactory instance was removed, false if not added

getTriggerFactories

public Iterable<TriggerFactory> getTriggerFactories()
Description copied from interface: RepositoryBuilder
Returns all the TriggerFactories which were added.

Specified by:
getTriggerFactories in interface RepositoryBuilder

assertReady

public final void assertReady()
                       throws ConfigurationException
Throw a configuration exception if the configuration is not filled out sufficiently and correctly such that a repository could be instantiated from it.

Throws:
ConfigurationException

errorCheck

public void errorCheck(Collection<String> messages)
                throws ConfigurationException
This method is called by assertReady, and subclasses must override to perform custom checks. Be sure to call super.errorCheck as well.

Parameters:
messages - add any error messages to this list
Throws:
ConfigurationException - if error checking indirectly caused another exception


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.