|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjp.co.fujitsu.reffi.client.swing.controller.AbstractController
jp.co.fujitsu.reffi.client.swing.controller.BaseController
public class BaseController
[概 要]
アクションとモデルを制御する基底コントローラクラスです。[詳 細]
イベント発生時、BaseControllerのController.invoke(Class, ParameterMapping)
実装は、以下の処理フロー形成を行います。
| 実行順序 | BaseAction | BaseController | BaseModel |
| 1 | invoke(Class, ParameterMapping) |
||
| 2 | runAction(Class, ParameterMapping) |
||
| 3 | run(ParameterMapping) |
||
| 4 | runModels(List, ParameterMapping, int, ModelProcessEvent) |
||
| 4´ | runModelsAndNoWait(List, ParameterMapping) |
||
| 5 | run() |
||
| 6 | モデル処理管理リスナ(成功) | ||
| 7 | successForward(int, Model, Object) |
||
| 6´ | モデル処理管理リスナ(失敗) | ||
| 7´ | failureForward(int, Model, Exception) |
||
| 8 | モデル処理管理リスナ(完了) | ||
| 9 | complete() |
||
| 10 | trap(Throwable) |
||
| 11 | invokeFinalize(ParameterMapping) |
[備 考]
使用例)
package demo.controller;
import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
import java.awt.event.ItemListener;
import java.awt.event.WindowListener;
import java.util.Hashtable;
import javax.naming.Context;
import javax.swing.event.InternalFrameListener;
import javax.swing.event.PopupMenuListener;
import jp.co.fujitsu.reffi.client.swing.controller.BaseController;
import jp.co.fujitsu.reffi.client.swing.controller.ClientConfig;
import jp.co.fujitsu.reffi.client.swing.controller.EventBinder;
import jp.co.fujitsu.reffi.client.swing.model.DatabaseCore;
import jp.co.fujitsu.reffi.client.swing.model.HTTPRequestCore;
import demo.chat.action.ChatFrameCloseAction;
import demo.chat.action.EnterChannelAction;
import demo.chat.action.RemarkSendAction;
import demo.communication.action.AllCommunicateAction;
import demo.communication.action.ClearResultAction;
import demo.communication.action.EjbCommunicateAction;
import demo.communication.action.HttpCommunicateAction;
import demo.communication.action.SoapCommunicateAction;
import demo.componentsearch.action.ComponentLocateAction;
import demo.componentsearch.action.SearchAction;
import demo.componentsearch.action.ShowSourceAction;
import demo.componentsearch.action.WindowNamesFetchAction;
import demo.correlation.action.CorrelationImageFrameInitAction;
import demo.dbaccess.action.UsersFetchAction;
import demo.form.action.AddressFocusLostAction;
import demo.form.action.EmailFocusLostAction;
import demo.form.action.FullNameFocusLostAction;
import demo.form.action.InputFormInitAction;
import demo.form.action.OpenPostalSearchAction;
import demo.form.action.PasswordFocusLostAction;
import demo.form.action.PostalFirstFocusLostAction;
import demo.form.action.PostalLastFocusLostAction;
import demo.form.action.UserIdFocusLostAction;
import demo.form.action.UserRegistAction;
import demo.functionlauncher.action.OpenChatAction;
import demo.functionlauncher.action.OpenCommunicationAction;
import demo.functionlauncher.action.OpenComponentSearchAction;
import demo.functionlauncher.action.OpenCorrelationAction;
import demo.functionlauncher.action.OpenDbAccessAction;
import demo.functionlauncher.action.OpenInputFormAction;
import demo.functionlauncher.action.OpenJFreeChartAction;
import demo.functionlauncher.action.OpenMapViewerAction;
import demo.functionlauncher.action.OpenWebServiceAction;
import demo.jfreechart.action.OpenLineChartAction;
import demo.jfreechart.action.OpenPieChartAction;
import demo.jfreechart.action.PieChartInitAction;
import demo.jfreechart.action.TimeSeriesChartCloseAction;
import demo.jfreechart.action.TimeSeriesChartInitAction;
import demo.login.action.LoginAction;
import demo.postal.action.DecideAction;
import demo.postal.action.NextPageAction;
import demo.postal.action.NumPerPageChangeAction;
import demo.postal.action.PostalSearchFacadeAction;
import demo.postal.action.PrevPageAction;
import demo.postal.action.WardsFetchAction;
import demo.webservice.action.MtomSendAction;
public class DemoController extends BaseController {
@Override
protected void initialize(ClientConfig config) {
// デフォルトJMS接続環境を設定
Hashtable jmsEnvironment = new Hashtable();
jmsEnvironment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jmsEnvironment.put(Context.PROVIDER_URL, "localhost:1099");
jmsEnvironment.put("java.naming.rmi.security.manager", "yes");
jmsEnvironment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
config.setDefaultJmsEnvironment(jmsEnvironment);
// デフォルトEJB接続環境を設定
Hashtable ejbEnvironment = new Hashtable();
ejbEnvironment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
ejbEnvironment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
config.setDefaultEjbEnvironment(ejbEnvironment);
// デフォルトDatabase接続環境を設定
Hashtable dbEnvironment = new Hashtable();
dbEnvironment.put(DatabaseCore.DB_DRIVER_FQCN, "org.postgresql.Driver");
dbEnvironment.put(DatabaseCore.DB_URL, "jdbc:postgresql://localhost:5432/RFD");
dbEnvironment.put(DatabaseCore.DB_USER, "nakanishi");
dbEnvironment.put(DatabaseCore.DB_PASSWORD, "shingon");
dbEnvironment.put(DatabaseCore.DB_AUTO_COMMIT, "true");
config.setDefaultDatabaseEnvironment(dbEnvironment);
Hashtable httpEnvironment = new Hashtable();
httpEnvironment.put(HTTPRequestCore.HTTP_URL_PREFIX, "http://localhost:8080/RFDforSwingWeb/");
config.setDefaultHttpEnvironment(httpEnvironment);
}
@Override
protected void bind(EventBinder eventBinder) {
// ログイン画面アクション
eventBinder.addEventBinding("loginFrame.jbLogin", ActionListener.class, "actionPerformed", LoginAction.class);
// 起動画面アクション
eventBinder.addEventBinding("functionlauncher.jbOpenChat", ActionListener.class, "actionPerformed", OpenChatAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenComponentSearch", ActionListener.class, "actionPerformed", OpenComponentSearchAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenDesktop", ActionListener.class, "actionPerformed", OpenJFreeChartAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenInputForm", ActionListener.class, "actionPerformed", OpenInputFormAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenCommunication", ActionListener.class, "actionPerformed", OpenCommunicationAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenDbAccess", ActionListener.class, "actionPerformed", OpenDbAccessAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenCorrelation", ActionListener.class, "actionPerformed", OpenCorrelationAction.class);
eventBinder.addEventBinding("functionLauncher.jbOpenMapViewer", ActionListener.class, "actionPerformed", OpenMapViewerAction.class);
eventBinder.addEventBinding("functionlauncher.jbOpenWebService", ActionListener.class, "actionPerformed", OpenWebServiceAction.class);
// チャットデモ画面アクション
eventBinder.addEventBinding("chatFrame.jbEnterChannel", ActionListener.class, "actionPerformed", EnterChannelAction.class);
eventBinder.addEventBinding("chatFrame.jbRemarkSend", ActionListener.class, "actionPerformed", RemarkSendAction.class);
eventBinder.addEventBinding("chatFrame", WindowListener.class, "windowClosing", ChatFrameCloseAction.class);
// コンポーネント検索画面アクション
eventBinder.addEventBinding("componentSearchFrame.jbSearch", ActionListener.class, "actionPerformed", SearchAction.class);
eventBinder.addEventBinding("componentSearchFrame.jcbWindowName", PopupMenuListener.class, "popupMenuWillBecomeVisible", WindowNamesFetchAction.class);
eventBinder.addEventBinding("componentSearchFrame.jbLocate", ActionListener.class, "actionPerformed", ComponentLocateAction.class);
eventBinder.addEventBinding("componentSearchFrame.jbShowSource", ActionListener.class, "actionPerformed", ShowSourceAction.class);
// JFreeChartデモ画面アクション
eventBinder.addEventBinding("desktopFrame.jmiPieChart", ActionListener.class, "actionPerformed", OpenPieChartAction.class);
eventBinder.addEventBinding("desktopFrame.jmiLineChart", ActionListener.class, "actionPerformed", OpenLineChartAction.class);
eventBinder.addEventBinding("jfreechart.jifPieChart", InternalFrameListener.class, "internalFrameOpened", PieChartInitAction.class);
eventBinder.addEventBinding("jfreechart.jifTimeSeriesChart", InternalFrameListener.class, "internalFrameOpened", TimeSeriesChartInitAction.class);
eventBinder.addEventBinding("jfreechart.jifTimeSeriesChart", InternalFrameListener.class, "internalFrameClosing", TimeSeriesChartCloseAction.class);
// 入力フォームデモ画面アクション
eventBinder.addEventBinding("inputFormFrame", WindowListener.class, "windowOpened", InputFormInitAction.class);
eventBinder.addEventBinding("inputFormFrame.jbOpenPostalSearch", ActionListener.class, "actionPerformed", OpenPostalSearchAction.class);
eventBinder.addEventBinding("inputFormFrame.jtfFullName", FocusListener.class, "focusLost", FullNameFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jtfPostalFirst", FocusListener.class, "focusLost", PostalFirstFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jtfPostalLast", FocusListener.class, "focusLost", PostalLastFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jtfAddress", FocusListener.class, "focusLost", AddressFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jtfEmail", FocusListener.class, "focusLost", EmailFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jtfUserId", FocusListener.class, "focusLost", UserIdFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jpwPassword", FocusListener.class, "focusLost", PasswordFocusLostAction.class);
eventBinder.addEventBinding("inputFormFrame.jbRegist", ActionListener.class, "actionPerformed", UserRegistAction.class);
// 郵便番号検索画面アクション
eventBinder.addEventBinding("postalSearchDialog", WindowListener.class, "windowOpened", WardsFetchAction.class);
eventBinder.addEventBinding("postalSearchDialog.jbSearch", ActionListener.class, "actionPerformed", PostalSearchFacadeAction.class);
eventBinder.addEventBinding("postalSearchDialog.jbDecide", ActionListener.class, "actionPerformed", DecideAction.class);
eventBinder.addEventBinding("postalSearchDialog.jcbNumPerPage", ItemListener.class, "itemStateChanged", NumPerPageChangeAction.class);
eventBinder.addEventBinding("postalSearchDialog.jbNextPage", ActionListener.class, "actionPerformed", NextPageAction.class);
eventBinder.addEventBinding("postalSearchDialog.jbPrevPage", ActionListener.class, "actionPerformed", PrevPageAction.class);
// 通信デモ画面アクション
eventBinder.addEventBinding("communicationFrame.jbEjb", ActionListener.class, "actionPerformed", EjbCommunicateAction.class);
eventBinder.addEventBinding("communicationFrame.jbHttp", ActionListener.class, "actionPerformed", HttpCommunicateAction.class);
eventBinder.addEventBinding("communicationFrame.jbSoap", ActionListener.class, "actionPerformed", SoapCommunicateAction.class);
eventBinder.addEventBinding("communicationFrame.jbAll", ActionListener.class, "actionPerformed", AllCommunicateAction.class);
eventBinder.addEventBinding("communicationFrame.jbClear", ActionListener.class, "actionPerformed", ClearResultAction.class);
eventBinder.addEventBinding("webServiceFrame.jbMtomSend", ActionListener.class, "actionPerformed", MtomSendAction.class);
// データベース直接アクセス画面アクション
eventBinder.addEventBinding("dbaccessFrame.jbLoad", ActionListener.class, "actionPerformed", UsersFetchAction.class);
// コンポーネントイメージ相関画面アクション
eventBinder.addEventBinding("correlationImageFrame", WindowListener.class, "windowOpened", CorrelationImageFrameInitAction.class);
}
}
・具象コントローラの登録方法
package demo;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import demo.controller.DemoController;
import demo.login.LoginFrame;
public class Main {
public static void main(String[] args) {
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e) {
e.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
DemoController controller = new DemoController();
LoginFrame loginFrame = new LoginFrame();
loginFrame.setVisible(true);
}
});
}
}
[環 境] JDK 6.0 Update 11
Copyright (c) 2008-2009 FUJITSU Japan All rights reserved.
| コンストラクタの概要 | |
|---|---|
BaseController()
|
|
| メソッドの概要 | |
|---|---|
Object |
invoke(Class<? extends Action> actionClass,
ParameterMapping parameterMapping)
[概 要] コントローラの主幹メソッドです。 |
protected void |
invokeFinalize(ParameterMapping mapping)
[概 要] 各ユーザ定義イベントハンドリングの最後にテンプレートコールされるメソッドです。 |
protected void |
modelsDone(ParameterMapping mapping)
[概 要] [詳 細] [備 考] |
ParameterMapping |
runAction(Class<? extends Action> actionClass,
ParameterMapping parameterMapping)
[概 要] イベントに対応するアクションを実行します。 |
void |
runModels(List<Class<? extends Model>> modelClasses,
ParameterMapping parameterMapping,
int executeIndex,
ModelProcessEvent modelProcessEvent)
[概 要] アクションで予約されたモデル郡をインスタンス化して連続実行します。 |
void |
runModelsAndNoWait(List<Class<? extends Model>> modelClasses,
ParameterMapping parameterMapping)
[概 要] アクションで予約されたモデル郡をインスタンス化して連続実行します。 |
protected void |
trap(Throwable e)
[概 要] MVC各レイヤで発生した例外が最終的にハンドリングされるメソッドです。 |
| クラス jp.co.fujitsu.reffi.client.swing.controller.AbstractController から継承されたメソッド |
|---|
addListener, bind, bindEvents, createParameterMapping, getClientConfig, getErrorComponentSnapshot, getEventBinder, getPermanent, getWindowManager, handlerFacade, initialize, postInitialize, registWindow, setClientConfig, setErrorComponentSnapshot, setEventBinder, setPermanent, setWindowManager, shutdown, windowOpen, windowShut |
| クラス java.lang.Object から継承されたメソッド |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| コンストラクタの詳細 |
|---|
public BaseController()
| メソッドの詳細 |
|---|
public Object invoke(Class<? extends Action> actionClass,
ParameterMapping parameterMapping)
[概 要]
コントローラの主幹メソッドです。[詳 細]
コントローラ処理フローの幹を形成します。 このメソッドのtryスコープで以下が行われます。#createParameterMapping() MVCレイヤを巡回するParameterMappingオブジェクトの生成runAction(Class, ParameterMapping) アクションの実行runModels(List, ParameterMapping, int, ModelProcessEvent) or runModelsAndNoWait(List, ParameterMapping) アクションで予約されたモデル群の実行
[備 考]
actionClass - parameterMapping - MVC各レイヤを伝播するパラメータオブジェクト
public ParameterMapping runAction(Class<? extends Action> actionClass,
ParameterMapping parameterMapping)
throws Exception
[概 要]
イベントに対応するアクションを実行します。[詳 細]
引数で指定されたアクションクラス型をインスタンス化、 実行(BaseAction.run(ParameterMapping))します。[備 考]
この結果がnullだった場合はコントローラの以降の処理は中止されます。BaseAction.run(ParameterMapping)がnullを返却するのは、
prepareがfalseを返却、もしくはvalidate結果がエラーだった場合があります。
actionClass - 実行するアクションクラスの型parameterMapping - MVCを巡回するパラメータマッピング
Exception
public void runModels(List<Class<? extends Model>> modelClasses,
ParameterMapping parameterMapping,
int executeIndex,
ModelProcessEvent modelProcessEvent)
throws Exception
[概 要]
アクションで予約されたモデル郡をインスタンス化して連続実行します。[詳 細]
BaseAction.reserveModels(List)で予約されたBaseModel実装モデル群を実行します。
モデル実行直前にBaseAction.nextModel(int, ModelProcessEvent, Model)がコールバックされます。
実行モデルへのパラメータ設定を上記メソッドで行うことが出来ます。
モデル実行後、成功時はBaseAction.successForward(int, Model, Object)が、
失敗時はBaseAction.failureForward(int, Model, Exception)がコールバックされます。
モデルの実行結果は上記メソッドで取得することが出来ます。
[備 考]
BaseAction.isRunModelsAndNoWait()
がfalseの場合、同期モードで実行されます。
modelClasses - BaseAction.reserveModels(List) で予約されたモデルクラス群parameterMapping - MVC各レイヤを伝播するパラメータexecuteIndex - モデル実行順序インデックスmodelProcessEvent - 直前に実行したモデルの処理結果イベントオブジェクト
Exception - モデル内で発生し得る例外
public void runModelsAndNoWait(List<Class<? extends Model>> modelClasses,
ParameterMapping parameterMapping)
throws Exception
[概 要]
アクションで予約されたモデル郡をインスタンス化して連続実行します。[詳 細]
BaseAction.reserveModels(List)で予約されたBaseModel実装モデル群を実行します。BaseAction.nextModel(int, ModelProcessEvent, Model)がコールバックされます。
モデル実行後、成功時はBaseAction.successForward(int, Model, Object)が、
失敗時はBaseAction.failureForward(int, Model, Exception)がコールバックされます。
モデルの実行結果は上記メソッドで取得することが出来ます。
[備 考]
BaseAction.isRunModelsAndNoWait()
がtrueの場合、非同期モードで実行されます。BaseAction.isRunModelsAndNoWait()を
オーバーライドしてtrueを返却して下さい。
@Override
protected boolean isRunModelsAndNoWait() {
return true;
}
modelClasses - BaseAction.reserveModels(List) で予約されたモデルクラス群parameterMapping - MVC各レイヤを伝播するパラメータオブジェクト
Exception - モデル内で発生し得る例外protected void trap(Throwable e)
[概 要]
MVC各レイヤで発生した例外が最終的にハンドリングされるメソッドです。[詳 細]
ClientConfig.isShowErrorDialogOnExceptionTrap()
がtrueの場合、キャッチした例外をダイアログ表示します。
[備 考]
自動ダイアログ表示を行いたくない場合、ClientConfig.isShowErrorDialogOnExceptionTrap()
がfalse返却するよう設定してください。
public class DemoController extends BaseController {
@Override
protected void initialize(ClientConfig config) {
config.setShowErrorDialogOnExceptionTrap(false);
}
e - MVC各レイヤで発生したスロー可能オブジェクトprotected void invokeFinalize(ParameterMapping mapping)
[概 要]
各ユーザ定義イベントハンドリングの最後にテンプレートコールされるメソッドです。[詳 細]
デフォルト処理は有りません。[備 考]
このメソッドを具象コントローラでオーバーライドすると、全イベントアクションの 共通最終処理を実装出来ます。
mapping - MVC各レイヤを伝播するパラメータオブジェクト
protected void modelsDone(ParameterMapping mapping)
throws Exception
[概 要]
[詳 細]
[備 考]
mapping -
Exception
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||