Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ jobs:
- echo 'Waiting for Oracle to boot...' && while ! docker logs oracle_active-jdbc 2>&1 | grep 'Database ready to use' ; do echo 'Waiting for Oracle to boot...'; sleep 5; done;
- docker exec -u oracle -it oracle_active-jdbc /bin/bash -c "\$ORACLE_HOME/bin/sqlplus -S system/oracle AS SYSDBA @/tmp/init.sql"
script:
- echo "Starting Oracle tests"
- sh .travisci/run_tests.sh
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo "Starting Oracle tests"; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sh .travisci/run_tests.sh; fi'

- # ----------------------- mssql -----------------------
env: DB=mssql_travis-ci
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,24 @@
package org.javalite.instrumentation;

import javassist.*;
import javassist.bytecode.AnnotationsAttribute;
import javassist.bytecode.ConstPool;
import javassist.bytecode.SignatureAttribute;
import javassist.bytecode.annotation.Annotation;
import javassist.bytecode.annotation.StringMemberValue;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
*
* @author Igor Polevoy
* @author Eric Nielsen
*/
public class ModelInstrumentation {

private static final String GENERATED_DATE_PATTERN = "yyyy-MM-dd'T'hh:mm:ss.SSSZZZ";

private final CtClass modelClass;

public ModelInstrumentation() throws NotFoundException {
Expand Down Expand Up @@ -83,6 +93,7 @@ private void doInstrument(CtClass target) throws NotFoundException, CannotCompil
newMethod.getMethodInfo().addAttribute((SignatureAttribute) attr);
}
}
addGeneratedAnnotation(newMethod, target);
target.addMethod(newMethod);
}
}
Expand All @@ -97,4 +108,20 @@ private boolean targetHasMethod(CtMethod[] targetMethods, CtMethod delegate) {
}
return false;
}

private void addGeneratedAnnotation(CtMethod generatedMethod, CtClass target)
{
ConstPool constPool = target.getClassFile().getConstPool();
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);

Annotation annot = new Annotation("javax.annotation.Generated", constPool);
annot.addMemberValue("value", new StringMemberValue("org.javalite.instrumentation.ModelInstrumentation", constPool));

ZonedDateTime now = ZonedDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(GENERATED_DATE_PATTERN);
annot.addMemberValue("date", new StringMemberValue(now.format(formatter), constPool));

attr.addAnnotation(annot);
generatedMethod.getMethodInfo().addAttribute(attr);
}
}