Spring is a unique Java application framework meant to simplify the development of applications. Whereas Enterprise Java Beans are very complex to use, the Spring Framework is an easy to use and understand framework for enterprise applications. Spring focuses on:
The Jetspeed portal is configured completely as a Spring application. All services in Jetspeed are constructed and configured as Spring beans. Jetspeed runs in a Spring container. Spring provides a great environment for customization your deployment of Jetspeed. Some of the added benefits of Spring in Jetspeed are:
Jetspeed, as a Spring application, is a collection of components, or services, all assembled together to create a complete working portal. If you look at from this point of view, you can see the major portal components being managed by the container, which is really just a Spring container as shown in the diagram below. Note this is by no way an inclusive list of all Jetspeed services wired in Spring:
When developing Jetspeed core, Jetspeed extensions, or Jetspeed Administrative Portlets, you should always program to the Jetspeed API. All Jetspeed Components are wired together on interfaces, not class implementations. This contract-by-interface approach to programming makes for a powerful and extensible programming model for developing enterprise portal applications. When you are configuring your Jetspeed Spring components (beans), you will see that components have their dependencies wired in to other Jetspeed components via dependency injection. The injected dependencies are always interfaces. Dependencies are declaratively managed in the Spring configuration. In Jetspeed, we support both constructor and setter dependency injection. Here is an example of a component having its dependencies constructor-injected:
<bean id='PortalAdministrationImpl' init-method="start" class='org.apache.jetspeed.administration.PortalAdministrationImpl'> <constructor-arg index='0'> <ref bean="org.apache.jetspeed.security.UserManager"/> </constructor-arg> <constructor-arg index='1'> <ref bean="org.apache.jetspeed.security.RoleManager"/> </constructor-arg> <constructor-arg index='2'> <ref bean="org.apache.jetspeed.security.GroupManager"/> </constructor-arg> <constructor-arg index='3'> <ref bean="org.apache.jetspeed.page.PageManager"/> </constructor-arg> <constructor-arg index='4'> <ref bean="org.apache.jetspeed.prefs.PreferencesProvider"/> </constructor-arg> <constructor-arg index='5'> <ref bean="org.apache.jetspeed.profiler.Profiler"/> </constructor-arg> <constructor-arg index='6'> <ref bean="mailSender"/> </constructor-arg> <constructor-arg index='7'> <ref bean="adminVelocityEngine"/> </constructor-arg> </bean>
And here is the Java code constructor matching the Spring configuration. Notice that the dependencies injected are interfaces, not concrete class implementations:
public PortalAdministrationImpl( UserManager userManager, RoleManager roleManager, GroupManager groupManager, PageManager pageManager, PreferencesProvider preferences, Profiler profiler, JavaMailSender mailSender, VelocityEngine velocityEngine)