Sunday, May 30, 2010

Java Injection (CanDI) Pattern Tutorial

Java Injection (CanDI) Pattern TutorialJava Injection (CanDI) Pattern Tutorial June 15, 2009 Contents 1 Overview 1 1.1 Tutorial Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Java Injection API . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Service Pattern 4 2.1 Using Services from PHP and JSP . . . . . . . . . . . . . . . . . 5 3 Resource XML Con guration Pattern 6 4 Startup Pattern 9 5 Plugin/Extension Pattern 9 1 Overview The four main CanDI patterns share a common goal: improve code with a declarative injection style. When Java classes cleanly describe their dependen- cies, their lifecycles, and their exports, they are self-documenting.

You can read the classes and understand how they will behave, i.e. you don’t need to read the code side-by-side with XML con guration to understand the system’s behavior. The custom, typesafe binding annotations are key to CanDI’s self- documentation, because injection points clearly describe the resources or ser- vices they expect with adjective-oriented annotations. Because the annotations are true Java classes, they are documented in JavaDoc and veri ed by the com- piler. The small number of meaningful adjectives means they don’t impose a signi cant coding burden, and are well worth the small extra development time. CanDI Application Patterns PATTERN DESCRIPTION Service Pattern Organize the application as a collec- tion of services. 1 1.1 Tutorial Architecture 1 OVERVIEW Resource Con guration Pattern Bind and resources with declara- tive annotations and con gure with XML. Startup Pattern Use @Startup beans to initialize ap- plication state. Plugin/Extension Pattern Discover plugin/extension classes for a service. This tutorial describes four main CanDI design patterns: services, resources, startup and extensions. Services center an application’s design by encapsulating management and data. Resources are the con gurable interface between the user and the application. Startup initializes the application. And extensions allow sophisticated applications to tailor...

Website: www.caucho.com | Filesize: 149kb
No of Page(s): 10
Download Java Injection (CanDI) Pattern Tutorial.pdf

No comments:

Post a Comment