svnno****@sourc*****
svnno****@sourc*****
2008年 12月 12日 (金) 03:36:41 JST
Revision: 2253 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2253 Author: daisuke_m Date: 2008-12-12 03:36:40 +0900 (Fri, 12 Dec 2008) Log Message: ----------- PostgresIdentifierValidatorの実装ミス修正。 /. add javadoc / refactor Modified Paths: -------------- artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/Artemis.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/ModelIdManager.java artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlIdentifierValidator.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java =================================================================== --- artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2008-12-11 18:02:39 UTC (rev 2252) +++ artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2008-12-11 18:36:40 UTC (rev 2253) @@ -67,6 +67,8 @@ /** SERLAL型のデータ型 */ private DataTypeDescriptor serialTypeDescriptor; + private RootModel rootModel; + /** * setup @@ -76,7 +78,7 @@ public void setUp() throws Exception { Jiemamy.init(Artemis.CORE, new ReflectionDialectAccessStrategy()); - RootModel rootModel = Jiemamy.newRootModel(); + rootModel = Jiemamy.newRootModel(); rootModel.setDialectId("org.jiemamy.dialect.postgresql.PostgresqlDialect"); dialect = Jiemamy.getDialect(rootModel); @@ -90,8 +92,9 @@ */ @After public void tearDown() throws Exception { + serialTypeDescriptor = null; dialect = null; - serialTypeDescriptor = null; + rootModel = null; Jiemamy.dispose(); } @@ -101,7 +104,6 @@ */ @Test public void test01_DBからのインポートテスト() throws Exception { - RootModel rootModel = Jiemamy.newRootModel(); ImportContext ctx = new ImportContextImpl(); ctx.setValue(DatabaseImporter.DIALECT, dialect); ctx.setValue(DatabaseImporter.DATABASE_NAME, "jpoll"); Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/Artemis.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/Artemis.java 2008-12-11 18:02:39 UTC (rev 2252) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/Artemis.java 2008-12-11 18:36:40 UTC (rev 2253) @@ -34,9 +34,9 @@ import org.jiemamy.exception.UnexpectedConditionError; /** - * Jiemamy関連クラスのインスタンスを {@link S2Container}から生成するストラテジクラス。 + * Jiemamy仕様の参照実装(Artemis)を表す型。 * - * <p>唯一の実装依存ポイント。</p> + * <p>インスタンスを{@link S2Container}から生成するストラテジとして機能する。唯一の実装依存ポイント。</p> * * @author daisuke */ @@ -59,6 +59,7 @@ /** DIコンテナ */ private S2Container container; + /** diconファイルのクラスパス内パス */ private String path; @@ -92,6 +93,7 @@ @SuppressWarnings("unchecked") public <T>T newInstance(Class<T> clazz) { Validate.notNull(clazz); + try { return (T) getContainer().getComponent(clazz); } catch (ComponentNotFoundRuntimeException e) { @@ -107,6 +109,7 @@ @SuppressWarnings("unchecked") public <T extends Identifiable>T newInstance(Class<T> clazz, UUID id) { Validate.notNull(id); + try { // HACK コンポーネント定義を捏造! これはひどいww ComponentDef componentDef = getContainer().getComponentDef(clazz); @@ -132,6 +135,15 @@ } } + /** + * Seasar2コンテナインスタンスを取得する。 + * + * <p>{@link S2Container} インスタンスは、遅延生成(このメソッドが呼ばれてはじめて生成)される。 + * コンストラクタで生成してしまうと、jiemamy-event.dicon等の拡張仕様の実装がクラスパス内に存在しなかった場合、 + * Artemisのクラスロード時点で例外が発生してしまう為。</p> + * + * @return Seasar2コンテナインスタンス + */ private S2Container getContainer() { if (container == null) { container = S2ContainerFactory.create(path); Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/ModelIdManager.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/ModelIdManager.java 2008-12-11 18:02:39 UTC (rev 2252) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/ModelIdManager.java 2008-12-11 18:36:40 UTC (rev 2253) @@ -29,7 +29,7 @@ public final class ModelIdManager { /** シングルトンインスタンス */ - private static ModelIdManager instance; + private static ModelIdManager singleton; /** @@ -38,10 +38,10 @@ * @return ModelManagerのインスタンス */ public static synchronized ModelIdManager getInstance() { - if (instance == null) { - instance = new ModelIdManager(); + if (singleton == null) { + singleton = new ModelIdManager(); } - return instance; + return singleton; } @@ -50,10 +50,10 @@ /** - * コンストラクタ。 + * privateコンストラクタ。 * @category instance creation */ - protected ModelIdManager() { + private ModelIdManager() { } /** Modified: artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlIdentifierValidator.java =================================================================== --- artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlIdentifierValidator.java 2008-12-11 18:02:39 UTC (rev 2252) +++ artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlIdentifierValidator.java 2008-12-11 18:36:40 UTC (rev 2253) @@ -31,7 +31,7 @@ * @category instance creation */ public PostgresqlIdentifierValidator() { - super("^[0-9a-zA-Z]$", new PostgresqlReservedWords()); + super("^[0-9a-zA-Z_]+$", new PostgresqlReservedWords()); } } Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java 2008-12-11 18:02:39 UTC (rev 2252) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java 2008-12-11 18:36:40 UTC (rev 2253) @@ -257,6 +257,10 @@ @SuppressWarnings("unchecked") public T getInstance(String fqcn) throws ClassNotFoundException { assert cache != null; + if (fqcn == null) { + throw new ClassNotFoundException(); + } + if (cache.get(fqcn) == null) { Class<? extends T> clazz; if (classLoader != null) {