Spring Framework Intro Rob Lambert
Spring Framework Intro Rob Lambert
Spring Framework
Rob Lambert
Schawk, Inc.
About Me
Spring Overview
from springframework.org
Note: Spring distribution comes as one big jar file and alternatively as a series of smaller
jars broken out along the above lines (so you can include only what you need)
Spring is Non-Invasive
What does that mean?
You are not forced to import or extend any Spring
APIs
An invasive API takes over your code.
Anti-patterns:
An AOP Framework
BeanFactories
BeanFactories
By default, beans are treated as singletons
Can also be prototypes
Here is an example:
The beans fully
The beans ID
qualified classname
<beans>
<bean id=widgetService
class=com.zabada.base.WidgetService>
<property name=poolSize>
<!-property value here-->
</property>
</bean>
Maps to a setPoolSize() call
</beans>
calls
setWidgetDAO(myWidgetDAO)
where myWidgetDAO is another
bean defined in the configuration
Dependency Injection
(Inversion of Control)
Complicated sounding terms for a fairly
simple concept
The Hollywood Principle: Dont call
me, Ill call you
Dependencies used from within a bean
arent asked for outwardly, but are
injected into the bean by the container
Dependency Injection
(Inversion of Control)
An ApplicationContext is a BeanFactory,
but adds framework features such as:
i18n messages
Event notifications
Auditing
Caching
Custom security
Data Access
Email
Remoting
Controller (org.springframework.web.servlet.mvc.Controller)
View (org.springframework.web.servlet.mvc.View)
Model
To complete the MVC trio, note that the model is typically handled as a
java.util.Map which is returned with the view
the values of the model are available, for example in a JSP, using a
<jsp:useBean/> where the id corresponds to the key value in the Map
My Spring Recipes
My Spring recipes and examples:
http://www.zabada.com/technology/Wiki.jsp?page=SpringRecipes
On to the examples
( See http://www.zabada.com/technology/Wiki.jsp?page=SpringRecipes )
Wrap Up
Questions/Comments?
Feedback is appreciated!
Email me: [email protected]
Credits