1.7.0_51 Hello World 依存 jar の追加 guice-3.0.jar と guice-servlet-3.0.jar をクラスパスに追加する。 build.gradle は以下。 dependencies { providedCompile 'org.apache.tomcat:tomcat-servlet-api:7.0.50' compile 'com.google.inject:guice:3.0' compile 'com.google.inject.extensions:guice-servlet:3.0' } <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.
HK2 is an implementation of JSR-330 in a JavaSE environment. JSR-330 defines services and injection points that can be dynamically discovered at runtime and which allow for Inversion of Control (IoC) and dependency injection (DI). HK2 provides an API for control over its operation and has the ability to automatically load services into the container. It is the foundation for the GlassFish V3 and V
JAX-RS 2.0からDI(JSR-330)が仕様に組み込まれています。JAX-RSの参照実装であるJerseyにも2.XからはDIが組み込まれています。ところが、そのJSR-330の実装はHK2でした。そのため同じくJSR-330の実装であるGuiceとJerseyの連携が、Jersey1.Xのころと同じ方法ではできなくなりました。どうする!? HK2がBridgeを提供してくれました! HK2がGuiceとのBridgeを提供してくれたので、ちょこっと書いたら動くようです。 package web; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.servlet.ServletModule; import org.glassfish.hk2.api.
I would like to know how can I use injection in my job using guice. As I can't use @Inject on the default constructor may I use it directly on the attribute as follow (I always got a NullPointerException with PersonDAO) ? I know that a DAO has nothing to do here but it's just for testing. public class SimpleQuartzJob implements Job { @Inject PersonDao Person; private static Logger logger = Logger.
Java 界隈には OSGi といういかついダイナミックモジュールシステムがあるのですけども、これは解決しようとしている問題の量が非常に多いのでちょっとしたものを作るために使おうとすると非常に辛い。 そもそも、アプリケーションのブートストラップ部分から全部 OSGi ベースで作りこまないと良い感じに動いてくれません。 そこで、OSGi を前提としたアーキテクチャ設計が必要になるのですけども、ちょっと便利なツール作りたいだけなのに膨大な時間をかけて OSGi を勉強するかと言われると、しませんよね。 という訳で、Java において簡易的なプラグインシステムを Guice で作ってみましょうという話です。 尚、Spring 界隈で実現する方法については@makingさんのエントリをどうぞ。 DI コンテナで実現する簡易プラグイン機構コードの場所#必要に応じてエントリ内にコードはありますが、実際
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く