操作
機能 #2014
完了ComponentAction listener の追加
ステータス:
終了
優先度:
高め
担当者:
-
対象バージョン:
-
開始日:
2011/01/27
期日:
進捗率:
100%
予定工数:
説明
- RTコンポーネントの各種アクション(ComponentAction)をフックするためのリスナクラス、ComponentAction listener を追加する。
- PreAction: 引数に ec_id を取るリスナ
- PostAction: 引数に ec_id と ReturnCode_t をとるリスナ
- RTObject にリスナホルダを持たせる
- RTObject のon_xxx() 関数内の onXxx() の前後にPreActionとPostActionを仕掛ける
- RTObject にリスナをセットする関数を追加する
匿名ユーザー さんが14年以上前に更新
- ステータス を 新規 から 担当 に変更
匿名ユーザー さんが約14年前に更新
Generics を使用して実装予定。
リスナの登録では、method名を文字列で指定する。
public <DataType>
PreComponentActionListener
addPreComponentActionListener(int listener_type,
DataType obj,
String memfunc) {
class Noname extends PreComponentActionListener {
public Noname(DataType obj, String memfunc) {
m_obj = obj;
try {
Class clazz = m_obj.getClass();
m_method = clazz.getMethod(memfunc,int.class);
}
catch(java.lang.Exception e){
rtcout.println(Logbuf.WARN,
"Exception caught."+e.toString());
}
}
public void operator(final int exec_handle) {
try {
m_method.invoke(
m_obj,
exec_handle);
}
catch(java.lang.Exception e){
rtcout.println(Logbuf.WARN,
"Exception caught."+e.toString());
}
}
private DataType m_obj;
private Method m_method;
};
Noname listener = new Noname(obj, memfunc);
addPreComponentActionListener(listener_type, listener, true);
return listener;
}
匿名ユーザー さんが約14年前に更新
コールバック
リスナーを準備する。
public class TestPreComponentActionListener {
public void listener_ON_INITIALIZE(int ic){
System.out.println("------------------------------");
System.out.println("PreComponentActionListener PRE_ON_INITIALIZE");
System.out.println("------------------------------");
}
}
リスナーを登録する。
TestPreComponentActionListener pcal
= new TestPreComponentActionListener();
addPreComponentActionListener(0,pcal,"listener_ON_INITIALIZE");
操作