SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
Get	
  ready	
  for	
  Spring	
  4	
  

Speaker:	
  Oleg	
  Tsal-­‐Tsalko	
  (@tsaltsol)	
  
Modern	
  Spring	
  ecosystem	
  
Spring	
  Boot	
  
Spring	
  Boot	
  Groovy	
  app	
  
@Controller	
  
class	
  ThisWillActuallyRun	
  {	
  
	
  
	
  	
  	
  	
  @RequestMapping("/")	
  
	
  	
  	
  	
  @ResponseBody	
  
	
  	
  	
  	
  String	
  home()	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  "Hello	
  World!"	
  
	
  	
  	
  	
  }	
  
	
  
}	
  
	
  
Spring	
  Boot	
  Java	
  app	
  
import	
  org.springframework.boot.*;	
  
import	
  org.springframework.boot.autoconfigure.*;	
  
import	
  org.springframework.stereotype.*;	
  
import	
  org.springframework.web.bind.annotaSon.*;	
  
	
  
@Controller	
  
@EnableAutoConfigura9on	
  
public	
  class	
  SampleController	
  {	
  
	
  
	
  	
  	
  	
  @RequestMapping("/")	
  
	
  	
  	
  	
  @ResponseBody	
  
	
  	
  	
  	
  String	
  home()	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  "Hello	
  World!";	
  
	
  	
  	
  	
  }	
  
	
  
	
  	
  	
  	
  public	
  staSc	
  void	
  main(String[]	
  args)	
  throws	
  ExcepSon	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  SpringApplica9on.run(SampleController.class,	
  args);	
  
	
  	
  	
  	
  }	
  
}	
  
	
  
Spring	
  XD	
  architecture	
  
Files	
  

Sensors	
  

Mobile	
  

Social	
  

Spring	
  XD	
  Shell	
  
Spring	
  XD	
  RunSme	
  

Gemfire	
  

Taps	
  

Jobs	
  

Compute	
  
HDFS	
  

PredicSve	
  modeling	
  

Workflow	
  

Redis	
  

Ingest	
  

Streams	
  

Export	
  

Export	
  

RDBMS	
  
NoSQL	
  
R,	
  SAS	
  
Spring	
  XD	
  RunSme	
  

XD	
  Admin	
  

hbp	
  |	
  filter	
  |	
  file	
  

CLUSTERED	
  NODE	
  

CLUSTERED	
  NODE	
  

CLUSTERED	
  NODE	
  

SINGLE	
  
NODE	
  

HTTP	
  
Module	
  

Filter	
  
Module	
  

File	
  
Module	
  

All	
  
Modules	
  

Rabbit,	
  Redis,	
  (Pluggable)	
  

In	
  Memory	
  
Transport	
  

hbp	
  |	
  filter	
  |	
  file	
  
Spring	
  4.0	
  

Almost	
  there…	
  RC1	
  now!!!	
  
Spring	
  4.0	
  
[RC1]	
  
Biggest	
  changes:	
  
•  Comprehensive	
  Java	
  8	
  support	
  
•  Support	
  for	
  Java	
  EE	
  7	
  APIs	
  
•  WebSocket	
  support	
  
•  Programming	
  model	
  for	
  message-­‐oriented	
  architectures	
  
Smaller	
  features:	
  
•  Support	
  for	
  @javax.transacSon.TransacSonal	
  
•  New	
  @CondiSonal	
  annotaSon	
  
•  New	
  @RestController	
  annotaSon	
  
•  AsyncRestTemplate	
  
•  Autowiring	
  of	
  generic	
  types	
  
•  Groovy	
  based	
  config	
  
And	
  more…	
  
4.0	
  M1	
  

Java	
  8	
  &	
  Java	
  EE	
  7	
  support	
  
Comprehensive	
  Java	
  8	
  
support	
  
• Lambdas	
  
• Date	
  and	
  Time	
  API	
  (JSR-­‐310)	
  
• Parameter	
  name	
  discovery	
  
• Repeatable	
  annotaSons	
  
• Concurrency	
  enhancement	
  

Support	
  for	
  Java	
  EE	
  7	
  APIs	
  
• Asynchronous	
  API	
  for	
  RestTemplate	
  
• Bean	
  ValidaSon	
  1.1	
  (JSR-­‐349)	
  
• Expression	
  Language	
  3.0	
  (JSR-­‐341)	
  
• JMS	
  2.0	
  (JSR-­‐343)	
  
• Concurrency	
  USliSes	
  for	
  Java	
  EE	
  
(JSR-­‐236)	
  
• JPA	
  2.1	
  (JSR-­‐338)	
  
• Servlet	
  3.1	
  (JSR-­‐340)	
  
• JSF	
  2.2	
  (JSR-­‐344)	
  
Get	
  advantage	
  of	
  Java	
  8	
  lambdas	
  
in	
  well	
  known	
  Spring	
  APIs!!!	
  
JdbcTemplate	
  jdbcTemplate;	
  	
  
	
  
//	
  method	
  references	
  	
  
private	
  Customer	
  map(ResultSet	
  rs,	
  int	
  rowNum)	
  throws	
  SQLExcepSon	
  {	
  	
  
	
  return	
  new	
  Customer(	
  rs.getString("name"),	
  rs.getInt("age")	
  );	
  }	
  	
  
	
  
//	
  let	
  it	
  saSsfy	
  the	
  `RowMapper`	
  funcSonal	
  interface	
  	
  
Customer	
  customer	
  =	
  jdbcTemplate.queryForObject(	
  	
  
	
  "select	
  name,	
  age	
  from	
  customers	
  ",this::map);	
  	
  
	
  
Customer	
  customer	
  =	
  jdbcTemplate.queryForObject(sql,	
  
	
  (rs,	
  rowNum)	
  -­‐>	
  new	
  Customer(rs.getLong("id")));	
  	
  
	
  

4.0	
  M1	
  
4.0	
  M1	
  

Lambdas	
  fit	
  naturally	
  wherever	
  you	
  
have	
  funcSonal	
  interfaces	
  
JmsTemplate+MessageCreator:	
  	
  
=>	
  Message	
  createMessage(Session	
  session)	
  throws	
  
JMSExcepSon	
  	
  
	
  
TransacSonTemplate+Transac9onCallback:	
  	
  
=>	
  Object	
  doInTransacSon(TransacSonStatus	
  status)	
  	
  
	
  
And	
  other:	
  
•  JdbcTemplate:	
  
–  ResultSetExtractor,	
  RowCallbackHandler	
  

•  JmsTemplate:	
  

–  MessagePostProcessor,	
  BrowserCallback	
  

• 

TaskExecutor:	
  

–  Runnable,	
  Callable	
  
4.0	
  M1	
  

JSR-­‐310	
  Date	
  and	
  Time	
  support	
  
import	
  java.Sme.*;	
  
import	
  org.springframework.format.annotaSon.*;	
  
	
  
public	
  class	
  Trade{	
  
	
  
	
  //…	
  
	
  
	
  @DateTimeFormat(iso=ISO.DATE)	
  
	
  private	
  LocalDate	
  tradeDate;	
  	
  
	
  	
  
	
  
	
  @DateTimeFormat(iso=ISO.DATE)	
  
	
  private	
  LocalDateTime	
  createTimestamp;	
  
}	
  
4.0	
  M1	
  

JDK8	
  support	
  in	
  depth	
  
•  Implicit	
  use	
  of	
  LinkedHashMap/Set	
  instead	
  of	
  simple	
  
HashMap/Set	
  to	
  preserve	
  ordering	
  diffs	
  in	
  JDK7	
  and	
  JDK8	
  
•  Embed	
  ASM4.1	
  into	
  Spring	
  codebase	
  to	
  support	
  JDK8	
  
bytecode	
  changes	
  and	
  to	
  keep	
  compaSbility	
  with	
  CGLib3.0	
  
•  Support	
  for	
  JDK	
  8	
  Data	
  &	
  Time	
  (JSR-­‐310)	
  encorporated	
  with	
  
Spring’s	
  Joda	
  Time	
  lib	
  
•  Add	
  awaitTerminaSonSeconds/commonPool	
  properSes	
  to	
  
ForkJoinPoolFactoryBean	
  to	
  support	
  JDK8	
  changes	
  in	
  it.	
  
•  Encorporate	
  JDK8	
  changes	
  in	
  reflecSon	
  API	
  (such	
  as	
  
java.lang.reflect.Parameter)	
  
Bean	
  ValidaSon	
  1.1	
  support	
  

4.0	
  M1	
  

MethodValida+onInterceptor	
  autodetects	
  Bean	
  Valida/on	
  1.1's	
  ExecutableValidator	
  API	
  now	
  	
  
and	
  uses	
  it	
  in	
  favor	
  of	
  Hibernate	
  Validator	
  4.2's	
  na/ve	
  variant.	
  
JMS	
  2.0	
  support	
  

4.0	
  M1	
  

What	
  was	
  done	
  already:	
  
•  Added	
  "deliveryDelay"	
  property	
  on	
  JmsTemplate	
  
•  Added	
  support	
  for	
  "deliveryDelay"	
  and	
  CompleSonListener	
  to	
  
CachedMessageProducer	
  
•  Added	
  support	
  for	
  the	
  new	
  "create(Shared)DurableConsumer"	
  variants	
  in	
  
Spring’s	
  CachingConnecSonFactory	
  
•  Added	
  support	
  for	
  the	
  new	
  "createSession"	
  variants	
  with	
  fewer	
  
parameters	
  in	
  Spring’s	
  SingleConnecSonFactory	
  
Known	
  constraints:	
  
•  There	
  is	
  no	
  special	
  support	
  for	
  the	
  simplified	
  JMSContext	
  API,	
  and	
  likely	
  
never	
  will	
  be,	
  because	
  of	
  different	
  Spring	
  mechanism	
  of	
  managing	
  
connecSon	
  pools	
  and	
  sessions	
  
•  JmsTemplate	
  has	
  no	
  out-­‐of-­‐the-­‐box	
  support	
  for	
  send	
  calls	
  with	
  an	
  async	
  
compleSon	
  listener.	
  
JEE7	
  concurrency	
  uSliSes	
  in	
  Spring	
  4	
  

4.0	
  M1	
  

This	
  is	
  built	
  into	
  ConcurrentTaskExecutor	
  and	
  ConcurrentTaskScheduler	
  now,	
  
automaScally	
  detecSng	
  the	
  JSR-­‐236	
  ExecutorService	
  variants	
  and	
  adapSng	
  
to	
  them.	
  
Example	
  of	
  ManagedExecutorService	
  usage	
  introduced	
  in	
  JEE7:	
  	
  
	
  
4.0	
  M1	
  

JPA	
  2.1	
  support	
  
EnStyManagerFactory.createEnStyManager(	
  
	
  Synchroniza9onType.SYNCHRONIZED/UNSYNCHRONIZED,	
  Map)	
  	
  
	
  
@PersistenceContext(	
  
	
  synchronizaSonType=SYNCHRONIZED/UNSYNCHRONIZED)	
  	
  
	
  
	
  
	
  
	
  Support	
  for	
  both	
  transacSonal	
  and	
  extended	
  EnStyManagers	
  	
  
	
  and	
  for	
  both	
  Spring-­‐managed	
  resource	
  transacSons	
  and	
  JTA	
  
transacSons	
  
WebSocket	
  JSR-­‐356	
  support	
  

4.0	
  M1	
  

(Annota/on	
  driven	
  using	
  Servlet	
  container	
  scan)	
  
import	
  javax.websocket.server.ServerEndpoint;	
  
import	
  org.springframework.web.socket.server.endpoint.SpringConfigurator;	
  
	
  
@ServerEndpoint(value	
  =	
  "/echo",	
  configurator	
  =	
  SpringConfigurator.class)	
  
public	
  class	
  EchoEndpoint	
  {	
  
	
  
	
  	
  private	
  final	
  EchoService	
  echoService;	
  
	
  
	
  	
  @Autowired	
  
	
  	
  public	
  EchoEndpoint(EchoService	
  echoService)	
  {	
  
	
  	
  	
  	
  this.echoService	
  =	
  echoService;	
  
	
  	
  }	
  
	
  
	
  	
  @OnMessage	
  
	
  	
  public	
  void	
  handleMessage(Session	
  session,	
  String	
  message)	
  {	
  
	
  	
  	
  	
  //	
  ...	
  
	
  	
  }	
  
}	
  
WebSocket	
  JSR-­‐356	
  support	
  

(Spring	
  container-­‐centric	
  registra/on)	
  
import	
  org.springframework.web.socket.server.endpoint.ServerEndpointExporter;	
  
	
  
@ConfiguraSon	
  
public	
  class	
  EndpointConfig	
  {	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  EchoEndpoint	
  echoEndpoint()	
  {	
  
	
  	
  	
  	
  return	
  new	
  EchoEndpoint(echoService());	
  
	
  	
  }	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  EchoService	
  echoService()	
  {	
  
	
  	
  	
  	
  //	
  ...	
  
	
  	
  }	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  ServerEndpointExporter	
  endpointExporter()	
  {	
  
	
  	
  	
  	
  return	
  new	
  ServerEndpointExporter();	
  
	
  	
  }	
  
}	
  

4.0	
  M1	
  
WebSocket	
  JSR-­‐356	
  support	
  

(Separate	
  endpoint	
  instance	
  per	
  socket)	
  
import	
  org.springframework.web.socket.server.endpoint.ServerEndpointExporter;	
  
import	
  org.springframework.web.socket.server.endpoint.ServerEndpointRegistra9on;	
  
	
  
@ConfiguraSon	
  
public	
  class	
  EndpointConfig	
  {	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  EndpointRegistra9on	
  echoEndpoint()	
  {	
  
	
  	
  	
  	
  return	
  new	
  EndpointRegistra9on("/echo",	
  EchoEndpoint.class);	
  
	
  	
  }	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  ServerEndpointExporter	
  endpointExporter()	
  {	
  
	
  	
  	
  	
  return	
  new	
  ServerEndpointExporter();	
  
	
  	
  }	
  
	
  
	
  	
  //	
  ..	
  
}	
  

4.0	
  M1	
  
4.0	
  M1	
  

WebSocket	
  JSR-­‐356	
  client	
  side	
  support	
  

Purely	
  programmaSc	
  way:	
  
	
  

WebSocketContainer	
  container	
  =	
  ContainerProvider.getWebSocketContainer();	
  
container.connectToServer(EchoEndpoint.class,	
  new	
  URI("ws:localhost:8080/webapp/echo"));	
  
	
  

Using	
  Spring	
  ApplicaSonContext:	
  
	
  

import	
  org.springframework.web.socket.client.endpoint.AnnotatedEndpointConnec9onManager;	
  
	
  
@ConfiguraSon	
  
public	
  class	
  EndpointConfig	
  {	
  
	
  
	
  	
  //	
  For	
  Endpoint	
  sub-­‐classes	
  use	
  EndpointConnecSonManager	
  instead	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  AnnotatedEndpointConnec9onManager	
  connecSonManager()	
  {	
  
	
  	
  	
  	
  return	
  new	
  AnnotatedEndpointConnec9onManager(echoEndpoint(),	
  "ws://localhost:8080/webapp/echo");	
  
	
  	
  }	
  
	
  
	
  	
  @Bean	
  
	
  	
  public	
  EchoEndpoint	
  echoEndpoint()	
  {	
  
	
  	
  	
  	
  //	
  ...	
  
	
  	
  }	
  
}	
  
	
  
Spring	
  WebSocket	
  API	
  
Why	
  own	
  API?	
  
•  To	
  support	
  available	
  fallback	
  opSons	
  for	
  
WebSockets	
  such	
  as	
  SockJS.	
  
•  WebSocket	
  API	
  is	
  too	
  low	
  level	
  (messages	
  could	
  
be	
  anything,	
  no	
  broadcast,	
  no	
  failure	
  handling	
  
mechanism,	
  etc.)	
  	
  
•  No	
  	
  way	
  to	
  handle	
  both	
  HTTP	
  and	
  WebSocket	
  
requests	
  in	
  one	
  place	
  as	
  per	
  Front	
  Controller	
  
pabern.	
  
•  No	
  sub-­‐protocol	
  and	
  higher	
  level	
  protocols	
  
support.	
  
Spring	
  WebSocket	
  API	
  	
  
I	
  
Inspira/on	
  
	
  	
  
Programming	
  model	
  for	
  building	
  message-­‐
oriented	
  applicaSons	
  using	
  STOMP	
  over	
  
WebSocket	
  protocol	
  for	
  example	
  
•  Transparent	
  WebSocket	
  emulaSon	
  using	
  SockJS	
  
•  Separate	
  messaging	
  module	
  with	
  main	
  messaging	
  
abstracSons	
  taken	
  from	
  Spring	
  IntegraSon	
  
•  STOMP	
  sub-­‐protocol	
  support	
  (built-­‐in	
  simple	
  STOMP	
  
broker)	
  
•  Higher	
  level	
  programming	
  model	
  
STOMP	
  
SUBSCRIBE 	
  	
  
id:sub-­‐1 	
  	
  
desSnaSon:/topic/price.stock.* 	
  	
  
	
  
MESSAGE 	
  	
  
subscripSon:sub-­‐1
	
  	
  
message-­‐id:wm2si1tj-­‐4	
  	
  
content-­‐type:	
  applicaSon/json
	
  	
  
desSnaSon:/topic/stocks.PRICE.STOCK.NASDAQ.EM
	
  	
  
{"Scker":"EMC","price":24.19}
	
  	
  
	
  
WebSocket	
  Client	
  API	
  
var	
  socket	
  =	
  new	
  SockJS('/spring-­‐websocket-­‐porholio/
porholio'); 	
  	
  
var	
  client	
  =	
  Stomp.over(socket);
	
  	
  
	
  
	
  	
  
var	
  onConnect	
  =	
  funcSon()	
  { 	
  	
  
	
  	
  client.subscribe("/topic/price.stock.*",	
  func9on(message)	
  {	
  
	
  	
  	
  	
  	
  	
  //	
  process	
  quote 	
  	
  
	
  	
  }); 	
  	
  
};
	
  	
  
client.connect('guest',	
  'guest',	
  onConnect); 	
  	
  
	
  
Spring	
  Simple	
  Messaging	
  API	
  

4.0	
  M1	
  

(Handling	
  STOMP	
  message	
  sent	
  via	
  WebSocket	
  
protocol)	
  
@Controller 	
  	
  
public	
  class	
  Por~olioController	
  { 	
  	
  
	
  
	
  	
  
	
  	
  //	
  ... 	
  	
  
	
  
	
  	
  
	
  	
  @MessageMapping(value="/app/trade")
	
  	
  
	
  	
  public	
  void	
  executeTrade(Trade	
  trade,	
  Principal	
  principal)	
  {
	
  	
  
	
  	
  	
  	
  trade.setUsername(principal.getName());
	
  	
  
	
  	
  	
  	
  this.tradeService.executeTrade(trade); 	
  	
  
	
  	
  }
	
  	
  
}
	
  	
  
	
  
Spring	
  Simple	
  Messaging	
  API	
  
(Failures	
  handling)	
  

@Controller 	
  	
  
public	
  class	
  Por~olioController	
  { 	
  	
  
	
  
	
  	
  
	
  	
  //	
  ... 	
  	
  
	
  
	
  	
  
	
  	
  @MessageExcep9onHandler	
  
	
  	
  @SendToUser("/queue/errors") 	
  	
  
	
  	
  public	
  String	
  handleExcepSon(Throwable	
  excepSon)	
  { 	
  	
  
	
  	
  	
  	
  return	
  excepSon.getMessage(); 	
  	
  
	
  	
  }
	
  	
  
}
	
  	
  
	
  

4.0	
  M1	
  
Spring	
  Simple	
  Messaging	
  API	
  

(Handle	
  SUBSCRIBE	
  events	
  from	
  client)	
  
@Controller 	
  	
  
public	
  class	
  Por~olioController	
  {	
  	
  
	
  
	
  	
  
	
  	
  //	
  ... 	
  	
  
	
  
	
  	
  
	
  	
  @SubscribeMapping("/app/posi9ons")
	
  	
  
	
  	
  public	
  List<Por~olioPosiSon>	
  getPor~olios(Principal	
  principal)	
  {	
  	
  
	
  	
  	
  	
  String	
  user	
  =	
  principal.getName();
	
  	
  
	
  	
  	
  	
  Por~olio	
  por~olio	
  =	
  this.por~olioService.findPor~olio(user); 	
  	
  
	
  	
  	
  	
  return	
  por~olio.getPosiSons();
	
  	
  
	
  	
  }
	
  	
  
}
	
  	
  
	
  

4.0	
  M1	
  
Spring	
  Simple	
  Messaging	
  API	
  

4.0	
  M1	
  

(Sending	
  updates	
  to	
  client	
  periodically)	
  
@Service
	
  	
  
public	
  class	
  QuoteService	
  {
	
  	
  
	
  
	
  	
  
	
  	
  private	
  final	
  MessageSendingOpera9ons<String>	
  messagingTemplate;	
  
	
  	
  
	
  	
  @Scheduled(fixedDelay=1000) 	
  	
  
	
  	
  public	
  void	
  sendQuotes()	
  {
	
  	
  
	
  	
  	
  	
  for	
  (Quote	
  quote	
  :	
  this.quoteGenerator.generateQuotes())	
  {
	
  	
  
	
  	
  	
  	
  	
  	
  String	
  desSnaSon	
  =	
  "/topic/price.stock."	
  +	
  quote.getTicker(); 	
  	
  
	
  	
  	
  	
  	
  	
  this.messagingTemplate.convertAndSend(des9na9on,	
  quote);	
  	
  
	
  	
  	
  	
  }
	
  	
  
	
  	
  }
	
  	
  
}
	
  	
  
Spring	
  Simple	
  Messaging	
  API	
  
(Configura/on)	
  

@ConfiguraSon	
  
@EnableWebSocketMessageBroker	
  
@EnableScheduling	
  
@ComponentScan(basePackages="org.springframework.samples")	
  
public	
  class	
  WebSocketConfig	
  implements	
  WebSocketMessageBrokerConfigurer	
  {	
  
	
  
	
  @Override	
  
	
  public	
  void	
  registerStompEndpoints(StompEndpointRegistry	
  registry)	
  {	
  
	
  
	
  registry.addEndpoint("/porholio").withSockJS();	
  
	
  }	
  
	
  
	
  @Override	
  
	
  public	
  void	
  configureMessageBroker(MessageBrokerConfigurer	
  configurer)	
  {	
  
	
  
	
  configurer.enableSimpleBroker("/queue/",	
  "/topic/");	
  
	
  
	
  //configurer.enableStompBrokerRelay("/queue/",	
  "/topic/");	
  
	
  
	
  configurer.setApplica9onDes9na9onPrefixes("/app");	
  
	
  }	
  
}	
  

4.0	
  M1	
  
spring-­‐websocket-­‐por~olio	
  	
  
DEMO	
  app	
  architecture	
  
Composable	
  stereotype	
  model	
  
@Service	
  
@Scope(“session”)	
  
@Primary	
  
@Transac9onal(rollbackFor=Run9meExcep9on.class)	
  
@RetenSon(RetenSonPolicy.RUNTIME)	
  
public	
  @interface	
  MyService	
  {	
  
	
  boolean	
  readOnly();	
  
}	
  
	
  
@MyService(readOnly=true)	
  
public	
  class	
  MyTradeService	
  {	
  
	
  //…	
  
}	
  
JEE	
  annotaSon	
  support	
  conSnue	
  
@ManagedBean	
  
public	
  class	
  MyTradeService	
  implements	
  TradeService{	
  
	
  	
  
	
  @Inject	
  
	
  public	
  MyTradeService(MatchingService	
  service){	
  
	
  
	
  //…	
  
	
  }	
  
	
  
	
  @javax.transac9on.Transac9onal	
  
	
  	
  public	
  void	
  matchTrade(Trade	
  trade){	
  
	
  
	
  //…	
  
	
  }
	
  	
  
}	
  
	
  
@CondiSonal	
  annotaSon	
  
@Condi9onal(MyCondi9on.class)	
  
@Configura9on	
  	
  
public	
  class	
  ExampleConfiguraSon	
  {	
  
	
  
	
  //	
  @Bean	
  methods	
  
}	
  
	
  
	
  
public	
  class	
  MyCondi9on	
  implements	
  Condi9on	
  {	
  
	
  
	
  public	
  boolean	
  matches(...)	
  {	
  
	
  
	
  //	
  return	
  true	
  if	
  the	
  condiSon	
  holds	
  true	
  
	
  }	
  
}	
  

4.0	
  M2	
  
Make	
  #result	
  available	
  for	
  SpEL	
  in	
  
@CachePut	
  key	
  abribute	
  

4.0	
  M2	
  

@CachePut(value	
  =	
  "personEn9ty",	
  key	
  =	
  "#result.id")	
  
public	
  Person	
  persistPerson(Person	
  p)	
  {	
  
	
  	
  Person	
  result	
  =	
  personRepository.save(p);	
  
	
  	
  return	
  result;	
  
}	
  
	
  
@EnSty	
  
public	
  class	
  Person	
  {	
  
	
  	
  @Id	
  @GeneratedValue	
  
	
  	
  private	
  Long	
  id;	
  
	
  	
  …	
  
}	
  
Introduce	
  AcSveProfilesResolver	
  in	
  the	
  
TestContext	
  framework	
  
@RunWith(SpringJUnitRunner.class)	
  
@ContextConfiguraSon(TestContext.class)	
  
@Ac9veProfiles	
  
public	
  class	
  IntegraSonTest	
  {	
  
	
  	
  	
  	
  //…	
  
	
  	
  	
  	
  @Test	
  
	
  	
  	
  	
  public	
  void	
  integraSonTest(){	
  
	
  	
  	
  	
  	
  	
  	
  	
  //...	
  
	
  	
  	
  	
  }	
  
}	
  
	
  
@ConfiguraSon	
  
public	
  class	
  TestContext{	
  
	
  	
  	
  	
  @Bean	
  
	
  	
  	
  	
  public	
  Ac9veProfilesResolver	
  acSveProfilesResolver(){	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  new	
  Ac9veProfilesResolver(){	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  String[]	
  resolve(Class<?>	
  testClass){	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  //…	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  return	
  new	
  String[]{"test"};	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  };	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  //...	
  
}	
  

4.0	
  M2	
  
4.0	
  M3	
  

Autowiring	
  ordered	
  collecSons	
  based	
  
on	
  @Order	
  annotaSon	
  
@Component	
  
@Order(value=1)	
  
public	
  class	
  BusinessServiceA	
  implements	
  BusinessService{}	
  
	
  
@Component	
  
@Order(value=2)	
  
public	
  class	
  BusinessServiceB	
  implements	
  BusinessService{}	
  
	
  
@Component	
  
public	
  class	
  ServiceRegistry	
  {	
  
	
  @Autowired	
  
	
  public	
  List<BusinessService>	
  services;	
  
}	
  
	
  
assertThat(services.get(0).getClass(),	
  is(BusinessServiceA.class));	
  
assertThat(services.get(1).getClass(),	
  is(BusinessServiceB.class));	
  
@PropertySources	
  annotaSon	
  

4.0	
  RC1	
  

@ConfiguraSon	
  
@PropertySources({	
  
	
  	
  @PropertySource(value	
  =	
  "file:/etc/applicaSon/config.properSes",	
  
	
  ignoreResourceNotFound	
  =	
  true),	
  
	
  	
  @PropertySource(value	
  =	
  "file:/usr/local/etc/applicaSon/config.properSes",	
  
	
  ignoreResourceNotFound	
  =	
  true),	
  
	
  	
  @PropertySource(value	
  =	
  "file:conf/config.properSes",	
  
	
  ignoreResourceNotFound	
  =	
  true),	
  
	
  	
  @PropertySource(value	
  =	
  "classpath:applicaSon.properSes")	
  
})	
  
public	
  class	
  AppConfiguraSon{	
  
	
  //…	
  
}	
  
	
  
Or	
  even	
  without	
  @PropertySources	
  using	
  Java8	
  repeatable	
  annota/ons!!!	
  
Autowiring	
  of	
  generic	
  types	
  

4.0	
  RC1	
  
Groovy	
  config	
  
def	
  bb	
  =	
  new	
  BeanBuilder()	
  	
  
bb.loadBeans("classpath:*SpringBeans.groovy")	
  
def	
  applica9onContext	
  =	
  bb.createApplicaSonContext()	
  	
  
	
  
//	
  MySpringBeans.groovy	
  	
  
import	
  o.sf.jdbc.core.JdbcTemplate	
  
import	
  o.sf.jdbc.datasource.DataSourceTransac9onManager	
  	
  
beans	
  {	
  	
  
	
  jdbcTemplate(JdbcTemplate)	
  {	
  	
  
	
  
	
  dataSource	
  =	
  dataSource	
  	
  
	
  }	
  	
  
	
  transac9onManager(DataSourceTransac9onManager){	
  	
  
	
  
	
  dataSource	
  =	
  dataSource	
  	
  
	
  }	
  	
  
	
  dataSource(BasicDataSource)	
  
	
  
	
  driverClassName	
  ="org.h2.Driver"	
  
	
  
	
  url="jdbc:h2:mem:grailsDB"	
  
	
  
	
  username="sa"	
  
	
  
	
  password=""	
  
	
  }	
  
}	
  	
  

4.0	
  RC1	
  
@ControllerAdvice	
  annotaSon	
  
@ControllerAdvice({"com.example.web.api"})	
  
public	
  class	
  GlobalErrorHandler	
  {	
  	
  
	
  	
  	
  //	
  common	
  @ExcepSonHandler	
  methods	
  are	
  defined	
  here	
  
}	
  
	
  
Will	
  be	
  applied	
  to	
  both	
  Controllers	
  below:	
  
com.example.web.api.feature1.Feature1Controller	
  	
  
com.example.web.api.feature2.Featuer2Controller	
  

4.0	
  RC1	
  
Other	
  changes…	
  
4.0	
  M1	
  
•  Replace	
  EasyMock	
  with	
  Mockito	
  
•  [SPR-­‐8258]	
  EhCache	
  2.5	
  support	
  
4.0	
  M2	
  
•  [SPR-­‐10664]	
  Make	
  #result	
  available	
  for	
  SpEL	
  in	
  @CachePut	
  key	
  abribute	
  
•  [SPR-­‐10338]	
  Introduce	
  AcSveProfilesResolver	
  in	
  the	
  TestContext	
  
framework	
  
4.0	
  M3	
  
•  [SPR-­‐5574]	
  Autowiring	
  should	
  support	
  ordered	
  collecSon	
  driven	
  by	
  Order	
  
annotaSon	
  or	
  Ordered	
  interface	
  
4.0	
  RC1	
  
•  [SPR-­‐8371]	
  Add	
  @PropertySources	
  annotaSon	
  and	
  support	
  
ignoreResourceNotFound	
  and	
  preserve	
  mulSple	
  @PropertySources	
  order	
  
•  [SPR-­‐10222]	
  Allow	
  @ControllerAdvice	
  to	
  be	
  cofigured	
  with	
  a	
  join	
  point	
  to	
  
target	
  a	
  subset	
  of	
  controller	
  
How	
  to	
  track	
  progress?	
  
•  Track	
  JIRA	
  -­‐	
  
hbps://jira.springsource.org/browse/SPR/
fixforversion/14229	
  
•  Check	
  commits	
  to	
  codebase	
  -­‐	
  
hbps://github.com/SpringSource/spring-­‐
framework/commits/master	
  
Thank	
  you!	
  
Oleg	
  Tsal-­‐Tsalko	
  
Email:	
  oleg.tsalko@gmail.com	
  
Twiber:	
  @tsaltsol	
  
	
  
	
  
	
  

Weitere ähnliche Inhalte

Was ist angesagt?

Li liq liqui liquibase
Li liq liqui liquibaseLi liq liqui liquibase
Li liq liqui liquibaseYoram Michaeli
 
Fatcat Automatic Web SQL Injector by Sandeep Kamble
Fatcat Automatic Web SQL Injector by Sandeep KambleFatcat Automatic Web SQL Injector by Sandeep Kamble
Fatcat Automatic Web SQL Injector by Sandeep KambleClubHack
 
Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019graemerocher
 
Continuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseContinuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseAidas Dragūnas
 
Spring boot
Spring bootSpring boot
Spring bootsdeeg
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developersIllia Seleznov
 
Repository design pattern in laravel
Repository design pattern in laravelRepository design pattern in laravel
Repository design pattern in laravelSameer Poudel
 
Testing Spring Boot Applications
Testing Spring Boot ApplicationsTesting Spring Boot Applications
Testing Spring Boot ApplicationsVMware Tanzu
 
Java Release Model (on Scala Matsuri)
Java Release Model (on Scala Matsuri)Java Release Model (on Scala Matsuri)
Java Release Model (on Scala Matsuri)なおき きしだ
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringarSqueed
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Gunith Devasurendra
 
Spring Framework Introduction
Spring Framework IntroductionSpring Framework Introduction
Spring Framework IntroductionAlex Su
 
Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)Sokngim Sa
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testHyukSun Kwon
 

Was ist angesagt? (20)

Li liq liqui liquibase
Li liq liqui liquibaseLi liq liqui liquibase
Li liq liqui liquibase
 
Fatcat Automatic Web SQL Injector by Sandeep Kamble
Fatcat Automatic Web SQL Injector by Sandeep KambleFatcat Automatic Web SQL Injector by Sandeep Kamble
Fatcat Automatic Web SQL Injector by Sandeep Kamble
 
LiquiBase
LiquiBaseLiquiBase
LiquiBase
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Database change management with Liquibase
Database change management with LiquibaseDatabase change management with Liquibase
Database change management with Liquibase
 
Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019
 
Continuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseContinuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With Liquibase
 
Spring boot
Spring bootSpring boot
Spring boot
 
Liquibase case study
Liquibase case studyLiquibase case study
Liquibase case study
 
Spring database - part2
Spring database -  part2Spring database -  part2
Spring database - part2
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
 
Repository design pattern in laravel
Repository design pattern in laravelRepository design pattern in laravel
Repository design pattern in laravel
 
Testing Spring Boot Applications
Testing Spring Boot ApplicationsTesting Spring Boot Applications
Testing Spring Boot Applications
 
Java Release Model (on Scala Matsuri)
Java Release Model (on Scala Matsuri)Java Release Model (on Scala Matsuri)
Java Release Model (on Scala Matsuri)
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringar
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
Spring Framework Introduction
Spring Framework IntroductionSpring Framework Introduction
Spring Framework Introduction
 
Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
 

Andere mochten auch

Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code ExamplesNaresh Chintalcheru
 
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...ZeroTurnaround
 
무식하게 배우는 gradle
무식하게 배우는 gradle무식하게 배우는 gradle
무식하게 배우는 gradleJi Heon Kim
 
Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"Michael Harlaut
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 updateJoshua Long
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVCGuy Nir
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
Spring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and NoteworthySpring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and NoteworthyRossen Stoyanchev
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservicesAlvaro Sanchez-Mariscal
 

Andere mochten auch (17)

Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
무식하게 배우는 gradle
무식하게 배우는 gradle무식하게 배우는 gradle
무식하게 배우는 gradle
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Spring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and NoteworthySpring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and Noteworthy
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservices
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 

Ähnlich wie Get ready for spring 4

Spring 4-groovy
Spring 4-groovySpring 4-groovy
Spring 4-groovyGR8Conf
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerZeroTurnaround
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring UpdateGunnar Hillert
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New EvolutionAllan Huang
 
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...Toshiaki Maki
 
Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017VMware Tanzu Korea
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Sam Brannen
 
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next GenerationJAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generationjazoon13
 
Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3JavaEE Trainers
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Spring5 New Features
Spring5 New FeaturesSpring5 New Features
Spring5 New FeaturesJay Lee
 
What’s New in Spring Batch?
What’s New in Spring Batch?What’s New in Spring Batch?
What’s New in Spring Batch?VMware Tanzu
 
Jakarta Concurrency: Present and Future
Jakarta Concurrency: Present and FutureJakarta Concurrency: Present and Future
Jakarta Concurrency: Present and FuturePayara
 
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Sam Brannen
 

Ähnlich wie Get ready for spring 4 (20)

Spring 4-groovy
Spring 4-groovySpring 4-groovy
Spring 4-groovy
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen Hoeller
 
The Spring Update
The Spring UpdateThe Spring Update
The Spring Update
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring Update
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
 
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
 
Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1
 
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next GenerationJAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
 
JSF2
JSF2JSF2
JSF2
 
Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Spring5 New Features
Spring5 New FeaturesSpring5 New Features
Spring5 New Features
 
Spring
SpringSpring
Spring
 
What’s New in Spring Batch?
What’s New in Spring Batch?What’s New in Spring Batch?
What’s New in Spring Batch?
 
Java SE 8 & EE 7 Launch
Java SE 8 & EE 7 LaunchJava SE 8 & EE 7 Launch
Java SE 8 & EE 7 Launch
 
Jakarta Concurrency: Present and Future
Jakarta Concurrency: Present and FutureJakarta Concurrency: Present and Future
Jakarta Concurrency: Present and Future
 
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
 

Mehr von Oleg Tsal-Tsalko

Developer on a mission (Devoxx UA 2021)
Developer on a mission (Devoxx UA 2021)Developer on a mission (Devoxx UA 2021)
Developer on a mission (Devoxx UA 2021)Oleg Tsal-Tsalko
 
From Streams to Reactive Streams
From Streams to Reactive StreamsFrom Streams to Reactive Streams
From Streams to Reactive StreamsOleg Tsal-Tsalko
 
JUG UA AdoptJSR participation
JUG UA AdoptJSR participationJUG UA AdoptJSR participation
JUG UA AdoptJSR participationOleg Tsal-Tsalko
 
Develop modern apps using Spring ecosystem at time of BigData
Develop modern apps using Spring ecosystem at time of BigData Develop modern apps using Spring ecosystem at time of BigData
Develop modern apps using Spring ecosystem at time of BigData Oleg Tsal-Tsalko
 
Java 8 date & time javaday2014
Java 8 date & time javaday2014Java 8 date & time javaday2014
Java 8 date & time javaday2014Oleg Tsal-Tsalko
 
Enterprise Integration Patterns
Enterprise Integration PatternsEnterprise Integration Patterns
Enterprise Integration PatternsOleg Tsal-Tsalko
 
Distributed systems and scalability rules
Distributed systems and scalability rulesDistributed systems and scalability rules
Distributed systems and scalability rulesOleg Tsal-Tsalko
 
JUG involvment in JCP and AdopJSR program
JUG involvment in JCP and AdopJSR programJUG involvment in JCP and AdopJSR program
JUG involvment in JCP and AdopJSR programOleg Tsal-Tsalko
 

Mehr von Oleg Tsal-Tsalko (13)

Developer on a mission (Devoxx UA 2021)
Developer on a mission (Devoxx UA 2021)Developer on a mission (Devoxx UA 2021)
Developer on a mission (Devoxx UA 2021)
 
Developer on a mission
Developer on a missionDeveloper on a mission
Developer on a mission
 
From Streams to Reactive Streams
From Streams to Reactive StreamsFrom Streams to Reactive Streams
From Streams to Reactive Streams
 
Java 9 Jigsaw HackDay
Java 9 Jigsaw HackDayJava 9 Jigsaw HackDay
Java 9 Jigsaw HackDay
 
JUG UA AdoptJSR participation
JUG UA AdoptJSR participationJUG UA AdoptJSR participation
JUG UA AdoptJSR participation
 
Develop modern apps using Spring ecosystem at time of BigData
Develop modern apps using Spring ecosystem at time of BigData Develop modern apps using Spring ecosystem at time of BigData
Develop modern apps using Spring ecosystem at time of BigData
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Lambdas HOL
Lambdas HOLLambdas HOL
Lambdas HOL
 
Java 8 date & time javaday2014
Java 8 date & time javaday2014Java 8 date & time javaday2014
Java 8 date & time javaday2014
 
Java 8 date & time
Java 8 date & timeJava 8 date & time
Java 8 date & time
 
Enterprise Integration Patterns
Enterprise Integration PatternsEnterprise Integration Patterns
Enterprise Integration Patterns
 
Distributed systems and scalability rules
Distributed systems and scalability rulesDistributed systems and scalability rules
Distributed systems and scalability rules
 
JUG involvment in JCP and AdopJSR program
JUG involvment in JCP and AdopJSR programJUG involvment in JCP and AdopJSR program
JUG involvment in JCP and AdopJSR program
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Kürzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Get ready for spring 4

  • 1. Get  ready  for  Spring  4   Speaker:  Oleg  Tsal-­‐Tsalko  (@tsaltsol)  
  • 2.
  • 5. Spring  Boot  Groovy  app   @Controller   class  ThisWillActuallyRun  {            @RequestMapping("/")          @ResponseBody          String  home()  {                  return  "Hello  World!"          }     }    
  • 6. Spring  Boot  Java  app   import  org.springframework.boot.*;   import  org.springframework.boot.autoconfigure.*;   import  org.springframework.stereotype.*;   import  org.springframework.web.bind.annotaSon.*;     @Controller   @EnableAutoConfigura9on   public  class  SampleController  {            @RequestMapping("/")          @ResponseBody          String  home()  {                  return  "Hello  World!";          }            public  staSc  void  main(String[]  args)  throws  ExcepSon  {                  SpringApplica9on.run(SampleController.class,  args);          }   }    
  • 7. Spring  XD  architecture   Files   Sensors   Mobile   Social   Spring  XD  Shell   Spring  XD  RunSme   Gemfire   Taps   Jobs   Compute   HDFS   PredicSve  modeling   Workflow   Redis   Ingest   Streams   Export   Export   RDBMS   NoSQL   R,  SAS  
  • 8. Spring  XD  RunSme   XD  Admin   hbp  |  filter  |  file   CLUSTERED  NODE   CLUSTERED  NODE   CLUSTERED  NODE   SINGLE   NODE   HTTP   Module   Filter   Module   File   Module   All   Modules   Rabbit,  Redis,  (Pluggable)   In  Memory   Transport   hbp  |  filter  |  file  
  • 9. Spring  4.0   Almost  there…  RC1  now!!!  
  • 10. Spring  4.0   [RC1]   Biggest  changes:   •  Comprehensive  Java  8  support   •  Support  for  Java  EE  7  APIs   •  WebSocket  support   •  Programming  model  for  message-­‐oriented  architectures   Smaller  features:   •  Support  for  @javax.transacSon.TransacSonal   •  New  @CondiSonal  annotaSon   •  New  @RestController  annotaSon   •  AsyncRestTemplate   •  Autowiring  of  generic  types   •  Groovy  based  config   And  more…  
  • 11. 4.0  M1   Java  8  &  Java  EE  7  support   Comprehensive  Java  8   support   • Lambdas   • Date  and  Time  API  (JSR-­‐310)   • Parameter  name  discovery   • Repeatable  annotaSons   • Concurrency  enhancement   Support  for  Java  EE  7  APIs   • Asynchronous  API  for  RestTemplate   • Bean  ValidaSon  1.1  (JSR-­‐349)   • Expression  Language  3.0  (JSR-­‐341)   • JMS  2.0  (JSR-­‐343)   • Concurrency  USliSes  for  Java  EE   (JSR-­‐236)   • JPA  2.1  (JSR-­‐338)   • Servlet  3.1  (JSR-­‐340)   • JSF  2.2  (JSR-­‐344)  
  • 12. Get  advantage  of  Java  8  lambdas   in  well  known  Spring  APIs!!!   JdbcTemplate  jdbcTemplate;       //  method  references     private  Customer  map(ResultSet  rs,  int  rowNum)  throws  SQLExcepSon  {      return  new  Customer(  rs.getString("name"),  rs.getInt("age")  );  }       //  let  it  saSsfy  the  `RowMapper`  funcSonal  interface     Customer  customer  =  jdbcTemplate.queryForObject(      "select  name,  age  from  customers  ",this::map);       Customer  customer  =  jdbcTemplate.queryForObject(sql,    (rs,  rowNum)  -­‐>  new  Customer(rs.getLong("id")));       4.0  M1  
  • 13. 4.0  M1   Lambdas  fit  naturally  wherever  you   have  funcSonal  interfaces   JmsTemplate+MessageCreator:     =>  Message  createMessage(Session  session)  throws   JMSExcepSon       TransacSonTemplate+Transac9onCallback:     =>  Object  doInTransacSon(TransacSonStatus  status)       And  other:   •  JdbcTemplate:   –  ResultSetExtractor,  RowCallbackHandler   •  JmsTemplate:   –  MessagePostProcessor,  BrowserCallback   •  TaskExecutor:   –  Runnable,  Callable  
  • 14. 4.0  M1   JSR-­‐310  Date  and  Time  support   import  java.Sme.*;   import  org.springframework.format.annotaSon.*;     public  class  Trade{      //…      @DateTimeFormat(iso=ISO.DATE)    private  LocalDate  tradeDate;            @DateTimeFormat(iso=ISO.DATE)    private  LocalDateTime  createTimestamp;   }  
  • 15. 4.0  M1   JDK8  support  in  depth   •  Implicit  use  of  LinkedHashMap/Set  instead  of  simple   HashMap/Set  to  preserve  ordering  diffs  in  JDK7  and  JDK8   •  Embed  ASM4.1  into  Spring  codebase  to  support  JDK8   bytecode  changes  and  to  keep  compaSbility  with  CGLib3.0   •  Support  for  JDK  8  Data  &  Time  (JSR-­‐310)  encorporated  with   Spring’s  Joda  Time  lib   •  Add  awaitTerminaSonSeconds/commonPool  properSes  to   ForkJoinPoolFactoryBean  to  support  JDK8  changes  in  it.   •  Encorporate  JDK8  changes  in  reflecSon  API  (such  as   java.lang.reflect.Parameter)  
  • 16. Bean  ValidaSon  1.1  support   4.0  M1   MethodValida+onInterceptor  autodetects  Bean  Valida/on  1.1's  ExecutableValidator  API  now     and  uses  it  in  favor  of  Hibernate  Validator  4.2's  na/ve  variant.  
  • 17. JMS  2.0  support   4.0  M1   What  was  done  already:   •  Added  "deliveryDelay"  property  on  JmsTemplate   •  Added  support  for  "deliveryDelay"  and  CompleSonListener  to   CachedMessageProducer   •  Added  support  for  the  new  "create(Shared)DurableConsumer"  variants  in   Spring’s  CachingConnecSonFactory   •  Added  support  for  the  new  "createSession"  variants  with  fewer   parameters  in  Spring’s  SingleConnecSonFactory   Known  constraints:   •  There  is  no  special  support  for  the  simplified  JMSContext  API,  and  likely   never  will  be,  because  of  different  Spring  mechanism  of  managing   connecSon  pools  and  sessions   •  JmsTemplate  has  no  out-­‐of-­‐the-­‐box  support  for  send  calls  with  an  async   compleSon  listener.  
  • 18. JEE7  concurrency  uSliSes  in  Spring  4   4.0  M1   This  is  built  into  ConcurrentTaskExecutor  and  ConcurrentTaskScheduler  now,   automaScally  detecSng  the  JSR-­‐236  ExecutorService  variants  and  adapSng   to  them.   Example  of  ManagedExecutorService  usage  introduced  in  JEE7:      
  • 19. 4.0  M1   JPA  2.1  support   EnStyManagerFactory.createEnStyManager(    Synchroniza9onType.SYNCHRONIZED/UNSYNCHRONIZED,  Map)       @PersistenceContext(    synchronizaSonType=SYNCHRONIZED/UNSYNCHRONIZED)            Support  for  both  transacSonal  and  extended  EnStyManagers      and  for  both  Spring-­‐managed  resource  transacSons  and  JTA   transacSons  
  • 20. WebSocket  JSR-­‐356  support   4.0  M1   (Annota/on  driven  using  Servlet  container  scan)   import  javax.websocket.server.ServerEndpoint;   import  org.springframework.web.socket.server.endpoint.SpringConfigurator;     @ServerEndpoint(value  =  "/echo",  configurator  =  SpringConfigurator.class)   public  class  EchoEndpoint  {        private  final  EchoService  echoService;        @Autowired      public  EchoEndpoint(EchoService  echoService)  {          this.echoService  =  echoService;      }        @OnMessage      public  void  handleMessage(Session  session,  String  message)  {          //  ...      }   }  
  • 21. WebSocket  JSR-­‐356  support   (Spring  container-­‐centric  registra/on)   import  org.springframework.web.socket.server.endpoint.ServerEndpointExporter;     @ConfiguraSon   public  class  EndpointConfig  {        @Bean      public  EchoEndpoint  echoEndpoint()  {          return  new  EchoEndpoint(echoService());      }        @Bean      public  EchoService  echoService()  {          //  ...      }        @Bean      public  ServerEndpointExporter  endpointExporter()  {          return  new  ServerEndpointExporter();      }   }   4.0  M1  
  • 22. WebSocket  JSR-­‐356  support   (Separate  endpoint  instance  per  socket)   import  org.springframework.web.socket.server.endpoint.ServerEndpointExporter;   import  org.springframework.web.socket.server.endpoint.ServerEndpointRegistra9on;     @ConfiguraSon   public  class  EndpointConfig  {        @Bean      public  EndpointRegistra9on  echoEndpoint()  {          return  new  EndpointRegistra9on("/echo",  EchoEndpoint.class);      }        @Bean      public  ServerEndpointExporter  endpointExporter()  {          return  new  ServerEndpointExporter();      }        //  ..   }   4.0  M1  
  • 23. 4.0  M1   WebSocket  JSR-­‐356  client  side  support   Purely  programmaSc  way:     WebSocketContainer  container  =  ContainerProvider.getWebSocketContainer();   container.connectToServer(EchoEndpoint.class,  new  URI("ws:localhost:8080/webapp/echo"));     Using  Spring  ApplicaSonContext:     import  org.springframework.web.socket.client.endpoint.AnnotatedEndpointConnec9onManager;     @ConfiguraSon   public  class  EndpointConfig  {        //  For  Endpoint  sub-­‐classes  use  EndpointConnecSonManager  instead        @Bean      public  AnnotatedEndpointConnec9onManager  connecSonManager()  {          return  new  AnnotatedEndpointConnec9onManager(echoEndpoint(),  "ws://localhost:8080/webapp/echo");      }        @Bean      public  EchoEndpoint  echoEndpoint()  {          //  ...      }   }    
  • 24. Spring  WebSocket  API   Why  own  API?   •  To  support  available  fallback  opSons  for   WebSockets  such  as  SockJS.   •  WebSocket  API  is  too  low  level  (messages  could   be  anything,  no  broadcast,  no  failure  handling   mechanism,  etc.)     •  No    way  to  handle  both  HTTP  and  WebSocket   requests  in  one  place  as  per  Front  Controller   pabern.   •  No  sub-­‐protocol  and  higher  level  protocols   support.  
  • 25. Spring  WebSocket  API     I   Inspira/on       Programming  model  for  building  message-­‐ oriented  applicaSons  using  STOMP  over   WebSocket  protocol  for  example   •  Transparent  WebSocket  emulaSon  using  SockJS   •  Separate  messaging  module  with  main  messaging   abstracSons  taken  from  Spring  IntegraSon   •  STOMP  sub-­‐protocol  support  (built-­‐in  simple  STOMP   broker)   •  Higher  level  programming  model  
  • 26. STOMP   SUBSCRIBE     id:sub-­‐1     desSnaSon:/topic/price.stock.*       MESSAGE     subscripSon:sub-­‐1     message-­‐id:wm2si1tj-­‐4     content-­‐type:  applicaSon/json     desSnaSon:/topic/stocks.PRICE.STOCK.NASDAQ.EM     {"Scker":"EMC","price":24.19}      
  • 27. WebSocket  Client  API   var  socket  =  new  SockJS('/spring-­‐websocket-­‐porholio/ porholio');     var  client  =  Stomp.over(socket);           var  onConnect  =  funcSon()  {        client.subscribe("/topic/price.stock.*",  func9on(message)  {              //  process  quote        });     };     client.connect('guest',  'guest',  onConnect);      
  • 28. Spring  Simple  Messaging  API   4.0  M1   (Handling  STOMP  message  sent  via  WebSocket   protocol)   @Controller     public  class  Por~olioController  {              //  ...              @MessageMapping(value="/app/trade")        public  void  executeTrade(Trade  trade,  Principal  principal)  {            trade.setUsername(principal.getName());            this.tradeService.executeTrade(trade);        }     }      
  • 29. Spring  Simple  Messaging  API   (Failures  handling)   @Controller     public  class  Por~olioController  {              //  ...              @MessageExcep9onHandler      @SendToUser("/queue/errors")        public  String  handleExcepSon(Throwable  excepSon)  {            return  excepSon.getMessage();        }     }       4.0  M1  
  • 30. Spring  Simple  Messaging  API   (Handle  SUBSCRIBE  events  from  client)   @Controller     public  class  Por~olioController  {              //  ...              @SubscribeMapping("/app/posi9ons")        public  List<Por~olioPosiSon>  getPor~olios(Principal  principal)  {            String  user  =  principal.getName();            Por~olio  por~olio  =  this.por~olioService.findPor~olio(user);            return  por~olio.getPosiSons();        }     }       4.0  M1  
  • 31. Spring  Simple  Messaging  API   4.0  M1   (Sending  updates  to  client  periodically)   @Service     public  class  QuoteService  {              private  final  MessageSendingOpera9ons<String>  messagingTemplate;          @Scheduled(fixedDelay=1000)        public  void  sendQuotes()  {            for  (Quote  quote  :  this.quoteGenerator.generateQuotes())  {                String  desSnaSon  =  "/topic/price.stock."  +  quote.getTicker();                this.messagingTemplate.convertAndSend(des9na9on,  quote);            }        }     }    
  • 32. Spring  Simple  Messaging  API   (Configura/on)   @ConfiguraSon   @EnableWebSocketMessageBroker   @EnableScheduling   @ComponentScan(basePackages="org.springframework.samples")   public  class  WebSocketConfig  implements  WebSocketMessageBrokerConfigurer  {      @Override    public  void  registerStompEndpoints(StompEndpointRegistry  registry)  {      registry.addEndpoint("/porholio").withSockJS();    }      @Override    public  void  configureMessageBroker(MessageBrokerConfigurer  configurer)  {      configurer.enableSimpleBroker("/queue/",  "/topic/");      //configurer.enableStompBrokerRelay("/queue/",  "/topic/");      configurer.setApplica9onDes9na9onPrefixes("/app");    }   }   4.0  M1  
  • 34. Composable  stereotype  model   @Service   @Scope(“session”)   @Primary   @Transac9onal(rollbackFor=Run9meExcep9on.class)   @RetenSon(RetenSonPolicy.RUNTIME)   public  @interface  MyService  {    boolean  readOnly();   }     @MyService(readOnly=true)   public  class  MyTradeService  {    //…   }  
  • 35. JEE  annotaSon  support  conSnue   @ManagedBean   public  class  MyTradeService  implements  TradeService{        @Inject    public  MyTradeService(MatchingService  service){      //…    }      @javax.transac9on.Transac9onal      public  void  matchTrade(Trade  trade){      //…    }     }    
  • 36. @CondiSonal  annotaSon   @Condi9onal(MyCondi9on.class)   @Configura9on     public  class  ExampleConfiguraSon  {      //  @Bean  methods   }       public  class  MyCondi9on  implements  Condi9on  {      public  boolean  matches(...)  {      //  return  true  if  the  condiSon  holds  true    }   }   4.0  M2  
  • 37. Make  #result  available  for  SpEL  in   @CachePut  key  abribute   4.0  M2   @CachePut(value  =  "personEn9ty",  key  =  "#result.id")   public  Person  persistPerson(Person  p)  {      Person  result  =  personRepository.save(p);      return  result;   }     @EnSty   public  class  Person  {      @Id  @GeneratedValue      private  Long  id;      …   }  
  • 38. Introduce  AcSveProfilesResolver  in  the   TestContext  framework   @RunWith(SpringJUnitRunner.class)   @ContextConfiguraSon(TestContext.class)   @Ac9veProfiles   public  class  IntegraSonTest  {          //…          @Test          public  void  integraSonTest(){                  //...          }   }     @ConfiguraSon   public  class  TestContext{          @Bean          public  Ac9veProfilesResolver  acSveProfilesResolver(){                  return  new  Ac9veProfilesResolver(){                            String[]  resolve(Class<?>  testClass){                                      //…                                      return  new  String[]{"test"};                            }                  };          }          //...   }   4.0  M2  
  • 39. 4.0  M3   Autowiring  ordered  collecSons  based   on  @Order  annotaSon   @Component   @Order(value=1)   public  class  BusinessServiceA  implements  BusinessService{}     @Component   @Order(value=2)   public  class  BusinessServiceB  implements  BusinessService{}     @Component   public  class  ServiceRegistry  {    @Autowired    public  List<BusinessService>  services;   }     assertThat(services.get(0).getClass(),  is(BusinessServiceA.class));   assertThat(services.get(1).getClass(),  is(BusinessServiceB.class));  
  • 40. @PropertySources  annotaSon   4.0  RC1   @ConfiguraSon   @PropertySources({      @PropertySource(value  =  "file:/etc/applicaSon/config.properSes",    ignoreResourceNotFound  =  true),      @PropertySource(value  =  "file:/usr/local/etc/applicaSon/config.properSes",    ignoreResourceNotFound  =  true),      @PropertySource(value  =  "file:conf/config.properSes",    ignoreResourceNotFound  =  true),      @PropertySource(value  =  "classpath:applicaSon.properSes")   })   public  class  AppConfiguraSon{    //…   }     Or  even  without  @PropertySources  using  Java8  repeatable  annota/ons!!!  
  • 41. Autowiring  of  generic  types   4.0  RC1  
  • 42. Groovy  config   def  bb  =  new  BeanBuilder()     bb.loadBeans("classpath:*SpringBeans.groovy")   def  applica9onContext  =  bb.createApplicaSonContext()       //  MySpringBeans.groovy     import  o.sf.jdbc.core.JdbcTemplate   import  o.sf.jdbc.datasource.DataSourceTransac9onManager     beans  {      jdbcTemplate(JdbcTemplate)  {        dataSource  =  dataSource      }      transac9onManager(DataSourceTransac9onManager){        dataSource  =  dataSource      }      dataSource(BasicDataSource)      driverClassName  ="org.h2.Driver"      url="jdbc:h2:mem:grailsDB"      username="sa"      password=""    }   }     4.0  RC1  
  • 43. @ControllerAdvice  annotaSon   @ControllerAdvice({"com.example.web.api"})   public  class  GlobalErrorHandler  {          //  common  @ExcepSonHandler  methods  are  defined  here   }     Will  be  applied  to  both  Controllers  below:   com.example.web.api.feature1.Feature1Controller     com.example.web.api.feature2.Featuer2Controller   4.0  RC1  
  • 44. Other  changes…   4.0  M1   •  Replace  EasyMock  with  Mockito   •  [SPR-­‐8258]  EhCache  2.5  support   4.0  M2   •  [SPR-­‐10664]  Make  #result  available  for  SpEL  in  @CachePut  key  abribute   •  [SPR-­‐10338]  Introduce  AcSveProfilesResolver  in  the  TestContext   framework   4.0  M3   •  [SPR-­‐5574]  Autowiring  should  support  ordered  collecSon  driven  by  Order   annotaSon  or  Ordered  interface   4.0  RC1   •  [SPR-­‐8371]  Add  @PropertySources  annotaSon  and  support   ignoreResourceNotFound  and  preserve  mulSple  @PropertySources  order   •  [SPR-­‐10222]  Allow  @ControllerAdvice  to  be  cofigured  with  a  join  point  to   target  a  subset  of  controller  
  • 45. How  to  track  progress?   •  Track  JIRA  -­‐   hbps://jira.springsource.org/browse/SPR/ fixforversion/14229   •  Check  commits  to  codebase  -­‐   hbps://github.com/SpringSource/spring-­‐ framework/commits/master  
  • 46. Thank  you!   Oleg  Tsal-­‐Tsalko   Email:  oleg.tsalko@gmail.com   Twiber:  @tsaltsol