チェンジセット 2442
- コミット日時:
- 2009/04/11 16:56:29 (3 年前)
- ファイル:
-
- air/AirDao/src/com/seacolorswind/dbi/AbstractStatementThread.as (更新) (7 diffs)
- air/AirDao/src/com/seacolorswind/dbi/AirDao.as (更新) (4 diffs)
- air/AirDao/src/com/seacolorswind/dbi/BatchCreateThread.as (更新) (5 diffs)
- air/AirDao/src/com/seacolorswind/dbi/ConnectionThread.as (更新) (3 diffs)
- air/AirDao/src/com/seacolorswind/dbi/CreateTableThread.as (更新) (7 diffs)
- air/AirDao/src/com/seacolorswind/dbi/CreateThread.as (更新) (6 diffs)
- air/AirDao/src/com/seacolorswind/dbi/PagingThread.as (更新) (2 diffs)
- air/AirDao/src/com/seacolorswind/dbi/Queue.as (更新) (6 diffs)
- air/AirDao/src/com/seacolorswind/dbi/ReadThread.as (更新) (7 diffs)
- air/AirDao/src/com/seacolorswind/dbi/RemoveThread.as (更新) (6 diffs)
- air/AirDao/src/com/seacolorswind/dbi/Resource.as (更新) (2 diffs)
- air/AirDao/src/com/seacolorswind/dbi/ResultEntityArray.as (更新) (2 diffs)
- air/AirDao/src/com/seacolorswind/dbi/ThreadQueue.as (更新) (5 diffs)
- air/AirDao/src/com/seacolorswind/dbi/UpdateThread.as (更新) (6 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
air/AirDao/src/com/seacolorswind/dbi/AbstractStatementThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import org.libspark.thread.Thread; … … 5 32 6 33 /** 7 * ...34 * テーブルに対するクエリを実行するスレッドの抽象クラスです。 8 35 * @author Kazushi Tominaga (Seacolor) 9 36 */ 10 37 internal class AbstractStatementThread extends Thread 11 38 { 39 /** 40 * データベースとの通信を格納するリソースです。 41 */ 12 42 protected var _resource:Resource; 43 /** 44 * エンティティクラスもしくはエンティティクラスのインスタンスす。 45 */ 13 46 protected var _entity:Object; 47 /** 48 * 実行が正常に完了した場合に呼び出される関数です。 49 */ 14 50 protected var _callback:Function; 51 /** 52 * 実行が失敗した場合に呼び出される関数です。 53 */ 15 54 protected var _errorHandler:Function; 16 55 17 56 /** 57 * @inheritDoc 58 */ 18 59 override protected function run():void 19 60 { 20 61 error(Error, catchEerror, false); 21 62 } 22 63 /** 64 * エラーハンドラです。 65 * @param e 発生したエラーです。 66 * @param t エラーが発生したスレッドです。 67 */ 23 68 protected function catchEerror(e:Error, t:Thread):void { 24 69 _isError = true; … … 29 74 } 30 75 } 31 76 /** 77 * @private 78 */ 32 79 protected var _isError:Boolean = false; 33 80 /** 81 * @private 82 */ 34 83 protected var _describe:XML; 35 84 /** 85 * エンティティに関連付いたテーブル名を取得します。 86 */ 36 87 protected function get tableName():String { 37 88 if (!_tableName) { … … 51 102 return _tableName; 52 103 } 53 104 /** 105 * @private 106 */ 54 107 protected var _tableName:String; 55 108 /** 109 * プロパティの一覧情報です。 110 */ 56 111 protected function get variables():XMLList { 57 112 if (!_variables) { … … 69 124 return _variables; 70 125 } 71 126 /** 127 * @private 128 */ 72 129 protected var _variables:XMLList; 73 130 /** 131 * プロパティが主キーに指定されているかどうかを判定します。 132 * @param variable プロパティ情報です。 133 * @return プロパティが主キーとして指定されている場合、trueを返却します。 それ以外の場合、falseを返却します。 134 */ 74 135 protected function isPrimary(variable:XML):Boolean { 75 136 if (variable.metadata.(@name == "Primary") != undefined) { … … 78 139 return false; 79 140 } 80 141 /** 142 * プロパティが自動採番に指定されているかどうかを判定します。 143 * @param variable プロパティ情報です。 144 * @return プロパティが自動採番として指定されている場合、trueを返却します。 それ以外の場合、falseを返却します。 145 */ 81 146 protected function isAutoincrement(variable:XML):Boolean { 82 147 if (variable.metadata.(@name == "Autoincrement") != undefined) { … … 86 151 } 87 152 153 /** 154 * プロパティがテーブルの列として見なさない指定になっているかどうかを判定します。 155 * @param variable プロパティ情報です。 156 * @return プロパティがテーブルの列ではない場合、trueを返却します。 それ以外の場合、falseを返却します。 157 */ 88 158 protected function isIgnore(variable:XML):Boolean { 89 159 if (variable.metadata.(@name == "Ignore") != undefined) { air/AirDao/src/com/seacolorswind/dbi/AirDao.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLConnection; … … 14 41 15 42 /** 16 * ... 43 * AirDao クラスは AirDao の全てのインターフェイスを提供します。 44 * AirDaoを用いたレコードの操作は、全てこのクラスのメソッドを呼び出して行います。 17 45 * @author Kazushi Tominaga (Seacolor) 18 46 */ 19 47 public class AirDao 20 48 { 49 /** 50 * @private 51 */ 21 52 protected const logger:ILogger = Log.getLogger("AirDao"); 53 /** 54 * データベースとの通信を格納するリソースです。 55 * このクラスにおける接続およびレコードの取得や更新はこのリソースを通して共有されます。 56 */ 22 57 protected var resource:Resource = new Resource(); 23 58 59 /** 60 * コンストラクタです。 61 * @param db データベースとして読み込みもしくは書き込みするファイルです。 この引数にnullを指定した場合、データベースはメモリに作成されます。 62 * @param threadExecutor 利用される IThreadExecutor です。 63 */ 24 64 public function AirDao(db:File = null, threadExecutor:IThreadExecutor = null) 25 65 { … … 37 77 } 38 78 79 /** 80 * このデータベースの活動状態です。 81 * クエリが実行中の場合、このプロパティはtrueを返却します。 82 * それ以外の状態の場合、このプロパティはfalseを返却します。 83 */ 39 84 public function get executing():Boolean { 40 85 logger.debug("numSeriarizeThreads: {0}", ThreadQueue.numSeriarizeThreads); 41 86 return ThreadQueue.numSeriarizeThreads > 0 ? true : false; 42 87 } 43 88 /** 89 * レコードを取得します。 90 * @param entity テーブル情報と対応したエンティティクラスです。 91 * @param callback レコードの取得が成功した場合に呼び出される関数です。 関数は下記の例の通り取得レコードの配列を引数として呼び出されます。 92 * <code> 93 * function callback(records:Array):void 94 * </code> 95 * @param param レコードの取得条件です。 下記の例の通り、連想配列で指定します。 96 * <code> 97 * {first_name: "foo", last_name: "bar"} 98 * </code> 99 * @param order レコードの整列条件です。 下記の例の通り、連想配列で指定します。 100 * <code> 101 * {first_name: "ASC", last_name: "DESC"} 102 * </code> 103 * @param errorHandler レコードの取得がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 104 */ 44 105 public function read(entity:Class, callback:Function, param:Object = null, order:Object = null, errorHandler:Function = null):void { 45 106 new ReadThread(resource, entity, callback, param, order, errorHandler).start(); 46 107 } 47 108 /** 109 * レコードを作成します。 このメソッド経由でレコードの作成を実行した場合、レコードの作成・削除・更新は同期化されます。 110 * @param entity 作成レコードの情報を格納したエンティティです。 111 * @param callback レコードの作成が成功した場合に呼び出される関数です。 112 * @param errorHandler レコードの作成がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 113 */ 48 114 public function create(entity:Object, callback:Function = null, errorHandler:Function = null):void { 49 115 if (entity is Array) { … … 53 119 } 54 120 } 55 121 /** 122 * レコードを削除します。 このメソッド経由でレコードの削除を実行した場合、レコードの作成・削除・更新は同期化されます。 123 * @param entity 削除レコードの情報を格納したエンティティです。 124 * @param callback レコードの削除が成功した場合に呼び出される関数です。 125 * @param errorHandler レコードの削除がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 126 */ 56 127 public function remove(entity:Object, callback:Function = null, errorHandler:Function = null):void { 57 128 ThreadQueue.addThread(resource, new RemoveThread(resource, entity, callback, errorHandler)) 58 129 } 59 130 /** 131 * レコードを更新します。 このメソッド経由でレコードの更新を実行した場合、レコードの作成・削除・更新は同期化されます。 132 * @param entity 更新レコードの情報を格納したエンティティです。 レコードは主キーに基づき、全ての列情報がプロパティに設定された値で上書きされます。 133 * @param callback レコードの更新が成功した場合に呼び出される関数です。 134 * @param errorHandler レコードの更新がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 135 */ 60 136 public function update(entity:Object, callback:Function = null, errorHandler:Function = null):void { 61 137 ThreadQueue.addThread(resource, new UpdateThread(resource, entity, callback, errorHandler)) air/AirDao/src/com/seacolorswind/dbi/BatchCreateThread.as
r2386 r2442 10 10 11 11 /** 12 * ...12 * テーブルのレコードを複数件作成するスレッドです。 13 13 * @author Kazushi Tominaga (Seacolor) 14 14 */ 15 15 internal class BatchCreateThread extends AbstractStatementThread 16 16 { 17 /** 18 * @private 19 */ 17 20 protected const logger:ILogger = Log.getLogger(className); 18 21 22 /** 23 * コンストラクタです。 24 * @param resource 共有リソースです。 25 * @param entity エンティティクラスもしくはエンティティクラスのインスタンスの配列です。 26 * @param callback テーブルの作成が成功した場合に呼び出される関数です。 27 * @param errorHandler テーブルの作成がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 28 */ 19 29 public function BatchCreateThread(resource:Resource, entity:Array, callback:Function = null, errorHandler:Function = null) 20 30 { … … 24 34 _errorHandler = errorHandler; 25 35 } 26 36 /** 37 * @inheritDoc 38 */ 27 39 override protected function run():void 28 40 { … … 40 52 next(execute); 41 53 } 42 54 /** 55 * クエリを実行します。 56 */ 43 57 protected function execute():void { 44 58 logger.debug("start execute()"); … … 60 74 logger.debug("end execute()"); 61 75 } 62 76 /** 77 * @private 78 */ 63 79 protected function finish():void { 64 80 logger.debug("start finish()"); … … 71 87 logger.debug("end finish()"); 72 88 } 73 89 /** 90 * SQLErrorイベントハンドラです。 91 * @param event SQLErrorイベント 92 */ 74 93 protected function errorHandler(error:Error):void { 75 94 _resource.connector.rollback(); air/AirDao/src/com/seacolorswind/dbi/ConnectionThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLConnection; … … 10 37 11 38 /** 12 * ...39 * テーブルとの接続を開始するスレッドです。 13 40 * @author Kazushi Tominaga (Seacolor) 14 41 */ 15 42 internal class ConnectionThread extends Thread 16 43 { 44 /** 45 * @private 46 */ 17 47 protected const logger:ILogger = Log.getLogger(className); 18 48 49 /** 50 * データベースとの通信を格納するリソースです。 51 */ 19 52 protected var _resource:Resource; 20 53 54 /** 55 * コンストラクタです。 56 * @param resource 共有リソースです。 57 */ 21 58 public function ConnectionThread(resource:Resource) 22 59 { … … 26 63 } 27 64 } 28 65 /** 66 * @inheritDoc 67 */ 29 68 override protected function run():void 30 69 { 31 70 event(_resource.connector, SQLEvent.OPEN, openHandler); 32 71 event(_resource.connector, SQLErrorEvent.ERROR, errorHandler); 72 // 非同期モードでデータベースファイルを開きます。 33 73 _resource.connector.openAsync(_resource.db); 34 74 } 35 75 /** 76 * @private 77 */ 36 78 protected function openHandler(event:SQLEvent):void { 37 79 logger.debug("connection successfull."); 38 80 } 39 81 /** 82 * SQLErrorイベントハンドラです。 83 * @param event SQLErrorイベント 84 */ 40 85 protected function errorHandler(event:SQLErrorEvent):void { 41 86 logger.debug("connection failed."); air/AirDao/src/com/seacolorswind/dbi/CreateTableThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLStatement; … … 8 35 9 36 /** 10 * ... 37 * テーブルを作成するスレッドです。 38 * データベースに該当のテーブルが存在しない場合、エンティティの情報に基づいてテーブルを作成します。 39 * 該当のテーブルが既に存在する場合、このスレッドは何もせずに終了します。 11 40 * @author Kazushi Tominaga (Seacolor) 12 41 */ 13 42 internal class CreateTableThread extends AbstractStatementThread 14 43 { 44 /** 45 * @private 46 */ 15 47 protected const logger:ILogger = Log.getLogger(className); 16 48 49 /** 50 * コンストラクタです。 51 * @param resource 共有リソースです。 52 * @param entity エンティティクラスもしくはエンティティクラスのインスタンスです。 53 * @param callback テーブルの作成が成功した場合に呼び出される関数です。 54 * @param errorHandler テーブルの作成がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 55 */ 17 56 public function CreateTableThread(resource:Resource, entity:Object, callback:Function = null, errorHandler:Function = null) 18 57 { … … 22 61 _errorHandler = errorHandler; 23 62 } 24 63 /** 64 * @inheritDoc 65 */ 25 66 override protected function run():void 26 67 { 27 68 super.run(); 28 69 // テーブルが作成済みの場合、スレッドを終了 29 70 if (_resource.created[tableName] || _entity.created_on) { 30 71 return; … … 32 73 next(execute); 33 74 } 34 75 /** 76 * クエリを実行します。 77 */ 35 78 protected function execute():void { 36 79 if (_isError) { … … 64 107 stmt.execute(); 65 108 } 66 109 /** 110 * プロパティのデータ型に対応した列親和型を返します。 111 * @param type プロパティのデータ型です。 112 * @return プロパティのデータ型に対応した列親和型です。 113 */ 67 114 protected function mapping(type:String):String { 68 115 switch (type) { … … 86 133 } 87 134 } 88 135 /** 136 * @private 137 */ 89 138 protected function create(event:SQLEvent):void { 90 139 logger.debug("statement successfull."); … … 96 145 if (_callback != null) _callback.apply(this, []); 97 146 } 98 147 /** 148 * SQLErrorイベントハンドラです。 149 * @param event SQLErrorイベント 150 */ 99 151 protected function errorHandler(event:SQLErrorEvent):void { 100 152 logger.debug("statement failed."); air/AirDao/src/com/seacolorswind/dbi/CreateThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLStatement; … … 10 37 11 38 /** 12 * ...39 * レコードを作成するスレッドです。 13 40 * @author Kazushi Tominaga (Seacolor) 14 41 */ 15 42 internal class CreateThread extends AbstractStatementThread 16 43 { 44 /** 45 * @private 46 */ 17 47 protected const logger:ILogger = Log.getLogger(className); 18 48 49 /** 50 * コンストラクタです。 51 * @param resource 共有リソースです。 52 * @param entity エンティティです。 53 * @param callback テーブルの作成が成功した場合に呼び出される関数です。 54 * @param errorHandler テーブルの作成がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 55 */ 19 56 public function CreateThread(resource:Resource, entity:Object, callback:Function = null, errorHandler:Function = null) 20 57 { … … 25 62 _errorHandler = errorHandler; 26 63 } 27 64 /** 65 * @inheritDoc 66 */ 28 67 override protected function run():void 29 68 { … … 37 76 next(execute); 38 77 } 39 78 /** 79 * クエリを実行します。 80 */ 40 81 protected function execute():void { 41 82 logger.debug("execute({0})", arguments); … … 94 135 stmt.execute(); 95 136 } 96 137 /** 138 * @private 139 */ 97 140 protected var _is_created_on:Boolean; 141 /** 142 * @private 143 */ 98 144 protected var _is_updated_on:Boolean; 145 /** 146 * @private 147 */ 99 148 protected var _created_on:Date; 100 149 /** 150 * @private 151 */ 101 152 protected function create(event:SQLEvent):void { 102 153 logger.debug("statement successfull."); … … 112 163 } 113 164 165 /** 166 * SQLErrorイベントハンドラです。 167 * @param event SQLErrorイベント 168 */ 114 169 protected function errorHandler(event:SQLErrorEvent):void { 115 170 logger.debug("statement failed."); air/AirDao/src/com/seacolorswind/dbi/PagingThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLResult; … … 10 37 11 38 /** 12 * ...39 * @private 13 40 * @author Kazushi Tominaga (Seacolor) 14 41 */ air/AirDao/src/com/seacolorswind/dbi/Queue.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.events.Event; … … 10 37 11 38 /** 12 * ... 13 * @author ... 39 * スレッドのキューです。 40 * ThreadQueueのaddThreadメソッドでスレッドを登録する事で、スレッドはキューに登録され、登録した順番に実行されます。 41 * @see com.seacolorswind.dbi.ThreadQueue 42 * @author Kazushi Tominaga (Seacolor) 14 43 */ 15 44 public class Queue extends Thread 16 45 { 46 /** 47 * @private 48 */ 17 49 protected const logger:ILogger = Log.getLogger(className); 18 50 51 /** 52 * コンストラクタです。 53 * @param resource 共有リソースです。 54 */ 19 55 public function Queue(resource:Resource) 20 56 { … … 22 58 _resource = resource; 23 59 } 24 60 /** 61 * @private 62 */ 25 63 protected var _resource:Resource; 26 64 /** 65 * スレッドをキューに登録します。 66 * @param queue キューに登録されるスレッドです。 67 */ 27 68 public function addQueue(queue:Thread):void { 28 69 logger.debug("addQueue({0})", arguments); 29 70 _waitingQueues.push(queue); 30 71 } 31 72 /** 73 * 待機中のキューの数です。 74 */ 32 75 public function get numQueues():int { 33 76 logger.debug("queues: {0}, state: {1}", _waitingQueues.length, state); 34 77 return _waitingQueues.length + (state == ThreadState.TERMINATED ? 0 : 1); 35 78 } 36 79 /** 80 * キューの永続性です。 81 */ 37 82 public function get seriarizable():Boolean { 38 83 logger.debug("seriarizable: {0}", _resource.db != null); 39 84 return _resource.db != null; 40 85 } 41 86 /** 87 * @private 88 */ 42 89 protected var _waitingQueues:Vector.<Thread> = new Vector.<Thread>(); 43 90 /** 91 * @inheritDoc 92 */ 44 93 override protected function run():void 45 94 { … … 50 99 _resource.connector.begin(); 51 100 } 52 101 /** 102 * キューを順番に実行します。 103 */ 53 104 protected function runQueue(e:Event = null):void { 54 105 logger.debug("runQueue({0})", arguments); … … 66 117 } 67 118 } 68 119 /** 120 * 全てのキューを実行した後に呼び出されるメソッドです。 121 */ 69 122 protected function destory(e:Event = null):void { 70 123 if (_waitingQueues.length > 0) 71 124 next(run); 72 125 } 73 126 /** 127 * SQLErrorイベントハンドラです。 128 * @param event SQLErrorイベント 129 */ 74 130 protected function sqlErrorHandler(e:SQLErrorEvent):void { 75 131 logger.debug("sqlErrorHandler()", arguments); … … 77 133 } 78 134 135 /** 136 * エラーハンドラです。 137 * @param e 発生したエラーです。 138 * @param t エラーが発生したスレッドです。 139 */ 79 140 protected function errorHandler(e:Error, t:Thread):void { 80 141 logger.debug("errorHandler({0})", arguments); air/AirDao/src/com/seacolorswind/dbi/ReadThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLResult; … … 11 38 12 39 /** 13 * ...40 * レコードを取得するスレッドです。 14 41 * @author Kazushi Tominaga (Seacolor) 15 42 */ 16 43 public class ReadThread extends AbstractStatementThread 17 44 { 45 /** 46 * @private 47 */ 18 48 protected const logger:ILogger = Log.getLogger(className); 19 49 /** 50 * @private 51 */ 20 52 protected var _query:String; 53 /** 54 * @private 55 */ 21 56 protected var _param:Object; 57 /** 58 * @private 59 */ 22 60 protected var _order:Object; 23 61 62 /** 63 * コンストラクタです。 64 * @param resource 共有リソースです。 65 * @param entity テーブル情報と対応したエンティティクラスです。 66 * @param callback レコードの取得が成功した場合に呼び出される関数です。 関数は下記の例の通り取得レコードの配列を引数として呼び出されます。 67 * <code> 68 * function callback(records:Array):void 69 * </code> 70 * @param param レコードの取得条件です。 下記の例の通り、連想配列で指定します。 71 * <code> 72 * {first_name: "foo", last_name: "bar"} 73 * </code> 74 * @param order レコードの整列条件です。 下記の例の通り、連想配列で指定します。 75 * <code> 76 * {first_name: "ASC", last_name: "DESC"} 77 * </code> 78 * @param errorHandler レコードの取得がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 79 */ 24 80 public function ReadThread(resource:Resource, entity:Class, callback:Function, param:Object = null, order:Object = null, errorHandler:Function = null) 25 81 { … … 32 88 _errorHandler = errorHandler; 33 89 } 34 90 /** 91 * @inheritDoc 92 */ 35 93 override protected function run():void 36 94 { … … 44 102 next(execute); 45 103 } 46 104 /** 105 * クエリを実行します。 106 */ 47 107 protected function execute():void { 48 108 logger.debug("execute({0})", arguments); … … 89 149 stmt.execute(); 90 150 } 91 151 /** 152 * @private 153 */ 92 154 protected var stmt:SQLStatement; 93 155 /** 156 * @private 157 */ 94 158 protected function read(event:SQLEvent):void { 95 159 logger.debug("read({0})", arguments); … … 129 193 } 130 194 131 /* var data:ResultEntityArray = new ResultEntityArray(result);132 var bitmapColumns:Array = [];133 for each (var variable:XML in variables) {134 if (variable.@type == "*") {135 bitmapColumns.push(variable.@name);136 }137 }138 data.forEach(function(item:*, index:int, columns:Array):void {139 for each (var column:String in bitmapColumns) {140 if (item[column]) {141 var dec:Base64Decoder = new Base64Decoder();142 dec.decode(item[column]);143 item[column] = dec.toByteArray();144 }145 }146 });147 */148 195 data.resource = _resource; 149 196 data.sqlStatement = stmt; … … 152 199 _callback.apply(this, [data]); 153 200 } 154 201 /** 202 * SQLErrorイベントハンドラです。 203 * @param event SQLErrorイベント 204 */ 155 205 protected function errorHandler(event:SQLErrorEvent):void { 156 206 logger.debug("statement failed."); air/AirDao/src/com/seacolorswind/dbi/RemoveThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLResult; … … 9 36 10 37 /** 11 * ...38 * レコードを削除するスレッドです。 12 39 * @author Kazushi Tominaga (Seacolor) 13 40 */ 14 41 internal class RemoveThread extends AbstractStatementThread 15 42 { 43 /** 44 * @private 45 */ 16 46 protected const logger:ILogger = Log.getLogger(className); 17 47 48 /** 49 * コンストラクタです。 50 * @param resource 共有リソースです。 51 * @param entity エンティティです。 52 * @param callback テーブルの作成が成功した場合に呼び出される関数です。 53 * @param errorHandler テーブルの作成がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 54 */ 18 55 public function RemoveThread(resource:Resource, entity:Object, callback:Function = null, errorHandler:Function = null) 19 56 { … … 23 60 _errorHandler = errorHandler; 24 61 } 25 62 /** 63 * @inheritDoc 64 */ 26 65 override protected function run():void 27 66 { … … 34 73 next(execute); 35 74 } 36 75 /** 76 * クエリを実行します。 77 */ 37 78 protected function execute():void { 38 79 if (_isError) { … … 63 104 stmt.execute(); 64 105 } 65 106 /** 107 * @private 108 */ 66 109 protected function remove(event:SQLEvent):void { 67 110 if (_isError) { … … 72 115 } 73 116 117 /** 118 * SQLErrorイベントハンドラです。 119 * @param event SQLErrorイベント 120 */ 74 121 protected function errorHandler(event:SQLErrorEvent):void { 75 122 throw event.error; air/AirDao/src/com/seacolorswind/dbi/Resource.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLConnection; … … 7 34 8 35 /** 9 * ...36 * Resource クラスはデータベースとの通信に用いられる全ての情報を保持します。 10 37 * @author Kazushi Tominaga (Seacolor) 11 38 */ 12 39 public class Resource 13 40 { 41 /** 42 * データベースとして読み込みもしくは書き込みするファイルです。 43 */ 14 44 public var db:File; 45 /** 46 * データベースの接続情報です。 47 * このプロパティはデータベースへの全ての操作に使われます。 48 */ 15 49 public var connector:SQLConnection = new SQLConnection(); 50 /** 51 * データベースのクエリ情報です。 52 * このプロパティはレコードの作成・更新・削除で利用され、レコードの取得時は使われません。 53 */ 16 54 public var statement:SQLStatement = new SQLStatement(); 55 /** 56 * テーブルの作成情報です。 57 * テーブル名をキーとして、テーブルが作成されていればtrueが設定されます。 58 */ 17 59 public var created:Dictionary = new Dictionary(); 18 60 } air/AirDao/src/com/seacolorswind/dbi/ResultEntityArray.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLResult; 4 31 import flash.data.SQLStatement; 32 import flash.errors.IllegalOperationError; 5 33 6 34 /** 7 * ...35 * レコードの取得結果の配列です。 8 36 * @author Kazushi Tominaga (Seacolor) 9 37 */ 10 38 public dynamic class ResultEntityArray extends Array 11 39 { 40 /** 41 * @private 42 */ 12 43 protected var _resource:Resource; 44 /** 45 * @private 46 */ 13 47 protected var _sqlStatement:SQLStatement; 14 48 /** 49 * @private 50 */ 15 51 protected var _complete:Boolean = true; 16 52 /** 53 * @inheritDoc 54 */ 17 55 public function ResultEntityArray(...args) 18 56 { … … 44 82 } 45 83 } 46 84 /** 85 * @private 86 */ 47 87 public function next(callback:Function):void { 48 if (!_complete && _sqlStatement != null && _resource != null) { 88 throw new IllegalOperationError("this method is not supported."); 89 /* if (!_complete && _sqlStatement != null && _resource != null) { 49 90 new PagingThread(_resource, _sqlStatement, function(result:ResultEntityArray):void { 50 //_complete = result.complete;51 //_resource = result.resource;52 //_sqlStatement = sqlStatement;53 91 callback.apply(this, [result]); 54 //concat(result);55 92 }).start(); 56 93 } 57 }94 */ } 58 95 59 96 public function remove(callback:Function = null):void { 97 throw new IllegalOperationError("this method is not supported."); 60 98 /* forEach(function(item:*, index:int, array:Array):void { 61 99 new QueueThread(_resource, new RemoveThread(resource, item)).start(); 62 100 }); 63 101 */ } 64 102 /** 103 * このレコードセットと関連する共有リソースです。 104 */ 65 105 public function get resource():Resource { 66 106 return resource; 67 107 } 108 /** 109 * @private 110 */ 68 111 public function set resource(value:Resource):void { 69 112 _resource = value; 70 113 } 71 114 /** 115 * このレコードセットと関連するSQLStatementです。 116 */ 72 117 public function get sqlStatement():SQLStatement { 73 118 return _sqlStatement; 74 119 } 120 /** 121 * @private 122 */ 75 123 public function set sqlStatement(value:SQLStatement):void { 76 124 _sqlStatement = value; 77 125 } 78 126 /** 127 * このレコードセットの取得完了状態です。 128 */ 79 129 public function set complete(value:Boolean):void { 80 130 _complete = value; 81 131 } 132 /** 133 * @private 134 */ 82 135 public function get complete():Boolean { 83 136 return _complete; air/AirDao/src/com/seacolorswind/dbi/ThreadQueue.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.utils.Dictionary; … … 8 35 9 36 /** 10 * ... 11 * @author ... 37 * スレッドのキューを管理するクラスです。 38 * キューは共有リソース毎に作成され、管理されます。 共有リソースの異なるスレッドは異なるキューと見なされます。 39 * @see com.seacolorswind.dbi.Queue 40 * @author Kazushi Tominaga (Seacolor) 12 41 */ 13 42 public class ThreadQueue 14 43 { 44 /** 45 * 全てのキューの待機中のスレッドの数です。 46 */ 15 47 public static function get numThreads():int { 16 48 var rtnNum:int = 0; … … 21 53 } 22 54 55 /** 56 * 永続キューの待機中のスレッドの数です。 57 */ 23 58 public static function get numSeriarizeThreads():int { 24 59 var rtnNum:int = 0; … … 29 64 return rtnNum; 30 65 } 31 66 /** 67 * キューを作成し、キューにスレッドを登録します。 68 * キューが作成済みの場合、キューは作成されずスレッドの登録のみが行われます。 69 * @param resource 共有リソースです。 70 * @param thread キューに登録されるスレッドです。 71 * @param threadExecutor 利用される IThreadExecutor です。 72 */ 32 73 public static function addThread(resource:Resource, thread:Thread, threadExecutor:IThreadExecutor = null):void { 33 74 if (!Thread.isReady) { … … 52 93 _queueThreads[resource] = _queueThread; 53 94 } 54 95 /** 96 * @private 97 */ 55 98 protected static var _queueThreads:Dictionary = new Dictionary(); 56 99 /** 100 * @private 101 */ 57 102 protected static var _queueThread:Queue; 58 103 } air/AirDao/src/com/seacolorswind/dbi/UpdateThread.as
r2386 r2442 1 package com.seacolorswind.dbi 1 /* 2 * ActionScript Thread Library 3 * 4 * Licensed under the MIT License 5 * 6 * Copyright (c) 2009 Kazushi tominaga 7 * Spark project (www.libspark.org) 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 * 27 */ 28 package com.seacolorswind.dbi 2 29 { 3 30 import flash.data.SQLStatement; … … 10 37 11 38 /** 12 * ...39 * レコードを更新するスレッドです。 13 40 * @author Kazushi Tominaga (Seacolor) 14 41 */ 15 42 internal class UpdateThread extends AbstractStatementThread 16 43 { 44 /** 45 * @private 46 */ 17 47 protected const logger:ILogger = Log.getLogger(className); 18 48 /** 49 * コンストラクタです。 50 * @param resource 共有リソースです。 51 * @param entity エンティティです。 52 * @param callback テーブルの作成が成功した場合に呼び出される関数です。 53 * @param errorHandler テーブルの作成がエラーにより失敗した場合に呼び出される関数です。 関数は発生したエラーのインスタンスを引数として呼び出されます。 54 */ 19 55 public function UpdateThread(resource:Resource, entity:Object, callback:Function = null, errorHandler:Function = null) 20 56 { … … 24 60 _errorHandler = errorHandler; 25 61 } 26 62 /** 63 * @inheritDoc 64 */ 27 65 override protected function run():void 28 66 { … … 36 74 next(execute); 37 75 } 38 76 /** 77 * クエリを実行します。 78 */ 39 79 protected function execute():void { 40 80 logger.debug("execute()"); … … 91 131 stmt.execute(); 92 132 } 93 133 /** 134 * @private 135 */ 94 136 protected var _is_updated_on:Boolean; 137 /** 138 * @private 139 */ 95 140 protected var _updated_on:Date; 96 141 /** 142 * @private 143 */ 97 144 protected function complete(event:SQLEvent):void { 98 145 logger.debug("complete({0})", arguments[0]); … … 106 153 } 107 154 155 /** 156 * SQLErrorイベントハンドラです。 157 * @param event SQLErrorイベント 158 */ 108 159 protected function errorHandler(event:SQLErrorEvent):void { 109 160 logger.debug("errorHandler({0})", arguments[0]);

