consciouscode.seedling.boot
Class SeedlingBuilder

java.lang.Object
  extended by consciouscode.seedling.boot.SeedlingBuilder

public final class SeedlingBuilder
extends Object

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

SeedlingBuilder

public SeedlingBuilder(File seedlingHome)
                throws IOException
Throws:
IOException
Method Detail

build

public Seedling build()
               throws SeedlingException
Throws:
SeedlingException

isDebugging

public boolean isDebugging()

setDebugging

public void setDebugging(boolean debugging)

isDelegatingClassLoading

public boolean isDelegatingClassLoading()
Indicates whether this builder will be delegating class loading to the surrounding application. If 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.

See Also:
setDelegatingClassLoading(boolean)

setDelegatingClassLoading

public void setDelegatingClassLoading(boolean delegating)
Declares whether the built 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.

Parameters:
delegating - when true, the Seedling will delegate class loading to the application.
See Also:
isDelegatingClassLoading()

addRepository

public void addRepository(File repository)
                   throws IOException
Appends the given directory to this builder's repository list.

Parameters:
repository - must be a readable directory.
Throws:
IOException

addRepositories

public void addRepositories(File... repositories)
                     throws IOException
Appends the given directories to this builder's repository list.

Parameters:
repositories - must be a non-null sequence of readable directories.
Throws:
IOException

addRepositoryPathList

@Deprecated
public void addRepositoryPathList(String pathList)
                           throws IOException
Deprecated. Use addRepositories(File...) instead.

Appends a sequence of paths to this builder's repository list.

Parameters:
pathList - is a sequence of paths, delimited by File.pathSeparator. Each entry must identify a readable directory.
Throws:
IOException

addRequiredModules

public void addRequiredModules(String... names)

addLocalConfigTrees

public void addLocalConfigTrees(File... localTrees)
Adds configuration directories that contain local overrides. These trees have priority over all configuration trees provided by modules.

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.

Parameters:
localTrees - the local trees, from lowest to highest priority.

getClasspath

public String[] getClasspath()
                      throws SeedlingException
For internal use only.

Throws:
SeedlingException


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.