O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required