[CUBBY-233] Guice でアクションを登録する方法の変更 Created: 2009-06-19  Updated: 2009-08-24  Resolved: 2009-06-25

Status: Closed
Project: Cubby
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.0-rc1

Type: Improvement Priority: Major
Reporter: baba Assignee: baba
Resolution: Fixed Votes: 0
Labels: None


 Description   

Guice のモジュールからアクションを登録する方法を変更します。

bind() メソッドで登録されたクラスがアクションだった場合に、自動的に PathResolver に登録します。
Converter、RequestParser も同様に bind() で自動登録します。
Guice 2.0 からはモジュールのオーバーライドができるので、AbstractCubbyModule で継承のために protected にしていたメソッドは廃止、AbstractCubbyModule は CubbyModule に変更します。
標準の Converter / RequestParser を bind する protected なメソッドを追加します。
(configureDefaultConverters / configureDefaultRequestParsers)
ファイルアップロードの基本的な設定をする FileUploadModule を追加します。

beta3 まで

@Override
protected void configure() {
	install(new ServletModule());
	install(new AbstractCubbyModule() {

		@Override
		protected PathResolver getPathResolver() {
			final PathTemplateParser pathTemplateParser = new PathTemplateParserImpl();
			final PathResolver pathResolver = new PathResolverImpl(
					pathTemplateParser);
			pathResolver.add(IndexAction.class);
			pathResolver.add(HelloAction.class);
			return pathResolver;
		}

	});
}

beta4から

@Override
protected void configure() {
	install(new ServletModule());
	install(new CubbyModule());
	install(new FileUploadModule());

	bind(IndexAction.class);
	bind(HelloAction.class);
}


 Comments   
Comment by baba [ 2009-06-25 ]

こんなふうに Module でパスを設定することも検討してみました。

path("/foo/bar").onSubmit("execute").priority(1).bind(FooAction.class, "bar").to(FooActionImpl.class);

bind はクラスについて処理するのに対し、Cubby のパスはメソッドに対して紐付けられます。
ちょっと対象が違うと思うので、今回は対応しないでおきます。

Generated at Sat Apr 27 02:55:14 JST 2024 using Jira 9.15.0#9150000-sha1:9ead8528714127d8cfabf2446010d7e62c0a195c.