Spring for Apache Hadoop

org.springframework.data.hadoop.config.common.annotation
Class AbstractConfiguredAnnotationBuilder<O,I,B extends AnnotationBuilder<O>>

java.lang.Object
  extended by org.springframework.data.hadoop.config.common.annotation.AbstractAnnotationBuilder<O>
      extended by org.springframework.data.hadoop.config.common.annotation.AbstractConfiguredAnnotationBuilder<O,I,B>
Type Parameters:
O - The object that this builder returns
I -
B - The type of this builder (that is returned by the base class)
All Implemented Interfaces:
AnnotationBuilder<O>
Direct Known Subclasses:
SpringYarnConfigBuilder, YarnAppmasterBuilder, YarnClientBuilder, YarnConfigBuilder, YarnContainerBuilder, YarnEnvironmentBuilder, YarnResourceLocalizerBuilder

public abstract class AbstractConfiguredAnnotationBuilder<O,I,B extends AnnotationBuilder<O>>
extends AbstractAnnotationBuilder<O>

A base AnnotationBuilder that allows AnnotationConfigurers to be applied to it. This makes modifying the AnnotationBuilder a strategy that can be customised and broken up into a number of AnnotationConfigurer objects that have more specific goals than that of the AnnotationBuilder.

Author:
Rob Winch, Janne Valkealahti

Constructor Summary
protected AbstractConfiguredAnnotationBuilder()
          Instantiates a new annotation builder.
protected AbstractConfiguredAnnotationBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
          Instantiates a new annotation builder.
protected AbstractConfiguredAnnotationBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor, boolean allowConfigurersOfSameType)
          Instantiates a new annotation builder.
 
Method Summary
<C extends AnnotationConfigurer<O,B>>
C
apply(C configurer)
          Applies a AnnotationConfigurer to this AnnotationBuilder overriding any AnnotationConfigurer of the exact same class.
<C extends AnnotationConfigurerAdapter<O,I,B>>
C
apply(C configurer)
          Applies a AnnotationConfigurerAdapter to this AnnotationBuilder and invokes AnnotationConfigurerAdapter.setBuilder(AnnotationBuilder).
protected  void beforeConfigureMains()
          Invoked prior to invoking each main AnnotationConfigurer.configure(AnnotationBuilder) method.
protected  void beforeConfigurePosts()
          Invoked prior to invoking each post AnnotationConfigurer.configure(AnnotationBuilder) method.
protected  void beforeInit()
          Invoked prior to invoking each AnnotationConfigurer.init(AnnotationBuilder) method.
protected  O doBuild()
          Subclasses should implement this to perform the build.
<C extends AnnotationConfigurer<O,B>>
C
getConfigurer(java.lang.Class<C> clazz)
          Gets the AnnotationConfigurer by its class name or null if not found.
<C extends AnnotationConfigurer<O,B>>
java.util.List<C>
getConfigurers(java.lang.Class<C> clazz)
          Gets all the AnnotationConfigurer instances by its class name or an empty List if not found.
<C extends AnnotationConfigurerAdapter<O,I,B>>
C
getOrApply(C configurer)
          Similar to apply(AnnotationConfigurer) but checks the state to determine if apply(AnnotationConfigurer) needs to be called first.
 O getOrBuild()
          Similar to AbstractAnnotationBuilder.build() and AbstractAnnotationBuilder.getObject() but checks the state to determine if AbstractAnnotationBuilder.build() needs to be called first.
<C> C
getSharedObject(java.lang.Class<C> sharedType)
          Gets a shared Object.
 java.util.Map<java.lang.Class<java.lang.Object>,java.lang.Object> getSharedObjects()
          Gets the shared objects.
 O objectPostProcessor(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
          Specifies the ObjectPostProcessor to use.
protected abstract  O performBuild()
          Subclasses must implement this method to build the object that is being returned.
protected
<P> P
postProcess(P object)
          Performs post processing of an object.
<C extends AnnotationConfigurer<O,B>>
C
removeConfigurer(java.lang.Class<C> clazz)
          Removes and returns the AnnotationConfigurer by its class name or null if not found.
<C extends AnnotationConfigurer<O,B>>
java.util.List<C>
removeConfigurers(java.lang.Class<C> clazz)
          Removes all the AnnotationConfigurer instances by its class name or an empty List if not found.
<C> void
setSharedObject(java.lang.Class<C> sharedType, C object)
          Sets an object that is shared by multiple AnnotationConfigurer.
 
Methods inherited from class org.springframework.data.hadoop.config.common.annotation.AbstractAnnotationBuilder
build, getObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConfiguredAnnotationBuilder

protected AbstractConfiguredAnnotationBuilder()
Instantiates a new annotation builder.


AbstractConfiguredAnnotationBuilder

protected AbstractConfiguredAnnotationBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
Instantiates a new annotation builder.

Parameters:
objectPostProcessor - the object post processor

AbstractConfiguredAnnotationBuilder

protected AbstractConfiguredAnnotationBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor,
                                              boolean allowConfigurersOfSameType)
Instantiates a new annotation builder.

Parameters:
objectPostProcessor - the object post processor
allowConfigurersOfSameType - the allow configurers of same type
Method Detail

doBuild

protected final O doBuild()
                   throws java.lang.Exception
Description copied from class: AbstractAnnotationBuilder
Subclasses should implement this to perform the build.

Specified by:
doBuild in class AbstractAnnotationBuilder<O>
Returns:
the object that should be returned by AbstractAnnotationBuilder.build().
Throws:
java.lang.Exception - if an error occurs

getOrBuild

public O getOrBuild()
Similar to AbstractAnnotationBuilder.build() and AbstractAnnotationBuilder.getObject() but checks the state to determine if AbstractAnnotationBuilder.build() needs to be called first.

Returns:
the result of AbstractAnnotationBuilder.build() or AbstractAnnotationBuilder.getObject(). If an error occurs while building, returns null.

apply

public <C extends AnnotationConfigurerAdapter<O,I,B>> C apply(C configurer)
                                                   throws java.lang.Exception
Applies a AnnotationConfigurerAdapter to this AnnotationBuilder and invokes AnnotationConfigurerAdapter.setBuilder(AnnotationBuilder).

Parameters:
configurer - the configurer
Returns:
Configurer passed as parameter
Throws:
java.lang.Exception - if error occurred

getOrApply

public <C extends AnnotationConfigurerAdapter<O,I,B>> C getOrApply(C configurer)
                                                        throws java.lang.Exception
Similar to apply(AnnotationConfigurer) but checks the state to determine if apply(AnnotationConfigurer) needs to be called first.

Parameters:
configurer - the configurer
Returns:
Configurer passed as parameter
Throws:
java.lang.Exception - if error occurred

apply

public <C extends AnnotationConfigurer<O,B>> C apply(C configurer)
                                          throws java.lang.Exception
Applies a AnnotationConfigurer to this AnnotationBuilder overriding any AnnotationConfigurer of the exact same class. Note that object hierarchies are not considered.

Parameters:
configurer - the configurer
Returns:
Configurer passed as parameter
Throws:
java.lang.Exception - if error occurred

setSharedObject

public <C> void setSharedObject(java.lang.Class<C> sharedType,
                                C object)
Sets an object that is shared by multiple AnnotationConfigurer.

Parameters:
sharedType - the Class to key the shared object by.
object - the Object to store

getSharedObject

public <C> C getSharedObject(java.lang.Class<C> sharedType)
Gets a shared Object. Note that object hierarchies are not considered.

Parameters:
sharedType - the type of the shared Object
Returns:
the shared Object or null if it is not found

getSharedObjects

public java.util.Map<java.lang.Class<java.lang.Object>,java.lang.Object> getSharedObjects()
Gets the shared objects.

Returns:
Shared objects

getConfigurers

public <C extends AnnotationConfigurer<O,B>> java.util.List<C> getConfigurers(java.lang.Class<C> clazz)
Gets all the AnnotationConfigurer instances by its class name or an empty List if not found. Note that object hierarchies are not considered.

Parameters:
clazz - the AnnotationConfigurer class to look for
Returns:
All configurers

removeConfigurers

public <C extends AnnotationConfigurer<O,B>> java.util.List<C> removeConfigurers(java.lang.Class<C> clazz)
Removes all the AnnotationConfigurer instances by its class name or an empty List if not found. Note that object hierarchies are not considered.

Parameters:
clazz - the AnnotationConfigurer class to look for
Returns:
Empty list of configurers

getConfigurer

public <C extends AnnotationConfigurer<O,B>> C getConfigurer(java.lang.Class<C> clazz)
Gets the AnnotationConfigurer by its class name or null if not found. Note that object hierarchies are not considered.

Parameters:
clazz - the configurer class type
Returns:
Matched configurers

removeConfigurer

public <C extends AnnotationConfigurer<O,B>> C removeConfigurer(java.lang.Class<C> clazz)
Removes and returns the AnnotationConfigurer by its class name or null if not found. Note that object hierarchies are not considered.

Parameters:
clazz - the configurer class type
Returns:
Matched configurers

objectPostProcessor

public O objectPostProcessor(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
Specifies the ObjectPostProcessor to use.

Parameters:
objectPostProcessor - the ObjectPostProcessor to use. Cannot be null
Returns:
the AnnotationBuilder for further customizations

postProcess

protected <P> P postProcess(P object)
Performs post processing of an object. The default is to delegate to the ObjectPostProcessor.

Parameters:
object - the Object to post process
Returns:
the possibly modified Object to use

beforeInit

protected void beforeInit()
                   throws java.lang.Exception
Invoked prior to invoking each AnnotationConfigurer.init(AnnotationBuilder) method. Subclasses may override this method to hook into the lifecycle without using a AnnotationConfigurer.

Throws:
java.lang.Exception

beforeConfigureMains

protected void beforeConfigureMains()
                             throws java.lang.Exception
Invoked prior to invoking each main AnnotationConfigurer.configure(AnnotationBuilder) method. Subclasses may override this method to hook into the lifecycle without using a AnnotationConfigurer.

Throws:
java.lang.Exception

beforeConfigurePosts

protected void beforeConfigurePosts()
                             throws java.lang.Exception
Invoked prior to invoking each post AnnotationConfigurer.configure(AnnotationBuilder) method. Subclasses may override this method to hook into the lifecycle without using a AnnotationConfigurer.

Throws:
java.lang.Exception

performBuild

protected abstract O performBuild()
                           throws java.lang.Exception
Subclasses must implement this method to build the object that is being returned.

Returns:
Object build by this builder
Throws:
java.lang.Exception

Spring for Apache Hadoop