protected void writeIndirectStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("com.mchange.v2.log.MLog.getLogger( this.getClass() ).log(com.mchange.v2.log.MLevel.FINE, \042Direct serialization provoked a NotSerializableException! Trying indirect.\042, nse);"); super.writeIndirectStoreObject( prop, propType, iw ); } };
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { super.generate( info, superclassType, props, propTypes, iw); writeExtraDeclarations( info, superclassType, props, propTypes, iw); }
protected void writeStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT) writeIndirectStoreObject( prop, propType, iw ); else if (policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("//test serialize"); iw.println("SerializableUtils.toByteArray(" + prop.getName() + ");"); super.writeStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (NotSerializableException nse)"); iw.println("{"); iw.upIndent(); writeIndirectStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeStoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT || policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("Object o = ois.readObject();"); iw.println("if (o instanceof IndirectlySerialized) o = ((IndirectlySerialized) o).getObject();"); iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") o;"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeUnstoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeIndirectStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("Indirector indirector = " + findIndirectorExpr + ';'); writeInitializeIndirector( prop, propType, iw ); iw.println("oos.writeObject( indirector.indirectForm( " + prop.getName() + " ) );"); iw.downIndent(); iw.println("}"); iw.println("catch (IOException indirectionIOException)"); iw.println("{ throw indirectionIOException; }"); iw.println("catch (Exception indirectionOtherException)"); iw.println("{ throw new IOException(\"Problem indirectly serializing " + prop.getName() + ": \" + indirectionOtherException.toString() ); }"); }
protected void writeStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT) writeIndirectStoreObject( prop, propType, iw ); else if (policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("//test serialize"); iw.println("SerializableUtils.toByteArray(" + prop.getName() + ");"); super.writeStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (NotSerializableException nse)"); iw.println("{"); iw.upIndent(); writeIndirectStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeStoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT || policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("Object o = ois.readObject();"); iw.println("if (o instanceof IndirectlySerialized) o = ((IndirectlySerialized) o).getObject();"); iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") o;"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeUnstoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeIndirectStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("Indirector indirector = " + findIndirectorExpr + ';'); writeInitializeIndirector( prop, propType, iw ); iw.println("oos.writeObject( indirector.indirectForm( " + prop.getName() + " ) );"); iw.downIndent(); iw.println("}"); iw.println("catch (IOException indirectionIOException)"); iw.println("{ throw indirectionIOException; }"); iw.println("catch (Exception indirectionOtherException)"); iw.println("{ throw new IOException(\"Problem indirectly serializing " + prop.getName() + ": \" + indirectionOtherException.toString() ); }"); }
protected void writeStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT) writeIndirectStoreObject( prop, propType, iw ); else if (policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("//test serialize"); iw.println("SerializableUtils.toByteArray(" + prop.getName() + ");"); super.writeStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (NotSerializableException nse)"); iw.println("{"); iw.upIndent(); writeIndirectStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeStoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeIndirectStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("com.mchange.v2.log.MLog.getLogger( this.getClass() ).log(com.mchange.v2.log.MLevel.FINE, \042Direct serialization provoked a NotSerializableException! Trying indirect.\042, nse);"); super.writeIndirectStoreObject( prop, propType, iw ); } };
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { super.generate( info, superclassType, props, propTypes, iw); writeExtraDeclarations( info, superclassType, props, propTypes, iw); }
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT || policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("// we create an artificial scope so that we can use the name o for all indirectly serialized objects."); iw.println("{"); iw.upIndent(); iw.println("Object o = ois.readObject();"); iw.println("if (o instanceof IndirectlySerialized) o = ((IndirectlySerialized) o).getObject();"); iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") o;"); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeUnstoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeIndirectStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("Indirector indirector = " + findIndirectorExpr + ';'); writeInitializeIndirector( prop, propType, iw ); iw.println("oos.writeObject( indirector.indirectForm( " + prop.getName() + " ) );"); iw.downIndent(); iw.println("}"); iw.println("catch (IOException indirectionIOException)"); iw.println("{ throw indirectionIOException; }"); iw.println("catch (Exception indirectionOtherException)"); iw.println("{ throw new IOException(\"Problem indirectly serializing " + prop.getName() + ": \" + indirectionOtherException.toString() ); }"); }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { super.generate( info, superclassType, props, propTypes, iw); writeExtraDeclarations( info, superclassType, props, propTypes, iw); }