Sam Brannen gave a presentation on composable software architecture with Spring. He discussed how modern enterprise applications need to interact with multiple external systems and services. A composable architecture uses modular, stateless components that can be assembled in different combinations. Spring supports this through features like dependency injection, inversion of control, and its ecosystem of projects. The roadmap for Spring 4.0 includes better support for Java 8, configuring Spring with Groovy, and key Java EE 7 technologies.
2. 2
Sam Brannen
• Spring and Java Consultant @ Swiftmind (Zurich)
• Developing Java for over 15 years
• Spring Framework Core Committer since 2007
• Spring Trainer
• Presenter on Spring, Java, OSGi, and testing
3. 3
Swiftmind
Your experts for Enterprise Java
Areas of expertise
• Spring Framework
• Java EE
• OSGi
• Agile Methodologies
• Software Engineering Best Practices
Headquarters
• Zurich, Switzerland
• @swiftmind
• http://www.swiftmind.com
4. 4
Agenda
• Enterprise Applications
• What we’ve learned as a community
• Composable Software Architecture
• Java EE + Open Source
• How Spring fits into the picture
• Spring 4.0 Roadmap
6. 6
What does "enterprise" mean?
Enterprise software is software used in organizations, such
as in a business or government, as opposed to software
used by individuals. Enterprise software is an integral part of
a (computer based) Information System.
-Wikipedia
10. 10
Typical Enterprise Application
• Supports enterprise business process
• Is relatively large
• Should be robust, scalable, and offer high performance
• Does not run in isolation
• Interacts with multiple external systems and services …
21. 21
Things to avoid
• Tight coupling to the container or frameworks
• Tight coupling to protocols and exchange formats in our
service layer
• Monolithic deployment units
• Anemic domain models
• Bloated transaction scripts
• Code tangling and scattering
22. 22
What we should aim for
• Modularity
• Layered architecture with
– a canonical domain model
– a dedicated orchestration layer
• Separation of concerns
• Externalized environment-specific configuration
• Design for testability
23. 23
How we achieve it
• OOA / OOD / OOP
• (@)POJO Programming Model
• Marshaling and automatic type conversion
• Dependency Injection (DI)
• Inversion of Control (IoC)
• AOP / Interceptor Model
• Automated out-of-container testing and CI
25. 25
Composability
Composability is a system design principle that deals with
the inter-relationships of components. A highly
composable system provides recombinant components that
can be selected and assembled in various combinations
to satisfy specific user requirements. (Wikipedia)
• Self-contained (modular)
• Typically stateless
39. 39
How is this new?
• To be honest, it’s not really new,
– if you just look at the diagram…
• The web tier or presentation layer has always effectively
been a type of orchestration layer.
• The difference is that we re-use all of the other layers
with multiple types of orchestration simultaneously!
40. 40
Orchestration Layer
• Lies at the heart of a composable architecture
• Orchestrates all interactions with the service layer
– potentially interacting directly with repositories (e.g.,
in batch processing)
• Handles external protocols
• Converts from external formats into our canonical domain
model
• Thereby… allowing application services to be composed in
a multitude of different ways!
41. 41
Common Types of Orchestration
• Web controller
– HTTP, HTTPS :: HTTP request and response
• REST or SOAP Web Service endpoint
– HTTP/HTTPS :: XML, JSON, binary, …
• JMS or AMQP listener (or message listener container)
– JMS Message types, domain entities, …
• Messaging endpoint (e.g., gateway + service activator)
– Web service, FTP, file system, email, …
• Batch component (e.g., reader, writer, processor)
– Files, SQL, …
43. 43
What's good about Java EE?
• Set of common enterprise standards for Java
• Consistent across containers and vendors (mostly)
• Great tooling and build support
• Catching up with innovation in open source
– Hibernate à JPA
– Spring DI / Guice / Seam à CDI
50. 50
or in an alternative light-weight container.
51. 51
Open Source Frameworks fill the Gaps
• Web frameworks and UI components
• NoSQL
• Big Data
• AMQP
• Mobile
• Social Media
• Batch
• Enterprise Integration (EAI)
• …
57. 57
Spring is an Ecosystem
• Spring MVC
• Spring REST
• Spring Web Flow
• Spring Security
• Spring Web Services
• Spring Batch
• Spring Integration
• Spring Data
• Spring Mobile
• Spring Social
• Spring AMQP
• …
58. 58
Spring MVC and REST
• @Controller annotated components serve as MVC
handler methods and REST endpoints
• Automatic type conversion
• Data binding to domain entities
• Marshaling
– JSON, JAXB, Castor, XMLBeans, JiBX, XStream, …
• Handler methods and endpoints orchestrate the service
layer
59. 59
Spring Web Services
• @Endpoint annotated components serve as SOAP Web
Service endpoints
• Marshaling (OXM)
– JAXB, Castor, XMLBeans, JiBX, XStream
• Endpoint methods orchestrate the service layer
60. 60
Spring JMS
• Message listener containers (MLC) support
– JMS MessageListener API
– Message-driven POJOs
• Automatic type conversion from JMS Message types into
– String, Map, Object, byte[]
– Customer converters also supported
• Marshaling
– Spring OXM, customer solutions, etc.
• MLC orchestrates the service layer
61. 61
Spring Integration
• Inbound and outbound messaging gateways
– Handle external protocols and APIs
– Too many to mention here!
• Automatic type conversion for method arguments and
return types in Service Activators
• Marshaling and custom type conversion also supported
• The service layer can be orchestrated via declarative
configuration (e.g., service activators in XML)
63. 63
Composable Architecture – with Spring
Infrastructure
Repository
Service
DomainModel
Spring REST
Spring MVC
Spring JMS
Spring Integration
Spring Batch
Spring WS
64. 64
Composable Architecture Checklist
þ Modularity
þ Layered architecture
þ Canonical Domain Model
þ Orchestration: web, batch, integration, web services
þ Service
þ Repository
þ Infrastructure
þ POJO programming model
þ Separation of concerns
þ Externalized environment-specific configuration
þ Testability, automated testing, and CI
66. 66
1st Class Support for Java 8 based apps
• Language features such as lambda expressions
– for callbacks with templates
– for concurrent execution
• think fork/join, map/reduce, etc.
• APIs such as JSR-310 Date and Time
– Alongside Spring’s existing support for JodaTime
67. 67
Configuring Spring with Groovy 2
• Configuring and implementing Spring-style applications
using Groovy 2.x
• Groovy-based bean definitions
• Groovy as the language of choice for an entire
application, as a direct and straightforward alternative to
Java source files
• Groovy 2.0's static compilation support completes the
picture here
68. 68
Support for Key Java EE 7 Technologies
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• Servlet 3.1
• And fully covering JCache 1.0
70. 70
Fine-grained Eventing and Messaging
• Introducing fine-grained eventing and messaging within
the application
• Building on our existing application event mechanism
• Aligned with our JMS message listener mechanism
71. 71
Pruning and Dependency Upgrades
• Removing a variety of deprecated packages across the
framework
– See Spring Framework 3.2's deprecations!
• Raising minimum dependencies to Java 6+
– Java SE 6+ and Java EE 6+
– with some compromises for EE 5++ servers