Whale is a lightweight dependence Injection(DI) container that fully implements JSR330, and supports  javax.inject  and  jakarta.inject  API both. If

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-10-03 13:00:04

Whale is a lightweight dependence Injection(DI) container that fully implements JSR330, and supports javax.inject and jakarta.inject API both. If you are a Java developer and familiar with spring framework or google guice, we highly recommend you giving whale a try.

JSR330's appeal lies in its simplicity, consisting of just 4 annotations and one interface. To enhance flexibility, whale adds 2 annotations: Valued and Bind, as follows:

Whale offers four approaches for managing the dependencies between Java objects. To illustrate these methods, let's examine some sample test code. We'll assume the test code is located in the directory on the classpath: "/tmp/project/demo/bin".

If you are a Spring Framework developer, you will be very familiar with XML configuration. Whale also supports you defining the manged objects in the XML file located in "/tmp/project/demo/beans.xml":

Please note that XML definition just supports field injection(using the props tag), constructor injection(using the args tag) and method injection(using the methods tag). For the constructor and method injection, you must explicitily declare the parameter types. Othewise, whale may not be able to correctly identify overloaded methods in certain situations. For example:

Leave a Comment