(25)【BusinessLogicの作成】

hirossy19772007-02-10


アドレス帳サンプルアプリの続きです。

では、今回はBusinessLogicを作成します。
一般的にCairngormではBusinessLogicに相当するクラスをDelegateと呼ばれていますが、
AS2のDelegateと混同してしまいそうなのでBusinessLogicとさせて頂いております。

package business
{
    import com.adobe.cairngorm.business.ServiceLocator;
    import mx.controls.Alert;
    import mx.rpc.AbstractService;
    import mx.rpc.IResponder;
    import vo.Address;
    import mx.rpc.AsyncToken;
    import mx.rpc.http.HTTPService;
    /**
     * ビジネスロジック。
     */
    public class AddressLogic{
        private var service : AbstractService;
        private var responder : IResponder;
        /**
         * コンストラクタ。
         */
        public function AddressLogic(callingCommand : IResponder){
            this.service = ServiceLocator.getInstance().getRemoteObject("addressService");
            this.responder = callingCommand;
        }
        /**
         * 検索
         */
        public function select():void{
            var token : AsyncToken = this.service.select();
            token.resultHandler = responder.result;
            token.faultHandler = responder.fault;
        }
        /**
         * 登録
         */
        public function insert(dto : Address ):void{
            var call:Object = this.service.insert(dto);
            call.resultHandler = this.responder.result;
            call.faultHandler = this.responder.fault;
        }
        /**
         * 修正
         */
        public function update(dto : Address ):void{
            var call:Object = this.service.update(dto);
            call.resultHandler = this.responder.result;
            call.faultHandler = this.responder.fault;
        }
        /**
         * 削除
         */
        public function remove(dto : Address ):void{
            var call:Object = this.service.remove(dto);
            call.resultHandler = this.responder.result;
            call.faultHandler = this.responder.fault;
        }
    }
}

次回は、Serviceの作成です。