Show
Ignore:
Timestamp:
12/1/2006 2:01:11 PM (2 years ago)
Author:
dhughes
Message:

This addresses (partially) a memory leak when in development and always modes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/reactor/core/objectFactory.cfc

    r395 r397  
    44        <cfset variables.ReactorFactory = "" /> 
    55        <cfset variables.BeanFactory = "" /> 
     6        <cfset variables.ObjectDao = "" /> 
    67        <!---<cfset variables.TimedCache = CreateObject("Component", "reactor.util.TimedCache").init(createTimeSpan(0, 0, 0, 10)) />---> 
    78        <cfset variables.Cache = StructNew() /> 
     
    3435                <!--- set the avaliable plugins ---> 
    3536                <cfset setPluginList(pluginList) /> 
     37 
     38                <!--- create the objectDao we'll use to read object data ---> 
     39                <cfset variables.ObjectDao = CreateObject("Component", "reactor.data.#getConfig().getType()#.ObjectDao").init(getConfig().getDsn(), getConfig().getUsername(), getConfig().getPassword()) /> 
    3640 
    3741                <cfreturn this /> 
     
    8185                                <cfset DbObject = getObject(arguments.alias) /> 
    8286                                <cfset generate = true /> 
    83                          
    84                         <cfelseif compareNocase(getConfig().getMode(), "development") is 0>                              
     87                 
     88                        <cfelseif compareNocase(getConfig().getMode(), "development") is 0>                      
    8589                                <!--- we always need the db object to compare to our existing object ---> 
    8690                                <cfset DbObject = getObject(arguments.alias) /> 
     91                                 
    8792                                <cftry> 
    8893                                        <!--- create an instance of the object and check its signature ---> 
     
    98103                                        </cfif> 
    99104                                </cfif> 
    100                          
     105                                 
    101106                        <cfelseif compareNocase(getConfig().getMode(), "production") is 0> 
    102107                                <cftry> 
     
    125130                                 
    126131                        </cfif> 
    127                          
     132                                         
    128133                        <cfcatch type="Reactor.NoSuchObject"> 
    129134                                <cfthrow type="Reactor.NoSuchObject" message="Object '#arguments.alias#' does not exist." detail="Reactor was unable to find an object in the database with the name '#arguments.alias#.'" /> 
     
    143148                                        <cfset metadata = create(arguments.alias, "Metadata") /> 
    144149                                </cfif> 
    145                                  
     150                         
    146151                                <cfset GeneratedObject = CreateObject("Component", getObjectDetails(arguments.type, arguments.alias, arguments.plugin).dbms)._configure(getConfig(), arguments.alias, getReactorFactory(), getConvention(), metadata) /> 
    147152                        <cfelse> 
     
    154159                                <cfif StructKeyExists(variables.Cache.metadata, arguments.alias)> 
    155160                                        <cfset metadata = variables.Cache.metadata[arguments.alias] /> 
    156                                 <cfelse>  
     161                                <cfelse> 
    157162                                        <cfset metadata = create(arguments.alias, "Metadata") /> 
    158163                                </cfif> 
     
    167172                        <cfset GeneratedObject._setBeanFactory(variables.BeanFactory) /> 
    168173                </cfif> 
     174                 
     175                <cfset ObjectTranslator = 0 /> 
     176                <cfset DbObject = 0 /> 
    169177                 
    170178                <cfreturn GeneratedObject /> 
     
    224232                <cfargument name="name" hint="I am the name of the object to translate." required="yes" type="any" _type="string" /> 
    225233                <cfset var Object = 0 /> 
    226                 <cfset var ObjectDao = 0/> 
    227234                 
    228235                <cfset Object = CreateObject("Component", "reactor.core.object").init(arguments.name, getConfig()) /> 
    229                 <cfset ObjectDao = CreateObject("Component", "reactor.data.#getConfig().getType()#.ObjectDao").init(getConfig().getDsn(), getConfig().getUsername(), getConfig().getPassword()) /> 
    230236                 
    231237                <!--- read the object ---> 
    232                 <cfset ObjectDao.read(Object) /> 
     238                <cfset variables.ObjectDao.read(Object) /> 
    233239                 
    234240                <!--- return the object ---> 
     
    241247                <cfargument name="plugin" hint="I indicate if this is creating a plugin" required="yes" type="any" _type="boolean" /> 
    242248                <cfset var result = StructNew() /> 
    243                 <cfset var pluginPath = "" /> 
    244     <cfif arguments.plugin> 
    245       <cfset pluginPath = ".plugins" /> 
    246     </cfif> 
     249                 
    247250                <!--- get the dbms-specific custom file first ---> 
    248                 <cfset result.dbms = getMapping(arguments.name) & pluginPath & "." & arguments.type & "." & arguments.name & arguments.type & getConfig().getType() /> 
    249                 <cfset result.custom = getMapping(arguments.name) & pluginPath & "." & arguments.type & "." & arguments.name & arguments.type /> 
    250                 <cfset result.project = "reactor.project." & getConfig().getProject() & pluginPath & "." & arguments.type & "." & arguments.name & arguments.type /> 
     251                <cfset result.dbms = getMapping(arguments.name) & Iif(arguments.plugin, De(".plugins"), De("")) & "." & arguments.type & "." & arguments.name & arguments.type & getConfig().getType() /> 
     252                <cfset result.custom = getMapping(arguments.name) & Iif(arguments.plugin, De(".plugins"), De("")) & "." & arguments.type & "." & arguments.name & arguments.type /> 
     253                <cfset result.project = "reactor.project." & getConfig().getProject() & "." & arguments.type & "." & arguments.name & arguments.type /> 
    251254                 
    252255                <!--- insure all three paths exists --->