Scott Conklin
09/28/2022, 11:42 PMproperty config;
...
public void function setupApplication() {
settings = config.getSettings();
application.AESKey = settings.keys.AES ;
application.captchaKey = settings.keys.captcha;
application.VTID = settings.application.vtid;
application.COTID = settings.application.cotid;
application.securelist = settings.securelist;
application.env = getEnvironment();
}
Scott Conklin
09/28/2022, 11:50 PMvariable [CONFIG] doesn't exist
websolete
09/28/2022, 11:53 PMwebsolete
09/28/2022, 11:54 PMScott Conklin
09/28/2022, 11:55 PMwebsolete
09/28/2022, 11:56 PMScott Conklin
09/28/2022, 11:57 PMfunction before( struct rc = {} ) {
// reset the application scope
if(structKeyExists(rc, 'resetApp')) {
userService.logout();
}
// user session data
rc["userSession"] = userService.getUserSession();
}
Scott Conklin
09/28/2022, 11:58 PMproperty config;
property userService;
// FW/1 settings
variables.framework = {
// action = 'action',
// defaultSection = 'main',
// defaultItem = 'default',
generateSES = true,
....
websolete
09/28/2022, 11:58 PMproperty userService;
?websolete
09/28/2022, 11:59 PMScott Conklin
09/28/2022, 11:59 PMScott Conklin
09/28/2022, 11:59 PMwebsolete
09/29/2022, 12:00 AMwritedump( getBeanFactory().getBeanInfo() )
and see if it sees the beans, it may be too early in the lifecycleScott Conklin
09/29/2022, 12:00 AMwebsolete
09/29/2022, 12:02 AMgetBeanFactory().getBean("userService")
? it's not clear to me if i missed the boat on somethingScott Conklin
09/29/2022, 12:04 AMwebsolete
09/29/2022, 12:05 AMScott Conklin
09/29/2022, 12:05 AMScott Conklin
09/29/2022, 12:06 AMwebsolete
09/29/2022, 12:06 AMwebsolete
09/29/2022, 12:07 AMScott Conklin
09/29/2022, 12:07 AMScott Conklin
09/29/2022, 12:07 AMwebsolete
09/29/2022, 12:07 AMScott Conklin
09/29/2022, 12:07 AMwebsolete
09/29/2022, 12:08 AMwebsolete
09/29/2022, 12:08 AMScott Conklin
09/29/2022, 12:09 AMwritedump(var="#getBeanFactory()#", abort="true");
This shows nothing
writedump(var="#getBeanFactory().getBeanInfo('config')#", abort="true");
websolete
09/29/2022, 12:09 AMScott Conklin
09/29/2022, 12:09 AMwebsolete
09/29/2022, 12:10 AMScott Conklin
09/29/2022, 12:10 AMwebsolete
09/29/2022, 12:10 AMScott Conklin
09/29/2022, 12:10 AMScott Conklin
09/29/2022, 12:11 AMwebsolete
09/29/2022, 12:11 AMScott Conklin
09/29/2022, 12:12 AMScott Conklin
09/29/2022, 12:12 AMwebsolete
09/29/2022, 12:15 AMgetBeanFactory().declare("config").asValue( application.config );
in setupApplication(). then it will appear to be a bean and you can inject config as a normal bean. not trying to sound remedial, i just don't know how far you may have exploredScott Conklin
09/29/2022, 1:16 AMseancorfield
seancorfield
seancorfield
getBeanFactory().declare(...)
!).seancorfield
property
in other CFCs as needed to cause it to be injected.seancorfield
application
variables are just "bad".seancorfield
Scott Conklin
09/29/2022, 2:11 PMScott Conklin
09/29/2022, 2:35 PMfunction onLoad( beanFactory ) {
beanFactory.declare( ... ).asValue( ... ).done()
.declare( ... ).asValue( ... ).done()
.declare( ... ).instanceOf( ... ).done()
...done()
// eagerly load all the singletons:
.load();
}
seancorfield
mimeTypes
bean that we initialize in onLoad()
with the list of mime types our app actually accepts
3) It's useful for providing aliases, renaming, overriding, and generally customizing the bean setup so that you can have both naturally-named CFCs and naturally-named properties for cases where they don't necessarily align exactlyseancorfield
onLoad()
at work -- it's dramatically simpler than it used to be as we've rewritten apps from CFML to Clojure over the years but it still illustrates some of the above:
function onLoad( di1 ) {
var stdout = createObject( "java", "java.lang.System" ).out;
if ( !di1.containsBean( "cfmljure" ) ) {
if ( structKeyExists( server, "__cfmljure" ) ) {
var cfmljure = server.__cfmljure;
stdout.println( "DI/1 Load Listener using cached cfmljure" );
} else {
stdout.println( "DI/1 Load Listener creating cfmljure" );
var cfmljure = new ws.framework.cfmljure(
project = "/repository",
boot = "/repository/build/bin/boot worldsingles"
);
}
di1.addBean( "cfmljure", cfmljure );
server.__cfmljure = cfmljure;
} else {
stdout.println("DI/1 Load Listener using existing cfmljure" );
}
// set up all the ColdSpring-specific tweaks
// validations first:
di1.addBean( "rules", [ ] ); // default version
// various aliases and special case overrides (due to poor naming and conflicts):
di1.addAlias( "clj", "ClojureService" );
di1.addAlias( "clojure", "ClojureService" );
// exclude beans we don't want managed/loaded by DI/1 by changing them to
// be transients (which will exclude them from non-lazy-loading):
var beanInfo = di1.getBeanInfo().beanInfo;
for ( var beanName in beanInfo ) {
var info = beanInfo[ beanName ];
if ( info.keyExists( "CFC" ) &&
info.cfc.startsWith( "ws.model.orm.Bean" ) ) {
di1.declareBean( beanName, info.cfc, false );
}
}
if ( url.keyExists( "dumpbeans" ) ) { writeDump(di1.getBeanInfo()); abort; }
// avoid lazy-loading in apps, but not in tests:
var cfg = di1.getConfig();
if ( !cfg.keyExists( "lazy" ) || !cfg.lazy ) {
di1.load();
}
}
seancorfield
seancorfield
setup()
methods, we specify lazy : true
so tests do not load the entire factory full of beans, only the ones they actually need during the test -- so tests run faster and the likelihood of race conditions there is very low.Scott Conklin
09/29/2022, 4:06 PMCharles Robertson
11/02/2022, 9:38 AMapplication.AESKey = settings.keys.AES ;
You can either inject the config component, directly, into your controllers/services
or just create:
variables.framework.environments = {
dev = {
someSetting = “”,
…
}
}
Although, I am not 100% sure you can add custom settings to variables.framework.environments