Spring I/O 2015報告会

2015/6/22 JSUG

agenda

内容 時間 発表者
概要 5min 池谷
Key Note 「Springの歴史」 10min 本橋
セッションサマリ(Spring 4.2) 45min 岩塚、池谷
セッションサマリ(その他) 20min 岩塚、池谷

自己紹介

Spring I/O 2015

Spring I/O 2015

Spring I/O 2015 概要

Spring I/O 2015 概要

Spring I/O 2015

バルセロナ

サグラダファミリア サグラダファミリア

会場

会場 会場

戦利品

ノベルティ

Spring I/O 2015 Key Note 「Springの歴史」

agenda

内容 時間 発表者
概要 5min 池谷
Key Note 「Springの歴史」 10min 本橋
セッションサマリ(Spring 4.2) 45min 岩塚、池谷
セッションサマリ(その他) 20min 岩塚、池谷

Spring 4.2

セッションサマリ(Spring 4.2)

タイトル カテゴリ スピーカー 報告者
Modern Java Component Design with Spring 4.2 Core Juergen Hoeller 池谷
Spring 4 Web Apps Web Rossen Stoyanchev 岩塚
Real-time with Spring: SSE and WebSockets Web Sergi Almar 岩塚
Testing with Spring 4.x Test Sam Brannen 岩塚

Spring 4.2

Spring 4.1の新機能(おさらい)

分類 新機能
Web 静的リソース制御の改善
Controller引数のOptionalサポート
Controllerの返値のListenableFutureサポート
Jacksonの@JsonViewサポート
JSONPサポート
ResponseBodyAdvice追加
新しいHttpMessageConverter追加
EL関数s:mvcUrl追加
ResponseEntityビルダーサポート
GroovyMarkupTemplateサポート

Spring 4.1の新機能(おさらい)

分類 新機能
JMS @JmsListenerサポート
spring-messagingサポート
Cache JCache(JSR-107)サポート
WebSocket SockJSのクライアントサイドサポート
STOMPのSubscribeイベントサポート
websocketスコープの追加
Test Groovy ScriptでのTestContext設定サポート
@Sql/@SqlConfigのサポート
@TestPropertySourceのサポート

詳細は、 http://www.slideshare.net/makingx/springone-2gx-2014-spring-41-jsug

Spring 4.2の新機能(カテゴリ)

4.1新機能 4.2新機能
Web
JMS
WebSocket
Test
Cache
Web
JMS
WebSocket
Test
Container
Data Access

Spring 4.2の新機能

分類 新機能 詳細
Container @BeanのJava8 defaultメソッド対応
@Importの改善
@OrderのConfigurationクラス対応 -
@Resource@Lazy対応 -
@EventListenerによるイベント検知
ApplicationEventを継承しないイベント
@AliasForによる@属性のエイリアス対応

Spring 4.2の新機能

分類 新機能 詳細
DefaultConversionServiceの改善 -
DefaultFormattingConversionServiceのJSR-354 Money & Currency対応 -
@NumberFormatのmeta-annotation対応 -
JavaMailSenderImplへのtestConnection()メソッド追加 -
ScheduledTaskRegistrarの改善 -
Apache commons-pool2のサポート -

@BeanのJava8 defaultメソッド対応

@BeanのJava8 defaultメソッド対応(Before)

Java-Based ConfigurationのBean定義

@Configuration
@Import({MyBookAdminConfig.class, MyBookConfig.class})
public class MyApplicationConfig { ... }

@Configuration
public class MyBookAdminConfig {
 @Bean
 public BookAdminService myBookAdminService() {
   MyBookAdminService service = new MyBookAdminService();
   service.setDataSource(bookAdminDataSource());
   return service;
 }
}

@BeanのJava8 defaultメソッド対応(After)

継承するので、必要に応じて生成Beanを@Overrideできる。

@Configuration
public class MyApplicationConfig
      implements MyBookAdminConfig, MyBookConfig { ... }

public interface MyBookAdminConfig {
 @Bean
 default BookAdminService myBookAdminService() {
   MyBookAdminService service = new MyBookAdminService();
   service.setDataSource(bookAdminDataSource());
   return service;
 }
}

@EventListener 周りの改善

@EventListener(Before)

public class MyApplicationEvent extends ApplicationEvent {...}

public class MyApplicationEventPublisher
               implements ApplicationEventPublisherAware {
  ...
  public void publishMyApplicationEvent() {
    publisher.publishEvent(new MyApplicationEvent());
  }
}
public class MyApplicationEventListener
               implements ApplicationListener<MyApplicationEvent> {
  public void onApplicationEvent(MyApplicationEvent event) { ... }
}

@EventListener(After)

@EventListener
public void processEvent(MyApplicationEvent event) {
 ...
}
@EventListener
public void processEvent(String payload) {
 // ApplicationEventを継承しない任意オブジェクトイベント
 ...
}
@EventListener(condition="#payload.startsWith('OK')")
public void processEvent(String payload) {
 ...
}

ApplicationEventを継承しないイベント

public class MyApplicationEventPublisher
               implements ApplicationEventPublisherAware {
  ...

  public void publishMyApplicationEvent() {
    publisher.publishEvent("Hello World.");
  }
}

@TransactionalEventListenerのサポート

イベント発行即時でなく、イベント発行側のトランザクション終了前後でイベントを検知できる。

@TransactionalEventListener()
public void afterCommit(MyApplicationEvent event) {
 ...
}
@TransactionalEventListener(phase=TransactionPhase.BEFORE_COMMIT)
public void beforeCommit(MyApplicationEvent event) {
 ...
}
@TransactionalEventListener(fallbackExecution = true)
public void afterCommitFallbackExecution(MyApplicationEvent event) {
 // トランザクション外でイベントが発行された場合も呼び出される
 ...
}

https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2

メタアノテーション属性上書きの改善

メタアノテーションとは

@Service
@Scope("session")
@Primary
@Transactional(rollbackFor=Exception.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyService {}

@MyService
public class MyBookAdminService { ... }

@AliasForエイリアス対応(Before)

@Service
@Scope("session")
@Primary
@Transactional(rollbackFor=Exception.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyService {
  boolean readOnly();
}

@AliasForエイリアス対応(After)

単一アノテーション内での利用

public @interface ContextConfiguration {
    @AliasFor(attribute = "locations")
    String[] value() default {};

    @AliasFor(attribute = "value")
    String[] locations() default {};
}

@AliasForによる@属性のエイリアス対応(After)

メタアノテーション内のエイリアスの利用

@Service
@Scope("session")
@Primary
@Transactional(rollbackFor=Exception.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyService {
  @AliasFor(annotation = Service.class, attribute = "value")
  String value() default "";

  @AliasFor(annotation = Transactional.class, attribute = "readOnly")
  boolean myReadOnly();
}

その他の改善

@Importの改善

@Import でComponentクラスをインポートできるようになった。 @ComponentScan@ComponentなしでBeanを生成できる。

@Configuration
@Import(MyBookAdminService.class)
public class MyApplicationConfig {
 ...
}

public class MyBookAdminService implements BookAdminService {
 @Autowired
 public MyBookAdminService(AccountRepository repo) {
 ...
 }
}

Spring 4.2の新機能

カテゴリ 新機能 詳細
Data Access AspectJによるjavax.transaction.Transactionalの対応 -
SimpleJdbcCallOperationsの名前バインディング対応 -
Hibernate ORM 5.0のフルサポート -
<jdbc:embedded-database>へのdatabase-name属性追加 -
JMS 省略 -

Spring 4.2の新機能

別資料へ

セッションサマリ(その他)

タイトル スピーカー
Spring Boot is made for tooling Yann Cébron & Stéphane Nicoll
Spring Batch for Large Enterprises Operations Ignasi González
TERASOLUNA Framework on the Spring IO Platform 槙さん
Manage your user’s session with Spring Session David Gomez
High Performance Spring Integration John Davies

セッションサマリ(その他)

タイトル スピーカー
Spring Data REST – Repositories meet hypermedia Oliver Gierke
Building High Performance Applications with Spring Data Neo4j 4.0 Michael Hunger & Vince Bickers
Document like the Spring team using Asciidoctor Alex Soto
A Brief History of Thymeleaf Jose Samper
JHipster, the leading application generator for Spring Boot + AngularJS Julien Dubois

Spring Batch for Large Enterprises Operations

Ignasi Gonzalez

Spring Batch for Large Enterprises Operations

Spring Batch for Large Enterprises Operations

TERASOLUNA Framework on the Spring IO Platform

Toshiaki Maki

TERASOLUNA Framework on the Spring IO Platform

Manage your user’s session with Spring Session

David Gomez

Manage your user’s session with Spring Session

Manage your user’s session with Spring Session

Spring Session

http://www.slideshare.net/dgomezg/managing-users-data-with-spring-session

A Brief History of Thymeleaf

Jose Samper

A Brief History of Thymeleaf

A Brief History of Thymeleaf

繰り返し処理の記述例

<ul>
  <li th:each="product : ${products}"
      th:text="${product.name}">
    Red carpet
  </li>
</ul>

Spring Boot is made for tooling

Yann Cébron Stéphane Nicoll

Spring Boot is made for tooling

その他

その他

Reference