SlideShare a Scribd company logo
1 of 34
Download to read offline
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

More Related Content

What's hot

the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 updateJoshua Long
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 
Java web programming
Java web programmingJava web programming
Java web programmingChing 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 SecurityIMC Institute
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with SpringJoshua Long
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal 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-RSFahad 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 JaFuVMware Tanzu
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page AppsZachary 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: GradleSkills 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 ApplicationMicha Kops
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session ManagementFahad Golra
 

What's hot (20)

the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 
Spring 4 - A&BP CC
Spring 4 - A&BP CCSpring 4 - A&BP CC
Spring 4 - A&BP CC
 
Dropwizard
DropwizardDropwizard
Dropwizard
 
Java web programming
Java web programmingJava web programming
Java web programming
 
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
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with Spring
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
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
 
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
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
 
[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?
 
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
 
Servlet
Servlet Servlet
Servlet
 
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
 
JAX-RS 2.1 Reloaded @ Devoxx
JAX-RS 2.1 Reloaded @ DevoxxJAX-RS 2.1 Reloaded @ Devoxx
JAX-RS 2.1 Reloaded @ Devoxx
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 

Similar to Spring4 whats up doc?

softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis 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 2014Antoine Sabot-Durand
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasyJBug Italy
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
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 comparisonEmily 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-DurandSOAT
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT TalkConstantine 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.pdfShaiAlmog1
 
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 CodeDaniel 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) DetailsFlorina 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, VonageDroidConTLV
 
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_tokyoToshiaki Maki
 

Similar to Spring4 whats up doc? (20)

Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
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
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
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 ...
 
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparison
 
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
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT Talk
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
 
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
 
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
 
VRaptor 4 - JavaOne
VRaptor 4 - JavaOneVRaptor 4 - JavaOne
VRaptor 4 - JavaOne
 
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
 
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!
 
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
 
Spring boot
Spring boot Spring boot
Spring boot
 
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
 
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
 

More from 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 2022David 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 AsynchrhonouslyDavid 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 2021David 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 integrationDavid 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'sDavid 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 modularidadDavid 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 HDTRDavid Gómez García
 
Construccion de proyectos con gradle
Construccion de proyectos con gradleConstruccion de proyectos con gradle
Construccion de proyectos con gradleDavid 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íaDavid 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 ScriptingDavid 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-mongodbDavid Gómez García
 

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
 
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...
 
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...
 
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
 
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
 
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
 
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
 
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
 
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
 
Parallel streams in java 8
Parallel streams in java 8Parallel streams in java 8
Parallel streams in java 8
 
Construccion de proyectos con gradle
Construccion de proyectos con gradleConstruccion de proyectos con gradle
Construccion de proyectos con gradle
 
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.
 
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)
 
Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min.
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
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
 
Geo-SentimentZ
Geo-SentimentZGeo-SentimentZ
Geo-SentimentZ
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript Scripting
 
Wtf per lineofcode
Wtf per lineofcodeWtf per lineofcode
Wtf per lineofcode
 
A real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodbA real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodb
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

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