svnno****@sourc*****
svnno****@sourc*****
2008年 11月 16日 (日) 01:29:56 JST
Revision: 2150 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2150 Author: daisuke_m Date: 2008-11-16 01:29:56 +0900 (Sun, 16 Nov 2008) Log Message: ----------- J-serializerの、実装依存をまた一つ減らした。あとModelIdManagerだけ…。どうするかなぁ。 Modified Paths: -------------- artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/specific/FieldHacker.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyModelCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/SerializationTest.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamyModelFactory.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/NotInitializedException.java Added Paths: ----------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyDefaultSerializer.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamySerializer.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/SerializationException.java Removed Paths: ------------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializer.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerFactory.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerImpl.java -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/specific/FieldHacker.java =================================================================== --- artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/specific/FieldHacker.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/specific/FieldHacker.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -1,18 +1,6 @@ package org.jiemamy.irenka.hack.specific; -import org.ashikunep.irenka.dom.CtClass; -import org.ashikunep.irenka.dom.CtEnum; -import org.ashikunep.irenka.dom.CtEnumConstant; -import org.ashikunep.irenka.dom.CtField; -import org.ashikunep.irenka.dom.CtJavadoc; -import org.ashikunep.irenka.dom.CtMember; -import org.ashikunep.irenka.dom.ElementKind; -import org.ashikunep.irenka.dom.ModifierKind; -import org.ashikunep.irenka.dom.doc.CtDocBlock; -import org.ashikunep.irenka.toolkit.DeclarationFactory; -import org.ashikunep.irenka.toolkit.DocFactory; -import org.ashikunep.irenka.toolkit.ElementFactory; -import org.ashikunep.irenka.toolkit.Messager; +import org.ashikunep.irenka.dom.CtMethod; /** * フィールドのEnumを生成するIrenka Hack。 @@ -21,52 +9,58 @@ public class FieldHacker { /** - * @param me - * @param klass - * @param decFactory - * @param elemFactory - * @param docFactory - * @when klass.simpleName =~ "^.*ModelX$" + * @when */ - public void foundModel(Messager me, CtClass<?> klass, DeclarationFactory decFactory, ElementFactory elemFactory, - DocFactory docFactory) { - System.out.println(klass.getSimpleName()); - - final String enumName = "Field"; - CtEnum<?> fieldEnum = null; - - for (CtMember member : klass.getMembers()) { - if (member.getElementKind() == ElementKind.ENUM && ((CtEnum<?>) member).getSimpleName().equals(enumName)) { - fieldEnum = (CtEnum<?>) member; - break; - } - } - - CtEnum<?> newEnum = decFactory.newEnum(enumName); - newEnum.getModifiersAndAnnotations().add(elemFactory.newModifier(ModifierKind.PUBLIC)); - if (fieldEnum == null) { - me.info("not found"); - klass.getMembers().add(newEnum); - - } else { - me.info("found"); - fieldEnum.substitute(newEnum); - } - - for (CtField<?> field : klass.getDeclaredFields()) { - CtEnumConstant<?> newEnumConstant = - decFactory.newEnumConstant(newEnum, field.getSimpleName().replaceAll("([A-Z])", "_$1") - .toUpperCase()); - newEnum.getMembers().add(newEnumConstant); - - String fieldDescription = klass.getSimpleName() + "#" + field.getSimpleName(); - CtDocBlock javadoc = docFactory.newDocBlock("@see " + fieldDescription); - newEnumConstant.getJavadoc().getBlocks().clear(); - newEnumConstant.getJavadoc().getBlocks().add(javadoc); - } - - CtJavadoc javadoc = docFactory.parseJavadoc("/** Auto generated by Irenka */"); - newEnum.getJavadoc().substitute(javadoc); + public void dummy(CtMethod<?> method) { + // dummy } +// /** +// * @param me +// * @param klass +// * @param decFactory +// * @param elemFactory +// * @param docFactory +// * @when klass.simpleName =~ "^.*ModelX$" +// */ +// public void foundModel(Messager me, CtClass<?> klass, DeclarationFactory decFactory, ElementFactory elemFactory, +// DocFactory docFactory) { +// System.out.println(klass.getSimpleName()); +// +// final String enumName = "Field"; +// CtEnum<?> fieldEnum = null; +// +// for (CtMember member : klass.getMembers()) { +// if (member.getElementKind() == ElementKind.ENUM && ((CtEnum<?>) member).getSimpleName().equals(enumName)) { +// fieldEnum = (CtEnum<?>) member; +// break; +// } +// } +// +// CtEnum<?> newEnum = decFactory.newEnum(enumName); +// newEnum.getModifiersAndAnnotations().add(elemFactory.newModifier(ModifierKind.PUBLIC)); +// if (fieldEnum == null) { +// me.info("not found"); +// klass.getMembers().add(newEnum); +// +// } else { +// me.info("found"); +// fieldEnum.substitute(newEnum); +// } +// +// for (CtField<?> field : klass.getDeclaredFields()) { +// CtEnumConstant<?> newEnumConstant = +// decFactory.newEnumConstant(newEnum, field.getSimpleName().replaceAll("([A-Z])", "_$1") +// .toUpperCase()); +// newEnum.getMembers().add(newEnumConstant); +// +// String fieldDescription = klass.getSimpleName() + "#" + field.getSimpleName(); +// CtDocBlock javadoc = docFactory.newDocBlock("@see " + fieldDescription); +// newEnumConstant.getJavadoc().getBlocks().clear(); +// newEnumConstant.getJavadoc().getBlocks().add(javadoc); +// } +// +// CtJavadoc javadoc = docFactory.parseJavadoc("/** Auto generated by Irenka */"); +// newEnum.getJavadoc().substitute(javadoc); +// } } Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyDefaultSerializer.java (from rev 2147, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerImpl.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyDefaultSerializer.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyDefaultSerializer.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -0,0 +1,81 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/10/13 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.serializer; + +import java.io.InputStream; + +import org.apache.commons.lang.SerializationException; + +import org.jiemamy.serializer.sax.JiemamySaxReader; +import org.jiemamy.spec.FactoryStrategy; +import org.jiemamy.spec.JiemamySerializer; +import org.jiemamy.spec.model.RootModel; + +/** + * TODO for daisuke + * @author daisuke + */ +public class JiemamyDefaultSerializer implements JiemamySerializer { + + private FactoryStrategy modelStrategy; + + private DialectInstanceCreationStrategy dialectStrategy; + + + /** + * コンストラクタ。 + * @param modelStrategy + * @category instance creation + */ + public JiemamyDefaultSerializer(FactoryStrategy modelStrategy) { + this(modelStrategy, new DefaultDialectInstanceCreationStrategy()); + } + + /** + * コンストラクタ。 + * @param modelStrategy + * @param dialectStrategy + * @category instance creation + */ + public JiemamyDefaultSerializer(FactoryStrategy modelStrategy, DialectInstanceCreationStrategy dialectStrategy) { + assert modelStrategy != null; + assert dialectStrategy != null; + this.modelStrategy = modelStrategy; + this.dialectStrategy = dialectStrategy; + } + + /** + * {@inheritDoc} + */ + public RootModel deserialize(InputStream in) { + return new JiemamySaxReader(modelStrategy, dialectStrategy).deserialize(in); + } + + /** + * {@inheritDoc} + */ + public InputStream serialize(RootModel rootModel) { + try { + return new ModelInputStream(rootModel); + } catch (Exception e) { + throw new SerializationException(e); + } + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyDefaultSerializer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializer.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializer.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializer.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -1,49 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/06/09 - * - * This file is part of Jiemamy-core. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.serializer; - -import java.io.InputStream; - -import org.apache.commons.lang.SerializationException; - -import org.jiemamy.spec.model.RootModel; - -/** - * シリアライザインターフェイス。 - * @author daisuke - */ -public interface JiemamySerializer { - - /** - * InputStreamからRootModelにデシリアライズする。 - * @param in デシリアライズするInputStream - * @return デシリアライズしたRootModel - * @throws SerializationException デシリアライズに失敗した時 - */ - RootModel deserialize(InputStream in); - - /** - * RootModelをInputStreamにシリアライズする。 - * @param rootModel シリアライズするRootModel - * @return シリアライズしたInputStream - * @throws SerializationException シリアライズに失敗した時 - */ - InputStream serialize(RootModel rootModel); - -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerFactory.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerFactory.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerFactory.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -1,59 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/09/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.serializer; - -/** - * JiemamySerializerのインスタンスを生成するためのファクトリ。 - * @author daisuke - */ -public final class JiemamySerializerFactory { - - private static volatile JiemamySerializer singleton; - - - /** - * 新しい {@link JiemamySerializer} のインスタンスを取得する。 - * @return {@link JiemamySerializer}のインスタンス。 - */ - public static JiemamySerializer getInstance() { - if (singleton == null) { - singleton = (new JiemamySerializerImpl()); - } - return singleton; - } - - /** - * 新しい {@link JiemamySerializer} のインスタンスを取得する。 - * @param strategy - * @return {@link JiemamySerializer}のインスタンス。 - */ - public static JiemamySerializer getInstance(DialectInstanceCreationStrategy strategy) { - if (singleton == null) { - singleton = new JiemamySerializerImpl(strategy); - } - return singleton; - } - - /** - * privateコンストラクタ。 - * @category instance creation - */ - private JiemamySerializerFactory() { - } -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerImpl.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerImpl.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySerializerImpl.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -1,72 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/10/13 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.serializer; - -import java.io.InputStream; - -import org.apache.commons.lang.SerializationException; - -import org.jiemamy.serializer.sax.JiemamySaxReader; -import org.jiemamy.spec.model.RootModel; - -/** - * TODO for daisuke - * @author daisuke - */ -public class JiemamySerializerImpl implements JiemamySerializer { - - private DialectInstanceCreationStrategy strategy; - - - /** - * コンストラクタ。 - * @category instance creation - */ - public JiemamySerializerImpl() { - strategy = new DefaultDialectInstanceCreationStrategy(); - } - - /** - * コンストラクタ。 - * @param strategy - * @category instance creation - */ - public JiemamySerializerImpl(DialectInstanceCreationStrategy strategy) { - this.strategy = strategy; - } - - /** - * {@inheritDoc} - */ - public RootModel deserialize(InputStream in) { - return new JiemamySaxReader(strategy).deserialize(in); - } - - /** - * {@inheritDoc} - */ - public InputStream serialize(RootModel rootModel) { - try { - return new ModelInputStream(rootModel); - } catch (Exception e) { - throw new SerializationException(e); - } - } - -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -23,8 +23,8 @@ import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; -import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.serializer.DialectInstanceCreationStrategy; +import org.jiemamy.spec.FactoryStrategy; import org.jiemamy.spec.JiemamyModelFactory; import org.jiemamy.spec.model.RootModel; @@ -37,6 +37,8 @@ // TODO debug用 private int depth = 0; + private FactoryStrategy modelStrategy; + /** DialectInstanceCreationStrategy */ private DialectInstanceCreationStrategy dialectStrategy; @@ -55,10 +57,14 @@ /** * コンストラクタ。 + * @param modelStrategy * @param dialectStrategy * @category instance creation */ - public JiemamyHandler(DialectInstanceCreationStrategy dialectStrategy) { + public JiemamyHandler(FactoryStrategy modelStrategy, DialectInstanceCreationStrategy dialectStrategy) { + assert modelStrategy != null; + assert dialectStrategy != null; + this.modelStrategy = modelStrategy; this.dialectStrategy = dialectStrategy; } @@ -109,7 +115,7 @@ @Override public void startDocument() { // FIXME 実装に依存しないように - JiemamyModelFactory.init(new S2FactoryStrategy("jiemamy-view.dicon")); + JiemamyModelFactory.init(modelStrategy); RootModel rootModel = JiemamyModelFactory.createRoot().init(); model = new ModelInfo(rootModel, dialectStrategy); commandStack.push(new CommandInfo(new FirstCommand(), xmlElementStack.snapshot())); Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyModelCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyModelCommand.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyModelCommand.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -58,6 +58,7 @@ * @param attributes * @return JiemamyModel */ + @SuppressWarnings("unchecked") protected <T extends JiemamyModel>T getReferenceModel(Attributes attributes) { String ref = attributes.getValue("ref"); UUID refId = UUID.fromString(ref); @@ -90,6 +91,7 @@ * @param name Enumの文字 * @return enum */ + @SuppressWarnings("cast") protected <T extends Enum<T>>T valueOf(Class<T> enumType, String name) { try { return Enum.valueOf(enumType, name); Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -30,6 +30,7 @@ import org.jiemamy.serializer.DefaultDialectInstanceCreationStrategy; import org.jiemamy.serializer.DialectInstanceCreationStrategy; +import org.jiemamy.spec.FactoryStrategy; import org.jiemamy.spec.model.RootModel; /** @@ -44,25 +45,30 @@ private static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + private FactoryStrategy modelStrategy; + /** DialectInstanceCreationStrategy */ - private DialectInstanceCreationStrategy strategy; + private DialectInstanceCreationStrategy dialectStrategy; /** * コンストラクタ。 + * @param modelStrategy * @category instance creation */ - public JiemamySaxReader() { - strategy = new DefaultDialectInstanceCreationStrategy(); + public JiemamySaxReader(FactoryStrategy modelStrategy) { + this(modelStrategy, new DefaultDialectInstanceCreationStrategy()); } /** * コンストラクタ。 - * @param strategy + * @param modelStrategy + * @param dialectStrategy * @category instance creation */ - public JiemamySaxReader(DialectInstanceCreationStrategy strategy) { - this.strategy = strategy; + public JiemamySaxReader(FactoryStrategy modelStrategy, DialectInstanceCreationStrategy dialectStrategy) { + this.modelStrategy = modelStrategy; + this.dialectStrategy = dialectStrategy; } /** @@ -81,7 +87,7 @@ parser.setProperty(SCHEMA_LANGUAGE, XML_SCHEMA); // parser.setProperty(SCHEMA_SOURCE, schema); // TODO XML Schemaによるバリデーションの実装。バリデーション失敗時には SerializationException をスロー。 - JiemamyHandler handler = new JiemamyHandler(strategy); + JiemamyHandler handler = new JiemamyHandler(modelStrategy, dialectStrategy); parser.parse(in, handler); Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/SerializationTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/SerializationTest.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/SerializationTest.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -35,6 +35,8 @@ import org.junit.Before; import org.junit.Test; +import org.jiemamy.spec.JiemamyModelFactory; +import org.jiemamy.spec.JiemamySerializer; import org.jiemamy.spec.extension.dialect.Dialect; import org.jiemamy.spec.model.RootModel; @@ -52,8 +54,7 @@ private RootModel rootModel; /** JiemamySerializer */ - private JiemamySerializer jiemamySerializer = - JiemamySerializerFactory.getInstance(new ReflectionDialectCreationStrategy()); + private JiemamySerializer jiemamySerializer; /** @@ -63,6 +64,9 @@ @Before public void setUp() throws Exception { rootModel = applicationModelCreator.createModel(); + System.out.println(JiemamyModelFactory.getStrategy()); + jiemamySerializer = + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), new ReflectionDialectCreationStrategy()); } /** @@ -71,6 +75,7 @@ */ @After public void tearDown() throws Exception { + jiemamySerializer = null; rootModel = null; } Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -30,6 +30,7 @@ import org.junit.Before; import org.junit.Test; +import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.core.model.ModelIdManager; import org.jiemamy.serializer.DialectInstanceCreationStrategy; import org.jiemamy.spec.extension.dialect.Dialect; @@ -68,7 +69,9 @@ @Test public void testとりあえず読み込んでみる() throws Exception { InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/jiemamy/serializer/sax/test01.xml"); - JiemamySaxReader reader = new JiemamySaxReader(new ReflectionDialectCreationStrategy()); + JiemamySaxReader reader = + new JiemamySaxReader(new S2FactoryStrategy("jiemamy-view.dicon"), + new ReflectionDialectCreationStrategy()); RootModel rootModel = reader.deserialize(is); System.out.println("RootModel(Id):" + rootModel.getId()); Modified: artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon =================================================================== --- artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon 2008-11-15 15:58:59 UTC (rev 2149) +++ artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon 2008-11-15 16:29:56 UTC (rev 2150) @@ -19,6 +19,9 @@ <arg><component class="org.jiemamy.core.appender.DomainAppender" /></arg> </initMethod> <initMethod name="registerAppender"> + <arg><component class="org.jiemamy.core.appender.InsertDataSetsAppender" /></arg> + </initMethod> + <initMethod name="registerAppender"> <arg><component class="org.jiemamy.view.DiagramPresentationModelAppender" /></arg> </initMethod> </component> Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2008-11-15 15:58:59 UTC (rev 2149) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -91,9 +91,9 @@ import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; import org.jiemamy.eclipse.editor.editpart.OutlineTreeEditPartFactory; import org.jiemamy.eclipse.utils.ExceptionHandler; -import org.jiemamy.serializer.JiemamySerializer; -import org.jiemamy.serializer.JiemamySerializerFactory; +import org.jiemamy.serializer.JiemamyDefaultSerializer; import org.jiemamy.spec.JiemamyModelFactory; +import org.jiemamy.spec.JiemamySerializer; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.view.model.DiagramPresentationModel; import org.jiemamy.spec.view.model.DiagramPresentations; @@ -161,7 +161,8 @@ IFile file = ((IFileEditorInput) getEditorInput()).getFile(); RootModel rootModel = (RootModel) getGraphicalViewer().getContents().getModel(); JiemamySerializer serializer = - JiemamySerializerFactory.getInstance(new EclipseDialectInstanceCreationStrategy()); + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); InputStream stream = serializer.serialize(rootModel); file.setContents(stream, true, true, monitor); getCommandStack().markSaveLocation(); @@ -194,8 +195,8 @@ try { RootModel rootModel = (RootModel) getGraphicalViewer().getContents().getModel(); JiemamySerializer serializer = - JiemamySerializerFactory - .getInstance(new EclipseDialectInstanceCreationStrategy()); + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); InputStream stream = serializer.serialize(rootModel); file.create(stream, true, monitor); } catch (Exception e) { @@ -444,7 +445,8 @@ // 最上位モデルの設定 IFile file = ((IFileEditorInput) getEditorInput()).getFile(); JiemamySerializer serializer = - JiemamySerializerFactory.getInstance(new EclipseDialectInstanceCreationStrategy()); + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); try { rootModel = serializer.deserialize(file.getContents()); // rootModel.setDisplayMode(DatabaseModel.MODE_PHYSICAL_ATTRTYPE); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2008-11-15 15:58:59 UTC (rev 2149) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -44,9 +44,9 @@ import org.jiemamy.eclipse.EclipseDialectInstanceCreationStrategy; import org.jiemamy.eclipse.utils.ExceptionHandler; -import org.jiemamy.serializer.JiemamySerializer; -import org.jiemamy.serializer.JiemamySerializerFactory; +import org.jiemamy.serializer.JiemamyDefaultSerializer; import org.jiemamy.spec.JiemamyModelFactory; +import org.jiemamy.spec.JiemamySerializer; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.view.model.DiagramPresentationModel; import org.jiemamy.spec.view.model.DiagramPresentations; @@ -88,7 +88,8 @@ try { IFile file = ((IFileEditorInput) getEditorInput()).getFile(); JiemamySerializer serializer = - JiemamySerializerFactory.getInstance(new EclipseDialectInstanceCreationStrategy()); + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); InputStream stream = serializer.serialize(rootModel); file.setContents(stream, true, true, monitor); for (DiagramEditor2 editor : editors) { @@ -122,8 +123,8 @@ public void execute(IProgressMonitor monitor) { try { JiemamySerializer serializer = - JiemamySerializerFactory - .getInstance(new EclipseDialectInstanceCreationStrategy()); + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); InputStream stream = serializer.serialize(rootModel); file.create(stream, true, monitor); } catch (Exception e) { @@ -163,7 +164,8 @@ // 最上位モデルの設定 IFile file = ((IFileEditorInput) input).getFile(); JiemamySerializer serializer = - JiemamySerializerFactory.getInstance(new EclipseDialectInstanceCreationStrategy()); + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); try { rootModel = serializer.deserialize(file.getContents()); // rootModel.setDisplayMode(DatabaseModel.MODE_PHYSICAL_ATTRTYPE); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2008-11-15 15:58:59 UTC (rev 2149) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -33,9 +33,9 @@ import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.eclipse.EclipseDialectInstanceCreationStrategy; import org.jiemamy.eclipse.utils.ExceptionHandler; -import org.jiemamy.serializer.JiemamySerializer; -import org.jiemamy.serializer.JiemamySerializerFactory; +import org.jiemamy.serializer.JiemamyDefaultSerializer; import org.jiemamy.spec.JiemamyModelFactory; +import org.jiemamy.spec.JiemamySerializer; import org.jiemamy.spec.model.RootModel; /** @@ -125,7 +125,9 @@ setTitle(Messages.Wizard_Title); setMessage(Messages.Wizard_Message); // setFileName("jiemamy.jer"); - serializer = JiemamySerializerFactory.getInstance(new EclipseDialectInstanceCreationStrategy()); + serializer = + new JiemamyDefaultSerializer(JiemamyModelFactory.getStrategy(), + new EclipseDialectInstanceCreationStrategy()); } /** Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamyModelFactory.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamyModelFactory.java 2008-11-15 15:58:59 UTC (rev 2149) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamyModelFactory.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -19,6 +19,7 @@ package org.jiemamy.spec; import org.jiemamy.spec.exception.JiemamyRuntimeException; +import org.jiemamy.spec.exception.NotInitializedException; import org.jiemamy.spec.model.RootModel; /** @@ -33,7 +34,7 @@ * * @author daisuke */ -public class JiemamyModelFactory { +public final class JiemamyModelFactory { /** 自クラスのインスタンス */ private static JiemamyModelFactory singleton; @@ -65,6 +66,17 @@ } /** + * TODO for daisuke + * @return + */ + public static FactoryStrategy getStrategy() { + if (singleton == null) { + throw new NotInitializedException(null); + } + return singleton.strategy; + } + + /** * ファクトリを初期化する。 * * <p>与えるファクトリ戦略によって、実装の種類及び、その実装が提供する仕様の範囲が決定される。</p> @@ -89,6 +101,7 @@ * @category instance creation */ private JiemamyModelFactory(FactoryStrategy strategy) { + assert strategy != null; this.strategy = strategy; } } Added: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamySerializer.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamySerializer.java (rev 0) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/JiemamySerializer.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -0,0 +1,48 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/06/09 + * + * This file is part of Jiemamy-core. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.spec; + +import java.io.InputStream; + +import org.jiemamy.spec.exception.SerializationException; +import org.jiemamy.spec.model.RootModel; + +/** + * シリアライザインターフェイス。 + * @author daisuke + */ +public interface JiemamySerializer { + + /** + * InputStreamからRootModelにデシリアライズする。 + * @param in デシリアライズするInputStream + * @return デシリアライズしたRootModel + * @throws SerializationException デシリアライズに失敗した時 + */ + RootModel deserialize(InputStream in) throws SerializationException; + + /** + * RootModelをInputStreamにシリアライズする。 + * @param rootModel シリアライズするRootModel + * @return シリアライズしたInputStream + * @throws SerializationException シリアライズに失敗した時 + */ + InputStream serialize(RootModel rootModel) throws SerializationException; + +} Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/NotInitializedException.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/NotInitializedException.java 2008-11-15 15:58:59 UTC (rev 2149) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/NotInitializedException.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -25,7 +25,7 @@ * @author daisuke */ @SuppressWarnings("serial") -public class NotInitializedException extends RuntimeException { +public class NotInitializedException extends JiemamyRuntimeException { /** 初期化され忘れているモデル */ private JiemamyModel jiemamyModel; Added: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/SerializationException.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/SerializationException.java (rev 0) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/SerializationException.java 2008-11-15 16:29:56 UTC (rev 2150) @@ -0,0 +1,68 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/10 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.spec.exception; + +/** + * シリアライズ・デシリアライズに失敗した時にスローされる。 + * @author daisuke + */ + @ SuppressWarnings("serial") +public class SerializationException extends JiemamyException { + + /** + * コンストラクタ。 + * @category instance creation + */ + public SerializationException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * コンストラクタ。 + * @param message + * @category instance creation + */ + public SerializationException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * コンストラクタ。 + * @param message + * @param cause + * @category instance creation + */ + public SerializationException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * コンストラクタ。 + * @param cause + * @category instance creation + */ + public SerializationException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} Property changes on: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/exception/SerializationException.java ___________________________________________________________________ Name: svn:mime-type + text/plain