super.init(argumentCollection=arguments); // Load objects into THIS local scope loadObjects(); return this; var keys = ""; var i = 1; var objectName = ""; // Loop over the variables - load the objects into this scope keys = StructKeyList(variables); for (i=1; i LTE ListLen(keys); i=i+1){ objectName = ListGetAt(keys,i); if ( (IsObject(variables[objectName])) AND (objectName NEQ "this") ){ this[objectName] = variables[objectName]; } } var app = ""; var throwError = false; var throwErrorMsg = ""; if ( LEN(arguments.appBeanName) ) { // Update the siteAppList application.ADF.siteAppList = ListAppend(application.ADF.siteAppList, arguments.appBeanName); // Validate if the "appBeanName" exists in the SERVER object factory if ( validateAppBeanExists(arguments.appBeanName) ){ // Create the Application Space for the app bean application[arguments.appBeanName] = StructNew(); // Copy the App bean config struct from server.ADF into application.ADF copyServerBeanToApplication(arguments.appBeanName); // Load the local App components into the object factory loadSiteAppComponents(arguments.appBeanName); // Load the App application[arguments.appBeanName] = application.ADF.objectFactory.getBean(arguments.appBeanName); // set up the configuration of the element setAppConfig(arguments.appBeanName); // Load the site ajax service proxy white list XML loadAppProxyWhiteList(arguments.appBeanName); // run the post init function if it is defined app = application.ADF.objectFactory.getBean(arguments.appBeanName); // [MFC] - Changed "isDefined" to "StructKeyExists" // [MFC] - Added check for if the "app" is a struct. if( isStruct(app) AND StructKeyExists(app, "postInit") ) app.postInit(); } else { // Throw error that the App Bean doesn't exist. throwError = true; throwErrorMsg = "The'#arguments.appBeanName#' app could not be loaded. Check that the app exists in the '/ADF/apps/' directory."; // cfscript 'throw' is not cf8 compatible //throw("The'#arguments.appBeanName#' app could not be loaded. Check that the app exists in the '/ADF/apps/' directory."); //server.ADF.objectFactory.getBean("log_1_0").logAppend(throwErrorMsg); } } // Load the Apps Configs for CE and XML configs into server.ADF.environment server.ADF.environment[request.site.id][arguments.appBeanName] = StructNew(); StructAppend(server.ADF.environment[request.site.id][arguments.appBeanName], getAppCEConfigs(arguments.appBeanName), true); StructAppend(server.ADF.environment[request.site.id][arguments.appBeanName], getAppXMLConfigs(arguments.appBeanName), true); var retConfigStruct = StructNew(); var configAppXMLPath = "#request.site.csAppsDIR#config/#arguments.appName#.xml"; // Check if the config file exists for the site if ( FileExists(configAppXMLPath) ) retConfigStruct = server.ADF.objectFactory.getBean("CoreConfig").getConfigViaXML(configAppXMLPath); // Get the apps local components var comPath = request.site.csAppsURL & getAppBeanDir(arguments.appBeanName) & "/components"; var appLibPath = request.site.csAppsURL & getAppBeanDir(arguments.appBeanName) & "/lib"; var utilsObj = ""; var siteComponents = QueryNew("tmp"); var siteComponentsFiles = QueryNew("tmp"); var beanData = StructNew(); var i = 1; var refreshObjFactory = false; var beanConfigStruct = application.ADF.beanConfig.getConfigStruct(); // Check if there is a 'components' directory in the site if ( directoryExists(expandPath(comPath)) ) { utilsObj = server.ADF.objectFactory.getBean("utils_1_0"); siteComponents = utilsObj.directoryFiles(expandPath(comPath), "false"); siteComponentsFiles = utilsObj.filterDirectoryQueryByType(siteComponents, '%.cfc'); // Loop over the returned components to add to the application.ADF object factory for ( i = 1; i LTE siteComponentsFiles.RecordCount; i = i + 1) { beanData = application.ADF.beanConfig.buildBeanDataStruct(siteComponentsFiles.directory[i], siteComponentsFiles.name[i]); // 2012-10-18 - Check to see if a bean already exists within an app, and load in the override. if ( StructKeyExists(beanConfigStruct, beanData.beanName) ){ // Get the nickname of the CFC to override if ( StructKeyExists(beanConfigStruct, arguments.appBeanName) AND StructKeyExists(beanConfigStruct[arguments.appBeanName], "CONSTRUCTORDEPENDENCYSTRUCT") AND StructKeyExists(beanConfigStruct[arguments.appBeanName].CONSTRUCTORDEPENDENCYSTRUCT, beanData.beanName) ){ beanData.cfcName = beanConfigStruct[arguments.appBeanName].CONSTRUCTORDEPENDENCYSTRUCT[beanData.beanName]; } } // Add the bean into the Application ADF objectfactory application.ADF.BeanConfig.addSingleton(beanData.cfcPath, beanData.beanName); application.ADF.BeanConfig.addConstructorDependency(arguments.appBeanName, beanData.beanName, beanData.cfcName); } // Set the refresh flag refreshObjFactory = true; } // Check if the Site App has any lib overrides if ( directoryExists(expandPath(appLibPath)) ){ // Load the ADF Lib components application.ADF.beanConfig.loadADFLibComponents("#appLibPath#/", "", "application"); // Set the refresh flag refreshObjFactory = true; } // Refresh the Object Factory if ( refreshObjFactory ) application.ADF.objectFactory = createObject("component","ADF.core.lightwire.LightWireExtendedBase").init(application.ADF.beanConfig); var i = 1; var j = 1; var k = 1; var cd_keys = ""; var md_keys = ""; var sd_keys = ""; var appBeanStruct = server.ADF.beanConfig.getConfigStruct(); // Check if we are working with a server.ADF bean if ( StructKeyExists(appBeanStruct, arguments.beanName) ) { appBeanStruct = appBeanStruct[arguments.beanName]; // Add the bean to the application ADF application.ADF.beanConfig.addConfigStruct(arguments.beanName, appBeanStruct); // Recurse over the beans fields fields to built the structure correctly // Add in the CONSTRUCTORDEPENDENCYSTRUCT beans cd_keys = StructKeyList(appBeanStruct.CONSTRUCTORDEPENDENCYSTRUCT); for ( i = 1; i LTE ListLen(cd_keys); i = i + 1) copyServerBeanToApplication(ListGetAt(cd_keys, i)); // Add in the MIXINDEPENDENCYSTRUCT beans md_keys = StructKeyList(appBeanStruct.MIXINDEPENDENCYSTRUCT); for ( j = 1; j LTE ListLen(md_keys); j = j + 1) copyServerBeanToApplication(ListGetAt(md_keys, j)); // Add in the SETTERDEPENDENCYSTRUCT beans sd_keys = StructKeyList(appBeanStruct.SETTERDEPENDENCYSTRUCT); for ( k = 1; k LTE ListLen(sd_keys); k = k + 1) copyServerBeanToApplication(ListGetAt(sd_keys, k)); } var configStruct = application.ADF.beanConfig.GETCONFIGSTRUCT(); var appBeanStruct = StructNew(); var pathVal = ""; var dir = ""; // find the structkey for the application.ADF if ( StructKeyExists(configStruct, arguments.appBeanName) ) { // get the struct out appBeanStruct = configStruct[#arguments.appBeanName#]; // Check if the path key exists if ( StructKeyExists(appBeanStruct, "path") ) { pathVal = appBeanStruct.path; // Find the list item before 'components' dir name dir = ListGetAt(pathVal, ListFindNoCase(pathVal, 'components', '.') - 1, '.'); } } var appBeanStruct = application.ADF.beanConfig.getConfigStruct(arguments.appName); var appDirName = ListGetAt(appBeanStruct[arguments.appName].path, 3, "."); var proxyWhiteListXMLPath = ExpandPath("/ADF/apps/#appDirName#/components/proxyWhiteList.xml"); var configStruct = StructNew(); // Check if the config file exists for the site if ( FileExists(proxyWhiteListXMLPath) ) { configStruct = server.ADF.objectFactory.getBean("CoreConfig").getConfigViaXML(proxyWhiteListXMLPath); // Merge this config struct into the application proxy white list application.ADF.proxyWhiteList = server.ADF.objectFactory.getBean("data_1_2").structMerge(application.ADF.proxyWhiteList, configStruct, true); } // Check if the App Bean is created in the Server ADF object factory if ( isObject(server.ADF.objectFactory.getBean(arguments.appName)) ) return true; else return false;