• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

monitoring user activity in jsf application (myfaces trinidad)

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is to track user activity on my application centrally. The purpose is to capture click times of user actions to monitor performance and for reporting purposes to end users. To break my question into two parts.

1) Capturing user interactions: How do I intercept all server side events and capture the start and end times of all requests ? For e.g. Is there a way to figure out the button that was clicked by the user at what time and how much time was spent in the request. Is there anyway to capture all sever events like valueChangeEvents, actionEvents in some kind of global listener for all events ?

2) Persisting the captured data: Once the data is available, I would need to persist them into a database. But I would want to do this in a way that the overhead is not very much and doesn't slow down the application very much. So, could you suggest a way to capture this data in a asynchronous fashion so that the logging doesn't slow down the application. Or maybe aggregate the data in the user session and only do the logging once in a while.

Can anyone suggest how do I achieve the above requirement. Thanks in advance.

Uday
 
Saloon Keeper
Posts: 21132
131
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Uday!

JSF is a web-based system, and therefore essentially batch-oriented. So attempting to capture individual control event timings is futile. No communications take place between client and server unless either a command is initiated (commandButton/commandLink), an AJAX request is fired, or an explicit URL request is made (usually from the user's browser navigation control).

In particular, timings on almost all listeners are meaningless, since most of them (valuechange, for example) are simply subroutines of the main command event. Value changes are not free-standing events, but rather they are indications that changes were seen in values when a command was initiated or AJAX request fired. They do not simply fire spontaneously when a user changes a control value (unless they have had AJAX capabilities attached to them).

Briefly, if you wanted control-level timings, you'd have to attach javascript events to all of your client-side controls to capture their timings. Then you'd have to cobble up some sort of mechanism to get those stats sent down to the server as part of a command or AJAX request.

Capture of the timing of actual HTTP request/response cycles is a lot easier. I do most of mine by simply using the Firebug plugin of my web browser. It displays the timings of all of the HTTP requests/responses associated with a page, since I'm mostly attempting to resolve end-to-end timing issues. You can often capture stats for the server by setting options in the server itself (Tomcat has Valve components that can be used for this).

To get fine-grained timings within an action handler method, you do the same thing that you'd do for non-web Java code. Use a profiler and/or manually add logic to capture timestamps of various points in the server-side code.

The actual use of a database to fetch and store data in a JSF webapp is something you should find in any decent JSF book. Although in fact, JSF has no built-in database awareness. You use databases in JSF code exactly the same way you would in non-JSF code.
 
expectation is the root of all heartache - shakespeare. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!