There is a large JSF application used by several simultaneous users.
The application gets PemGem space errors, increased use of CPU (mostly due to gurbage collection) and increased utilization of RAM. We need to optimize the code-base among several other measures to overcome these issues.
The application uses few common functions extensively. I want to know which is the best place to include such functions to optimize memory and CPU usage.
Example Function (We can simply convert these to static functions if necessary)
public long calculateAgeInDays(Date dob, Date toDate) {
if (dob == null || toDate == null) {
return 0l;
}
long ageInDays;
ageInDays = (toDate.getTime() - dob.getTime()) / (1000 * 60 * 60 * 24);
if (ageInDays < 0) {
ageInDays = 0;
}
return ageInDays;
}
What is the best place to include these very common functions.
- EJB - Singlton
- EJB - Stateless
- JSF Managed Beans (Controllers) - Application Scoped
- JSF Managed Beans (Controllers) - Session Scoped
- JSF Managed Beans (Controllers) - Request Scoped
- Simple Java Class
Thanks in advance