
Johan Bijker (Customer) asked a question.
We're busy migrating a web application from classic webspeed in 11.7 to PASOE in 12.2.
One of the issues we're facing is with shared variables. We have a startup procedure that creates these shared variables, and because this startup procedure is run from web-disp.p in classic Webspeed, every request that comes in from web-disp.p will be in the right context and will have access to those shared variables.
In PASOE things are a bit different. The startup procedure still creates these new shared variables, but now if a request comes in you have to create a new set of shared variables from the activate procedure, otherwise the code will fail to run. However, these shared variables are different from the shared variables created by the startup procedure.
Luckily it looks like it's possible to define GLOBAL SHARED variables, and if a request comes it will latch on the the ones already started in the startup procedure.
However - there's still an issue if you're using a shared buffer. For some reason you can't define a buffer as a GLOBAL SHARED buffer, so there's just no way for this buffer to latch on to the buffer already created in the startup procedure.
What we managed to do so far is to change web-handler.p to run a procedure in a handle created by the startup procedure, which in turn does a RUN run-web-object in web-utilities-hdl. The web request will now have access to the same shared variables as created in the startup procedure, including the shared buffer. The problem is this only works for web, but for any other type (rest / soap / appserver) we will have the same issue.
Does anyone have some other ideas we can try to make it work across all types of requests?
Ideally you'd want to move away from shared variables, but they do exist in reality, and changing application code may take some time.
As @Johan Bijker (Customer) notes, using SHARED (non-GLOBAL) variables in PASOE has a couple of challenges, all related to the fact that in order to access the values, the code must be in the call stack of the code that defined them as NEW. In Classic WebSpeed, all ABL code is run the web-disp.p call stack, and Life Is Good. In PASOE, though, there are a couple-three stacks: the session startup procedure, the activate procedure, and the CompatibilityHandler's run of web-handler (which effectively replaces web-disp.p).
In the PASOE webhandler model there is no simple equivalent: the webhandler (class) is run and it runs the webspeed code via our "web-handler.p". Ideally applications could define and set the values in a webhandler that overrides the CompatibilityHandler, but since you cannot set shared variables from classes (because you can't define them in a class), they can't do this.
Some have worked around this by using global shared variables, set in the session startup. Using globals may have other side effects.
I've found another workaround which is to "extend" the shipped web-handler.p, in the manner below. Variables can be defined and set once, and since web-handler.p is included and is part of the callstack, which runs the classic webspeed code, shared variables are available to the application code.
The next step is to replace the use of the CompatibilityHandler with a class that does
Now the application's shared variables are available "downstream".
Note that you should test this thoroughly, if you decide to use it.
One issue with this is that if the CompatibilityHandler is not run as a singleton in a session (such as when the srvDebug property is enabled, the setup code will run on each request.