150 likes | 411 Views
Creation of external bundles . Gendoc2 v1.0.1 2010/03/29. External bundles usage. External bundles are used to : Provide a set of Java services that will be used inside Gendoc2 scripts Group services by functionality or model type ex : Requirements, UML, …
E N D
Creation of external bundles Gendoc2 v1.0.12010/03/29
External bundles usage • External bundles are used to : • Provide a set of Java services that will be used inside Gendoc2 scripts • Group services by functionality or model type ex : Requirements, UML, … • External bundles can be used inside gendoc2 scripts : • Imported by default or imported explicitly using the attribute ‘importedBundles’ of the <context> tag • Bundle names are separated by a semicolon (‘;’) when importing several bundles in a script with attribute ‘importedBundles’ Example : <context model=‘${model}’ element=‘RootElement’ importedBundles=‘topcased;requirements’/> => Bundles “topcased” and “requirements” are imported. • When a bundle has been imported, all services provided by the bundle can be used directly into Gendoc2 scripts that follow this context definition
Creation of an external bundle NOTE : • All the examples presented in the following steps refer to Acceleo technology for scripts. • For now, Acceleo language is the only script language handled by Gendoc2. • Acceleo language description is available at: http://wiki.eclipse.org/Acceleo • Steps to create an external bundle • Creation of an Acceleo project • Creation of an Acceleo generation file • References to the metamodel(s) • Creation of one (or several) Java file(s) containing a list of services • Creation of Acceleo queries mapped with Java methods • Registration to Gendoc2 extension point for external bundles • Export of the bundle as a plugin to integrate into Eclipse platform
Creation of an Acceleo project (1/3) • Create a new Acceleo project using menu File -> New … -> Acceleo project • Fill project name :(for example : org.topcased.gendoc2.bundle.acceleo.<<your bundle name>>)
Creation of an Acceleo project (2/3) • Initialize the Acceleo generation file Name of the generation module Metamodelto use for generation No impact for external bundles
Creation of an Acceleo project (3/3) • Overview of the generated plugin and generation file Generatedbundle plugin Metamodel URL Generation file Module name Useless for bundles(Can be deleted manually) Acceleo script
Creation of Java services • Create Java classes containing the Java services into the bundle plugin
Mapping Java services to Acceleo queries • Inside Acceleo file (.mtl) : • Remove generated part containing [template …] • Add necessary metamodels (separated by ‘,’) • For each Java service needed, add a query with : • A name • A list of typed parameters • A return type • An invoke of the Java method Metamodel(s) Java class Java method Input parameters
Registration to Gendoc2 extension point (1/4) • Add a dependency to org.topcased.gendoc2.script.acceleo plugin • Inside MANIFEST.MF file, in “Dependancies” tab, clic on button “Add”
Registration to Gendoc2 extension point (2/4) • Inside tab “Extensions” of MANIFEST.MF, clic on ‘Add’ • Select the extension point to register to : “org.topcased.gendoc2.script.acceleo.services”
Registration to Gendoc2 extension point (3/4) • The extension definition needs : • A unique name • A .emtl file (corresponds to a compiled.mtl file) => can be found in /bin directory of the plugin instead of /src • A boolean : • If false : this bundle must be explicitely referenced inside “importedBundles” attribute of the <context> tag • If true : bundle imported by default
Registration to Gendoc2 extension point (4/4) • The list of metamodels that are necessary for the services provided must be associated to the extension. They can be added by a right-clic on the service • For each one, fill : • the metamodel name • the metamodel URL
Export the external bundle plugin (1/2) • Before exporting, indicate specifically the export of all .emtl file(s) present in /bin directory In “Build” tab of plugin.xml file : Add .emtl file to binary build
Export the external bundle plugin (2/2) • Use export wizard, present in “Overview” tab of the plugin.xml file, indicating the output directory • Put the generated JAR file inside directory “dropins” of your Eclipse install. • Restart your Eclipse : the bundle is available for use
Usage in a Gendoc2 template document • Add bundle name in the “importedBundles” attribute of <context> tag(not necessary if the bundle has been created as “importedByDefault”) • Call the queries declared in the bundle inside <gendoc> tags • Generated :