Hi Kathlyn,
thanks for your question.
Unfortunately Scout has no such built in feature. Not yet
I agree with Jérémie's proposal to do the profiling on the Server side. This is how I would do it:
1) Create a new Service on the server: 'ProfileService'
My implementation looks as follows:
public class ProfileService extends AbstractService implements IProfileService {
private static final IScoutLogger LOG = ScoutLogManager.getLogger(ProfileService.class);
private static Map<String, Integer> numberOfUses = new HashMap<String, Integer>();
@Override
public void log(String name) throws ProcessingException {
LOG.info("Log the following element: " + name);
if (numberOfUses.containsKey(name)) {
int number = numberOfUses.get(name);
number++;
numberOfUses.put(name, number);
LOG.info("The element " + name + " has been used " + number + " times.");
}
else {
LOG.info("The element " + name + " has been used the first time");
numberOfUses.put(name, 1);
}
}
}
It is simply a method which count's how often a certain string has been passed. In a real world scenario I would log it into a database.
2) In order to log pages, I override the page's 'execPageActivated()' method:
@Override
protected void execPageActivated() throws ProcessingException {
super.execPageActivated();
SERVICES.getService(IProfileService.class).log(MyTablePage.class.getSimpleName());
}
Every time the page is activated, it will profile it.
3) In order to log forms, I override the form's 'execFormActivated()' method:
@Override
protected void execFormActivated() throws ProcessingException {
super.execFormActivated();
SERVICES.getService(IProfileService.class).log(MyForm.class.getSimpleName());
}
And here is some sample output from the Server:
...
Log the following element: MyTablePage
The element MyTablePage has been used 2 times.
Log the following element: MyTablePage
The element MyTablePage has been used 3 times.
Log the following element: MyForm
The element MyForm has been used the first time
Log the following element: MyForm
The element MyForm has been used 3 times.
Note: If you have a lot of pages and forms it is cumbersome to always add the logging to the execPageActivated method (dry - don't repeat yourself). Therefore I would suggest to move the code to the super class and then extend your forms/pages from those class, e.g. instead of
public class MyForm extends AbstractForm
use
public class MyForm extends ProfilingAbstractForm
and then in ProfilingAbstractForm implement the logging.
I hope this helps and meets your requirements. If you have any further questions, let us know.
Best regards,
Matthias