Package com.bareflow

Core Bareflow framework classes.

See:
          Description

Interface Summary
IBuilderContext  
IComponentBuilder An interface to build a component from a model object.
IComponentRegistry This interface represents a registry of all the components for a module.
ICondition This interface represents condition that can be evaluated in a runtime context.
IExpression This interface represents an expression that can be evaluated during runtime in the given runtime context.
IExtensionFactory This interface is used to instantiate Extension.
IModule This interface represents a module.
IProvider Provider supplies data for downstream processing.
IRuntime Interface to run task in the given context.
IRuntimeContext This interface represents runtime context.
IRuntimeContextIterator An iterator over a collection of runtime contexts.
IRuntimeFactory Defines a factory API to create the following essential runtime objects: runtime runtime context runtime value expression script Each runtime is identified by its own id (see IRuntimeFactory.getRuntimeId()).
IRuntimeValue This interface represents a value object that can be evaluated only at runtime and in a runtime context.
IScript  
ITask An interface for task components.
 

Class Summary
Extension  
ModuleFactory Defines a factory to create module instances.
Runtime This class provides default implementation for the IRuntime interface.
 

Enum Summary
AttributeScope Enumeration of runtime context scopes.
 

Exception Summary
BareflowException  
 

Annotation Types Summary
Builder An annotation to be used by component model object to specify builder class name
 

Package com.bareflow Description

Core Bareflow framework classes. This package can be used to create custom components, component builders, custom runtime implementations, embed the framework into applications.

Custom Components

There are three main component types supported by the framework: Task components implement ITask interface. Condition components implement ICondition interface. Provider components implement IProvider interface.
Custom components can be used as external objects from the default schema or associated with a schema extension. In order for a component to qualify as external object it should implement one of the three interfaces above and follow JavaBeans specification.

Component Builders

Component builders are used to create custom components from schema binding objects. Normally any schema binding class should use Builder annotation to specify associated builder class. The builder class should implement IComponentBuilder interface and follow JavaBeans specification.

Custom Runtime Implementations

Custom runtime implementations can be used to support custom scripting and expression languages, runtime values, change module runtime behavior. For more information see IRuntimeFactory.

Embedding

Bareflow can be embedded into an application. Embedding includes the following steps: The first three steps can be done once. The remaining four steps can be repeated.

Example:

        ModuleFactory factory = ModuleFactory.newInstance();
        IModule module = factory.createModule(inputStream);
        IRuntimeFactory runtimeFactory = module.getRuntimeFactory();
        
        IRuntimeContext ctx = runtimeFactory.createContext();
        ctx.setAttribute("myAttribute", 1234, AttributeScope.GLOBAL);
        module.run(ctx);
        Object result = ctx.getAttribute("myAttribute");

Embedding and Thread Safety

Once module is created it can be run by multiple threads. Core framework components are thread safe. It is a responsibility of a developer to ensure thread safety of custom components.

Example:

        ModuleFactory moduleFactory = ModuleFactory.newInstance();
        final IModule module = moduleFactory.createModule(inputStream);
        final IRuntimeFactory runtimeFactory = module.getRuntimeFactory();
        
        class MyThread extends Thread{
            private int value;
            
            MyThread(int value) {
                this.value = value;
            }

            public void run() {
                try {
                    IRuntimeContext ctx = runtimeFactory.createContext();
                    ctx.setAttribute("myAttribute", value, AttributeScope.GLOBAL);
                    module.run(ctx);
                    Object result = ctx.getAttribute("myAttribute");
                    System.out.println(result);
                } catch (BareflowException e) {
                    e.printStackTrace();
                }
            }
        };

        new MyThread(1).start();
        new MyThread(2).start();

Related Documentation

For overviews, tutorials, examples, guides, and tool documentation, please see: