On 01/23/2012 05:38 PM, Yair Zaslavsky wrote:
Hi all,
I am refactoring now DiskImageDAODbFacadeImpl.
As part of my work, I'm also defining there a Spring-JDBC mapper ,
similar to other ParameterizedRowMapper based mappers we have in code
(i.e DbUserDAODbFacadeImpl has one)
Looks like in our DAO getXXXX methods we instantiate these mapper
objects (each method creates a new mapper object).
Can anyone see a reason , in case a mapper object is stateless (and from
what I see, they are) - why not to have a single instantiation per
mapper type (i.e - Have a MapperUtils class, with static methods like
MapperUtils.getDiskImageMapper() ?
IMHO this can save us some unnecessary instanatiations and improve
performance
+1 for the static suggestion.
Since each mapper is used by a specific DAO impl class (and sometimes
several mappers per DAO), but never shared between those DAOs, IMO they
should be remained in the scope of the DAO which uses them and be
defined inside the DAO class in a static block;
static {
mapper = new ParameterizedRowMapper<Entity>() {
@Override
public Entity mapRow(ResultSet rs, int rowNum){
...
}
};
}
Yair
_______________________________________________
Engine-devel mailing list
Engine-devel(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-devel