Wednesday, November 21, 2007

Dependencies

Examples:
* any kind of service (eg session bean)
* config
* Transporta appconfig

Problems
* testing - dependency which requires initialization, eg. transporta appconfig
helper invokes through xcs for the appconfig
* config reads from database
* injection doesnt work for non-ejb components
* need a uniform way of handling these things
* where do you initialise things?

Solution Ideas
* dependency injection
* put all dependencies in the constructor, use interfaces
* have service locators or singletons

Dependency Injection
=====================

have an interface, and component is
injected with a working service at run time - BUT - this is troublesome if you
don't have an injection container.

alternatives to DI - new, static, Factory, JNDI

What is Spring?

Non Dependency Injection
========================

Declare dependencies in constructor, use interfaces if they need to be mocked
out. Initialization can be through JNDI container-created components, otherwise
through a setup class.

through constructors, you can make sure dependencies are met, you can easily see
what a class uses.



Links
* http://www.onjava.com/pub/a/onjava/2006/02/08/j2ee-without-application-server.html
* http://www.brandonwerner.com/category/technology/architecture/service-oriented-architecture/page/2/
* http://www.theserverside.com/tt/articles/article.tss?l=SpringFramework

No comments: