| Package: MachII |
| Base component for Application.cfc integration |
| Method Summary | |
|---|---|
| public AppManager |
getAppManager()
Get the Mach-II AppManager. Not available until loadFramework has been called. |
| public any |
getProperty(string propertyName, [any defaultValue=""])
Returns the property value by name. If the property is not defined, and a default value is passed, it will be returned. If the property and a default value are both not defined then an exception is thrown. Not available until loadFramework() has been called. |
| public void |
handleRequest()
Handles a Mach-II request. Recommend to call in onRequestStart() event. |
| public boolean |
isPropertyDefined(string propertyName)
Checks if property name is defined in the properties. Not available until loadFramework() has been called. |
| public void |
loadFramework()
Loads the framework. Only call in onApplicationStart() event. |
| public void |
setProperty(string propertyName, any propertyValue)
Sets the property value by name. Not available until loadFramework() has been called. |
| public boolean |
shouldReloadConfig()
Returns if the config should be dynamically reloaded. |
| Method Detail |
|---|
| getAppManager |
|---|
public AppManager getAppManager( )
Get the Mach-II AppManager. Not available until loadFramework has been called.
Parameters:
Code:
<cffunction name="getAppManager" access="public" returntype="MachII.framework.AppManager" output="false" hint="Get the Mach-II AppManager. Not available until loadFramework has been called."> <cfreturn application[MACHII_APP_KEY].appLoader.getAppManager() /> </cffunction>
| getProperty |
|---|
public any getProperty( string propertyName, [any defaultValue=""] )
Returns the property value by name. If the property is not defined, and a default value is passed, it will be returned. If the property and a default value are both not defined then an exception is thrown. Not available until loadFramework() has been called.
Parameters:
| string propertyName |
| [any defaultValue=""] |
Code:
<cffunction name="getProperty" access="public" returntype="any" output="false" hint="Returns the property value by name. If the property is not defined, and a default value is passed, it will be returned. If the property and a default value are both not defined then an exception is thrown. Not available until loadFramework() has been called."> <cfargument name="propertyName" type="string" required="true" /> <cfargument name="defaultValue" type="any" required="false" default="" /> <cfreturn getAppManager().getPropertyManager().getProperty(arguments.propertyName, arguments.defaultValue) /> </cffunction>
| handleRequest |
|---|
public void handleRequest( )
Handles a Mach-II request. Recommend to call in onRequestStart() event.
Parameters:
Code:
<cffunction name="handleRequest" access="public" returntype="void" output="true"
hint="Handles a Mach-II request. Recommend to call in onRequestStart() event.">
<cfif StructKeyExists(request,"MachIIConfigMode")>
<cfset MACHII_CONFIG_MODE = request.MachIIConfigMode />
</cfif>
<cfif NOT IsDefined("application.#MACHII_APP_KEY#.appLoader") OR NOT IsObject(application[MACHII_APP_KEY].appLoader)>
<cflock name="application_#MACHII_APP_KEY#_reload" type="exclusive" timeout="120">
<cfif NOT IsDefined("application.#MACHII_APP_KEY#.appLoader") OR NOT IsObject(application[MACHII_APP_KEY].appLoader)>
<cfset loadFramework() />
</cfif>
</cflock>
</cfif>
<cfif MACHII_CONFIG_MODE EQ -1>
<cfelseif MACHII_CONFIG_MODE EQ 1 AND NOT StructKeyExists(request, "MachIIReload")>
<cflock name="application_#MACHII_APP_KEY#_reload" type="exclusive" timeout="120">
<cfset application[MACHII_APP_KEY].appLoader.reloadConfig(MACHII_VALIDATE_XML) />
</cflock>
<cfelseif MACHII_CONFIG_MODE EQ 0 AND application[MACHII_APP_KEY].appLoader.shouldReloadBaseConfig()>
<cflock name="application_#MACHII_APP_KEY#_reload" type="exclusive" timeout="120">
<cfset application[MACHII_APP_KEY].appLoader.reloadConfig(MACHII_VALIDATE_XML) />
</cflock>
<cfelseif MACHII_CONFIG_MODE EQ 0 AND application[MACHII_APP_KEY].appLoader.shouldReloadModuleConfig()>
<cflock name="application_#MACHII_APP_KEY#_reload" type="exclusive" timeout="120">
<cfset application[MACHII_APP_KEY].appLoader.reloadModuleConfig(MACHII_VALIDATE_XML) />
</cflock>
</cfif>
<cfset application[MACHII_APP_KEY].appLoader.getAppManager().getRequestHandler().handleRequest() />
</cffunction>
| isPropertyDefined |
|---|
public boolean isPropertyDefined( string propertyName )
Checks if property name is defined in the properties. Not available until loadFramework() has been called.
Parameters:
| string propertyName |
Code:
<cffunction name="isPropertyDefined" access="public" returntype="boolean" output="false" hint="Checks if property name is defined in the properties. Not available until loadFramework() has been called."> <cfargument name="propertyName" type="string" required="true"/> <cfreturn getAppManager().getPropertyManager().isPropertyDefined(arguments.propertyName) /> </cffunction>
| loadFramework |
|---|
public void loadFramework( )
Loads the framework. Only call in onApplicationStart() event.
Parameters:
Code:
<cffunction name="loadFramework" access="public" returntype="void" output="false"
hint="Loads the framework. Only call in onApplicationStart() event.">
<cfset application[MACHII_APP_KEY] = StructNew() />
<cfset application[MACHII_APP_KEY].appLoader = CreateObject("component", "MachII.framework.AppLoader").init(MACHII_CONFIG_PATH, MACHII_DTD_PATH, MACHII_APP_KEY, MACHII_VALIDATE_XML) />
<cfset request.MachIIReload = FALSE />
</cffunction>
| setProperty |
|---|
public void setProperty( string propertyName, any propertyValue )
Sets the property value by name. Not available until loadFramework() has been called.
Parameters:
| string propertyName |
| any propertyValue |
Code:
<cffunction name="setProperty" access="public" returntype="void" output="false" hint="Sets the property value by name. Not available until loadFramework() has been called."> <cfargument name="propertyName" type="string" required="true" /> <cfargument name="propertyValue" type="any" required="true" /> <cfset getAppManager().getPropertyManager().setProperty(arguments.propertyName, arguments.propertyValue) /> </cffunction>
| shouldReloadConfig |
|---|
public boolean shouldReloadConfig( )
Returns if the config should be dynamically reloaded.
Parameters:
Code:
<cffunction name="shouldReloadConfig" access="public" returntype="boolean" output="false" hint="Returns if the config should be dynamically reloaded."> <cfreturn application[MACHII_APP_KEY].appLoader.shouldReloadConfig() /> </cffunction>