|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object consciouscode.seedling.boot.SeedlingBuilder
public final class SeedlingBuilder
Builds a new Seedling
instance based on application-provided
configuration. This is the primary mechanism for embedding Seedling within
an application that defines its own main()
entry point.
By default, Seedling will perform dynamic class loading to access the code
provided by each module. This requires the application (that is, the code
using SeedlingBuilder
to bootstrap the class path with the libraries
of the runtime
module; code for other modules will be loaded on
demand.
Seedling can also delegate responsibility for all class loading to the
application. This can be useful for some deployment scenarios but is
generally not recommended. Use setDelegatingClassLoading(boolean)
to control this behavior.
Here's a sample of how embedding works:
private void embedSeedling(String repositoryPaths, boolean debug) throws Exception { File seedlingHome = new File("/path/to/Seedling"); SeedlingBuilder builder = new SeedlingBuilder(seedlingHome); builder.addRepositoryPathList(repositoryPaths); builder.setDebugging(debug); builder.addRequiredModules("myAppModule"); Seedling seedling = builder.build(); seedling.setHandlingSeedlingUrls(true); seedling.start(); try { // Do your thing. For example, you can grab nodes: Object myNode = seedling.getRoot().getNode("/example/MyNode"); } finally { // Don't forget to stop the Seedling when you're done with it. seedling.stop(); } }
This class is not safe for use by multiple threads.
Constructor Summary | |
---|---|
SeedlingBuilder(File seedlingHome)
|
Method Summary | |
---|---|
void |
addLocalConfigTrees(File... localTrees)
Adds configuration directories that contain local overrides. |
void |
addRepositories(File... repositories)
Appends the given directories to this builder's repository list. |
void |
addRepository(File repository)
Appends the given directory to this builder's repository list. |
void |
addRepositoryPathList(String pathList)
Deprecated. Use addRepositories(File...) instead. |
void |
addRequiredModules(String... names)
|
Seedling |
build()
|
String[] |
getClasspath()
For internal use only. |
boolean |
isDebugging()
|
boolean |
isDelegatingClassLoading()
Indicates whether this builder will be delegating class loading to the surrounding application. |
void |
setDebugging(boolean debugging)
|
void |
setDelegatingClassLoading(boolean delegating)
Declares whether the built Seedling will delegate responsibility
for class loading to the application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SeedlingBuilder(File seedlingHome) throws IOException
IOException
Method Detail |
---|
public Seedling build() throws SeedlingException
SeedlingException
public boolean isDebugging()
public void setDebugging(boolean debugging)
public boolean isDelegatingClassLoading()
true
, then this builder and any
Seedling
it creates will not perform dynamic class loading for
code needed by its modules.
This property is false
by default: the Seedling
will
perform dynamic class loading.
setDelegatingClassLoading(boolean)
public void setDelegatingClassLoading(boolean delegating)
Seedling
will delegate responsibility
for class loading to the application. In such cases Seedling will do no
custom class loading, and the caller must ensure that all necessary
code will be available.
delegating
- when true
, the Seedling
will delegate
class loading to the application.isDelegatingClassLoading()
public void addRepository(File repository) throws IOException
repository
- must be a readable directory.
IOException
public void addRepositories(File... repositories) throws IOException
repositories
- must be a non-null sequence of readable directories.
IOException
@Deprecated public void addRepositoryPathList(String pathList) throws IOException
addRepositories(File...)
instead.
pathList
- is a sequence of paths, delimited by
File.pathSeparator
. Each entry must identify a readable
directory.
IOException
public void addRequiredModules(String... names)
public void addLocalConfigTrees(File... localTrees)
Local trees are not required: they need not exist when this method is invoked or when this builder constructs a Seedling. In addition, the Seedling will allow the trees and their configuration files to be added after startup.
localTrees
- the local trees, from lowest to highest priority.public String[] getClasspath() throws SeedlingException
SeedlingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |