org.chromattic.api
Class ChromatticBuilder

java.lang.Object
  extended by org.chromattic.api.ChromatticBuilder

public abstract class ChromatticBuilder
extends java.lang.Object

The builder configures and create a Chromattic runtime.

Version:
$Revision$
Author:
Julien Viet

Nested Class Summary
static class ChromatticBuilder.Configuration
           
static class ChromatticBuilder.Option<D>
          A configuration option.
 
Field Summary
static ChromatticBuilder.Option<java.lang.Boolean> CREATE_ROOT_NODE
          A boolean option that creates the root node designated by the ROOT_NODE_PATH option when it does not exist.
static ChromatticBuilder.Option<java.lang.String> INSTRUMENTOR_CLASSNAME
          The instrumentor class name for Chromattic's objects.
static ChromatticBuilder.Option<java.lang.Boolean> JCR_OPTIMIZE_ENABLED
          Enable / disable all JCR optimizations.
static ChromatticBuilder.Option<java.lang.Boolean> JCR_OPTIMIZE_HAS_NODE_ENABLED
          Enable / disable access to JCR has property.
static ChromatticBuilder.Option<java.lang.Boolean> JCR_OPTIMIZE_HAS_PROPERTY_ENABLED
          Enable / disable access to JCR has property.
static ChromatticBuilder.Option<java.lang.Boolean> LAZY_CREATE_ROOT_NODE
          A boolean option that indicates that the root node should be lazyly created when it is required.
static ChromatticBuilder.Option<java.lang.String> OBJECT_FORMATTER_CLASSNAME
          The object name formatter class name.
static ChromatticBuilder.Option<java.lang.Boolean> PROPERTY_CACHE_ENABLED
          The boolean indicating if caching is performed.
static ChromatticBuilder.Option<java.lang.Boolean> PROPERTY_READ_AHEAD_ENABLED
          Todo.
static ChromatticBuilder.Option<java.lang.String> ROOT_NODE_PATH
          The path of the root node.
static ChromatticBuilder.Option<java.lang.String> ROOT_NODE_TYPE
          A string value that is the root node type when Chromattic has to build the path to the root node.
static ChromatticBuilder.Option<java.lang.String> SESSION_LIFECYCLE_CLASSNAME
          The JCR session life cycle class name.
static ChromatticBuilder.Option<java.lang.Boolean> USE_SYSTEM_PROPERTIES
          A special option that will lookup system properties when set to true to configure options by default.
 
Constructor Summary
ChromatticBuilder()
           
 
Method Summary
 void add(java.lang.Class<?> clazz)
          Adds a class definition.
 void add(java.lang.Class<?> first, java.lang.Class<?>... other)
          Adds a class definition.
protected abstract  Chromattic boot(ChromatticBuilder.Configuration options)
           
 Chromattic build()
          Builds the runtime and return a configured Chromattic instance.
 Chromattic build(ChromatticBuilder.Configuration config)
          Builds the runtime and return a configured Chromattic instance.
static ChromatticBuilder create()
          Create and return an instance of the builder.
protected  ChromatticBuilder.Configuration createDefaultConfiguration()
          Create the default configuration.
 ChromatticBuilder.Configuration getConfiguration()
          Returns a copy of the current configuration.
 boolean init()
          Initialize the builder, this operation should be called once per builder, unlike the build(Configuration) operation that can be called several times with different configurations.
protected abstract  void init(java.util.Set<java.lang.Class<?>> classes)
           
<D> void
setOptionValue(ChromatticBuilder.Option<D> option, D value)
          Set the option value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_SYSTEM_PROPERTIES

public static final ChromatticBuilder.Option<java.lang.Boolean> USE_SYSTEM_PROPERTIES
A special option that will lookup system properties when set to true to configure options by default.


INSTRUMENTOR_CLASSNAME

public static final ChromatticBuilder.Option<java.lang.String> INSTRUMENTOR_CLASSNAME
The instrumentor class name for Chromattic's objects. The specified class must implement the org.chromattic.spi.instrument.Intrumentor class.


SESSION_LIFECYCLE_CLASSNAME

public static final ChromatticBuilder.Option<java.lang.String> SESSION_LIFECYCLE_CLASSNAME
The JCR session life cycle class name. The specified class must implement the org.chromattic.spi.jcr.SessionLifeCycle class.


OBJECT_FORMATTER_CLASSNAME

public static final ChromatticBuilder.Option<java.lang.String> OBJECT_FORMATTER_CLASSNAME
The object name formatter class name. The specified class must implement the org.chromattic.api.format.ObjectFormatter class.


PROPERTY_CACHE_ENABLED

public static final ChromatticBuilder.Option<java.lang.Boolean> PROPERTY_CACHE_ENABLED
The boolean indicating if caching is performed. When cache is enabled each session maintains a cache that avoids to use the underlying JCR session. As a consequence any change made directly to the JCR session will not be visible in the object domain.


PROPERTY_READ_AHEAD_ENABLED

public static final ChromatticBuilder.Option<java.lang.Boolean> PROPERTY_READ_AHEAD_ENABLED
Todo.


JCR_OPTIMIZE_ENABLED

public static final ChromatticBuilder.Option<java.lang.Boolean> JCR_OPTIMIZE_ENABLED
Enable / disable all JCR optimizations.


JCR_OPTIMIZE_HAS_PROPERTY_ENABLED

public static final ChromatticBuilder.Option<java.lang.Boolean> JCR_OPTIMIZE_HAS_PROPERTY_ENABLED
Enable / disable access to JCR has property.


JCR_OPTIMIZE_HAS_NODE_ENABLED

public static final ChromatticBuilder.Option<java.lang.Boolean> JCR_OPTIMIZE_HAS_NODE_ENABLED
Enable / disable access to JCR has property.


ROOT_NODE_PATH

public static final ChromatticBuilder.Option<java.lang.String> ROOT_NODE_PATH
The path of the root node. The default value is the path of the JCR workspace root node.


CREATE_ROOT_NODE

public static final ChromatticBuilder.Option<java.lang.Boolean> CREATE_ROOT_NODE
A boolean option that creates the root node designated by the ROOT_NODE_PATH option when it does not exist.


LAZY_CREATE_ROOT_NODE

public static final ChromatticBuilder.Option<java.lang.Boolean> LAZY_CREATE_ROOT_NODE
A boolean option that indicates that the root node should be lazyly created when it is required.


ROOT_NODE_TYPE

public static final ChromatticBuilder.Option<java.lang.String> ROOT_NODE_TYPE
A string value that is the root node type when Chromattic has to build the path to the root node.

Constructor Detail

ChromatticBuilder

public ChromatticBuilder()
Method Detail

create

public static ChromatticBuilder create()
Create and return an instance of the builder.

Returns:
the chromattic builder instance

createDefaultConfiguration

protected ChromatticBuilder.Configuration createDefaultConfiguration()

Create the default configuration. Subclass can override it to provide a suitable default configuration. The returned object will likely be modified and therefore a new copy should be created every time this method is invoked.

The default implementation relies on the ServiceLoader to load an instance of ChromatticBuilder.Configuration.Factory If no configuration is found then a builder exception is thrown.

Returns:
the default configuration

getConfiguration

public final ChromatticBuilder.Configuration getConfiguration()
Returns a copy of the current configuration.

Returns:
the configuration

add

public void add(java.lang.Class<?> clazz)
         throws java.lang.NullPointerException,
                java.lang.IllegalStateException
Adds a class definition.

Parameters:
clazz - the class to add
Throws:
java.lang.NullPointerException - if the provided class is null
java.lang.IllegalStateException - if the builder is already initialized

add

public void add(java.lang.Class<?> first,
                java.lang.Class<?>... other)
         throws java.lang.NullPointerException,
                java.lang.IllegalStateException
Adds a class definition.

Parameters:
first - the first class to add
other - the other classes to add
Throws:
java.lang.NullPointerException - if the provided class is null
java.lang.IllegalStateException - if the builder is already initialized

build

public final Chromattic build()
                       throws BuilderException
Builds the runtime and return a configured Chromattic instance.

Returns:
the chromattic instance
Throws:
BuilderException - any builder exception

build

public final Chromattic build(ChromatticBuilder.Configuration config)
                       throws BuilderException
Builds the runtime and return a configured Chromattic instance.

Parameters:
config - the configuration to use
Returns:
the chromattic instance
Throws:
BuilderException - any builder exception

init

public final boolean init()
                   throws BuilderException
Initialize the builder, this operation should be called once per builder, unlike the build(Configuration) operation that can be called several times with different configurations. This operation is used to perform the initialization that is common to any configuration such as building the meta model from the classes.

Returns:
whether or not initialization occured
Throws:
BuilderException - any exception that would prevent the initialization to happen correctly

init

protected abstract void init(java.util.Set<java.lang.Class<?>> classes)
                      throws BuilderException
Throws:
BuilderException

boot

protected abstract Chromattic boot(ChromatticBuilder.Configuration options)
                            throws BuilderException
Throws:
BuilderException

setOptionValue

public <D> void setOptionValue(ChromatticBuilder.Option<D> option,
                               D value)
                    throws java.lang.NullPointerException
Set the option value.

Type Parameters:
D - the option data type
Parameters:
option - the option to set
value - the option value
Throws:
java.lang.NullPointerException - if any argument is null


Copyright © 2012 eXo Platform SAS. All Rights Reserved.