Info
- Note: The Actifsource Template Editor is a text editor
- Writing a template for Service means that any specific information on services comes from the specific domain model
- The generic filename must contain a Variable to be unique for any specific Service
↪ Place the cursor on the Filename Line
↪ Use Content Assist (Ctrl+Space) to insert a Variable
↪ Choose the Resource Service
↪ Press ‘. ’ (dot) after Service
↪ Content Assist opens automatically.
↪ Press Ctrl+Space to reopen Content Assist manually
↪ Select the Attribut name for Service
↪ Add the postfix Impl
to the file name
↪ Add the language extension .java
to the file name
↪ Save the file → a new file in your Target Folder src is created
Info
- Note that syntax highlighting is automatically activated based on the file extension
Info
- The orange bar on the left hand side is called main context
- All text in the main context is generated for every specific Resource of type Service
↪ Write a Java Class as shown above. Make sure the class name contains the Variable Service.name
↪ Use Content Assist (Ctrl+Space) to insert the Variable
↪ Or use Copy/Paste (Ctrl+C/Ctrl+V) to copy the class name from file name
↪ Save the file (Ctrl+S) → Generated code can be found in the target folder src
Info
- Let’s create a function for every Call in the Service
↪ Place the cursor in the class body
↪ Use the tool Insert Line Context (Alt+Insert) from the tool bar
Info
- A new Line Context has been created
- All text in the Sub Context shall be generated for every Resource of type Call in this Service
↪ Attach the Sub Context to the Parent Context using the Selector
↪ The given Selector must therefore navigate from Service to Call using Service.call
↪ Use Content Assist (Ctrl+Space) to specify the Selector
↪ Press Enter in the Selector to return to code
↪ Write a function in the Call Context as shown above
Info
- The context grows as used
- Save the file (Ctrl+S). The generated file should contain a class and its methods. Tip: Add another Service/Call.
Info
- Let’s create a Java parameter for every Parameter in the Call
↪ Place cursor between the brackets
↪ Use the tool Insert Column Context (Alt+Shift+Insert) from the tool bar
↪ Write a parameter list in the Parameter Context as shown above
↪ Don’t forget the ‘, ’ (Comma) at the end
↪ Save the file (Ctrl+S). The generated file should contain a Java class , its methods and parameters
Info
- Note that all text in the Parameter Context shall be generated
- For that reason, there is a superfluous comma at the end of the last Parameter
Info
- Single characters, but even lines, can be marked with Attributes
- First (Alt+1) → Applied for the first iteration of the Context
- Not First (Alt+2) → Applied for any iterations of the Context but the first
- Not Last (Alt+3) → Applied for any iterations of the Context but the last
- Last (Alt+4) → Applied for the last iteration of the Context
- Empty (Alt+5) → Applied if Context is never iterated
Info
- The comma has to be written after each Parameter except after the last one
↪ Select both the comma and the following space
↪ Choose Not Last (Alt+3) from the tool bar
↪ Save the file (Ctrl+S). The generated file should contain a class , its methods and parameters
Info
- No superfluous comma is generated this time
Info
- Let’s write specific code for the generated functions
↪ Place cursor in the function body
↪ Insert a Protected Context in the function body with the tool shown above
↪ Write any text in the Protected Context, e.g. a TODO comment
Info
Note that Call is translated in Call. Tip: Rename Call to ServiceCall to find out why this makes sense
↪ Write specific code within the Protected Regions of the generated files
Info
You must not delete the Tags Begin Protected Region and End Protected Region
Tip
Alter the template code. Save the template. See what happens with the Protected Regions