2011-02-01から1ヶ月間の記事一覧

3.14. The BeanFactory

3.14 The BeanFactory 基本的にBeanFactoryを直接使う必要はなくApplicationContextを使えばOK。以上。3.14.2 Glue code and the evil singleton 根性切れた。省略

3.13. Additional Capabilities of the ApplicationContext

概要 ApplicationContextは、BeanFactoryの機能に以下が追加されている MessageSource (リソースバンドル) ResourceLoader (URLやファイルリソース) ApplicationListener (イベント配信) HierarchicalBeanFactory (コンテナ間の連携?) 3.13.1 Inter…

3.12. Registering a LoadTimeWeaver

<beans> <context:load-time-weaver/> </beans> これを付けるとLoadTimeWeaverAwareをインジェクションできる。これはJPAなどロード時のウィービングを行う場合に役立つ。詳細は別で。

3.11. Java-based container configuration

3.11.1 Basic concepts: @Configuration and @Bean @Configurationをつけたクラスに、@Beanをつけたメソッドを定義するとbeanを定義できる。というのが中心概念。メソッド名がbean名になります。 3.11.2 Instantiating the Spring container using Annotatio…

3.10. Classpath scanning and managed components

3.10.1 @Component and further stereotype annotations ステレオタイプアノテーションについて。 @Component Springが管理するコンポーネントを表す。 @Controller MVCのコントローラ @Service サービス層 @Repository DBアクセス クラスアノテーションとし…

3.9. Annotation-based container configuration

概要 大まかにサポートするアノテーションは以下のとおり @Required @Autowired JSR-250(@Resources,@PostConstruct) JSR-330(@Inject,@Qualifier,@Named,@Provider) → CDIですね。 これらのアノテーションを使うためには、対応するBeanPostProcessorが登録…

p6spy手順メモとカスタマイズ

JDBCドライバをラップしてSQLログを出力するP6SpyというOSSを試してみました。作業手順 以下ダウンロードしてspy-install.jarを展開する。 http://sourceforge.net/projects/p6spy/ p6spy.jarとspy.propertiesをクラスパスに置く spy.propertiesを編集。 デ…

3.6. Customizing the nature of a bean

3.6 Customizing the nature of a bean 3.6.1 Lifecycle callbacks Beanを生成・破棄するタイミングでコールバックしてくれる。これはBeanPostProcessor で実装しておりカスタマイズ可能。 3.6.1.1 Initialization callbacks,3.6.1.2 Destruction callbacks …

3.5. Bean scopes

3.5 Bean scopes Beanのスコープの定義はこうだ! ・singleton デフォルト。シングルトンです。ステートレスにしなさい。 ・prototype 毎回生成します。ステートフルにしなさい。 ・request HTTPリクエストのスコープです。Web層のアプリケーションコンテキ…

3.4. Dependencies

3.4 Dependencies bean間の依存関係の定義について。なんか書いてあったけど忘れたので省略。この節は長いな…。3.4.1 Dependency injection SpringのDIには、コンストラクタインジェクションと、セッターインジェクションがある。 3.4.1.1 Constructor-based…

3.3. Bean overview

3.3.1 Naming beansBeanの定義の基礎について。 すべてのbeanはひとつ以上の名前を定義できる。普通は名前はひとつだけど。複数のエイリアスをつけることもできる。 Bean名はid属性かname属性で定義する。idはXML elementのidなのでXMLで唯一でないといけな…

3.8. Container extension points

3.8 Container extension points コンテナの機能については、プラガブルに拡張できます。ここは後で見ようかと思うが、概要だけ。 3.8.1 Customizing beans using the BeanPostProcessor Interface ここはBeanのライフサイクルコールバック、依存解決ロック…

3.7. Bean definition inheritance

3.7 Bean definition inheritance <bean id="inheritsWithDifferentClass" class="org.springframework.beans.DerivedTestBean" parent="inheritedTestBean" init-method="initialize">こうやると、idがinheritedTestBeanのbean定義をプロパティ継承できる。プロパティは継承先で上書きもできる。なおdepends on, autowire mode, dependency check, singleton, scope, …</bean>

3.1. Introduction to the Spring IoC container and beans

BeanFactoryとApplicationContextについて。ApplicationContextはBeanFactoryのサブセットであり、エンタープライズアプリ作るために必要な機能がいろいろ追加されてる。普通はApplicationContextを考えればよい。 以上。…内容端折り過ぎだ(´・ω・`)

3.2. Container overview

概要 Springにおける「コンテナ」という概念について。 ・ApplicationContextがSpringIOCのコンテナを表す。 ・ApplicationContextの実装で代表的なものとして、ClassPathXmlApplicationContextやFileSystemXmlApplicationContextがある。 ・普通はApplicati…

Spring Framework 3.0 リファレンス オレオレ和訳(日本語訳) 目次

とりあえず、自分の気が向く間だけでもSpringFrameworkのドキュメント読んだ内容をメモっていきます。邦訳ではなく、自分が読んだ足跡を自分向けに残しているだけですので精度も悪いですが(そもそも英語は超苦手です)、まぁ公開することで恥さらしするのも…

StrategyPattern

ApplicationContextAwareを使わないStrategyPatternの実装例。 もとねた:http://seasarproject.g.hatena.ne.jp/abhrsh/comment?date=20040822ストラテジ public interface Strategy { public String getMessage(); }ストラテジの実装クラス @Component publ…