I might be missing the purpose of your factory, but maybe you can just 
implement it like this:

function PluginFactory() {
    //
}

exports.PluginFactory = new PluginFactory();


As long as you don't mess with the require cache, I think that would 
effectively be a singleton.  Maybe there are other reasons to implement the 
singleton like you did though.

-Bryan


On Tuesday, March 25, 2014 6:50:27 AM UTC-6, [email protected] wrote:
>
> Hi,
>
> So i'm having problems with my architecture of my node application, I know 
> the problem, I'm just trying to find the best solution.
>
> My problems is exactly the same as: 
> https://groups.google.com/forum/#!topic/nodejs/u_9IE2z_6rM 
>
> Only I'm using a Factory class to create plugins of the type "IPlugin". 
> These plugins have certain actions, called PluginAction.
>
> A PluginAction has a field plugin, which refers to its parent plugin. When 
> serializing to JSON, i replace the plugin object with a string identifier, 
> pointing to the correct plugin.
>
> My PluginFactory can retrieve a plugin using retrieve(identifier). The 
> problem occurs when I try to deserialize a given PluginAction.
>
> At that point I would like to convert the plugin identifier back to the 
> plugin object, by retrieving it from the Factory. This is where it goes 
> wrong.
>
> I understand this could be a bit hard to follow, so I've included a part 
> of my class diagram, which might clarify it more. Short summary:
>
>
>    1. PluginFactory.initialize() loads all plugins in a certain directory 
>    using require()
>    2. PluginAction.toJSON() changes the plugin object to a string 
>    containing the plugin identifier
>    3. PluginAction.fromJSON() when trying to retrieve the plugin object 
>    using the PluginFactory, I cannot load the PluginFactory file.
>    
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to