Alfresco is built using the best of breed open-source components, designed with extensibility in mind. Heavily utilizing the Spring Framework, Alfresco provides hooks to update basic configuration, customize behavior and presentation, add new functionality, and even replace entire subsystems. This talk will cover different Spring configuration options available and demonstrate specific use cases for Alfresco.
2. Agenda!
Spring Overview
Dependency Injection
Bean Definitions
Alfresco Spring Bootstrap
Some Examples
3. What is Spring?!
• The most popular application development framework for
enterprise Java
• Based on code published in “Expert One-on-One J2EE
Design and Development” by Rod Johnson (Wrox, 2002).
• Made up of many modules
• Fosters integration with good existing solutions
4. What is a Spring Bean?!
• Plain Old Java Objects!
• No special interfaces or base classes needed!
• Usually have getter and setter methods for accessing properties!
• Can be interrogated or manipulated via the Java Reflection API!
• Focused on implementing your business logic!
• Across all tiers of your application!
• Usually highly cohesive!
• Not an old pre-3.0 EJB!!
• Usually agnostic to the Spring container!
5. Agenda!
Spring Overview
Dependency Injection
Bean Definitions
Alfresco Spring Bootstrap
Some Examples
6. What is Dependency Injection?!
• Springʼs Dependency Injection instantiates and combines
beans to form your application!
• Decouples the configuration and specification of
dependencies from your actual program logic!
• Removes the need for programmatic singletons!
• Beans should implements and depend on interfaces!
10. BeanFactory and ApplicationContext!
• org.springframework.beans.factory.BeanFactory
• Base interface for actual Spring DI container!
• Instantiates or sourcing application objects!
• Configures such objects!
• Assembles the dependencies between these objects!
• org.springframework.context.ApplicationContext
• ApplicationContext is a complete superset of a BeanFactory!
• adds enhanced capabilities to it, more J2EE and enterprise-centric!
12. Bean Definition!
Bean are represented as BeanDefinition objects!
• Bean Identifier(s)!
• Class name!
• Bean Properties / Constructor-Args!
• Behavioral Elements!
• Definition Reuse!
13. Bean Definition - Identifiers!
• All beans must have at least 1 identifier!
• Beans identifiers must be unique withind BeanFactory!
• Prefer using id attribute vs name attribute!
• Multiple identifiers are considered aliases!
14. Bean Definition - Class Names!
• Class attribute is usually the class we want to construct!
• Class is almost always needed!
• Except for non-static factory beans and abstract beans!
• Use fully qualified class names!
• FactoryBean interface build object of different types!
15. Bean Definition - Properties!
• Writeable Bean Properties correspond to “setters”!
• Property name follows JavaBean convention!
• Values set can be primitives or objects!
• Static values, e.g. Strings, ints, …!
• Property lookups, from a Properties file or Environment variable!
• Other bean definitions references!
16. Bean Definition – Contructor Args!
• Number/Type of arguments must match an existing
constructor!
• Useful for explicitly requiring dependencies!
• Constructor argument names are usually “erased” during
compilation !!
• Sometimes “index” or “type” needed to disambiguate!