IntroductionDash Obtain provides an annotation-based approach to declaring component dependencies. With Dash Obtain dependencies are acquired, not injected. Dash Obtain is similar to the the Java EE @Resource annotation, but provides greater extensibility and is more easily integrated with other frameworks. Dependency acquisition is more clear than injection. The benefits of acquisition are:
How is it used?Dash Obtain is an annotation applied to static and instance fields. A simple code sample of using Dash Obtain: package example.dash.obtain;
public class Command implements Runnable {
@Obtain Connection dbConn;
@Obtain long maxCount;
public void run() {
Statement stmt = dbConn.createStatment();
...
}
}The configuration (maxCount) and component wiring (dbConn) are obtained when needed by this Command component. A sample configuration for this component (using the builtin PropertiesConfigProvider) is: # in file {classpath}/example/dash/obtain/Command.properties
maxCount=5
dbConn=jndi:jdbc/example.dbHow does it work?Dash Obtain ... See DashObtainCodeRoadmap for details of obtaining a field and how it works. |