Your SlideShare is downloading. ×
0
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Hands on Spring 2.5
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Hands on Spring 2.5

3,096

Published on

Taller sobre Spring 2.5 creado por Sergi Almar y Erick Camacho. …

Taller sobre Spring 2.5 creado por Sergi Almar y Erick Camacho.
Impartido en el Open Java Day, en Madrid en junio de 2008 y en la 2a reunión de SpringhHspano en México D.F. en octubre de 2008

Published in: Technology, Self Improvement
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,096
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
203
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Hands-on Sergi Almar i Graupera (sergi.almar@javahispano.org)‏ Erick Camacho (ecamacho@javahispano.org)‏
  • 2. Contenido
    • Introducción a Spring
    • Spring en la capa de datos:
    • Spring JPA
    • Gestión de transacciones
    • Spring en la capa de servicios
    • Spring en la capa web:
    • SpringMVC
    • SpringSecurity
    Hands-on Spring 2.5
  • 3. Java JDK 5 o superior Eclipse 3.3 (Europa)‏ Herramientas Hands-on Spring 2.5
  • 4. Es un contenedor ligero de inversión de control (IOC). Contenedor de POJOs: BeanFactory y ApplicationContext IOC: Inyección de dependencias ¿Qué es Spring? Hands-on Spring 2.5 Hands-on Spring 2.5
  • 5. ¿Qué es Spring? II Diseño modular y extensible Hands-on Spring 2.5
  • 6. ¿Qué es Spring? III Integración con otras tecnologías. “ Spring should not compete with good existing solutions, but should foster integration”. (Spring no debe competir con soluciones buenas existentes, sino buscar la integración)‏ misión de Spring JDBC JPA Hibernate iBatis TopLink Quartz Struts JSF WebServices JTA LDAP Hands-on Spring 2.5
  • 7. El application Context: La piedra de toque < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot; > < bean id = &quot;mibean&quot; class = &quot;com.mipaquete.MiClase&quot; /> </beans> Hands-on Spring 2.5
  • 8. Anotaciones - @Autowired @Qualifier - @Resource, @PostConstruct, @PostDestruct - @Configurable <context:load-time-weaver aspectj-weaving=&quot;on&quot;/> - Stereotypes @Component (@Controller, @Service, @Repository...)‏ - @Transactional Hands-on Spring 2.5
  • 9. Spring JPA Integración transparente Inyección del EntityManager gestionado por Spring Nuevo en 2.5: @Repository Hands-on Spring 2.5
  • 10. Spring Transacciones Capa de abstracción para uniformizar el uso de transacciones con muchas tecnologías como JTA, JXTA, JDBC, etc. Declarativa en el XML o mediante anotaciones Hands-on Spring 2.5
  • 11. Spring MVC: DispatcherServlet Hands-on Spring 2.5
  • 12. ApplicationContext Hands-on Spring 2.5
  • 13. Beans especiales - Controladores - HandlerMappings - View resolvers - LocaleResolver - ThemeResolver - MultipartFileResolver Hands-on Spring 2.5
  • 14. Jerarquia controladores Hands-on Spring 2.5
  • 15. public class UsuarioController extends MultiActionController { public ModelAndView listar(HttpServletRequest req, HttpServletResponse res) {...} public ModelAndView buscar(HttpServletRequest req, HttpServletResponse res) {...} public ModelAndView mostrar(HttpServletRequest req, HttpServletResponse res) {...} } Ejemplo Spring 2.0 Hands-on Spring 2.5
  • 16. Spring MVC 2.5 simplifica la programación de Controladores - Anotaciones - Convention-over-configuration Spring MVC 2.5 Hands-on Spring 2.5
  • 17. - Nuevo model de controlador “multi-action” basado en POJO - Ya no es necesario extender de clases específicas del framework - Mapear URLs a métodos usando anotaciones @Controller Hands-on Spring 2.5
  • 18. @Controller public class UsuarioController { @RequestMapping public void listar() {...} @RequestMapping public void buscar(SearchCriteria criteria, BindingResult result) {...} @RequestMapping public void mostrar(@RequestParam(&quot;id&quot;) Long id) {...} } Ejemplo @Controller Hands-on Spring 2.5
  • 19. @RequestMapping - Mapea las peticiones - Diferentes estratégias para mapear - Simple - Relativo al nombre del controlador - Externalizado - Basado en convención (recomendado)‏ - Hands-on Spring 2.5
  • 20. @RequestMapping - Simple @Controller public class UsuarioController { @RequestMapping( “/usuario/listar” )‏ public void listar() {...} @RequestMapping( “/usuario/buscar” )‏ public void buscar(SearchCriteria criteria, BindingResult result) {...} @RequestMapping( “/usuario/mostrar” )‏ public void mostrar(@RequestParam(&quot;id&quot;) Long id) {...} } Hands-on Spring 2.5
  • 21. @RequestMapping – Relativo controlador @Controller @RequestMapping( “/usuario/*” )‏ public class UsuarioController { @RequestMapping public void listar() {...} @RequestMapping public void buscar(SearchCriteria criteria, BindingResult result) {...} @RequestMapping public void mostrar(@RequestParam(&quot;id&quot;) Long id) {...} } Hands-on Spring 2.5
  • 22. @RequestMapping – Externalizado @Controller public class UsuarioController { @RequestMapping public void listar() {...} @RequestMapping public void buscar(SearchCriteria criteria, BindingResult result) {...} @RequestMapping public void mostrar(@RequestParam(&quot;id&quot;) Long id) {...} } <bean class=“...SimpleUrlHandlerMapping”> <property name=&quot;mappings&quot;> <value> /usuario/*=usuarioController </value> </property> </bean> Hands-on Spring 2.5
  • 23. @RequestMapping – Convención <bean class =“...ControllerClassNameUrlHandlerMapping” /> @Controller public class UsuarioController { @RequestMapping public void listar() {...} @RequestMapping public void buscar(SearchCriteria criteria, BindingResult result) {...} @RequestMapping public void mostrar(@RequestParam(&quot;id&quot;) Long id) {...} } Hands-on Spring 2.5
  • 24. Binding -Simple @RequestMapping public void mostrar( @RequestParam ( &quot;id&quot; ) Long id) {...} Hands-on Spring 2.5
  • 25. @RequestMapping public void foo(HttpServletRequest req, ...) {...} @RequestMapping public void foo(HttpServletResponse res, ...) {...} @RequestMapping public void foo(HttpSession session, ...) {...} @RequestMapping public void foo(Locale locale, ...) {...} @RequestMapping public void foo(Principal principal, ...) {...} Parámetros especiales Hands-on Spring 2.5
  • 26. Seleccionar vistas Dos técnicas: - Por convención @Controller public class UsuarioController { @RequestMapping public void listar() {...} } - Nombre de vista en String @Controller public class UsuarioController { @RequestMapping public String listar() { return “/usuario/listar” ; } } Hands-on Spring 2.5
  • 27. Exponer objectos del modelo Dos técnicas: - Devolver un único objecto (no String; recomendado para casos simples)‏ - Declarar un Modelo y añadir parámetros (más flexible) Hands-on Spring 2.5
  • 28. @RequestMapping public List<Usuario> buscar(SearchCriteria criteria) {...} - El parámetro se expone en usuarioList - @RequestMapping public @ModelAttribute( “usuarios” ) List<Usuario> buscar(SearchCriteria criteria) {...} Devolver un Objeto Hands-on Spring 2.5
  • 29. @RequestMapping public void buscar(SearchCriteria criteria, Model model) { List<Usuario> usuarios = usuarioServicice.getUsuarios(criteria); model.addObject(“usuarios”, usuarios); } Añadir al modelo Hands-on Spring 2.5
  • 30. Exportar @Controllers Dos técnicas: - Definición del bean explícito <bean class = “...SimpleUrlHandlerMapping” > <property name=&quot;mappings&quot;> <value> /usuario/*=usuarioController </value> </property> </bean> <bean id =“ usuarioController ” class = “...UsuarioController” /> - Classpath scanning <context:annotation-config /> <context:component-scan base-package = ”com.mycompany.app” /> Hands-on Spring 2.5
  • 31. Form • JA-SIG CAS • Basic • JOSSO • JDBC • SiteMinder • LDAP • Atlassian Crowd • NTLM • OpenID • Containers • X.509 • JAAS • Digest Métodos de autenticación Hands-on Spring 2.5
  • 32. GRACIAS!! Hands-on Spring 2.5

×