Wicket で Google guice を連携する時の要は、Wicketで配布している
wicket-guice-1.4.x.jar の中の
org.apache.wicket.guice.GuiceComponentInjector
を org.apache.wicket.protocol.http.WebApplication 継承クラスで
init()メソッドをオーバーライドした中で
WebApplication → org.apache.wicket.Applicationクラスの public final メソッドである
void addComponentInstantiationListener(IComponentInstantiationListener arg0)
の引数として実行することである。→GuiceComponentInjector は、
IComponentInstantiationListener を実装している。
つまり、、、
import org.apache.wicket.guice.GuiceComponentInjector;
import org.apache.wicket.protocol.http.WebApplication;
import com.google.inject.Module;
/**
* WebApplication 継承 → web.xml WicketFilter
* init-param name=applicationClassName の value として登録されてる
*/
public class NadiaApplication extends WebApplication{
/* Web起動時の初期化処理
* @see org.apache.wicket.protocol.http.WebApplication#init()
*/
@Override
protected void init(){
super.init();
:
// Guice インジェクション
addComponentInstantiationListener(new GuiceComponentInjector(
this
,new Module[]{
new SqlMapModule() //←Google guice の AbstractModule継承のインスタンス
,new PaperModule() //←Google guice の AbstractModule継承のインスタンス
}
)
);
}
@Override
public Class<? extends Page> getHomePage(){
return HomePage.class;
}
}