To understand the answer to this question, it is important you first understand the answer to the question What is an Across context?
The Across application is the combination of all modules configured in your application. The Across application module is a single module in your application, it is the one containing your application specific logic. The application module is always considered to depend on all other “shared” modules, and as such is started as the last module (with the exception of possible specialized postprocessor modules).
Shared modules have an explicit module descriptor, whereas the application module has an implicit one that is derived from the name and package of the @AcrossApplication
annotated class. The application module is determined using a convention-over-configuration approach. The content of the application module is all content present in the application
package that is a child of the package holding the @AcrossApplication
class. The key for resources of this module will be derived from the @AcrossApplication
class name.
An example:
@AcrossApplication
class is com.foo.MyApplication
MyApplicationModule
com.foo.application
my
An application module will only be created if there is a package named application
. You can have an Across application built using only shared modules.
The @AcrossApplication
class is part of the root Spring ApplicationContext
. That class should typically only contain application setup and configuration code. Anything declared in that ApplicationContext
will be available to all modules. The other way around - accessing module components on the @AcrossApplication
level directly - should be avoided.
Across prefers all business logic to be packaged in modules. Having your application-specific logic bundled inside an application module allows you to use any of the exposed beans from other modules, as the bootstrap order can be guaranteed. Conditions on the existence of components will work as expected and it also makes it easier to convert the application module to a shared module at any point in time (by simply providing a module descriptor).