Streamlining Python Development: A Guide to a Modern Project Setup
Developing Agile Java Applications using Spring tools
1. Developing Java Applications in Agile way using SpringSource Tool Suite (STS) 2.3.2, Maven, Spring tc server Presented by : Sathish Chittibabu Date : May 11th2010 Event : Solstice Consultants Round table discussion
2. Agenda 2/19 Spring Framework (Introduction) Spring 3.0 – What’s new ? (if needed) SpringSource Tool Suite (STS) 2.3.2 Spring tcServer Maven Quick example So what’s Agile here ?
4. Spring Framework Open source framework for Java development ( Spring Core, Spring MVC, Spring JDBC, Web Services etc.,) Lightweight, non-invasive container Dependency Injection or Inversion of Controller Assemble complex system from loosely coupled POJOs Reusable business and data access components not tied to J2EE services. Spring managed applications can run in any J2EE environment, as standalone apps, test environments Lean Software Movement 4/19
5. Spring 3.0 – What’s new ? Java 5+ support Spring Expression Language REST Support Portlet 2.0 Declarative model validation Early support for Java EE6 5/19
16. Every method returns a spring managed bean@Bean @Primary @Lazy public DemoServicedemoService(){ DemoServiceImpl service = new DemoServiceImpl(); service.setDataSource(…); return service; } 7/19
19. App code doesn’t depend on Spring Annotations instead uses Java Annotations@Service@Scope ("request") @Transactional(rollbackFor=Exception.class) @Retention(RetentionPolicy.RUNTIME) public @interface MyService{} @MyService public class DemoService{ … } 8/19
23. Implicit web specific attributes are also available (e.g., contextParameters, contextAttributes, request, session)#{systemProperties.databaseName} #{myBean.myProperty} 9/19
24.
25. @PathVariable introduced – URI templates@Controller@RequestMapping("/hotels/{hotel}") --- optional public class HotelsController{ @RequestMapping-- matches /hotels/42 public void handleHotel(@PathVariable("hotel") String hotel) { //... } @RequestMapping("bookings/{booking}") -- matches /hotels/42/bookings/21 public void handleBooking(@PathVariable("hotel") String hotel, @PathVariableint booking){ // ... } } 10/19
36. JSR 303 – “Bean Validation” through annotation
37. Validation in any layerpublic class DemoBean { @NotNull @Past private Date someDate; } 12/19
38. SpringSource Tool Suite (STS) 2.3.2 Eclipse-powered Java Integrated development environment (IDE) for building spring-powered enterprise applications Includes tools for all of the latest Enterprise Java and Spring based technologies Supports application targeting local, virtual and cloud based servers In built support for SpringSourcedmServer and SpringSourcetcServer Also available as Eclipse plugin 13/19
39. Spring tcServer Enterprise version of Apache Tomcat Spring and Apache Tomcat – KISSing cousins Lightweight App Server suited for usage in modern virtual or Cloud environments Small foot print, lean approach requires significantly less computing resources Available in Spring edition, Standard edition and Developer edition Developer edition is integrated with STS Spring insight – analytical and advanced diagnostic tool for real time insight into performance (metrics) and behavior of Spring applications 14/19
40. Maven Project Management and comprehension tool to manage Builds, Documentation, Reporting, Dependencies, SCMs, Releases, Distribution Ant is procedural while Maven is Object Oriented Employs standard conventions and practices to accelerate development cycle Concept of Central Repository – share 3rd party and open source libraries across projects (intranet as well internet) Continuous Integration – automated build, release, tests etc., In words of Jason van Zyl "the intent of Maven is to make intra-project development highly manageable in the hopes of providing more time for cross-project development. You might call it cross-project pollination or the sharing of project development knowledge; this is what Maven attempts to encourage". 15/19
41. Maven – Pom.xml POM (Project Object Model) – XML representation of maven project Declarative manifestation of “who” , “what” and “where”, while the build lifecycle is the “when” and “how” Maven solves Dependency Management issues “jarmageddon” and “jar Hell” thru common local repository from which to link projects correctly 16/19
42. Maven- Standard Layout for Projects Java sources go under ${basedir}/src/main/java Web stuff go under ${basedir}/src/main/webapp Test sources go under ${basedir}/src/test/java Compiled classes go under ${basedir}/target/classes where ${basedir} represents the directory containing pom.xml Maven local repository –~/.m2/repository 17/19
43. So What’s Agile here ? Don’t have to worry about build infrastructure – boiler plate Don’t have to scratch your head on the different version of libraries Don’t have to spend time on App server setup on your dev environment Can develop “Runtime Environment Agnostic” Java code Development is quick - Hot deployment on tcServer Develop lean software – easy to support & maintain And now you can actually concentrate on building application code 18/19