13.2. Database Classes

In the source folder of the sample project you will find a folder named sql containing two classes, SQLiteManager and FlexBlogDatabaseManager. You will not be expected to edit any code in these classes, but as they are specific to our backend solution I want to cover how they will be used and the impact they have on delegate classes.

The SQLiteManager class simply contains the basic logic needed to work with an SQLite database.

The FlexBlogDatabaseManager extends SQLiteManager so that it has database access capabilities and does what you would normally do by calling an HTTPservice or similar class. For example, in a delegate responsible for loading posts you might typically do something like this:

package com.FlexBlog.delegates
{
    import com.adobe.cairngorm.business.ServiceLocator;
    import mx.rpc.AsyncToken;
    import mx.rpc.IResponder;
    import mx.rpc.http.HTTPService;
    public class PostDelegate
    {
        private var responder:IResponder;
        public function PostDelegate(responder:IResponder)
        {
            this.responder = responder
        }
        public function loadPosts():void{
            var service:HTTPService
=ServiceLocator.getInstance().getHTTPService('loadPosts');
            var token:AsyncToken = service.send();
            token.addResponder(this.responder);
        }
    }
}

However, in the sample application we will simulate service calls using the SQL classes that have been provided in the sample project as in the following:

package com.FlexBlog.delegates { import mx.rpc.IResponder; public class PostDelegate { private var responder:IResponder; ...

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.