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 :)
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. • 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. • 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. 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. 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"/>