Butterfly DI Container v. 2.5-9-beta: Easier Collection, Array, and Map Configuration
Butterfly Container is a Java dependency injection container. It is smaller (~100KB jar), yet more flexible and easier to use than Spring, Pico, and Guice (at least in the developers' opinion). Instead of XML, Butterfly Container is configured using a simple, flexible, Java-like configuration language, or by plugging plain non-annotation, non-reflection Java factories into the container. There are no external dependencies.
Here is an example of the script language:
object = * com.jenkov.MyObject();
myBean = * com.jenkov.MyBean(object);
myBean2 = * myBean.setExtraValue("someExtraValue");
The * means "new instance". A 1 would means "singleton".
Though less important, Butterfly Container also has great performance. It is 2-4 times faster at instantiating objects than Guice. Since Guice claims to be faster than Spring, Butterfly Container is probably faster than Spring too.
Version 2.5.9-beta brings easy Collection, array, and Map configuration in the Butterfly Container Script language. Here are two examples:
myList = * ["value1", valueFromFactory2, com.jenkov.Value3() ];
myMap = *<"key1" : "value1", keyFromFactory2 : valueFromFactory2, com.jenkov.Key3() : com.jenkov.Value3() > ;
Version 2.5.9-beta also adds the ability to assign names to the input streams you read container scripts from. This name is used when an error is detected in the script, making it easier to find out what file the error ocurred in. It is now also possible to have the ScriptFactoryBuilder close the script input stream for you. This version also fixes a minor bug related to parsing and error messages.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)