eniac00
11/28/2024, 6:17 AMcfml
engines (Lucee or ACF) work under the hood. How they process things, and how the servlet container facilitates them.
I have googled but found nothing specifically on this topic. Please help me with guidance.mjhagen
eniac00
11/28/2024, 10:15 AMmjhagen
eniac00
11/28/2024, 10:37 AMgunnar
11/28/2024, 10:51 AMgunnar
11/28/2024, 10:52 AMaliaspooryorik
aliaspooryorik
bdw429s
11/29/2024, 3:58 PMeniac00
11/30/2024, 10:44 AMeniac00
11/30/2024, 10:46 AMaliaspooryorik
bdw429s
12/02/2024, 5:06 PMbdw429s
12/02/2024, 5:08 PMbdw429s
12/02/2024, 5:11 PMinit()
runs once when the servlet context is created, and the service()
method is run for every incoming requestbdw429s
12/02/2024, 5:15 PMdefineClass()
method. Lucee, BoxLang, and ACF vary quite a bit in their approach to generating bytecode, but generally speaking, a single CFM file translates to a single Java class where the logic in the template is represented in the bytecode of a method which is invoked via a shared interface or superclass. Lucee will compile UDFs (be it from CFMs or CFCs) into a single class. ACF and BoxLang will use inner classes for each UDF instance, but that's generally an implementation detail hidden from the developer.bdw429s
12/02/2024, 5:18 PMbdw429s
12/02/2024, 5:24 PM// CFML code
if( foo && name == "brad" ) {}
will compile down to the bytecode equiv of a Java if statement, but the actual operators will be replaced with classes that implement the "and" and "equals" operator. e.g.
// Java code equivalent represented in bytecode
if( AndOperator.invoke( BooleanCaster.cast( foo ), EqualsOperator.invoke( context.getVariable( "name" ), "brad" ) ) ) {}
☝️ Pseudo code-- the CF engines differ a deal here, but accomplish the same thing at the end of the day. This allows them to enforce what can be cast to a Boolean, implicit type coercion, variable access, and logical operator behavior.bdw429s
12/02/2024, 5:26 PMDave Merrill
12/02/2024, 9:26 PMleftbower
12/04/2024, 1:04 AMeniac00
12/14/2024, 7:13 AM1. the incoming request -> servlet match -> physical path (happens through servlet class)
2. if it is the first run then servlet class 'init()' method is called else 'service()'
3. searches if templates are in the cache
4. if not in cache then JIT parse the template into java class and then compiled into byte code (each cfm or cfc converts into single class and all UDFs are in one class)
5. byte code loaded on the fly via a custom URL class loader and gets invoked()
Please let me know if there are mistakes or there are more explanations to be added. Thanks again and God bless you.