A good question.  I would put it in MoveManagerImpl.  Try using [mixin]
on the class an implementing the init() method.

 

[Mixin]

/**

 ...

 */

public class MoveManagerImpl... 

{

 

            /**

             *  Mixin callback 

             */

            public static function init(root:DisplayObject):void

            {

Singleton.registerClass("com.teotiGraphix.managers.moveManagerClasses::I
UIMoveManager ", MoveManagerImpl);
}

 

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Schmalle
Sent: Thursday, January 11, 2007 2:10 PM
To: [email protected]
Subject: Re: [flexcomponents] Singleton :: Where to register with
classMap

 

Wow Alex,

Thanks for the quick response. 

After actually thinking a bit, the interface answer seems obvious now.
:)

So say I am creating a move manager that developer will use. Now my
question is more direct. 

Where should I put the register method? 

I have MoveManagerFX static class; This class indirectly implements the
IUIMoveManager interface through static methods.

   private static var implClassDependency:MoveManagerImpl; 

    private static var impl:IUIMoveManager =
 
Singleton.getInstance("com.teotiGraphix.managers.moveManagerClasses::IUI
MoveManager") as IUIMoveManager;

Then in the MoveManagerImpl; this class directly implements the
IUIMoveManager interface through public methods. 

    /**
     * The single instance of the <code>MoveManagerImpl </code>.
     * @private
     */
    private static var instance:MoveManagerImpl = null;
    
    /**
     * Returns the single instance of the <code>MoveManagerImpl </code>.

     * 
     * @return Returns the single instance of the <code>MoveManagerImpl
</code>
     * instance.
     */
    public static function getInstance():IUIMoveManager
    {
        if (instance == null) 
            instance = new MoveManagerImpl();
        return instance;
    }

With these two classes, where I am going to put this line;


Singleton.registerClass("com.teotiGraphix.managers.moveManagerClasses::I
UIMoveManager ", MoveManagerImpl);


Am I conceptualizing this wrong?

Thanks, Mike



On 1/11/07, Alex Harui < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
wrote:

You can register anytime before you need to ask for the singleton.
Since our managers get used early in startup, we register them as early
as possible.  You might be able to wait longer, even as late as
creationComplete.  In some apps, the popup manager is loaded in a module
that is loaded way after the app started.

 

We register interfaces instead of classes for version control.  If a
module in an application requires an older version of the framework, it
will live in its own application domain and thus not share the same
singleton as the main app.  What we promise is that the interfaces will
never change, and the interfaces are put in a bootstrap app domain.
Then when you ask for the singleton, you can share it across app
domains.

 

-Alex

 

________________________________

From: [email protected]
<mailto:[email protected]>  [mailto:flexcompone
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] On Behalf Of Michael
Schmalle
Sent: Thursday, January 11, 2007 1:38 PM
To: [email protected]
<mailto:[email protected]> 
Subject: [flexcomponents] Singleton :: Where to register with classMap

 

Hi,

I have managers I am implementing singletons with.

I am trying to stick to the singleton pattern. I see that yor singletons
are registered in the systemManager frame 2 handler.

I also see that you are not using registerInitCallbacks() anymore. 

So the question is... Where do I put my line of code that registers the
implementation class with the Singleton class map?

IE you have

Singleton.registerClass("mx.managers::ICursorManager ",
Class(getDefinitionByName("mx.managers::CursorManagerImpl")));

I want

Singleton.registerClass("com.teotiGraphix.manager::IMoveManager",
Class(getDefinitionByName("com.teotiGraphix.manager::MoveMangerImpl
")));

Also, why do you use the interface name when registering the class, is
that so others can override you implementation? (with the same register
call)... This is the first time I actually thought about it this way.
;-) 

Peace, Mike

PS I have been kind holding back on releasing components thus far
because I wanted my managers piped into this new algorithm.


-- 
Teoti Graphix
http://www.teotigraphix.com <http://www.teotigraphix.com> 

Blog - Flex2Components
http://www.flex2components.com <http://www.flex2components.com> 

You can find more by solving the problem then by 'asking the question'. 




-- 
Teoti Graphix
http://www.teotigraphix.com <http://www.teotigraphix.com> 

Blog - Flex2Components
http://www.flex2components.com <http://www.flex2components.com> 

You can find more by solving the problem then by 'asking the question'. 

 

Reply via email to