レベルエンター山本大のブログ

面白いプログラミング教育を若い人たちに

BLOCKVROCKリファレンス目次はこちら

[翻訳]Guice User's Guide ■26. Development Stages

デベロップメントステージ(開発・テスト環境ステージ)

Guice is aware that your application goes through different stages of development. You can tell it which stage the application is running in when you create a container. Guice currently supports "development" and "production." We've found that tests usually fall under one stage or the other.

Guiceは、アプリケーションが「開発・テスト環境ステージ」から別のステージへの移行に対応しています。コンテナを生成する際に、アプリケーションが実行されるステージを設定する事が出来ます。Guiceは現在のところ「"development" :開発環境」と「"production.":本番環境」 に対応しています。テストは通常一つの環境で行います。

During development, Guice will load singleton objects on demand. This way, your application starts up fast and only loads the parts you're testing.

開発中は、Guiceは要求に従ってシングルトンでオブジェクトをロードします。これはアプリケーションがすばやく起動するためであり、テスト時には一部しかロードしなくて良いためです。

In production, Guice will load all your singleton objects at startup. This helps catch errors early and takes any performance hits up front.

「本番環境ステージ」では、Guiceは起動時にすべてのオブジェクトをシングルトンで起動します。これは早い段階でエラーを補足することを助け、事前にパフォーマンスへの影響を取り除くためです。

Your modules can also apply method interceptors and other bindings based on the current stage. For example, an interceptor might verify that you don't use your objects out of scope during development.

モジュールでは、現在のステージに基づいたバインドや、メソッドインターセプターを適用することも出来ます。たとえば、あるインターセプターを使って開発中にスコープの外でオブジェクトが使用されていないことを証明することができます。