Description
This method starts the customization for a certain component. It runs the right "customcode/<bucomp>.p" program persistently. The mechanism built into the customization procedures (customcode/<buscomp>.p) guarantees all necessary datasets are bound, and all standard methods are available in the customization code by adding the whole super-procedure stack.
After starting the customization code, a version check is executed. The method will return oiReturnStatus = 1 if the version in the customization is not matching the version that is expected by the standard business code.
PostCondition
For the component that is being started, the customization code is also started persistently (customcode/<buscomp>.p), and properly initialized. Also the version is checked.
PreCondition
The CustomizationController is active, and the ComponentPool is in the process of starting a component, by starting all associated .p programs.
Parameters
ihProgram | input | handle | Handle to the standard component "program/<buscomp>.p" for which the customization needs to be started. |
icUserDefinedContext | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/customizationcontroller.p)
vcProcList = string(ihProgram) + "," + ihProgram:super-procedures.
do viA = num-entries(vcProcList) to 1 by -1:
vhFcComponent = widget-handle(entry(viA,vcProcList)).
if vhFcComponent:file-name begins "custprogram/"
then do:
assign vcClassName = entry(1,entry(2,vhFcComponent:file-name,"/"),".").
run value ("appinfo/" + vcClassName + "version.p")
(output viClassMajorVersion,
output viClassMinorVersion) no-error.
for each tCustomizedComponent where
tCustomizedComponent.tcComponentName = (if vcClassName = "bcustom" then vcClassName + "[" + lc(icUserDefinedContext) + "]" else vcClassName) and
tCustomizedComponent.tlIsValid <> no
on error undo, throw:
if tCustomizedComponent.tlIsValid = ?
then do:
/* ================================================================= */
/* 'dummy' run to identify the version number only. */
/* ================================================================= */
do transaction on error undo, leave on stop undo, leave:
vcCustomizationVersion = "*NotAvailable*".
run value (tCustomizedComponent.tcFullPath) persistent set vhCust (input ?, input ?) no-error.
vcCustomizationVersion = dynamic-function ("CheckVersion" in vhCust) no-error.
delete procedure vhCust.
end.
if vcCustomizationVersion <> string(viClassMajorVersion) + "." + string(viClassMinorVersion)
then do:
create tFcMessages.
assign tFcMessages.tcFcMessage = substitute("Version mismatch for customization of class &1 (&2 should be &3).",
vcClassName,
vcCustomizationVersion,
string(viClassMajorVersion) + "." + string(viClassMinorVersion))
tFcMessages.tcFcType = "W"
oiReturnStatus = 1.
release tFcMessages.
end.
end.
/* ================================================================= */
/* Run the customization program for real now. */
/* ================================================================= */
do transaction on error undo, leave on stop undo, leave:
vhCust = ?.
tCustomizedComponent.tlIsValid = no.
run value (tCustomizedComponent.tcFullPath)
persistent set vhCust
(input vhFcComponent,
input ihProgram) no-error.
tCustomizedComponent.tlIsValid = yes.
end.
if not valid-handle(vhcust)
then do:
vcCallStack = program-name(2).
viFcCount1 = 3.
if session:error-stack-trace
then do while program-name(viFcCount1) <> ?:
vcCallStack = vcCallStack + chr(10) + program-name(viFcCount1).
viFcCount1 = viFcCount1 + 1.
end.
do viFcCount1 = 1 to error-status:num-messages:
create tFcMessages.
assign tFcMessages.tcFcMessage = error-status:get-message (viFcCount1)
tFcMessages.tcFcBusMethod = vcCallStack
tFcMessages.tiFcSeverity = 1
tFcMessages.tcFcType = "S".
release tFcMessages.
end.
create tFcMessages.
assign tFcMessages.tcFcMessage = substitute (#T-39'Failed to run customization for component &1.':255(515095293)T-39#,tCustomizedComponent.tcFullPath)
tFcMessages.tcFcBusMethod = vcCallStack
tFcMessages.tiFcSeverity = 1
tFcMessages.tcFcType = "S"
oiReturnStatus = 1. /* do not return an error. Customization will be ignored, but standard code can continue. */
release tFcMessages.
return.
end.
create tCustomizationPool.
assign tCustomizationPool.thProgram = ihProgram
tCustomizationPool.thCustImplementation = vhCust.
end.
end.
end.