DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Butterfly DI Container v. 2.5-9-beta: Easier Collection, Array, and Map Configuration

Jakob Jenkov user avatar by
Jakob Jenkov
·
Sep. 10, 08 · · News
Like (0)
Save
Tweet
570 Views

Join the DZone community and get the full member experience.

Join For Free

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.

Container

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Synchronization Methods for Many-To-Many Associations
  • Java Hashtable, HashMap, ConcurrentHashMap: Performance Impact
  • Use Lambda Function URL To Write a Serverless App Backed by DynamoDB
  • Why Is Software Integration Important for Business?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo