Customizations
There are 2 ways to add custom code to an applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution.:
- Insert code in custom anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion..
- Add a custom class to one of the ext directories.
You will be using both when implementing custom features in you applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution..
Custom Anchors
A custom anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. is a location in the generated code that is demarcated by 2 comments: a start and an end anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion..
Custom anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. always start with anchor:custom-.
This sets them apart from other anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion., which do not contain custom and are not harvestable.
@EJB
MessageCrudsLocal messageCrudsLocal;
// anchor:custom-variables:start
// anchor:custom-variables:end
Simply add some code between the anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion. and then execute harvest. The changes you made will be stored in the source directory.
// anchor:custom-variables:start
private int count;
// anchor:custom-variables:end
Ext Directories
Each Component LayerLayerLogical separation of functionality within a single system/application, focused on code organization. has an ext and a gen directory.
- The gen directory contains all of the generated artifactsArtifactA build or deployment result, such as a Docker container image or Java archive, produced by a software project..
- The ext directory can be used to add additional classes and other files to the project.
When harvestingHarvestingThe process of extracting and persisting custom code from anchors and ext directories back into source directories., files in these directories are stored to the source directory to be returned on the next expansion.
demoApp
├── components
│ ├── space
. │ ├── control
. │ ├── gen
│ └── ext
├── data
│ ├── gen
. └── ext
Hiding non-custom Anchors
You can hide non-custom anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion. in the generated code by adding the following option to your expansionSettings:
ExpansionSettingsHide non-custom anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion., such as anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion. used by expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. and feature anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion.
<options>
<hideAnchors/>
</options>