SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

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