private void replaceWriteAccess( ClassTransformation transformation, String fieldName, String fieldType, String sessionKey, String requestField) { String writeMethodName = transformation.newMemberName("write", fieldName); TransformMethodSignature writeSignature = new TransformMethodSignature( Modifier.PRIVATE, "void", writeMethodName, new String[] {fieldType}, null); String body = String.format("%s.getSession(true).setAttribute(\"%s\", $1);", requestField, sessionKey); transformation.addMethod(writeSignature, body); transformation.replaceWriteAccess(fieldName, writeMethodName); }
private void replaceReadAccess( ClassTransformation transformation, String fieldName, String fieldType, String sessionKey, String requestField) { String readMethodName = transformation.newMemberName("read", fieldName); TransformMethodSignature readMethodSignature = new TransformMethodSignature(Modifier.PRIVATE, fieldType, readMethodName, null, null); String body = String.format( "return (%s) %s.getSession(true).getAttribute(\"%s\");", fieldType, requestField, sessionKey); transformation.addMethod(readMethodSignature, body); transformation.replaceReadAccess(fieldName, readMethodName); }