org.neovera.jdiablo.internal
Class BuilderImpl

java.lang.Object
  extended by org.neovera.jdiablo.internal.BuilderImpl
All Implemented Interfaces:
EnvironmentBuilder, ExecutionHandler, Executor, HelpProvider, TargetBuilder

public class BuilderImpl
extends Object
implements TargetBuilder, EnvironmentBuilder, Executor, HelpProvider, ExecutionHandler


Constructor Summary
BuilderImpl(BuilderFactory builderFactory)
           
BuilderImpl(String[] args, BuilderFactory builderFactory)
           
 
Method Summary
 Executor build()
           
 ExecutionState execute()
          Execute the launchable catching all RuntimeExceptions (logged).
 ExecutionState executeNoCatch()
          Execute the launchable without catching or logging RuntimeExceptions.
 String[] getArgs()
           
 TargetBuilder getChainedExecutor()
           
<E extends Environment>
E
getEnvironment(Class<E> clz)
           
 void showHelp()
          Prints out command line help.
 EnvironmentBuilder withNewInstanceOf(Class<? extends Environment> clz)
          Use this when chaining Launchables (calling one Launchable from another) where you want a new (non-specialized or uninitialized) instance of an Environment to be used in the execution.
<E extends Environment>
EnvironmentBuilder
withSpecialization(Class<E> clz, Specialization<E> specialization)
          Allows for programmatic specialization (setting of properties) when launching.
<L extends Launchable>
EnvironmentBuilder
withTarget(Class<L> launchableClass)
          Tell the builder to build a launchable of a particular derived type.
<L extends Launchable>
EnvironmentBuilder
withTarget(Class<L> launchableClass, Specialization<L> specialization)
          Tell the builder to build a launchable of a particular type with given specialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuilderImpl

public BuilderImpl(BuilderFactory builderFactory)

BuilderImpl

public BuilderImpl(String[] args,
                   BuilderFactory builderFactory)
Method Detail

getEnvironment

public <E extends Environment> E getEnvironment(Class<E> clz)
Specified by:
getEnvironment in interface ExecutionHandler
Type Parameters:
E - Environment type
Parameters:
clz - Class of the environment
Returns:
Reference to environment for the current execution if it exists, null otherwise.

getArgs

public String[] getArgs()

withTarget

public <L extends Launchable> EnvironmentBuilder withTarget(Class<L> launchableClass)
Description copied from interface: TargetBuilder
Tell the builder to build a launchable of a particular derived type.

Specified by:
withTarget in interface TargetBuilder
Type Parameters:
L - Launchable type
Parameters:
launchableClass - Launchable class
Returns:
Environment builder to customize environments for this launchable type.

withTarget

public <L extends Launchable> EnvironmentBuilder withTarget(Class<L> launchableClass,
                                                            Specialization<L> specialization)
Description copied from interface: TargetBuilder
Tell the builder to build a launchable of a particular type with given specialization.

Specified by:
withTarget in interface TargetBuilder
Type Parameters:
L - Launchable type
Parameters:
launchableClass - Launchable class
specialization - The specialization to apply to the launchable type.
Returns:
Environment builder to customize environments for this launchable type.

withNewInstanceOf

public EnvironmentBuilder withNewInstanceOf(Class<? extends Environment> clz)
Description copied from interface: EnvironmentBuilder
Use this when chaining Launchables (calling one Launchable from another) where you want a new (non-specialized or uninitialized) instance of an Environment to be used in the execution. For example, when calling one launchable from another, if you want to call the second Launchable class with a different Spring context, call this method passing in SpringEnvironment class so that you can pass in a new initialization for it.

Specified by:
withNewInstanceOf in interface EnvironmentBuilder
Parameters:
clz - Environment class
Returns:
Environment builder.

withSpecialization

public <E extends Environment> EnvironmentBuilder withSpecialization(Class<E> clz,
                                                                     Specialization<E> specialization)
Description copied from interface: EnvironmentBuilder
Allows for programmatic specialization (setting of properties) when launching. Example: different command line processes in a project require different Spring contexts, you can plug-in the context selection in here. Of course, in the case of Spring you can also annotate the Launchable with the @SpringContext annotation or simply pass that as a command line, but the specialization hook allows for algorithmic determination of the context.

Specified by:
withSpecialization in interface EnvironmentBuilder
Returns:
Environment

build

public Executor build()
Specified by:
build in interface EnvironmentBuilder
Returns:
build an executor for the above defined specs.

execute

public ExecutionState execute()
Description copied from interface: Executor
Execute the launchable catching all RuntimeExceptions (logged).

Specified by:
execute in interface Executor

executeNoCatch

public ExecutionState executeNoCatch()
Description copied from interface: Executor
Execute the launchable without catching or logging RuntimeExceptions.

Specified by:
executeNoCatch in interface Executor

getChainedExecutor

public TargetBuilder getChainedExecutor()
Specified by:
getChainedExecutor in interface ExecutionHandler
Returns:
Target builder for a chained execution.

showHelp

public void showHelp()
Prints out command line help.

Specified by:
showHelp in interface HelpProvider


Copyright © 2014 Neovera Inc.. All rights reserved.