Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Spring

590 views

Published on

Alex a ne-a prezentat Spring la Geek Meet #6 Timişoara. Spring este o platformă de dezvoltare croită pentru proiecte Java, iar despre avantajele ce le oferă puteţi afla mai multe din prezentare, asta dacă nu aţi ajuns la Geek Meet :)

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Spring

  1. 1. Spring
  2. 2. Spring? • Inversion of control • Dependency Injection
  3. 3. • DEPENDENCY INJECTION Atunci cand : • public Car buildCar() { Car car = new Car(); Engine engine = new Engine(); car.setEngine(engine); return car; } - Scriem cod ca asta si vrem sa-i impresionam pe altii;
  4. 4. • INVERSION OF CONTROL Atunci cand : • public Car buildCar() { Car car = new Car(); Engine engine = new Engine(); car.setEngine(engine); return car; } … si chestia de mai sus, o face Springu’
  5. 5. • Cool stuff: – Roo - roo generate controller ;) – Easy configuration with xml; – Templates for Hibernate DAO; – AOP features: aspects, advices, pointcuts ☺ – Easy to configure a project with it: – Standard set of libraries; – Many examples; – Good documentation and many books; – Its so full of patterns! ☺
  6. 6. Container Configuration • Dependency Injection <bean id=“myCar" class=“gm.Ford"> <property name=“engine" ref=“renaultEngine" /> </bean> <bean id=“renaultEngine" class=“renault.engines.RenaultEngine“/> • Inversion of control myCar = context.getBean(“myCar”); • Service locator Is what spring is using for retrieving the objects from its container;
  7. 7. Fast configuration • Autowiring <bean id="sequenceGenerator“ class="SequenceGenerator” autowire="byType"> </bean> <bean id="datePrefixGenerator” class="DatePrefixGenerator"> class SequenceGenerator { public SequenceGenerator(DatePrefixGenerator generator) {…} } • Scan package <context:component-scan base-package=“org.mypackage"/>
  8. 8. …bean creation • Prototype (instance/request) • Singleton (instance/IOC container) • Session/Request (instance/session/request) • Proxying: • Necessary for AOP (see proxy pattern)
  9. 9. Aspects • Advice • Ex: logging before and after • Pointcut • Ex: account.putMoney() • Aspect – Advice + Pointcut: Log(“[Enter]putMoney”) Account.putMoney(); Log(“[Exit]putMoney”)
  10. 10. Externalized configuration • @Controller • @RequestMapping • @Aspect • @Autowired
  11. 11. QA? http://alexsisu.posterous.com/ alexandru.sisu@gmail.com
  12. 12. Resources • http://www.springsource.org/ • http://www.springbyexample.org • http://www.springsource.org/roo

×