SlideShare a Scribd company logo
Subtitle Text
Author
Contact info

David Gómez
@dgomezg
Spring 4
core improvements
Spring 4 core improvements
Generics in Qualifiers
Exposing attributes in Meta-annotations
Autowiring Lists and Arrays
@Description on @Configuration classes
@Conditional (user-defined @Profiles)
Time Zone support on Locale Context
Generics in Qualifiers
En Spring 3.2….
public interface MessageService {	

!
!

public String getMessage();	

}	
public class GeneralWaver 	
implements MessageService{	
	
	
@Override	
public String getMessage() {	
return "Hello world!";	
}	

public class PersonWaver	
	
	
implements MessageService {	

!

	

!

!

}	

@Autowired	
public PersonRepository personRepository;	
@Override	
public String getMessage() {	
...	
}	

}
public class MultiMessagePrinter {	

!

	

!

!

}	

//All Message Services are injected	
@Autowired 	
private List<MessageService> messageServices;	
public void printMessage() {	
for (MessageService messageService: messageServices) {	
System.out.println(messageService.getMessage());	
}	
}
Generics in Qualifiers
En Spring 3.2….
<?xml version="1.0" encoding="UTF-8"?>	
<beans ...>	

!
!

	

!
!

<context:annotation-config/>	
<!-- Database config -->	
<jdbc:embedded-database id="dataSource">	
<jdbc:script location="classpath:sql/schema.ddl"/>	
<jdbc:script location="classpath:sql/data.sql"/>	
</jdbc:embedded-database>	
<bean id=“personRepository"	
	
class="com.autentia.playground.spring4.helloWorld.db.JdbcPersonRepository"/>	
<!-- Wavers (MessageService implementations) -->	
<bean id="personWaver" class="com.autentia.playground.spring4.helloWorld.messages.PersonWaver"/>	
<bean id="generalWaver" class="com.autentia.playground.spring4.helloWorld.messages.GeneralWaver"/>	

<!-- Printer : waves to everybody using available MessageServices -->	
<bean id="messagePrinter"
class="com.autentia.playground.spring4.helloWorld.messages.MultiMessagePrinter"/>	

!

</beans>
Generics in Qualifiers
En Spring 4 also….
public interface MessageService<T> {	

!
!

public T getMessage();	

}	
public class GeneralWaver 	
implements MessageService<String>{	
	
	
@Override	
public String getMessage() {	
return "Hello world!";	
}	

public class PersonWaver	
	
	
implements MessageService<Person> {	

!

	

!

!

}	

@Autowired	
public PersonRepository personRepository;	
@Override	
public Person getMessage() {	
...	
}	

}
public class MultiMessagePrinter {	

!
!
!

}	

@Autowired 	
private MessageService<Person> messageServices;	
public void printMessage() {	
System.out.println(messageService.getMessage().toString());	
}
Autowiring ordered Lists and Arrays
In Spring 3.2….
public interface MessageService {	

!
!

public String getMessage();	

}	
public class GeneralWaver 	
implements MessageService{	
	
	
@Override	
public String getMessage() {	
return "Hello world!";	
}	

public class PersonWaver	
	
	
implements MessageService {	

!

	

!

!

}	

@Autowired	
public PersonRepository personRepository;	
@Override	
public String getMessage() {	
...	
}	

}
public class MultiMessagePrinter {	

!

	

!

!

}	

//All Message Services are injected	
@Autowired 	
private List<MessageService> messageServices;	
public void printMessage() {	
for (MessageService messageService: messageServices) {	
System.out.println(messageService.getMessage());	
}	
Hello Sr. David Gomez G.	
}	
Hello world!
Autowiring ordered Lists and Arrays
In Spring 4….
public interface MessageService {	

!
!

public String getMessage();	

public class GeneralWaver 	 }	
implements MessageService, Ordered {	

!

!

!

}	

@Override	
public String getMessage() {	
return "Hello world!";	
}	
@Override	
public int getOrder() {	
return Integer.MIN_VALUE;	
}	
public class MultiMessagePrinter {	

!

	

!

!

}	

public class PersonWaver	
	
	
implements MessageService {	

!

	

!

@Autowired	
public PersonRepository personRepository;	
@Override	
public int getOrder() {	
return 0;	
}	

}

//All Message Services are injected	
@Autowired 	
private List<MessageService> messageServices;	
public void printMessage() {	
for (MessageService messageService: messageServices) {	
System.out.println(messageService.getMessage());	
}	
Hello world!	
}	

Hello Sr. David Gomez G.
Exposing attributes in Meta-annotations
In Spring 3.2….
@Target({ElementType.TYPE})	
@Retention(RetentionPolicy.RUNTIME)	
@Documented	
@Component	
public @interface Service {	
String[] value();	
}	

@Target({ElementType.TYPE})	
@Retention(RetentionPolicy.RUNTIME)	
@Service	
@Transactional(timeout=60)	
public @interface MyTransactionalService {	
String[] value();	
}	

@MyTransactionalService	
public class PersonWaver	
	
	
implements MessageService {	

!

	

!

}

@Autowired	
public PersonRepository personRepository;	
@Override	
public String getMessage() {	
...	
}
Exposing attributes in Meta-annotations
In Spring 4….
@Target({ElementType.TYPE})	
@Retention(RetentionPolicy.RUNTIME)	
@Service	
@Transactional	
public @interface MyTransactionalService {	
String[] value();	
Propagation propagation() default Propagation.REQUIRED;	
int timeout() default TransactionDefinition.TIMEOUT_DEFAULT;	

!

}	

@MyTransactionalService(propagation=Propagation.REQUIRES_NEW)	
public class PersonWaver	
	
	
implements MessageService {	

!

	

!

}

@Autowired	
public PersonRepository personRepository;	
@Override	
public String getMessage() {	
...	
}
@Description on @Configuration classes
In Spring 4….
@Configuration	
@ComponentScan	
public class Application {	

!

@Bean	
@Description("This is a mock implementation of MockService")	
MessageService mockMessageService() {	
return new MessageService() {	
@Override	
public String getMessage() {	
return "Hello world!";	
}	
};	
}	

}	

Useful when beans are exposed, !
for example, as JMX beans
@Profiles and @Conditional
In Spring 3.2….

!

<beans profile="dev">	
<jdbc:embedded-database id="dataSource">	
<jdbc:script location="classpath:sql/schema.ddl"/>	
<jdbc:script location="classpath:sql/data.sql"/>	
</jdbc:embedded-database>	
</beans>	
<beans profile="prod">	
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/LiveDataSource"/>	
</beans>	
-Dspring.profiles.active=“dev"

@Configuration	
@ComponentScan	
@Profile(“test”)	
public class Application {	

!

}	

@Bean	
@Description("This is a mock implementation of MockService")	
MessageService mockMessageService() {	
return new MessageService() {	
@Override	
public String getMessage() {	
return "Hello world!";	
}	
};	
}
@Profiles and @Conditional
In Spring 4….
@Configuration	
@ComponentScan	
public class Application {	

!

@Bean	
@Description("This is a mock implementation of MockService”)	
@Conditional(NoMessageServiceDefined.class)	
MessageService mockMessageService() {	
return new MessageService() {	
@Override	
public String getMessage() {	
return "Hello world!";	
}	
};	
}	

}	

!

public class NoMessageServiceDefined implements Condition {	

!

	
}

@Override	
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {	
return context.getBeanFactory().getBeansOfType(MessageService.class)	
	
	
	
.isEmpty();	
}
Web Container
improvements
Spring 4 web improvements
Support for Servlet 3.0
(Servlet 2.5 still supported for GAE compatibility)
(servlet 3.0 jar needed for SPRING MVC Tests)
@RestController (@RequestMapping + @ResponseBody)
@AsyncRestTemplate (Non-blocking REST clients)
!
@RestController
In Spring 3.2….
@Controller	
public class WaverController {	

!

!

!

}	

@RequestMapping("/person")	
public @ResponseBody Person showPersonalMessage() {	
return personWaver.getMessage();	
}	
@RequestMapping("/message")	
public @ResponseBody String showMessage() {	
return genericWaver.getMessage();	
}
@RestController
In Spring 4…
@RestController = @Controller + @ResponseBody
@RestController	
public class WaverController {	

!

!

!

}	

@RequestMapping("/person")	
public Person showPersonalMessage() {	
return personWaver.getMessage();	
}	
@RequestMapping("/message")	
public String showMessage() {	
return genericWaver.getMessage();	
}
@AsyncRestTemplate (Non-blocking REST clients)
RestTemplate
public class RestTemplate {	
	
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) {}	
	
public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object...
urlVariables) {}	
	
public <T> T postForObject(String url, Object request, Class<T> responseType, Object...
uriVariables) {}	
	
public void put(String url, Object request, Object... urlVariables) {}	
}	

public class RestTemplate {	
	
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) {}	
	
public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object...
urlVariables) {}	
	
public <T> T postForObject(String url, Object request, Class<T> responseType, Object...
uriVariables) {}	
	
public void put(String url, Object request, Object... urlVariables) {}	
}
@AsyncRestTemplate (Non-blocking REST clients)
AsyncRestTemplate
public class AsyncRestTemplate {	

!

	
	

public <T> ListenableFuture<ResponseEntity<T>> 	
	
	
getForEntity(String url, Class<T> responseType, Object... uriVariables) {}	

	
	

public ListenableFuture<URI> 	
	
	
postForLocation(String url, HttpEntity<?> request, Object... uriVariables) {}	

	
	
}	

public ListenableFuture<?> 	
	
	
put(String url, HttpEntity<?> request, Object... uriVariables) {}	

!
!

public interface ListenableFuture<T> extends Future<T> {	

!

	

!

}	

void addCallback(ListenableFutureCallback<? super T> callback);
@AsyncRestTemplate (Non-blocking REST clients)
AsyncRestTemplate
ListenableFuture<ResponseEntity<Person>> futureEntity = template.getForEntity(	
	
"http://localhost:8080/spring4/person/{personId}", Integer.class, 1);	

!

// register a callback	
futureEntity.addCallback(new ListenableFutureCallback<ResponseEntity<Person>>() {	
@Override	
public void onSuccess(ResponseEntity<Person> entity) {	
//...	
}	

!

	
});

@Override	
public void onFailure(Throwable t) {	
//...	
}
Spring 4
meets
Java 8
Support for lambdas on callbacks
In Spring 3.2
	
	

	
	
	

public Person findById(int id) {	
return jdbcTemplate.query("select * from persons where id = ?", 	
	
	
new RowMapper<Person>() {	
@Override	
	
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
	
	
return new Person(rs.getInt("id"),	
	
	
rs.getString("treatment"),	
	
rs.getString("name"),	
	
rs.getString("surname"),	
	
	
new Date(rs.getDate("birthDate").getTime()));	
	 	
}	
},	
	
id)	
	
.get(0);	
}
Support for lambdas on callbacks
In Spring 4

public Person findById(int id) {	
return jdbcTemplate.queryForObject(	
"select * from persons where id = ?",	
(rs, rowNum) -> new Person(rs.getInt("id"),	
rs.getString("treatment"),	
rs.getString("name"),	
rs.getString("surname"),	
new Date(rs.getDate("birthDate").getTime())),	
id);	
}
Support for lambdas on callbacks
In Spring 4

@Override	
@Transactional	
public Person getMessage() {	
final Person person;	

!

!
}

txTemplate.execute((txStatus) -> {	
person = messageRepository.findById(1);	
txStatus.setRollbackOnly();	
return null;	
});	
return person;
JSR-310
package java.time
Distinction between Computer-times and Human-Times
Human-Times
TimeZone (ISO-8601)
LocalDateTime
LocalDate
LocalTime
JSR-310
package java.time
Amounts of Time
Duration (nanosecond resolution)
Amounts of Days
Period (years, months, and days)
TimeZones
ZonedDateTime
OffsetDateTime
JSR-310 in Spring 4
In web handler Methods

import java.time.Clock;	
import java.time.ZoneId;	

!

@RestController	
public class WaverController {	

!

	
	

!

}	

@RequestMapping("/person")	
public Person showPersonalMessage(ZoneId zoneId) {	
	
Clock clock = Clock.of(zoneId)	
	
LocalTime time = LocalTime.now(clock);	
return personWaver.getMessageFor(time);	
}
External Libraries
External Libraries Support
Hibernate 3.6+
Hibernate 4.3 (JPA 2.1)
EhCache 2.1
Quartz 1.8
JodaTime 2.0
Hibernate Validator 4.3 (Bean Validation 1.1)
Jackson 2.0 (1.8/1.9 deprecated)
Other changes
Support for JEE7 (& JEE6)
Serlvet 3.0
JMS 2.0
JTA 1.2
JPA 2.1
Bean Validation 1.1
JSR-236 Concurrency (ThreadExecutors)
WebSockets
with
Spring 4
WebSocket Support
WebSocket server support via JSR-356 runtimes
(Tomcat 7.0.7 -Jetty 9)
Fallback option using SockJS
(SockJsHttpRequestHandler)

k on
tal
g 4”
ed
prin
icat
ed
ith S
D
ts w
ocke
ebS
“W
soon
ming
co
(de momento)

Subtitle Text
Author
Contact info

David Gómez
@dgomezg
Ad

More Related Content

What's hot (20)

the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
Joshua Long
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
Joshua Long
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
Andrei Savu
 
Spring 4 - A&BP CC
Spring 4 - A&BP CCSpring 4 - A&BP CC
Spring 4 - A&BP CC
JWORKS powered by Ordina
 
Dropwizard
DropwizardDropwizard
Dropwizard
Scott Leberknight
 
Java web programming
Java web programmingJava web programming
Java web programming
Ching Yi Chan
 
Java Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application SecurityJava Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application Security
IMC Institute
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
Rossen Stoyanchev
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with Spring
Joshua Long
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
kamal kotecha
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFu
VMware Tanzu
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
Zachary Klein
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
backdoor
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
Skills Matter
 
Servlet
Servlet Servlet
Servlet
Dhara Joshi
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
Micha Kops
 
JAX-RS 2.1 Reloaded @ Devoxx
JAX-RS 2.1 Reloaded @ DevoxxJAX-RS 2.1 Reloaded @ Devoxx
JAX-RS 2.1 Reloaded @ Devoxx
Santiago Pericas-Geertsen
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
Fahad Golra
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
Joshua Long
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
Joshua Long
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
Andrei Savu
 
Java web programming
Java web programmingJava web programming
Java web programming
Ching Yi Chan
 
Java Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application SecurityJava Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application Security
IMC Institute
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with Spring
Joshua Long
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
kamal kotecha
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFu
VMware Tanzu
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
Zachary Klein
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
backdoor
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
Skills Matter
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
Micha Kops
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
Fahad Golra
 

Similar to Spring4 whats up doc? (20)

Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
Ignacio Coloma
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
Alexis Hassler
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
JBug Italy
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
javatwo2011
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
Massimiliano Dessì
 
TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...
tdc-globalcode
 
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparison
Emily Jiang
 
1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand
SOAT
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT Talk
Constantine Mars
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
DataArt
 
Creating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdfCreating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdf
ShaiAlmog1
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
Daniel Wellman
 
VRaptor 4 - JavaOne
VRaptor 4 - JavaOneVRaptor 4 - JavaOne
VRaptor 4 - JavaOne
Rodrigo Turini
 
MVM - It's all in the (Implementation) Details
MVM - It's all in the (Implementation) DetailsMVM - It's all in the (Implementation) Details
MVM - It's all in the (Implementation) Details
Florina Muntenescu
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Michel Schudel
 
JavaCro'15 - GWT integration with Vaadin - Peter Lehto
JavaCro'15 - GWT integration with Vaadin - Peter LehtoJavaCro'15 - GWT integration with Vaadin - Peter Lehto
JavaCro'15 - GWT integration with Vaadin - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Spring boot
Spring boot Spring boot
Spring boot
Vinay Prajapati
 
Android Architecture Components - Guy Bar on, Vonage
Android Architecture Components - Guy Bar on, VonageAndroid Architecture Components - Guy Bar on, Vonage
Android Architecture Components - Guy Bar on, Vonage
DroidConTLV
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
Toshiaki Maki
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
Alexis Hassler
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
JBug Italy
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
javatwo2011
 
TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Android How we figured out we had a SRE team at ...
tdc-globalcode
 
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparison
Emily Jiang
 
1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand
SOAT
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT Talk
Constantine Mars
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
DataArt
 
Creating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdfCreating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdf
ShaiAlmog1
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
Daniel Wellman
 
MVM - It's all in the (Implementation) Details
MVM - It's all in the (Implementation) DetailsMVM - It's all in the (Implementation) Details
MVM - It's all in the (Implementation) Details
Florina Muntenescu
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Michel Schudel
 
Android Architecture Components - Guy Bar on, Vonage
Android Architecture Components - Guy Bar on, VonageAndroid Architecture Components - Guy Bar on, Vonage
Android Architecture Components - Guy Bar on, Vonage
DroidConTLV
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
Toshiaki Maki
 
Ad

More from David Gómez García (20)

Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022
David Gómez García
 
Building Modular monliths that could scale to microservices (only if they nee...
Building Modular monliths that could scale to microservices (only if they nee...Building Modular monliths that could scale to microservices (only if they nee...
Building Modular monliths that could scale to microservices (only if they nee...
David Gómez García
 
Building modular monoliths that could scale to microservices (only if they ne...
Building modular monoliths that could scale to microservices (only if they ne...Building modular monoliths that could scale to microservices (only if they ne...
Building modular monoliths that could scale to microservices (only if they ne...
David Gómez García
 
Leveraging Completable Futures to handle your query results Asynchrhonously
Leveraging Completable Futures to handle your query results AsynchrhonouslyLeveraging Completable Futures to handle your query results Asynchrhonously
Leveraging Completable Futures to handle your query results Asynchrhonously
David Gómez García
 
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
David Gómez García
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
David Gómez García
 
What's in a community like Liferay's
What's in a community like Liferay'sWhat's in a community like Liferay's
What's in a community like Liferay's
David Gómez García
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
David Gómez García
 
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTRT3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
David Gómez García
 
Parallel streams in java 8
Parallel streams in java 8Parallel streams in java 8
Parallel streams in java 8
David Gómez García
 
Construccion de proyectos con gradle
Construccion de proyectos con gradleConstruccion de proyectos con gradle
Construccion de proyectos con gradle
David Gómez García
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
David Gómez García
 
Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min.
David Gómez García
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
David Gómez García
 
El poder del creador de Software. Entre la ingeniería y la artesanía
El poder del creador de Software. Entre la ingeniería y la artesaníaEl poder del creador de Software. Entre la ingeniería y la artesanía
El poder del creador de Software. Entre la ingeniería y la artesanía
David Gómez García
 
Geo-SentimentZ
Geo-SentimentZGeo-SentimentZ
Geo-SentimentZ
David Gómez García
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript Scripting
David Gómez García
 
Wtf per lineofcode
Wtf per lineofcodeWtf per lineofcode
Wtf per lineofcode
David Gómez García
 
A real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodbA real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodb
David Gómez García
 
Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022
David Gómez García
 
Building Modular monliths that could scale to microservices (only if they nee...
Building Modular monliths that could scale to microservices (only if they nee...Building Modular monliths that could scale to microservices (only if they nee...
Building Modular monliths that could scale to microservices (only if they nee...
David Gómez García
 
Building modular monoliths that could scale to microservices (only if they ne...
Building modular monoliths that could scale to microservices (only if they ne...Building modular monoliths that could scale to microservices (only if they ne...
Building modular monoliths that could scale to microservices (only if they ne...
David Gómez García
 
Leveraging Completable Futures to handle your query results Asynchrhonously
Leveraging Completable Futures to handle your query results AsynchrhonouslyLeveraging Completable Futures to handle your query results Asynchrhonously
Leveraging Completable Futures to handle your query results Asynchrhonously
David Gómez García
 
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
David Gómez García
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
David Gómez García
 
What's in a community like Liferay's
What's in a community like Liferay'sWhat's in a community like Liferay's
What's in a community like Liferay's
David Gómez García
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
David Gómez García
 
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTRT3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
David Gómez García
 
Construccion de proyectos con gradle
Construccion de proyectos con gradleConstruccion de proyectos con gradle
Construccion de proyectos con gradle
David Gómez García
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
David Gómez García
 
Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min.
David Gómez García
 
El poder del creador de Software. Entre la ingeniería y la artesanía
El poder del creador de Software. Entre la ingeniería y la artesaníaEl poder del creador de Software. Entre la ingeniería y la artesanía
El poder del creador de Software. Entre la ingeniería y la artesanía
David Gómez García
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript Scripting
David Gómez García
 
A real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodbA real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodb
David Gómez García
 
Ad

Recently uploaded (20)

Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 

Spring4 whats up doc?

  • 3. Spring 4 core improvements Generics in Qualifiers Exposing attributes in Meta-annotations Autowiring Lists and Arrays @Description on @Configuration classes @Conditional (user-defined @Profiles) Time Zone support on Locale Context
  • 4. Generics in Qualifiers En Spring 3.2…. public interface MessageService { ! ! public String getMessage(); } public class GeneralWaver implements MessageService{ @Override public String getMessage() { return "Hello world!"; } public class PersonWaver implements MessageService { ! ! ! } @Autowired public PersonRepository personRepository; @Override public String getMessage() { ... } } public class MultiMessagePrinter { ! ! ! } //All Message Services are injected @Autowired private List<MessageService> messageServices; public void printMessage() { for (MessageService messageService: messageServices) { System.out.println(messageService.getMessage()); } }
  • 5. Generics in Qualifiers En Spring 3.2…. <?xml version="1.0" encoding="UTF-8"?> <beans ...> ! ! ! ! <context:annotation-config/> <!-- Database config --> <jdbc:embedded-database id="dataSource"> <jdbc:script location="classpath:sql/schema.ddl"/> <jdbc:script location="classpath:sql/data.sql"/> </jdbc:embedded-database> <bean id=“personRepository" class="com.autentia.playground.spring4.helloWorld.db.JdbcPersonRepository"/> <!-- Wavers (MessageService implementations) --> <bean id="personWaver" class="com.autentia.playground.spring4.helloWorld.messages.PersonWaver"/> <bean id="generalWaver" class="com.autentia.playground.spring4.helloWorld.messages.GeneralWaver"/> <!-- Printer : waves to everybody using available MessageServices --> <bean id="messagePrinter" class="com.autentia.playground.spring4.helloWorld.messages.MultiMessagePrinter"/> ! </beans>
  • 6. Generics in Qualifiers En Spring 4 also…. public interface MessageService<T> { ! ! public T getMessage(); } public class GeneralWaver implements MessageService<String>{ @Override public String getMessage() { return "Hello world!"; } public class PersonWaver implements MessageService<Person> { ! ! ! } @Autowired public PersonRepository personRepository; @Override public Person getMessage() { ... } } public class MultiMessagePrinter { ! ! ! } @Autowired private MessageService<Person> messageServices; public void printMessage() { System.out.println(messageService.getMessage().toString()); }
  • 7. Autowiring ordered Lists and Arrays In Spring 3.2…. public interface MessageService { ! ! public String getMessage(); } public class GeneralWaver implements MessageService{ @Override public String getMessage() { return "Hello world!"; } public class PersonWaver implements MessageService { ! ! ! } @Autowired public PersonRepository personRepository; @Override public String getMessage() { ... } } public class MultiMessagePrinter { ! ! ! } //All Message Services are injected @Autowired private List<MessageService> messageServices; public void printMessage() { for (MessageService messageService: messageServices) { System.out.println(messageService.getMessage()); } Hello Sr. David Gomez G. } Hello world!
  • 8. Autowiring ordered Lists and Arrays In Spring 4…. public interface MessageService { ! ! public String getMessage(); public class GeneralWaver } implements MessageService, Ordered { ! ! ! } @Override public String getMessage() { return "Hello world!"; } @Override public int getOrder() { return Integer.MIN_VALUE; } public class MultiMessagePrinter { ! ! ! } public class PersonWaver implements MessageService { ! ! @Autowired public PersonRepository personRepository; @Override public int getOrder() { return 0; } } //All Message Services are injected @Autowired private List<MessageService> messageServices; public void printMessage() { for (MessageService messageService: messageServices) { System.out.println(messageService.getMessage()); } Hello world! } Hello Sr. David Gomez G.
  • 9. Exposing attributes in Meta-annotations In Spring 3.2…. @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Component public @interface Service { String[] value(); } @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Service @Transactional(timeout=60) public @interface MyTransactionalService { String[] value(); } @MyTransactionalService public class PersonWaver implements MessageService { ! ! } @Autowired public PersonRepository personRepository; @Override public String getMessage() { ... }
  • 10. Exposing attributes in Meta-annotations In Spring 4…. @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Service @Transactional public @interface MyTransactionalService { String[] value(); Propagation propagation() default Propagation.REQUIRED; int timeout() default TransactionDefinition.TIMEOUT_DEFAULT; ! } @MyTransactionalService(propagation=Propagation.REQUIRES_NEW) public class PersonWaver implements MessageService { ! ! } @Autowired public PersonRepository personRepository; @Override public String getMessage() { ... }
  • 11. @Description on @Configuration classes In Spring 4…. @Configuration @ComponentScan public class Application { ! @Bean @Description("This is a mock implementation of MockService") MessageService mockMessageService() { return new MessageService() { @Override public String getMessage() { return "Hello world!"; } }; } } Useful when beans are exposed, ! for example, as JMX beans
  • 12. @Profiles and @Conditional In Spring 3.2…. ! <beans profile="dev"> <jdbc:embedded-database id="dataSource"> <jdbc:script location="classpath:sql/schema.ddl"/> <jdbc:script location="classpath:sql/data.sql"/> </jdbc:embedded-database> </beans> <beans profile="prod"> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/LiveDataSource"/> </beans> -Dspring.profiles.active=“dev" @Configuration @ComponentScan @Profile(“test”) public class Application { ! } @Bean @Description("This is a mock implementation of MockService") MessageService mockMessageService() { return new MessageService() { @Override public String getMessage() { return "Hello world!"; } }; }
  • 13. @Profiles and @Conditional In Spring 4…. @Configuration @ComponentScan public class Application { ! @Bean @Description("This is a mock implementation of MockService”) @Conditional(NoMessageServiceDefined.class) MessageService mockMessageService() { return new MessageService() { @Override public String getMessage() { return "Hello world!"; } }; } } ! public class NoMessageServiceDefined implements Condition { ! } @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return context.getBeanFactory().getBeansOfType(MessageService.class) .isEmpty(); }
  • 15. Spring 4 web improvements Support for Servlet 3.0 (Servlet 2.5 still supported for GAE compatibility) (servlet 3.0 jar needed for SPRING MVC Tests) @RestController (@RequestMapping + @ResponseBody) @AsyncRestTemplate (Non-blocking REST clients) !
  • 16. @RestController In Spring 3.2…. @Controller public class WaverController { ! ! ! } @RequestMapping("/person") public @ResponseBody Person showPersonalMessage() { return personWaver.getMessage(); } @RequestMapping("/message") public @ResponseBody String showMessage() { return genericWaver.getMessage(); }
  • 17. @RestController In Spring 4… @RestController = @Controller + @ResponseBody @RestController public class WaverController { ! ! ! } @RequestMapping("/person") public Person showPersonalMessage() { return personWaver.getMessage(); } @RequestMapping("/message") public String showMessage() { return genericWaver.getMessage(); }
  • 18. @AsyncRestTemplate (Non-blocking REST clients) RestTemplate public class RestTemplate { public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) {} public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... urlVariables) {} public <T> T postForObject(String url, Object request, Class<T> responseType, Object... uriVariables) {} public void put(String url, Object request, Object... urlVariables) {} } public class RestTemplate { public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) {} public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... urlVariables) {} public <T> T postForObject(String url, Object request, Class<T> responseType, Object... uriVariables) {} public void put(String url, Object request, Object... urlVariables) {} }
  • 19. @AsyncRestTemplate (Non-blocking REST clients) AsyncRestTemplate public class AsyncRestTemplate { ! public <T> ListenableFuture<ResponseEntity<T>> getForEntity(String url, Class<T> responseType, Object... uriVariables) {} public ListenableFuture<URI> postForLocation(String url, HttpEntity<?> request, Object... uriVariables) {} } public ListenableFuture<?> put(String url, HttpEntity<?> request, Object... uriVariables) {} ! ! public interface ListenableFuture<T> extends Future<T> { ! ! } void addCallback(ListenableFutureCallback<? super T> callback);
  • 20. @AsyncRestTemplate (Non-blocking REST clients) AsyncRestTemplate ListenableFuture<ResponseEntity<Person>> futureEntity = template.getForEntity( "http://localhost:8080/spring4/person/{personId}", Integer.class, 1); ! // register a callback futureEntity.addCallback(new ListenableFutureCallback<ResponseEntity<Person>>() { @Override public void onSuccess(ResponseEntity<Person> entity) { //... } ! }); @Override public void onFailure(Throwable t) { //... }
  • 22. Support for lambdas on callbacks In Spring 3.2 public Person findById(int id) { return jdbcTemplate.query("select * from persons where id = ?", new RowMapper<Person>() { @Override public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getInt("id"), rs.getString("treatment"), rs.getString("name"), rs.getString("surname"), new Date(rs.getDate("birthDate").getTime())); } }, id) .get(0); }
  • 23. Support for lambdas on callbacks In Spring 4 public Person findById(int id) { return jdbcTemplate.queryForObject( "select * from persons where id = ?", (rs, rowNum) -> new Person(rs.getInt("id"), rs.getString("treatment"), rs.getString("name"), rs.getString("surname"), new Date(rs.getDate("birthDate").getTime())), id); }
  • 24. Support for lambdas on callbacks In Spring 4 @Override @Transactional public Person getMessage() { final Person person; ! ! } txTemplate.execute((txStatus) -> { person = messageRepository.findById(1); txStatus.setRollbackOnly(); return null; }); return person;
  • 25. JSR-310 package java.time Distinction between Computer-times and Human-Times Human-Times TimeZone (ISO-8601) LocalDateTime LocalDate LocalTime
  • 26. JSR-310 package java.time Amounts of Time Duration (nanosecond resolution) Amounts of Days Period (years, months, and days) TimeZones ZonedDateTime OffsetDateTime
  • 27. JSR-310 in Spring 4 In web handler Methods
 import java.time.Clock; import java.time.ZoneId; ! @RestController public class WaverController { ! ! } @RequestMapping("/person") public Person showPersonalMessage(ZoneId zoneId) { Clock clock = Clock.of(zoneId) LocalTime time = LocalTime.now(clock); return personWaver.getMessageFor(time); }
  • 29. External Libraries Support Hibernate 3.6+ Hibernate 4.3 (JPA 2.1) EhCache 2.1 Quartz 1.8 JodaTime 2.0 Hibernate Validator 4.3 (Bean Validation 1.1) Jackson 2.0 (1.8/1.9 deprecated)
  • 31. Support for JEE7 (& JEE6) Serlvet 3.0 JMS 2.0 JTA 1.2 JPA 2.1 Bean Validation 1.1 JSR-236 Concurrency (ThreadExecutors)
  • 33. WebSocket Support WebSocket server support via JSR-356 runtimes (Tomcat 7.0.7 -Jetty 9) Fallback option using SockJS (SockJsHttpRequestHandler) k on tal g 4” ed prin icat ed ith S D ts w ocke ebS “W soon ming co
  • 34. (de momento) Subtitle Text Author Contact info David Gómez @dgomezg