cache Constructors of handlers - this speeds up getHandler(StorableBaseObject ) when handler is not in facilityCache
1.1 --- a/mdr/src/org/netbeans/mdr/NBMDRepositoryImpl.java Tue Nov 22 17:50:07 2005 +0000
1.2 +++ b/mdr/src/org/netbeans/mdr/NBMDRepositoryImpl.java Fri Nov 25 13:59:08 2005 +0000
1.3 @@ -81,6 +81,7 @@
1.4
1.5 private final Map parameters;
1.6
1.7 + private Map constructorCache = new HashMap();
1.8 private Set shutdownListeners = new HashSet();
1.9
1.10 /* -------------------------------------------------------------------- */
1.11 @@ -645,7 +646,6 @@
1.12 cls = StorableObject.class;
1.13 }
1.14 /* create handler object, if necessary */
1.15 - Constructor cons = cl.getConstructor(new Class[] {cls});
1.16 MOFID mofId = s.getMofId();
1.17 Object lock = s.getMdrStorage().getStorageByMofId(mofId);
1.18 if (lock == null)
1.19 @@ -655,6 +655,12 @@
1.20 synchronized (facilityCache) {
1.21 Object oldRecord = facilityCache.get(mofId);
1.22 if (oldRecord == null) {
1.23 + Constructor cons = (Constructor) constructorCache.get(cl);
1.24 +
1.25 + if (cons == null) {
1.26 + cons = cl.getConstructor(new Class[] {cls});
1.27 + constructorCache.put(cl,cons);
1.28 + }
1.29 oldRecord = cons.newInstance(new Object[] {s});
1.30 facilityCache.put(mofId, oldRecord);
1.31 }