Petals CDK

Better organisation of the JBI Schemas and their handling in Java

Details

  • Type: Task Task
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 5.4.2
  • Fix Version/s: 5.9.0
  • Component/s: Utils
  • Security Level: Public
  • Description:
    Hide

    Currently we got the following situation with respect to the JBI xml schema:

    • There is a schema definition in petals-jbi-descriptor that follows the official JBI specification
    • associated to it are JAXB generated classes and a JAXB parser to get a Java view of a jbi xml file.
    • There is an extension in the same project
    • the schema describe only the supplementary elements in a different namespace without saying where they are (it does not actually extends the jbi schema)
    • there is a JAXB parser that is applied in an ad-hoc way to the anyOrAny element of the service element.
    • There is the CDK jbidescriptor that completely redefines the JBI schema with its added elements
    • there are associated JAXB Java classes and the parser
    • For some components, there is extension to the CDK schema defined with xsd
    • but they are not actually used as real schema extension of the CDK jbi (not used for validation, not used for parsing with the CDK parser)
    • sometimes there are ad-hoc jaxb parser for them (for example in the SE BPMN2)

    There is thus the following problem:

    • some classes are duplicated and potentially different between the original JBI and the CDK jbi
    • there is ad-hoc handling of the original extension but manipulable using Java classes
    • there is ad-hoc low-level handling of the component-specific schema elements without any generalised mechanism to validate and parse them.

    Currently, things work because there is multiple "any" elements everywhere (in services, consumes and provides I think... maybe in other places) we have the need to add component-specific things in an ad-hoc way...

    In the same way as with the issue EASYWSDL-13, we should try to find a way to:

    • reuse generated classes, but in this case the problem is mainly that we want to extend schemas.
    • provide, from a component development point of view, a JAXB parser that takes the extension as an xsd and as generated classes, and that parse the extended xml files seamlessly.

    The first one is going to be hard, the second one should be easier.

    Show
    Currently we got the following situation with respect to the JBI xml schema:
    • There is a schema definition in petals-jbi-descriptor that follows the official JBI specification
    • associated to it are JAXB generated classes and a JAXB parser to get a Java view of a jbi xml file.
    • There is an extension in the same project
    • the schema describe only the supplementary elements in a different namespace without saying where they are (it does not actually extends the jbi schema)
    • there is a JAXB parser that is applied in an ad-hoc way to the anyOrAny element of the service element.
    • There is the CDK jbidescriptor that completely redefines the JBI schema with its added elements
    • there are associated JAXB Java classes and the parser
    • For some components, there is extension to the CDK schema defined with xsd
    • but they are not actually used as real schema extension of the CDK jbi (not used for validation, not used for parsing with the CDK parser)
    • sometimes there are ad-hoc jaxb parser for them (for example in the SE BPMN2)
    There is thus the following problem:
    • some classes are duplicated and potentially different between the original JBI and the CDK jbi
    • there is ad-hoc handling of the original extension but manipulable using Java classes
    • there is ad-hoc low-level handling of the component-specific schema elements without any generalised mechanism to validate and parse them.
    Currently, things work because there is multiple "any" elements everywhere (in services, consumes and provides I think... maybe in other places) we have the need to add component-specific things in an ad-hoc way... In the same way as with the issue EASYWSDL-13, we should try to find a way to:
    • reuse generated classes, but in this case the problem is mainly that we want to extend schemas.
    • provide, from a component development point of view, a JAXB parser that takes the extension as an xsd and as generated classes, and that parse the extended xml files seamlessly.
    The first one is going to be hard, the second one should be easier.
  • Environment:
    -

Issue Links

Activity

Hide
Vincent Zurczak added a comment - Wed, 4 Mar 2015 - 16:10:58 +0100

And this is only about the way Petals parses jbi.xml files.

Get prepared for some reading!

You could also think about finding a common solution for both the platform and the tooling (Maven, Eclipse, whatever). The best solution would be to have a single module that handles parsing and validation for the CDK. Same thing for every component.

Moreover, the way it is done currently in the server part was designed this way because of the XSD redefine keyword. This feature allowed to redefine an element in XSD 1.0. The idea was to refine the jbi type in the CDK, and then in the component. Unfortunately, but for obvious reasons, this keyword was deprecated in XSD 1.1. Thus, the XML configuration of Petals files relies on dirty hacks and is hardly manageable.

Still for history, even if the redefine keyword seemed a clean solution at the time, JAX-B never supported it. So, basically, the way jbi.xml files are defined never worked efficiently, neither in implementation, nor in design. You either have to use any elements, or you have to create a big XML schema that defines everything (take a look at Petals Studio, there is such one big nasty XSD for the Eclipse XML editor). The current option does not allow modularity and extensibility in an efficient manner.

This organization was implemented by the end of 2007. It has been discussed hundreds of times until 2012, with Roland Naudin, Nicolas Salatgé and many others. Everytime, no action was undertaken because there were so called other priorities. This has also slowed down the creation of tools (Eclipse to not mention it). The studio has its own parser for configuration files (and it's really messy). And in fact, there has been two different parsers implemented (one with a XSD parser, another one based on EMF, both with the intent of generating user interfaces - almost - automatically from the model, which has been another long-time requirement from the team leaders).

IMO, the way jbi.xml files are organized is only good for trash.
The way there are parsed and retrieved in the components and above (CDK, container) is also inefficient. In my last work period on Petals, we were focused on other issues related to user features in exploitation environments (monitoring, logs, etc). But if I had continued to work on Petals, this topic would come number one on the todo-list. If you look at the studio's code on GitHub, there is a branch called properties-model. You will find a plugin called com.ebmwebsourcing.petals.studio.dev.properties. The idea I explored back then was to split the jbi.xml file (keep the standard part, move the CDK configuration in a distinct properties file, and move the component in another properties file). If you look at Petals components, they only have simple properties. Same thing for the CDK, except it has also few (simple) lists. The idea behind the library was to...

  • ... define the model in properties files. Parameters are property names. Default values are property values. And types and optionality would be defined in comments with a simple syntax.
  • ... simplify the Petals wizards in the studio. Instead of giving parameter values, just select which component version you want to configure through a SU and generate a pre-filled project.
  • ... move the project edition entirely in editors. Most of the UI could be generated or enriched from the model.
  • ... define core modules, one per CDK version and one per component version. Such a module would contain an annotated properties file that defines the model, Java classes (for additional validators and code generators), plus Java beans to use at runtime in components (that could be generated from the properties model).

These changes would bring three things.
First, drop the base code of the studio from several ten thousands LOC to less than 20K.
Second, have an efficient model and approach when developing components (code generation for the Java beans, conventions for validations, etc).
And last, developing a Petals component would imply (under the hood) prepare the tooling for this component (less development efforts, just integration to complete then).

I do not know whether this is the best option.
But it has the advantage of being simple to understand and to maintain, by modularizing the code, by centralizing the parts for the runtime and tools, by reducing the code base, and by relying on something tailored for "our" needs (and not for hypothetical ones). If you have completed user features and start working on this, a redesign would be welcome (and since this will break everything, that's what I used to call Petals 5). I do not know whether Petals wants to bring back code contributors, but if so, I think this has to be done (with or without properties, whatever...).

My 2 (x10 = 20) cents.

Show
Vincent Zurczak added a comment - Wed, 4 Mar 2015 - 16:10:58 +0100 And this is only about the way Petals parses jbi.xml files. Get prepared for some reading! You could also think about finding a common solution for both the platform and the tooling (Maven, Eclipse, whatever). The best solution would be to have a single module that handles parsing and validation for the CDK. Same thing for every component. Moreover, the way it is done currently in the server part was designed this way because of the XSD redefine keyword. This feature allowed to redefine an element in XSD 1.0. The idea was to refine the jbi type in the CDK, and then in the component. Unfortunately, but for obvious reasons, this keyword was deprecated in XSD 1.1. Thus, the XML configuration of Petals files relies on dirty hacks and is hardly manageable. Still for history, even if the redefine keyword seemed a clean solution at the time, JAX-B never supported it. So, basically, the way jbi.xml files are defined never worked efficiently, neither in implementation, nor in design. You either have to use any elements, or you have to create a big XML schema that defines everything (take a look at Petals Studio, there is such one big nasty XSD for the Eclipse XML editor). The current option does not allow modularity and extensibility in an efficient manner. This organization was implemented by the end of 2007. It has been discussed hundreds of times until 2012, with Roland Naudin, Nicolas Salatgé and many others. Everytime, no action was undertaken because there were so called other priorities. This has also slowed down the creation of tools (Eclipse to not mention it). The studio has its own parser for configuration files (and it's really messy). And in fact, there has been two different parsers implemented (one with a XSD parser, another one based on EMF, both with the intent of generating user interfaces - almost - automatically from the model, which has been another long-time requirement from the team leaders). IMO, the way jbi.xml files are organized is only good for trash. The way there are parsed and retrieved in the components and above (CDK, container) is also inefficient. In my last work period on Petals, we were focused on other issues related to user features in exploitation environments (monitoring, logs, etc). But if I had continued to work on Petals, this topic would come number one on the todo-list. If you look at the studio's code on GitHub, there is a branch called properties-model. You will find a plugin called com.ebmwebsourcing.petals.studio.dev.properties. The idea I explored back then was to split the jbi.xml file (keep the standard part, move the CDK configuration in a distinct properties file, and move the component in another properties file). If you look at Petals components, they only have simple properties. Same thing for the CDK, except it has also few (simple) lists. The idea behind the library was to...
  • ... define the model in properties files. Parameters are property names. Default values are property values. And types and optionality would be defined in comments with a simple syntax.
  • ... simplify the Petals wizards in the studio. Instead of giving parameter values, just select which component version you want to configure through a SU and generate a pre-filled project.
  • ... move the project edition entirely in editors. Most of the UI could be generated or enriched from the model.
  • ... define core modules, one per CDK version and one per component version. Such a module would contain an annotated properties file that defines the model, Java classes (for additional validators and code generators), plus Java beans to use at runtime in components (that could be generated from the properties model).
These changes would bring three things. First, drop the base code of the studio from several ten thousands LOC to less than 20K. Second, have an efficient model and approach when developing components (code generation for the Java beans, conventions for validations, etc). And last, developing a Petals component would imply (under the hood) prepare the tooling for this component (less development efforts, just integration to complete then). I do not know whether this is the best option. But it has the advantage of being simple to understand and to maintain, by modularizing the code, by centralizing the parts for the runtime and tools, by reducing the code base, and by relying on something tailored for "our" needs (and not for hypothetical ones). If you have completed user features and start working on this, a redesign would be welcome (and since this will break everything, that's what I used to call Petals 5). I do not know whether Petals wants to bring back code contributors, but if so, I think this has to be done (with or without properties, whatever...). My 2 (x10 = 20) cents.
Hide
Victor NOËL added a comment - Mon, 5 Oct 2015 - 11:28:05 +0200

See also PETALSCDK-21

Show
Victor NOËL added a comment - Mon, 5 Oct 2015 - 11:28:05 +0200 See also PETALSCDK-21
Hide
Christophe DENEUX added a comment - Mon, 5 Oct 2015 - 15:56:45 +0200 - edited

Postponed to 5.7.2 or upper

Show
Christophe DENEUX added a comment - Mon, 5 Oct 2015 - 15:56:45 +0200 - edited Postponed to 5.7.2 or upper

People

Dates

  • Created:
    Wed, 4 Mar 2015 - 15:05:53 +0100
    Updated:
    Tue, 11 Apr 2023 - 11:54:53 +0200