protected void generatePostDelegateCode( Class intfcl, String genclass, Method method, IndentedWriter iw ) throws IOException { if ("setClientInfo".equals(method.getName())) { super.generatePostDelegateCode( intfcl, genclass, method, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (Exception e)"); iw.println("{ throw SqlUtils.toSQLClientInfoException( e ); }"); } else super.generatePostDelegateCode( intfcl, genclass, method, iw ); } }
protected void generatePostDelegateCode( Class intfcl, String genclass, Method method, IndentedWriter iw ) throws IOException { if ("setClientInfo".equals(method.getName())) { super.generatePostDelegateCode( intfcl, genclass, method, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (Exception e)"); iw.println("{ throw SqlUtils.toSQLClientInfoException( e ); }"); } else super.generatePostDelegateCode( intfcl, genclass, method, iw ); } }
protected void writeInternalUtilityFunctions() throws IOException { iw.println("private boolean eqOrBothNull( Object a, Object b )"); iw.println("{"); iw.upIndent(); iw.println("return"); iw.upIndent(); iw.println("a == b ||"); iw.println("(a != null && a.equals(b));"); iw.downIndent(); iw.downIndent(); iw.println("}"); }
protected void writeInternalUtilityFunctions() throws IOException { iw.println("private boolean eqOrBothNull( Object a, Object b )"); iw.println("{"); iw.upIndent(); iw.println("return"); iw.upIndent(); iw.println("a == b ||"); iw.println("(a != null && a.equals(b));"); iw.downIndent(); iw.downIndent(); iw.println("}"); }
protected void writeInternalUtilityFunctions() throws IOException { iw.println("private boolean eqOrBothNull( Object a, Object b )"); iw.println("{"); iw.upIndent(); iw.println("return"); iw.upIndent(); iw.println("a == b ||"); iw.println("(a != null && a.equals(b));"); iw.downIndent(); iw.downIndent(); iw.println("}"); }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { BeangenUtils.writeExplicitDefaultConstructor( Modifier.PRIVATE, info, iw); iw.println(); iw.println("public " + info.getClassName() + "( boolean autoregister )"); iw.println("{"); iw.upIndent(); iw.println( "if (autoregister)"); iw.println("{"); iw.upIndent(); iw.println("this.identityToken = C3P0ImplUtils.allocateIdentityToken( this );"); iw.println("C3P0Registry.reregister( this );"); iw.downIndent(); iw.println("}"); iw.downIndent(); iw.println("}"); } }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { BeangenUtils.writeExplicitDefaultConstructor( Modifier.PRIVATE, info, iw); iw.println(); iw.println("public " + info.getClassName() + "( boolean autoregister )"); iw.println("{"); iw.upIndent(); iw.println( "if (autoregister)"); iw.println("{"); iw.upIndent(); iw.println("this.identityToken = C3P0ImplUtils.allocateIdentityToken( this );"); iw.println("C3P0Registry.reregister( this );"); iw.downIndent(); iw.println("}"); iw.downIndent(); iw.println("}"); } }
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 writePropertyGetter( Property prop, Class propType ) throws IOException { String stn = prop.getSimpleTypeName(); String pfx = ("boolean".equals( stn ) ? "is" : "get" ); String methodName = pfx + BeangenUtils.capitalize( prop.getName() ); iw.print( CodegenUtils.getModifierString( prop.getGetterModifiers() ) ); iw.println(' ' + prop.getSimpleTypeName() + ' ' + methodName + "()"); iw.println('{'); iw.upIndent(); iw.println( stn + ' ' + prop.getName() + " = innerBean." + methodName + "();"); String retVal = this.getGetterDefensiveCopyExpression( prop, propType ); if (retVal == null) retVal = prop.getName(); iw.println("return " + retVal + ';'); iw.downIndent(); iw.println('}'); }
protected void writePropertyGetter( Property prop, Class propType ) throws IOException { String stn = prop.getSimpleTypeName(); String pfx = ("boolean".equals( stn ) ? "is" : "get" ); String methodName = pfx + BeangenUtils.capitalize( prop.getName() ); iw.print( CodegenUtils.getModifierString( prop.getGetterModifiers() ) ); iw.println(' ' + prop.getSimpleTypeName() + ' ' + methodName + "()"); iw.println('{'); iw.upIndent(); iw.println( stn + ' ' + prop.getName() + " = innerBean." + methodName + "();"); String retVal = this.getGetterDefensiveCopyExpression( prop, propType ); if (retVal == null) retVal = prop.getName(); iw.println("return " + retVal + ';'); iw.downIndent(); iw.println('}'); }
protected void writePropertyGetter( Property prop, Class propType ) throws IOException { String stn = prop.getSimpleTypeName(); String pfx = ("boolean".equals( stn ) ? "is" : "get" ); String methodName = pfx + BeangenUtils.capitalize( prop.getName() ); iw.print( CodegenUtils.getModifierString( prop.getGetterModifiers() ) ); iw.println(' ' + prop.getSimpleTypeName() + ' ' + methodName + "()"); iw.println('{'); iw.upIndent(); iw.println( stn + ' ' + prop.getName() + " = innerBean." + methodName + "();"); String retVal = this.getGetterDefensiveCopyExpression( prop, propType ); if (retVal == null) retVal = prop.getName(); iw.println("return " + retVal + ';'); iw.downIndent(); iw.println('}'); }
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 { int num_props = props.length; Property[] masked = new Property[ num_props ]; for (int i = 0; i < num_props; ++i) masked[i] = new SimplePropertyMask( props[i] ); iw.println("protected static class SimpleStateBean implements ExportedState"); iw.println("{"); iw.upIndent(); for (int i = 0; i < num_props; ++i) { masked[i] = new SimplePropertyMask( props[i] ); BeangenUtils.writePropertyMember( masked[i], iw ); iw.println(); BeangenUtils.writePropertyGetter( masked[i], iw ); iw.println(); BeangenUtils.writePropertySetter( masked[i], iw ); } iw.downIndent(); iw.println("}"); } }
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 generateExtraDeclarations( Class intfcl, String genclass, IndentedWriter iw ) throws IOException { super.generateExtraDeclarations( intfcl, genclass, iw ); iw.println(); iw.println("NewProxyConnection proxyCon;"); iw.println(); iw.print( CodegenUtils.fqcnLastElement( genclass ) ); iw.println("( " + CodegenUtils.simpleClassName( intfcl ) + " inner, NewPooledConnection parentPooledConnection, NewProxyConnection proxyCon )"); iw.println("{"); iw.upIndent(); iw.println("this( inner, parentPooledConnection );"); iw.println("this.proxyCon = proxyCon;"); iw.downIndent(); iw.println("}"); } }
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 generateExtraDeclarations( Class intfcl, String genclass, IndentedWriter iw ) throws IOException { super.generateExtraDeclarations( intfcl, genclass, iw ); iw.println(); iw.println("NewProxyConnection proxyCon;"); iw.println(); iw.print( CodegenUtils.fqcnLastElement( genclass ) ); iw.println("( " + CodegenUtils.simpleClassName( intfcl ) + " inner, NewPooledConnection parentPooledConnection, NewProxyConnection proxyCon )"); iw.println("{"); iw.upIndent(); iw.println("this( inner, parentPooledConnection );"); iw.println("this.proxyCon = proxyCon;"); iw.downIndent(); iw.println("}"); } }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { iw.print( CodegenUtils.getModifierString( ctor_modifiers ) ); iw.print( info.getClassName() + "( "); BeangenUtils.writeArgList(props, true, iw); iw.println(" )"); iw.println("{"); iw.upIndent(); for (int i = 0, len = props.length; i < len; ++i) { iw.print("this." + props[i].getName() + " = "); String setExp = props[i].getDefensiveCopyExpression(); if (setExp == null) setExp = props[i].getName(); iw.println(setExp + ';'); } iw.downIndent(); iw.println("}"); } }
protected void generateExtraDeclarations( Class intfcl, String genclass, IndentedWriter iw ) throws IOException { super.generateExtraDeclarations( intfcl, genclass, iw ); iw.println(); iw.println("Object creator;"); iw.println("Object creatorProxy;"); iw.println("NewProxyConnection proxyConn;"); iw.println(); iw.print( CodegenUtils.fqcnLastElement( genclass ) ); iw.println("( " + CodegenUtils.simpleClassName( intfcl ) + " inner, NewPooledConnection parentPooledConnection, Object c, Object cProxy )"); iw.println("{"); iw.upIndent(); iw.println("this( inner, parentPooledConnection );"); iw.println("this.creator = c;"); iw.println("this.creatorProxy = cProxy;"); iw.println("if (creatorProxy instanceof NewProxyConnection) this.proxyConn = (NewProxyConnection) cProxy;"); iw.downIndent(); iw.println("}"); }
protected void generateExtraDeclarations( Class intfcl, String genclass, IndentedWriter iw ) throws IOException { super.generateExtraDeclarations( intfcl, genclass, iw ); iw.println(); iw.println("Object creator;"); iw.println("Object creatorProxy;"); iw.println("NewProxyConnection proxyConn;"); iw.println(); iw.print( CodegenUtils.fqcnLastElement( genclass ) ); iw.println("( " + CodegenUtils.simpleClassName( intfcl ) + " inner, NewPooledConnection parentPooledConnection, Object c, Object cProxy )"); iw.println("{"); iw.upIndent(); iw.println("this( inner, parentPooledConnection );"); iw.println("this.creator = c;"); iw.println("this.creatorProxy = cProxy;"); iw.println("if (creatorProxy instanceof NewProxyConnection) this.proxyConn = (NewProxyConnection) cProxy;"); iw.downIndent(); iw.println("}"); }