#49115: caching of generated class files moved from HandlerGenerator to BaseObjectHandler
1.1 --- a/mdr/src/org/netbeans/mdr/handlers/BaseObjectHandler.java Fri Oct 15 11:45:41 2004 +0000
1.2 +++ b/mdr/src/org/netbeans/mdr/handlers/BaseObjectHandler.java Mon Oct 18 12:55:54 2004 +0000
1.3 @@ -95,8 +95,23 @@
1.4
1.5 if (result == null) {
1.6 try {
1.7 - /* generate and define handler class */
1.8 - byte[] handlerClassFile = HandlerGenerator.generateHandler(className, ifc, s);
1.9 + byte[] handlerClassFile;
1.10 + StorableObject metaObject = s.getMetaObject();
1.11 + if (s instanceof StorableObject) {
1.12 + handlerClassFile = metaObject.getInstanceClassFile();
1.13 + } else {
1.14 + handlerClassFile = metaObject.getClassFile();
1.15 + }
1.16 +
1.17 + if (handlerClassFile == null) {
1.18 + /* generate and define handler class */
1.19 + handlerClassFile = HandlerGenerator.generateHandler(className, ifc, s);
1.20 + if (s instanceof StorableObject) {
1.21 + metaObject.setInstanceClassFile(handlerClassFile);
1.22 + } else {
1.23 + metaObject.setClassFile(handlerClassFile);
1.24 + }
1.25 + }
1.26
1.27 /* [XXX] Allow the use of a system property org.netbeans.mdr.byteCodeDir, write class
1.28 * files to that directory, if the system property is set.
1.29 @@ -110,6 +125,8 @@
1.30 // }
1.31
1.32 result = loader.defineClass(className, handlerClassFile);
1.33 + } catch (StorageException e) {
1.34 + throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
1.35 } finally {
1.36 releaseCache(cache, result, className);
1.37 }
2.1 --- a/mdr/src/org/netbeans/mdr/handlers/gen/HandlerGenerator.java Fri Oct 15 11:45:41 2004 +0000
2.2 +++ b/mdr/src/org/netbeans/mdr/handlers/gen/HandlerGenerator.java Mon Oct 18 12:55:54 2004 +0000
2.3 @@ -61,28 +61,14 @@
2.4 */
2.5 public static byte[] generateHandler(final String name, Class ifc, StorableBaseObject storable) {
2.6 HandlerGenerator gen;
2.7 - byte[] result = null;
2.8 try {
2.9 - StorableObject metaObject = storable.getMetaObject();
2.10 if (storable instanceof StorableAssociation) {
2.11 - result = metaObject.getClassFile();
2.12 - if (result != null)
2.13 - return result;
2.14 gen = new AssociationGenerator(name, ifc, ((StorableAssociation)storable).getAssociationSuperclass(), (StorableAssociation)storable, ((StorableAssociation)storable).getAssociationCustomImpl());
2.15 } else if (storable instanceof StorableClass) {
2.16 - result = metaObject.getClassFile();
2.17 - if (result != null)
2.18 - return result;
2.19 gen = new ClassGenerator(name, ifc, ((StorableClass) storable).getClassSuperclass(), (StorableClass)storable, ((StorableClass) storable).getClassCustomImpl());
2.20 } else if (storable instanceof StorablePackage) {
2.21 - result = metaObject.getClassFile();
2.22 - if (result != null)
2.23 - return result;
2.24 gen = new PackageGenerator(name, ifc, ((StorablePackage) storable).getPackageSuperclass(), (StorablePackage)storable, ((StorablePackage) storable).getPackageCustomImpl());
2.25 } else if (storable instanceof StorableObject) {
2.26 - result = metaObject.getInstanceClassFile();
2.27 - if (result != null)
2.28 - return result;
2.29 StorableClass proxy = ((StorableObject) storable).getClassProxy();
2.30 gen = new InstanceGenerator(name, ifc, proxy.getInstanceSuperclass(), (StorableObject)storable, proxy.getInstanceCustomImpl());
2.31 } else {
2.32 @@ -94,18 +80,7 @@
2.33
2.34 ByteArrayOutputStream bout = new ByteArrayOutputStream();
2.35 gen.generateClassFile(bout);
2.36 - result = bout.toByteArray();
2.37 - try {
2.38 - StorableObject metaObject = storable.getMetaObject();
2.39 - if (storable instanceof StorableObject) {
2.40 - metaObject.setInstanceClassFile(result);
2.41 - } else {
2.42 - metaObject.setClassFile(result);
2.43 - }
2.44 - } catch (Exception e) {
2.45 - throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
2.46 - }
2.47 - return result;
2.48 + return bout.toByteArray();
2.49 }
2.50
2.51 public static boolean customImplContainsMethod(Class customImpl, String name, String descriptor) {