Now let us assume we want to refactor one of our modules to have an extra layer. We cannot do this change in the aspect file because this would apply to all modules. If we still want to be able to use the aspect for this module we need some way to extend or modify the elements in the aspect file:
artifact Module2 { include "Module2/**" apply "layering" // New layer artifact BusinessInterface { include "**/businessinterface/**" } // Now Business and UI need access to BusinessInterface extend Business { connect to BusinessInterface } extend UI { connect to BusinessInterface // UI should not use Business directly disconnect from Business } }
Extending an artifact only makes sense in the context of apply directives. It allows us to add nested elements to an artifact and/or modify its connections to other artifacts. Within an extended artifact you can also use the keyword override to override the definitions of interfaces or connectors defined in the original version of the artifact:
artifact Module2 { // ... extend Business { // This assumes that the imported version of Business has an interface named "X" override interface X { // Use other patterns or other exports include "**/x/*" } connect to BusinessInterface } // ... }
This allows you to adapt the architecture elements derived from an aspect file when needed.