svnno****@sourc*****
svnno****@sourc*****
2009年 2月 9日 (月) 21:36:49 JST
Revision: 2640 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2640 Author: shin1 Date: 2009-02-09 21:36:49 +0900 (Mon, 09 Feb 2009) Log Message: ----------- EventBrokerとCommand関連のインターフェースを切り出してみた。 Modified Paths: -------------- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java Added Paths: ----------- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/EventBroker.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandListener.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java -------------- next part -------------- Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/EventBroker.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/EventBroker.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/EventBroker.java 2009-02-09 12:36:49 UTC (rev 2640) @@ -0,0 +1,52 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/09 + * + * 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; + +import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandListener; + +/** + * コマンドの実行を監視し、登録されている{@link CommandListener}にイベントを通知する。 + * + * @author shin1ogawa + */ +public interface EventBroker { + + /** + * リスナを登録する。 + * + * @param listener + */ + void addListener(CommandListener listener); + + /** + * 実行されたコマンドをイベントとして通知する。 + * + * @param command + */ + void fireCommandProcess(Command command); + + /** + * リスなを削除する。 + * + * @param listener + */ + void removeListener(CommandListener listener); + +} Property changes on: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/EventBroker.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java 2009-02-09 12:35:04 UTC (rev 2639) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java 2009-02-09 12:36:49 UTC (rev 2640) @@ -168,6 +168,14 @@ } /** + * イベントブローカを取得する。 + * @return イベントブローカ + */ + public EventBroker getEventBroker() { + return defaultImplementation.getEventBroker(); + } + + /** * JiemamyFactoryを取得する。 * * <p>このメソッドで初期化を行った場合、Jiemamy実装及び{@link Dialect}インスタンス取得戦略は、 Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java 2009-02-09 12:35:04 UTC (rev 2639) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java 2009-02-09 12:36:49 UTC (rev 2640) @@ -34,6 +34,16 @@ public interface JiemamyImplementation { /** + * イベントブローカを取得する。 + * + * <p>{@code null}を返してはならない。</p> + * + * @return イベントブローカ + * @see Jiemamy#getReferenceResolver() + */ + EventBroker getEventBroker(); + + /** * 指定したインスタンス空間に属するモデルを生成するファクトリを取得する。 * * <p>{@code null}を返してはならない。</p> Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java 2009-02-09 12:36:49 UTC (rev 2640) @@ -0,0 +1,60 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/09 + * + * 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.editcommand; + +import java.util.Stack; + +import org.jiemamy.model.JiemamyElement; + +/** + * モデルを編集するためのコマンドのインターフェース + * + * @author daisuke + * @author shin1ogawa + */ +public interface Command { + + /** + * コマンドを実行する。 + * + * @param processor コマンドプロセッサ + * @return 逆操作を行うコマンド + * @throws Exception + */ + Command execute(CommandProcessor processor) throws Exception; + + /** + * コマンドを実行する。 + * + * <p>逆操作を行うコマンドは、与えられたスタックに追加する。</p> + * + * @param commandProcessor コマンドプロセッサ + * @param commandStack undoの為のコマンドスタック + * @throws Exception + */ + void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) throws Exception; + + /** + * 操作対象の{@link JiemamyElement}を返す。 + * + * @return 操作対象の{@link JiemamyElement} + */ + JiemamyElement getTarget(); + +} Property changes on: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandListener.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandListener.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandListener.java 2009-02-09 12:36:49 UTC (rev 2640) @@ -0,0 +1,26 @@ +package org.jiemamy.editcommand; + +import org.jiemamy.EventBroker; +import org.jiemamy.model.JiemamyElement; + +/** + * コマンドが実行されたイベントの通知を受け取るリスナ。 + * + * @author shin1ogawa + */ +public interface CommandListener { + + /** + * 監視対象に変更があった場合に{@link EventBroker}がCallbackしてくれる。 + * + * @param command + */ + void commandProcess(Command command); + + /** + * 監視対象を返す。 + * + * @return 監視対象の{@link JiemamyElement} + */ + JiemamyElement getTarget(); +} Property changes on: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java 2009-02-09 12:36:49 UTC (rev 2640) @@ -0,0 +1,34 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/09 + * + * 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.editcommand; + +/** + * {@link Command}を実行するクラスのインターフェース。 + * + * @author shin1ogawa + */ +public interface CommandProcessor { + + /** + * {@link Command}を実行する。 + * + * @param command + */ + void process(Command command); +} Property changes on: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java ___________________________________________________________________ Added: svn:mime-type + text/plain