Ordering¶
Note
Guicey always preserve items registration order, which may be changed only
by using explicit @Order
annotation).
General¶
Order is natural. For example, @Order(10)
will be before @Order(20)
.
When no annotation present, class order set to Integer.MAX_VALUE
, so
all classes without order annotation are always goes last.
Extensions order¶
Note
Not all extensions supports ordering: look specific installer page or
installers report.
For example, managed, servlets and
filters installers support order.
The most common case for ordering is ordering managed objects. For example:
@Order(20)
public class Managed1 implements Managed { ... }
@Order(10)
public class Managed2 implements Managed { ... }
public class Managed3 implements Managed { ... }
Will be ordered as: Managed2
, Managed1
, Managed3
Note
Guicey remembers extensions registration order:
.extensions(Ext1.class, Ext2.class)
So when no explicit ordering defined (or for elements with the same order value) registration order will be preserved.
Tip
You can use diagnostic report to see actual extensions order.
Installers order¶
All bundled installers are ordered from 0 to ~110 with gap 10 between them to let you easily put your installers between (if required).
Use @Order
annotation to order custom installer, otherwise it will go after all
default installers.
Tip
You can use installers report to see actual installers order.
Bundles order¶
Attention
Bundles can't be explicitly ordered.
Bundles are transitive and transitive registrations appear at the middle of bundle configuration, so it is physically impossible to order bundles.
Still there are implicit order of bundle processing:
- Manually registered bundles (including transitive)
- Bundles lookup
But, again, don't count on this order because, for example, bundle resolved through lookup mechanism could be also manually registered and so processed with manual bundles.
Modules order¶
Attention
Modules can't be explicitly ordered.
According to guice guice: modules should not contain conditional logic So modules should only register bindings and order does not matter in that case.