Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Provides a DSL to declare instances without relying on XML.
This DSL looks like a fluent API using in classes annotated with the @Configuration annotation:
@Configuration
public class MyInstances {
Instance i1 = instance().of("my.factory")
.with("simple").setto("simple");
Instance i2 = instance()
.of("my.factory")
.with("simple").setto("simple")
.with("list").setto(list(1, 2, 3))
.with("list2").setto(list().with(1).with(2).with(3))
.with("map").setto(map().with(pair("entry", "value")))
.with("map").setto(map()
.with(pair("entry2", list("aaa", "bbb"))));
}
Methods returning instances should also be called (receiving an optional bundle context). Thus we can add some logic computing the instance configuration.
The DSL creates an instance declaration and not just an instance. It's equivalent to the <instance/> XML declaration.