Implement a new Bundle Lifecycle

Description

The main focus on this new bundle lifecycle management is to easy the configuration enabling users start using osl even without config bundles.

To make it easy we reformulate our bundle concept. Bundle now is an almost abstract component that groups tasks.

And we have 2 kinds of Tasks: AfterFederationTask and ConfigurableTask.

AfterFederationTask: This kind of task are executed without any user config, started just after the federation engine process.

ConfigurableTask: This kind of tasks are executed only with user configuration. Configurations means a list of artifacts as input (using include or exclude artifacts) + additional properties. Properties can be a classpath information for instance. ConfigurableTask is also divided into 2 types: ArtifactTask and ProcessingTask.
ArtifactTask: this type is executed for every input artifact.
ProcessingTask: this type is executed just once, without artifact reference, usually this type will be used to notify beginning of artifacts processing or to save pending actions after all tasks were executed.

To implement task dependencies we going to use a mechanism based on annotation - but to be a bit more flexible we'll have 2 annotations: WeakDependsOn and StrongDependsOn.
WeakDependsOn: Will execute the task using OR boolean operator
StrongDependsOn: Will execute the task using AND boolean operator
Important: note that this dependency mechanism can be used by both: AfterFederationTask and ConfigurableTask.

As AfterFederationTask is executed automatically after the federation without any user config, it can use an annotation to filter Artifacts. The ArtifactFilter annotation will filter artifacts by: prefix, sufix or exact match.
Important: ArtifactFilter annotation can be used just by AfterFederationTask.

As mentioned previous, ConfigurableTask are executed after some user configuration that means some artifacts and properties. These properties are also defined by an annotation: PropertyDef. PropertyDef annotation should have 3 arguments: propertyName, dataType (STRING|INT|FLOAT|BOOLEAN|PATH|CONTEXT_REF|CONTEXT_LIST_REF}, mandatory={true|false}) and mandatory indicator (boolean value). ConfigurableTask are just executed if the mandatory properties are set, if not, its skiped (and all the other tasks that depends on that aren't executed too).

All these task should be grouped into a bundle. A bundle will be an interface that will be used just on: dev mode (who are the tasks of x bundle) and to list available bundles and wich are their properties (this kind of information will be usefull to build config ui).

The bundle root interface will be "Bundle" and an spefific interface should be created like this: "JavaBundle extends Bundle". We should create some Annotations to help describe the bundle like: @Description.
As mentioned before: any task should be related to one bundle, so any task should implement a XXXBundle (it will not work if it implements just the root Bundle interface).

Paralelization:

Tasks of different types will never be executed in parellel!!! So: One task at a time! It will avoid racing conditions and etc..
Important: Each collection of tasks of a same type are executed in paralell, each one receiving a different artifact. A task instance will receive an artifact. So, there's no risk of a same artifact been modified by different tasks at the same time, making the parallel processing easier and safe.
A bundle will have tasks of different types. For example: JavaPublicElementTask, JavaVariablesTask, etc.

Saving:
The save machnism (graph) should be handled by each bundle. There is no automatic SAVE!

Implementation details:

All task types: AfterFederationTask, ArtifactTask and ProcessingTask, will have an abstract class that should be extended. It's necessary to force receive parameters on contructor. This is a impl detail but its important 'cos it avoids us to wrap each task into another callable interface. General code:

Task extends Callable<Void>

BaseTask implements Task, Callable<Void>

DependsOnStrong(value[]: Class<? extends BaseTask>)
DependsOnWeak(value[]: Class<? extends BaseTask>)

Comparator<Class<? extends Task>>{
int compare(Class<? extends Task> classA, Class<? extends Task> classB){
// get the annotation DependsOnStrong and/or DependsOnWeak
// each class entrie on DependsOn will add one "point" to the compare item
// after that, perform the same procedure on this class entrie
}
}

Environment

Any

Activity

Show:

Alex PorcelliNovember 7, 2010 at 11:05 AM

The PropertyDef annotation will continue, not for any kind of validation. PropertyDef will be used just to, during user's config actions, list all properties (including additional info like: name, is mandatory, data type and some description).

Alex PorcelliNovember 6, 2010 at 11:19 PM

[Por hora em português]
A task ArtifactTask deve ser dividida em dois tipos, uma que processa todos os arquivos a cada Task (ex: extração dos java types de todos os fontes) e outra que pode processar várias tasks por cada artefato (ex: extrair informação de jpa, extrator de métricas -> ambas necessitam antes que a extração dos java types já tenha sido executado

Alex PorcelliNovember 6, 2010 at 6:30 PM

As the PropertyDef changed just to have a name... and its the Task obligatio nto check if everything is ok, than we don't need the PropertyDef anymore...
And the task will just receive a Map<String, String>...

Alex PorcelliNovember 6, 2010 at 6:23 PM

And based on last comment, this is the needed config:

Group Jboss.org
Source svn.jboss.org
Mapping jboss/drools/expert/
classpath="xxx"; //this is a property
JavaInitTask.class; // this is a task definition that will get all setted properties.
ScalaInitTask; //another task that will receive the same properties (even if they aren't needed)

Alex PorcelliNovember 6, 2010 at 6:19 PM

In the beginning we defined the PropertyDef witgh the following data: propertyName, dataType (STRING|INT|FLOAT|BOOLEAN|PATH|CONTEXT_REF|CONTEXT_LIST_REF}, mandatory={true|false}) and mandatory indicator (boolean value).

But we figured out that teh Task shoudl validade and convert by itself if the properties are corrected set without any typing enforcement.

If a proprerty is a list of contexts or a boolean value, its a task obligation to check and handle that.

Details

Assignee

Reporter

Complexity

Medium

Components

Affects versions

Priority

Created July 19, 2010 at 4:36 PM
Updated November 7, 2010 at 11:05 AM