補遺編集:
経験豊富な Spring Framework 開発者からのフィードバックがなかったため、これに対する回答を受け入れていません。
私は、Spring-Framework の applicationContext.xml ファイル (ここでは、Spring Bean ファクトリにロードするための Bean の初期化と依存関係が記述されています) に使用する代替 DSL に取り組んでいます。
私の動機は、Spring がこの目的で XML を使用するのが好きではなく、これまでに考案された代替手段がどれも本当に好きではないということです。ここでは説明しませんが、さまざまな理由から、Groovy などの命令型スクリプト言語ではなく、宣言型言語にとどまりたいと考えています。
そこで私は ANTLR パーサー ツールを手に入れ、SFig と名付けた新しい Bean ファクトリ DSL を考案しました。これについて詳しく説明しているリンクは次のとおりです。
SFig™ - Spring-Framework の代替メタデータ構成言語
ソースコードリポジトリサイトは次のとおりです。
http://code.google.com/p/sfig/
これまでのところ、言語構文でどのようにやっているのか知りたいです。SFig は効率的でわかりやすいと思いますか? (私は現在、複数行のテキスト文字列に特に関心があります):
properties_include "classpath:application.properties";
org.apache.commons.dbcp.BasicDataSource dataSource {
@scope = singleton;
@destroy-method = close;
driverClassName = "${jdbc.driverClassName}";
url = "${jdbc.url}";
username = "${jdbc.username}";
password = "${jdbc.password}";
defaultAutoCommit = true;
}
org.springframework.orm.ibatis.SqlMapClientFactoryBean sqlMapClient {
@scope = singleton;
@init-method = afterPropertiesSet;
@factory-method = getObject;
configLocation = "classpath:sqlmap-config.xml";
dataSource = $dataSource;
}
/* this string will have Java unescape encoding applied */
STRING str = "\tA test\u0020string with \\ escaped character encodings\r\n";
/* this string will remain literal - with escape characters remaining in place */
STRING regexp = @"(\$\{([a-zA-Z][a-zA-Z0-9._]*)\})";
/* multi-line text block - equates to a java.lang.String instance */
TEXT my_multi_line_text = ///
Here is a line of text.
This is yet another. Here is a blank line:
Now picks up again.
///;
/* forward use of 'props' bean */
java.util.HashMap map {
this( $props );
}
/* equates to a java.util.Propertis instance */
PROPERTIES props {
"James Ward" = "Adobe Flex evangelist";
"Stu Stern" = "Gorilla Logic - Flex Monkey test automation";
Dilbert = "character in popular comic strip of same title";
"App Title Display" = "Application: ${app.name}";
"${app.desc}" = "JFig processes text-format Java configuration data";
}
/* equates to a java.util.ArrayList instance */
LIST list {
this( ["dusty", "moldy", "${app.version}", $str] );
[234, 9798.76, -98, .05, "numbers", $props, ["red", "green", "blue"]];
}