ADF BC Application Module provides standard class called AMStatistics. This class gives you info about AM creation time as for example, Web Session ID assigned to the current session, etc. What is cool about this class - it is not limited with out of the box statics only, it allows to add your custom statistics. I will describe use case of tracking activation timestamp for the AM and keeping it custom AMStatistics variable.
Here you can download completed sample application - AMStatisticsApp.zip. This sample overrides ADF BC method - activateState in Application Module Implementation class. Mehtod activateState is invoked by the framework, when activation event happens. At this time, we create new custom StatsInfo instance and save it in AMStatistics (it overrides previously saved statistic with the same name). Activation timestamp is saved into AMStatistics:
Custom method - checkLastActivationTime is accessing AMStatistics and reads AM activation time custom statistics saved earlier. This method is invoked from the button.
To see the log output, when checkLastActivationTime method is invoked, make sure to set INFO log level for the Application Module Implementation class:
For the test purposes, I have set Referenced Pool Size = 1, this means with two users active - it will start to passivate and activate Application Module instances and we would be able to see changed timestamp:
Here we can see output from the runtime test. When first user is activated, I press Check Last Activation Time button - timestamp is set and printed in the log:
Moving to the second user, activation is performed. Last activation time is updated:
Until Application Module instance remains assigned to the current user, activation time will remain unchanged - you can see this in the log:
This was an example of a use case, when AMStatistics can be used to keep custom statistic values.
Here you can download completed sample application - AMStatisticsApp.zip. This sample overrides ADF BC method - activateState in Application Module Implementation class. Mehtod activateState is invoked by the framework, when activation event happens. At this time, we create new custom StatsInfo instance and save it in AMStatistics (it overrides previously saved statistic with the same name). Activation timestamp is saved into AMStatistics:
Custom method - checkLastActivationTime is accessing AMStatistics and reads AM activation time custom statistics saved earlier. This method is invoked from the button.
To see the log output, when checkLastActivationTime method is invoked, make sure to set INFO log level for the Application Module Implementation class:
For the test purposes, I have set Referenced Pool Size = 1, this means with two users active - it will start to passivate and activate Application Module instances and we would be able to see changed timestamp:
Here we can see output from the runtime test. When first user is activated, I press Check Last Activation Time button - timestamp is set and printed in the log:
Moving to the second user, activation is performed. Last activation time is updated:
Until Application Module instance remains assigned to the current user, activation time will remain unchanged - you can see this in the log:
This was an example of a use case, when AMStatistics can be used to keep custom statistic values.
No comments:
Post a Comment