スプリングフレームワーク

Spring Frameworkは最も人気のあるJava EEフレームワークの一つです。この記事では、以下の内容について学びます。

  • Spring framework architecture
  • Core components of Spring
  • Various projects under the spring framework umbrella.

Springフレームワーク、Servlet、JSP、JSFのGoogleトレンドチャートを見ました。明らかにSpringは他のJava EEテクノロジーよりも大きくリードしています。

Spring Framework Popularity

スプリングフレームワークとは何ですか? (Supuringu fureemwaku to wa nan desu ka?)

春はJavaエンタープライズエディション向けの最も人気のあるフレームワークの一つです。世界中の開発者が信頼性と高品質なアプリケーションを開発するためにSpringを使用しています。SpringフレームワークはRod Johnsonによって設計されました。それ以来、SpringはEJBモデルに対するJava世界での代替技術となっています。Springフレームワークを使用することで、さまざまな種類のアプリケーションを作成することができます。

スプリングのコアコンセプト – DI、IoC、AOP

  • It is impossible to understand what is Spring Framework without understanding what is Dependency Injection and Inversion of Control. Dependency Injection also called as DI, is one of the types of Inversion of Control (IoC).
  • Inversion of Control – this is the principle of object-oriented programming, in which objects of the program do not depend on concrete implementations of other objects, but may have knowledge about their abstractions (interfaces) for later interaction.
  • Dependency Injection – is a composition of structural design patterns, in which for each function of the application there is one, a conditionally independent object (service) that can have the need to use other objects (dependencies) known to it by interfaces. Dependencies are transferred (implemented) to the service at the time of its creation. This is a situation where we introduce an element of one class into another. In practice, DI is implemented by passing parameters to the constructor or using setters. Libraries that implement this approach are also called IoC containers.
  • Aspect oriented programming – a programming paradigm that allows you to distinguish cross-through (functional) functionality in application. These functions, which span multiple application nodes, are called cross-cutting concerns and these cross-cutting notes are separated from the immediate business logic of the application. In OOP, the key unit is the class, while in AOP, the key element is the aspect. DI helps to separate application classes into separate modules, and AOP helps to separate cross-cutting concerns from the objects they affect.

スプリングフレームワークのアーキテクチャ

spring framework architecture

Springフレームワークのコアコンポーネント

Springのコアコンテナには、SpEL、コンテキスト、コア、ビーンの4つのモジュールが含まれています。これらの要素の説明は次の通りです。

    1. SpELモジュールは、実行中にオブジェクトを操作するための強力な式言語を提供します。

 

    1. ContextはBeansとCoreを積み重ねて構築され、設定された任意のオブジェクトにアクセスすることができます。Contextモジュールのキーエレメントは、ApplicationContextインターフェースです。

 

    1. Coreモジュールは、IoCとDIのプロパティを含むフレームワークの主要な要素を提供します。

 

    Beanモジュールは、Spring Beansを作成および管理し、アプリケーションコンテキストの構造単位です。

スプリングフレームワークウェブ

SpringフレームワークのWeb層には、Web、Web-MVC、Web-Socket、Web-Portletなどが含まれています。

    1. Webモジュールは、ファイルのダウンロード、Webアプリケーションの作成、REST Webサービスなどの機能を提供します。

 

    1. Web-MVCは、Webアプリケーション用のSpring MVCの実装を含んでいます。

 

    1. Web-Socketは、Webアプリケーションでのクライアントとサーバー間の通信をWeb-Socketを使用してサポートします。

 

    Web-Portletは、ポートレット環境でのMVC実装を提供します。

スプリングフレームワークのデータアクセス

データアクセス/統合コンテナには、JDBC、ORM、OXM、JMS、トランザクションモジュールが含まれています。

    1. JDBCはJDBCの抽象レイヤーを提供し、データベースへの接続に関連する単調なコードの手動登録が不要になります。

 

    1. Spring ORMはHibernate、JDOなどの人気のあるORM(JPAの実装)との統合を提供します。

 

    1. OXMモジュールはオブジェクト/ XML(XMLBeans、JAXBなど)のリンクを担当します。

 

    1. JMS(Java Messaging Service)モジュールはメッセージの作成、送信、受信を担当します。

 

    Transactionsは特定のメソッドとPOJOを実装するクラスのトランザクション管理をサポートします。

さまざまなモジュール

春には、AOP、アスペクト、インストゥルメンテーション、メッセージング、テストなど、さまざまな重要なモジュールが含まれています。

    1. AOPはアスペクト指向プログラミングを実装し、AOPの機能をすべて使うことができます。

 

    1. Aspectsモジュールは、パワフルなAOPフレームワークであるAspectJとの統合を提供しています。

 

    1. Instrumentationは、サーバーアプリケーションで使用されるクラスのインストゥルメンテーションとクラスローダーのサポートを担当しています。

 

    1. MessagingモジュールはSTOMPサポートを提供しています。

 

    最後に、TestモジュールはTestNGまたはJUnitフレームワークを使用したテストを提供します。

春の5つの特徴

Spring 5はSpring 4に大規模なアップデートをもたらしました。Spring 5の重要な機能のいくつかは次の通りです:

    1. Java 8、 Java 9、 Java EE 7、 Java EE 8、 Servlet 4.0、 Bean Validation 2.0、および JPA 2.2のサポート。Springが主要な最新のテクノロジーのバージョンに追いつこうとしているのを見ることができてうれしいです。

 

    1. 新しいモジュール、 spring-jclによる改善されたログ記録。

 

    1. ファイル操作はNIO 2 ストリームを使用しているため、パフォーマンスが向上しました。

 

    1. Spring MVC コントローラのメソッドからの戻り値として、Reactor 3.1 Flux と Mono、RxJava 1.3 と 2.1のサポート。

 

    1. Jackson や GSON の代替として、Kotlin、Project Lombok、JSON Binding APIのサポート。

 

    1. Spring WebFlux – Springが反応的になる。

 

    1. JUnit 5のサポート

 

    Kotlinを介した関数型プログラミングのサポート。

私たちのGitHubリポジトリでSpring Projectsをチェックアウトできます。

参照先: Spring公式ウェブサイト、Springリファレンスドキュメンテーション

コメントを残す 0

Your email address will not be published. Required fields are marked *