My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DashObtain  
Dash Obtain and Dependency Acquisition
obtain, intro
Updated Mar 1, 2007 by jhei...@gmail.com

Introduction

Dash 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:

  • Each component declaratively identifies its dependencies. This makes components more obvious, provides opportunities for automated documention, and increase the clarity of the code.
  • Lazy-loading Dependencies. DA make true lazy-loading (instead of proxy-based lazy-loading) a trivial implementation option. This helps avoid high start-up costs wiring components together.
  • A DA framework can be overlaid onto existing components. Tools like AspectJ can declare Annotations without even source code access.
  • Enables the provisioning of any resource. Spring and other IoC DI container already provide this, but EJB3 @Resource Annotations don't.

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.db

How does it work?

Dash Obtain ...

See DashObtainCodeRoadmap for details of obtaining a field and how it works.


Sign in to add a comment
Powered by Google Project Hosting