From: Lukas P. <pe...@us...> - 2002-04-23 14:33:37
|
Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime In directory usw-pr-cvs1:/tmp/cvs-serv10585 Modified Files: AllocThreadMethodR.java AllocThreadTraceR.java AllocTypeMethodR.java AllocTypeThreadMethodR.java AllocTypeThreadR.java AllocTypeThreadTraceR.java AllocTypeTraceR.java ImageR.java Added Files: MultiRootDataR.java Log Message: fixed lazy object creation bug --- NEW FILE: MultiRootDataR.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.realtime; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; /** Superclass for multi-rooted realtime data classes. * @author Lukas Petru */ abstract class MultiRootDataR extends DataR { /** Finishes multi-root object construction with info gained from * profiled VM. * @param typeId Identification of <code>AllocType</code> root. * @param threadId Identification of <code>Thread</code> root. * @param locationId Identification of <code>Location</code> root. * @param sid Object info. */ abstract void construct(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid); } Index: AllocThreadMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocThreadMethodR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** AllocThreadMethodR.java 21 Apr 2002 19:43:48 -0000 1.2 --- AllocThreadMethodR.java 23 Apr 2002 14:33:34 -0000 1.3 *************** *** 46,50 **** * @author Lukas Petru */ ! public class AllocThreadMethodR extends DataR implements AllocThreadMethod { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 46,51 ---- * @author Lukas Petru */ ! public class AllocThreadMethodR extends MultiRootDataR implements ! AllocThreadMethod { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 92,103 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! thread=image.resolveThread(threadId); ! location=image.resolveMethod(locationId); ! // resolve parents ! isReady=true; ! // add to parents' lists ! thread.addAllocThreadMethod(this); ! location.addAllocThreadMethod(this); } --- 93,97 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 218,221 **** --- 212,230 ---- void addAllocThreadTrace(AllocThreadTrace o) { allocThreadTraces.add(o); + } + + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + thread=image.resolveThread(threadId); + location=image.resolveMethod(locationId); + // resolve parents + isReady=true; + // add to parents' lists + thread.addAllocThreadMethod(this); + location.addAllocThreadMethod(this); + } } Index: AllocThreadTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocThreadTraceR.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** AllocThreadTraceR.java 21 Apr 2002 19:43:48 -0000 1.1 --- AllocThreadTraceR.java 23 Apr 2002 14:33:34 -0000 1.2 *************** *** 46,50 **** * @author Lukas Petru */ ! public class AllocThreadTraceR extends DataR implements AllocThreadTrace { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 46,51 ---- * @author Lukas Petru */ ! public class AllocThreadTraceR extends MultiRootDataR implements ! AllocThreadTrace { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 90,109 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! thread=image.resolveThread(threadId); ! location=image.resolveAllocTrace(locationId); ! // resolve parent ! Integer methodId=new Integer(sid.parentUpObjId); ! if (image.containsId(methodId)) ! method=(AllocThreadMethodR) image.getObject(methodId); ! else { ! method=new AllocThreadMethodR(methodId, image); ! image.putObject(methodId, method); ! } ! isReady=true; ! // add to parents' lists ! thread.addAllocThreadTrace(this); ! location.addAllocThreadTrace(this); ! method.addAllocThreadTrace(this); } --- 91,95 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 214,217 **** --- 200,226 ---- void addAllocTypeThreadTrace(AllocTypeThreadTrace o) { allocTypeThreadTraces.add(o); + } + + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + thread=image.resolveThread(threadId); + location=image.resolveAllocTrace(locationId); + // resolve parent + Integer methodId=new Integer(sid.parentUpObjId); + if (image.containsId(methodId)) + method=(AllocThreadMethodR) image.getObject(methodId); + else { + method=new AllocThreadMethodR(methodId, image); + image.putObject(methodId, method); + } + isReady=true; + // add to parents' lists + thread.addAllocThreadTrace(this); + location.addAllocThreadTrace(this); + method.addAllocThreadTrace(this); + } } Index: AllocTypeMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeMethodR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** AllocTypeMethodR.java 15 Apr 2002 19:46:05 -0000 1.2 --- AllocTypeMethodR.java 23 Apr 2002 14:33:34 -0000 1.3 *************** *** 44,48 **** * @author Lukas Petru */ ! public class AllocTypeMethodR extends DataR implements AllocTypeMethod { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 44,49 ---- * @author Lukas Petru */ ! public class AllocTypeMethodR extends MultiRootDataR implements AllocTypeMethod ! { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 88,98 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! type=image.resolveAllocType(typeId); ! location=image.resolveMethod(locationId); ! isReady=true; ! // add to parents' lists ! type.addAllocTypeMethod(this); ! location.addAllocTypeMethod(this); } --- 89,93 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 218,221 **** --- 213,230 ---- void addAllocTypeThreadMethod(AllocTypeThreadMethod o) { allocTypeThreadMethods.add(o); + } + + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + type=image.resolveAllocType(typeId); + location=image.resolveMethod(locationId); + isReady=true; + // add to parents' lists + type.addAllocTypeMethod(this); + location.addAllocTypeMethod(this); + } } Index: AllocTypeThreadMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeThreadMethodR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** AllocTypeThreadMethodR.java 21 Apr 2002 19:43:48 -0000 1.2 --- AllocTypeThreadMethodR.java 23 Apr 2002 14:33:34 -0000 1.3 *************** *** 46,50 **** * @author Lukas Petru */ ! public class AllocTypeThreadMethodR extends DataR implements AllocTypeThreadMethod { /** Tells if any data was loaded from profiled VM about this Type. */ --- 46,50 ---- * @author Lukas Petru */ ! public class AllocTypeThreadMethodR extends MultiRootDataR implements AllocTypeThreadMethod { /** Tells if any data was loaded from profiled VM about this Type. */ *************** *** 94,128 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! type=image.resolveAllocType(typeId); ! thread=image.resolveThread(threadId); ! location=image.resolveMethod(locationId); ! // resolve parents ! Integer typeMethodId=new Integer(sid.parentLeftObjId); ! if (image.containsId(typeMethodId)) ! typeMethod=(AllocTypeMethodR) image.getObject(typeMethodId); ! else { ! typeMethod=new AllocTypeMethodR(typeMethodId, image); ! image.putObject(typeMethodId, typeMethod); ! } ! Integer typeThreadId=new Integer(sid.parentUpObjId); ! if (image.containsId(typeThreadId)) ! typeThread=(AllocTypeThreadR) image.getObject(typeThreadId); ! else { ! typeThread=new AllocTypeThreadR(typeThreadId, image); ! image.putObject(typeThreadId, typeThread); ! } ! Integer threadMethodId=new Integer(sid.parentRightObjId); ! if (image.containsId(threadMethodId)) ! threadMethod=(AllocThreadMethodR) image.getObject(threadMethodId); ! else { ! threadMethod=new AllocThreadMethodR(threadMethodId, image); ! image.putObject(threadMethodId, threadMethod); ! } ! isReady=true; ! // add to parents' lists ! typeMethod.addAllocTypeThreadMethod(this); ! typeThread.addAllocTypeThreadMethod(this); ! threadMethod.addAllocTypeThreadMethod(this); } --- 94,98 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 234,237 **** --- 204,245 ---- void addAllocTypeThreadTrace(AllocTypeThreadTrace o) { allocTypeThreadTraces.add(o); + } + + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + type=image.resolveAllocType(typeId); + thread=image.resolveThread(threadId); + location=image.resolveMethod(locationId); + // resolve parents + Integer typeMethodId=new Integer(sid.parentLeftObjId); + if (image.containsId(typeMethodId)) + typeMethod=(AllocTypeMethodR) image.getObject(typeMethodId); + else { + typeMethod=new AllocTypeMethodR(typeMethodId, image); + image.putObject(typeMethodId, typeMethod); + } + Integer typeThreadId=new Integer(sid.parentUpObjId); + if (image.containsId(typeThreadId)) + typeThread=(AllocTypeThreadR) image.getObject(typeThreadId); + else { + typeThread=new AllocTypeThreadR(typeThreadId, image); + image.putObject(typeThreadId, typeThread); + } + Integer threadMethodId=new Integer(sid.parentRightObjId); + if (image.containsId(threadMethodId)) + threadMethod=(AllocThreadMethodR) image.getObject(threadMethodId); + else { + threadMethod=new AllocThreadMethodR(threadMethodId, image); + image.putObject(threadMethodId, threadMethod); + } + isReady=true; + // add to parents' lists + typeMethod.addAllocTypeThreadMethod(this); + typeThread.addAllocTypeThreadMethod(this); + threadMethod.addAllocTypeThreadMethod(this); + } } Index: AllocTypeThreadR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeThreadR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** AllocTypeThreadR.java 21 Apr 2002 19:43:48 -0000 1.3 --- AllocTypeThreadR.java 23 Apr 2002 14:33:34 -0000 1.4 *************** *** 46,50 **** * @author Lukas Petru */ ! public class AllocTypeThreadR extends DataR implements AllocTypeThread { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 46,51 ---- * @author Lukas Petru */ ! public class AllocTypeThreadR extends MultiRootDataR implements AllocTypeThread ! { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 90,100 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! type=image.resolveAllocType(typeId); ! thread=image.resolveThread(threadId); ! isReady=true; ! // add to parents' lists ! type.addAllocTypeThread(this); ! thread.addAllocTypeThread(this); } --- 91,95 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 222,225 **** --- 217,234 ---- void addAllocTypeThreadTrace(AllocTypeThreadTrace o) { allocTypeThreadTraces.add(o); + } + + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + type=image.resolveAllocType(typeId); + thread=image.resolveThread(threadId); + isReady=true; + // add to parents' lists + type.addAllocTypeThread(this); + thread.addAllocTypeThread(this); + } } Index: AllocTypeThreadTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeThreadTraceR.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** AllocTypeThreadTraceR.java 21 Apr 2002 19:43:48 -0000 1.1 --- AllocTypeThreadTraceR.java 23 Apr 2002 14:33:34 -0000 1.2 *************** *** 46,50 **** * @author Lukas Petru */ ! public class AllocTypeThreadTraceR extends DataR implements AllocTypeThreadTrace { /** Tells if any data was loaded from profiled VM about this Type. */ --- 46,50 ---- * @author Lukas Petru */ ! public class AllocTypeThreadTraceR extends MultiRootDataR implements AllocTypeThreadTrace { /** Tells if any data was loaded from profiled VM about this Type. */ *************** *** 88,125 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! type=image.resolveAllocType(typeId); ! thread=image.resolveThread(threadId); ! location=image.resolveAllocTrace(locationId); ! // resolve parents ! Integer methodId=new Integer(sid.parentUpObjId); ! if (image.containsId(methodId)) ! method=(AllocTypeThreadMethodR) image.getObject(methodId); ! else { ! method=new AllocTypeThreadMethodR(methodId, image); ! image.putObject(methodId, method); ! } ! Integer typeTraceId=new Integer(sid.parentLeftObjId); ! if (image.containsId(typeTraceId)) ! typeTrace=(AllocTypeTraceR) image.getObject(typeTraceId); ! else { ! typeTrace=new AllocTypeTraceR(typeTraceId, image); ! image.putObject(typeTraceId, typeTrace); ! } ! Integer threadTraceId=new Integer(sid.parentRightObjId); ! if (image.containsId(threadTraceId)) ! threadTrace=(AllocThreadTraceR) image.getObject(threadTraceId); ! else { ! threadTrace=new AllocThreadTraceR(threadTraceId, image); ! image.putObject(threadTraceId, threadTrace); ! } ! typeThread=(AllocTypeThreadR) method.getParentAllocTypeThread(); ! ! isReady=true; ! // add to parents' lists ! method.addAllocTypeThreadTrace(this); ! typeTrace.addAllocTypeThreadTrace(this); ! threadTrace.addAllocTypeThreadTrace(this); ! typeThread.addAllocTypeThreadTrace(this); } --- 88,92 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 223,226 **** --- 190,234 ---- // ---------- private / package + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + type=image.resolveAllocType(typeId); + thread=image.resolveThread(threadId); + location=image.resolveAllocTrace(locationId); + // resolve parents + Integer methodId=new Integer(sid.parentUpObjId); + if (image.containsId(methodId)) + method=(AllocTypeThreadMethodR) image.getObject(methodId); + else { + method=new AllocTypeThreadMethodR(methodId, image); + image.putObject(methodId, method); + } + Integer typeTraceId=new Integer(sid.parentLeftObjId); + if (image.containsId(typeTraceId)) + typeTrace=(AllocTypeTraceR) image.getObject(typeTraceId); + else { + typeTrace=new AllocTypeTraceR(typeTraceId, image); + image.putObject(typeTraceId, typeTrace); + } + Integer threadTraceId=new Integer(sid.parentRightObjId); + if (image.containsId(threadTraceId)) + threadTrace=(AllocThreadTraceR) image.getObject(threadTraceId); + else { + threadTrace=new AllocThreadTraceR(threadTraceId, image); + image.putObject(threadTraceId, threadTrace); + } + typeThread=(AllocTypeThreadR) method.getParentAllocTypeThread(); + + isReady=true; + // add to parents' lists + method.addAllocTypeThreadTrace(this); + typeTrace.addAllocTypeThreadTrace(this); + threadTrace.addAllocTypeThreadTrace(this); + typeThread.addAllocTypeThreadTrace(this); + } + } + /** Determines whether refresh should be done and does, if so. */ Index: AllocTypeTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeTraceR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** AllocTypeTraceR.java 21 Apr 2002 19:43:48 -0000 1.2 --- AllocTypeTraceR.java 23 Apr 2002 14:33:34 -0000 1.3 *************** *** 45,49 **** * @author Lukas Petru */ ! public class AllocTypeTraceR extends DataR implements AllocTypeTrace { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 45,49 ---- * @author Lukas Petru */ ! public class AllocTypeTraceR extends MultiRootDataR implements AllocTypeTrace { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 89,108 **** image=RtImage; objId=new Integer(sid.objId); ! // resolve roots ! type=image.resolveAllocType(typeId); ! location=image.resolveAllocTrace(locationId); ! // resolve parent ! Integer methodId=new Integer(sid.parentUpObjId); ! if (image.containsId(methodId)) ! method=(AllocTypeMethodR) image.getObject(methodId); ! else { ! method=new AllocTypeMethodR(methodId, image); ! image.putObject(methodId, method); ! } ! isReady=true; ! // add to parents' lists ! type.addAllocTypeTrace(this); ! location.addAllocTypeTrace(this); ! method.addAllocTypeTrace(this); } --- 89,93 ---- image=RtImage; objId=new Integer(sid.objId); ! construct(typeId, threadId, locationId, sid); } *************** *** 213,216 **** --- 198,224 ---- void addAllocTypeThreadTrace(AllocTypeThreadTrace o) { allocTypeThreadTraces.add(o); + } + + /** Finishes full object construction. */ + void construct(Integer typeId, Integer threadId, Integer locationId, + IProf.sID sid) { + if (! isReady) { + // resolve roots + type=image.resolveAllocType(typeId); + location=image.resolveAllocTrace(locationId); + // resolve parent + Integer methodId=new Integer(sid.parentUpObjId); + if (image.containsId(methodId)) + method=(AllocTypeMethodR) image.getObject(methodId); + else { + method=new AllocTypeMethodR(methodId, image); + image.putObject(methodId, method); + } + isReady=true; + // add to parents' lists + type.addAllocTypeTrace(this); + location.addAllocTypeTrace(this); + method.addAllocTypeTrace(this); + } } Index: ImageR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ImageR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ImageR.java 21 Apr 2002 19:43:48 -0000 1.3 --- ImageR.java 23 Apr 2002 14:33:34 -0000 1.4 *************** *** 112,115 **** --- 112,123 ---- final Constructor allocThreadTraceFactory; final Constructor allocTypeThreadTraceFactory; + // multi-root ID factories + final Constructor allocTypeMethodIDFactory; + final Constructor allocTypeTraceIDFactory; + final Constructor allocTypeThreadIDFactory; + final Constructor allocThreadMethodIDFactory; + final Constructor allocTypeThreadMethodIDFactory; + final Constructor allocThreadTraceIDFactory; + final Constructor allocTypeThreadTraceIDFactory; Set getAllFlags=new HashSet(); *************** *** 217,220 **** --- 225,252 ---- "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); + // init multi-root ID factories + mrParameterTypes=new java.lang.Class[] { + integerClass, this.getClass() }; + allocTypeMethodIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeMethodR" + ).getDeclaredConstructor(mrParameterTypes); + allocTypeTraceIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeTraceR") + .getDeclaredConstructor(mrParameterTypes); + allocTypeThreadIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadR" + ).getDeclaredConstructor(mrParameterTypes); + allocThreadMethodIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocThreadMethodR" + ).getDeclaredConstructor(mrParameterTypes); + allocTypeThreadMethodIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadMethodR" + ).getDeclaredConstructor(mrParameterTypes); + allocThreadTraceIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocThreadTraceR" + ).getDeclaredConstructor(mrParameterTypes); + allocTypeThreadTraceIDFactory=java.lang.Class.forName( + "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadTraceR" + ).getDeclaredConstructor(mrParameterTypes); } catch (ClassNotFoundException e) { throw new RuntimeException(e); *************** *** 242,248 **** Integer oId=new Integer(sid.objId); DataR dataObject; ! if ( containsId(oId) ) dataObject=getObject(oId); ! else { try { dataObject=(DataR) factory.newInstance(new Object[] {sid, this --- 274,281 ---- Integer oId=new Integer(sid.objId); DataR dataObject; ! if ( containsId(oId) ) { dataObject=getObject(oId); ! dataObject.construct(sid); ! } else { try { dataObject=(DataR) factory.newInstance(new Object[] {sid, this *************** *** 391,402 **** IProf.sID sid=(IProf.sID) itChildren.next(); Integer oId=new Integer(sid.objId); ! DataR dataObject; ! if ( containsId(oId) ) ! dataObject=getObject(oId); ! else { ! parentMap.put(varyKey, new Integer(sid.infoId)); try { ! dataObject=(DataR) factory.newInstance(new Object[] { ! parentMap.get(TYPE_KEY), parentMap.get(THREAD_KEY), parentMap.get(LOCATION_KEY), sid, this}); } catch (InstantiationException e) { --- 424,438 ---- IProf.sID sid=(IProf.sID) itChildren.next(); Integer oId=new Integer(sid.objId); ! MultiRootDataR dataObject; ! parentMap.put(varyKey, new Integer(sid.infoId)); ! if ( containsId(oId) ) { ! dataObject=(MultiRootDataR) getObject(oId); ! dataObject.construct((Integer) parentMap.get(TYPE_KEY), ! (Integer) parentMap.get(THREAD_KEY), (Integer) parentMap. ! get(LOCATION_KEY), sid); ! } else { try { ! dataObject=(MultiRootDataR) factory.newInstance(new Object[] ! { parentMap.get(TYPE_KEY), parentMap.get(THREAD_KEY), parentMap.get(LOCATION_KEY), sid, this}); } catch (InstantiationException e) { *************** *** 551,554 **** --- 587,619 ---- boolean getAlwaysRefresh() { return isAlwaysRefresh; + } + + /** Find object by its objId. If none such object exists, create new + * object using given constructor. + * @param oId Object ID. + * @param factory Constructor to create new object. Parameter must be + * "IDFactory". + */ + MultiRootDataR resolveObject(Integer oId, java.lang.reflect.Constructor + factory) { + MultiRootDataR o; + if (containsId(oId)) + o=(MultiRootDataR) getObject(oId); + else { + try { + o=(MultiRootDataR) factory.newInstance(new Object[] {oId, this}) + ; + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (java.lang.reflect.InvocationTargetException e) { + throw new RuntimeException(e); + } + putObject(oId, o); + } + return o; } |