Browse Source

REPORT-91824 refactor: fine-hibernate移动到fine-essential

research/11.0
Cloud.Liu 2 years ago
parent
commit
6ba2cbf69c
  1. 2
      base-third-project/base-third-step1/pom.xml
  2. 1
      base-third-project/base-third-step3/pom.xml
  3. 2
      base-third-project/base-third-step5/pom.xml
  4. 10
      build.third_step1-jdk11.gradle
  5. 10
      build.third_step1.gradle
  6. 4
      build.third_step3-jdk11.gradle
  7. 4
      build.third_step3.gradle
  8. 4
      build.third_step4-jdk11.gradle
  9. 4
      build.third_step4.gradle
  10. 8
      build.third_step5-jdk11.gradle
  11. 8
      build.third_step5.gradle
  12. 6
      fine-classmate/.gitignore
  13. 6
      fine-classmate/README.md
  14. 18
      fine-classmate/pom.xml
  15. 115
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/AnnotationConfiguration.java
  16. 44
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/AnnotationInclusion.java
  17. 100
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/AnnotationOverrides.java
  18. 132
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/Annotations.java
  19. 10
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/Filter.java
  20. 25
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/GenericType.java
  21. 238
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/MemberResolver.java
  22. 403
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/ResolvedType.java
  23. 721
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/ResolvedTypeWithMembers.java
  24. 237
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/TypeBindings.java
  25. 552
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/TypeResolver.java
  26. 68
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/HierarchicType.java
  27. 61
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawConstructor.java
  28. 58
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawField.java
  29. 98
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawMember.java
  30. 74
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawMethod.java
  31. 26
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedConstructor.java
  32. 36
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedField.java
  33. 156
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedMember.java
  34. 65
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedMethod.java
  35. 81
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedParameterizedMember.java
  36. 5
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/package-info.java
  37. 13
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/package-info.java
  38. 108
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedArrayType.java
  39. 162
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedInterfaceType.java
  40. 287
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedObjectType.java
  41. 157
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedPrimitiveType.java
  42. 149
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedRecursiveType.java
  43. 101
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/TypePlaceHolder.java
  44. 5
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/package-info.java
  45. 69
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/ClassKey.java
  46. 72
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/ClassStack.java
  47. 71
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/MethodKey.java
  48. 141
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/ResolvedTypeCache.java
  49. 4
      fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/package-info.java
  50. 2
      fine-druid/pom.xml
  51. 6
      fine-ehcache/pom.xml
  52. 6
      fine-hibernate/.gitignore
  53. 9
      fine-hibernate/README.md
  54. BIN
      fine-hibernate/lib/ant-1.8.2.jar
  55. BIN
      fine-hibernate/lib/antlr-3.5.2-complete.jar
  56. BIN
      fine-hibernate/lib/cdi-api-1.1-PFD.jar
  57. BIN
      fine-hibernate/lib/dom4j-1.6.1.jar
  58. BIN
      fine-hibernate/lib/jandex-2.0.3.Final.jar
  59. BIN
      fine-hibernate/lib/jboss-jacc-api_1.4_spec-1.0.2.Final.jar
  60. BIN
      fine-hibernate/lib/junit-4.12.jar
  61. BIN
      fine-hibernate/lib/slf4j-api-1.7.7.jar
  62. BIN
      fine-hibernate/lib/slf4j-simple-1.6.2.jar
  63. BIN
      fine-hibernate/lib/validation-api-1.1.0.Final.jar
  64. 118
      fine-hibernate/pom.xml
  65. 35
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/AnnotationException.java
  66. 46
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/AssertionFailure.java
  67. 104
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/BaseSessionEventListener.java
  68. 212
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/BasicQueryContract.java
  69. 178
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/Cache.java
  70. 94
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/CacheMode.java
  71. 46
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/CallbackException.java
  72. 35
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/ConnectionAcquisitionMode.java
  73. 51
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/ConnectionReleaseMode.java
  74. 566
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/Criteria.java
  75. 157
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/CustomEntityDirtinessStrategy.java
  76. 128
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/DuplicateMappingException.java
  77. 134
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/EmptyInterceptor.java
  78. 61
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/EntityMode.java
  79. 24
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/EntityNameResolver.java
  80. 50
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/FetchMode.java
  81. 72
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/Filter.java
  82. 113
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/FlushMode.java
  83. 183
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/Hibernate.java
  84. 33
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/HibernateError.java
  85. 47
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/HibernateException.java
  86. 60
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/IdentifierLoadAccess.java
  87. 23
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/Incubating.java
  88. 77
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/InstantiationException.java
  89. 276
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/Interceptor.java
  90. 132
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/InvalidMappingException.java
  91. 85
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/JDBCException.java
  92. 39
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/LazyInitializationException.java
  93. 78
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/LobHelper.java
  94. 158
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/LockMode.java
  95. 300
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/LockOptions.java
  96. 44
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/MappingException.java
  97. 76
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/MappingNotFoundException.java
  98. 119
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/MultiIdentifierLoadAccess.java
  99. 82
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/MultiTenancyStrategy.java
  100. 76
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/NaturalIdLoadAccess.java
  101. Some files were not shown because too many files have changed in this diff Show More

2
base-third-project/base-third-step1/pom.xml

@ -16,7 +16,6 @@
<modules>
<module>../../fine-aspectj</module>
<module>../../fine-classmate</module>
<module>../../fine-commons-math3</module>
<module>../../fine-commons-pool</module>
<module>../../fine-cssparser</module>
@ -27,7 +26,6 @@
<module>../../fine-imageJ</module>
<module>../../fine-j2v8</module>
<!-- <module>../../fine-jai</module>-->
<module>../../fine-jboss-transaction-api</module>
<module>../../fine-jgit</module>
<module>../../fine-jna</module>
<module>../../fine-jodd</module>

1
base-third-project/base-third-step3/pom.xml

@ -16,7 +16,6 @@
<modules>
<module>../../fine-itext</module>
<module>../../fine-jboss-logging</module>
</modules>
<build>

2
base-third-project/base-third-step5/pom.xml

@ -15,7 +15,7 @@
<packaging>pom</packaging>
<modules>
<module>../../fine-hibernate</module>
<!-- <module>../../fine-hibernate</module>-->
</modules>
<build>

10
build.third_step1-jdk11.gradle

@ -34,7 +34,6 @@ sourceSets{
"${srcDir}/fine-deprecated-utils/src/main/java",
"${srcDir}/fine-asm/src/main/java",
"${srcDir}/fine-aspectj/src/main/java",
"${srcDir}/fine-classmate/src/main/java",
"${srcDir}/fine-commons-math3/src/main/java",
"${srcDir}/fine-commons-pool/src/main/java",
"${srcDir}/fine-cssparser/src/main/java",
@ -44,7 +43,6 @@ sourceSets{
"${srcDir}/fine-icu4j/src/main/java",
"${srcDir}/fine-j2v8/src/main/java",
// "${srcDir}/fine-jai/src/main/java",
"${srcDir}/fine-jboss-transaction-api/src/main/java",
"${srcDir}/fine-jgit/src/main/java",
"${srcDir}/fine-jna/jna/src/main/java",
"${srcDir}/fine-jna/jna-platform/src/main/java",
@ -58,11 +56,9 @@ sourceSets{
"${srcDir}/fine-third-default/fine-sun-misc/src/main/java",
"${srcDir}/fine-third-default/fine-zip-tools/src/main/java",
"${srcDir}/fine-third-default/fine-sun-jpeg/src/main/java",
"${srcDir}/fine-third-jdk11/fine-activation/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-annotation/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-jws/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-xml-soap/src/main/java",
"${srcDir}/fine-third-jdk11/fine-jaxb/src/main/java",
"${srcDir}/fine-third-jdk11/fine-jaxws/src/main/java"
]
}
@ -75,8 +71,6 @@ def resourceDirs = [
"${srcDir}/fine-asm/src/main/resources",
"${srcDir}/fine-aspectj/src/main/java",
"${srcDir}/fine-aspectj/src/main/resources",
"${srcDir}/fine-classmate/src/main/java",
"${srcDir}/fine-classmate/src/main/resources",
"${srcDir}/fine-commons-math3/src/main/java",
"${srcDir}/fine-commons-math3/src/main/resources",
"${srcDir}/fine-commons-pool/src/main/java",
@ -94,8 +88,6 @@ def resourceDirs = [
"${srcDir}/fine-j2v8/src/main/java",
"${srcDir}/fine-j2v8/src/main/resources",
// "${srcDir}/fine-jai/src/main/java",
"${srcDir}/fine-jboss-transaction-api/src/main/java",
"${srcDir}/fine-jboss-transaction-api/src/main/resources",
"${srcDir}/fine-jgit/src/main/java",
"${srcDir}/fine-jgit/src/main/resources",
"${srcDir}/fine-jna/jna/src/main/resources",
@ -117,11 +109,9 @@ def resourceDirs = [
"${srcDir}/fine-third-default/fine-sun-misc/src/main/java",
"${srcDir}/fine-third-default/fine-zip-tools/src/main/java",
"${srcDir}/fine-third-default/fine-sun-jpeg/src/main/java",
"${srcDir}/fine-third-jdk11/fine-activation/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-annotation/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-jws/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-xml-soap/src/main/java",
"${srcDir}/fine-third-jdk11/fine-jaxb/src/main/java",
"${srcDir}/fine-third-jdk11/fine-jaxws/src/main/java"
]

10
build.third_step1.gradle

@ -35,7 +35,6 @@ sourceSets{
"${srcDir}/fine-deprecated-utils/src/main/java",
"${srcDir}/fine-asm/src/main/java",
"${srcDir}/fine-aspectj/src/main/java",
"${srcDir}/fine-classmate/src/main/java",
"${srcDir}/fine-commons-math3/src/main/java",
"${srcDir}/fine-commons-pool/src/main/java",
"${srcDir}/fine-cssparser/src/main/java",
@ -45,7 +44,6 @@ sourceSets{
"${srcDir}/fine-icu4j/src/main/java",
"${srcDir}/fine-j2v8/src/main/java",
// "${srcDir}/fine-jai/src/main/java",
"${srcDir}/fine-jboss-transaction-api/src/main/java",
"${srcDir}/fine-jgit/src/main/java",
"${srcDir}/fine-jna/jna/src/main/java",
"${srcDir}/fine-jna/jna-platform/src/main/java",
@ -61,11 +59,9 @@ sourceSets{
"${srcDir}/fine-third-default/fine-sun-jpeg/src/main/java",
"${srcDir}/fine-third-jdk8/xml-apis/src/main/java",
"${srcDir}/fine-third-jdk8/fine-mini-tools/tools-common/src/main/java",
"${srcDir}/fine-third-jdk11/fine-activation/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-annotation/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-jws/src/main/java",
"${srcDir}/fine-third-jdk11/fine-javax-xml-soap/src/main/java",
"${srcDir}/fine-third-jdk11/fine-jaxb/src/main/java",
"${srcDir}/fine-third-jdk11/fine-jaxws/src/main/java",
"${srcDir}/fine-skywalking-toolkit-trace/src/main/java"
]
@ -125,8 +121,6 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
with dataContent.call("${srcDir}/fine-asm/src/main/resources")
with dataContent.call("${srcDir}/fine-aspectj/src/main/java")
with dataContent.call("${srcDir}/fine-aspectj/src/main/resources")
with dataContent.call("${srcDir}/fine-classmate/src/main/java")
with dataContent.call("${srcDir}/fine-classmate/src/main/resources")
with dataContent.call("${srcDir}/fine-commons-math3/src/main/java")
with dataContent.call("${srcDir}/fine-commons-math3/src/main/resources")
with dataContent.call("${srcDir}/fine-commons-pool/src/main/java")
@ -142,8 +136,6 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
with dataContent.call("${srcDir}/fine-j2v8/src/main/java")
with dataContent.call("${srcDir}/fine-j2v8/src/main/resources")
// with dataContent.call("${srcDir}/fine-jai/src/main/java")
with dataContent.call("${srcDir}/fine-jboss-transaction-api/src/main/java")
with dataContent.call("${srcDir}/fine-jboss-transaction-api/src/main/resources")
with dataContent.call("${srcDir}/fine-jgit/src/main/java")
with dataContent.call("${srcDir}/fine-jgit/src/main/resources")
with dataContent.call("${srcDir}/fine-jna/jna/src/main/resources")
@ -168,11 +160,9 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
with dataContent.call("${srcDir}/fine-third-jdk8/xml-apis/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk8/fine-mini-tools/tools-common/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk8/fine-mini-tools/tools-common/src/main/resources")
with dataContent.call("${srcDir}/fine-third-jdk11/fine-activation/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk11/fine-javax-annotation/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk11/fine-javax-jws/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk11/fine-javax-xml-soap/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk11/fine-jaxb/src/main/java")
with dataContent.call("${srcDir}/fine-third-jdk11/fine-jaxws/src/main/java")
into "${classesDir}"
}

4
build.third_step3-jdk11.gradle

@ -32,7 +32,6 @@ sourceSets{
srcDirs=[
"${srcDir}/fine-itext/src/main/java",
"${srcDir}/fine-jedis/src/main/java",
"${srcDir}/fine-jboss-logging/src/main/java"
]
}
}
@ -44,8 +43,6 @@ def resourceDirs = [
"${srcDir}/fine-itext/src/main/resources",
"${srcDir}/fine-jedis/src/main/java",
"${srcDir}/fine-jedis/src/main/resources",
"${srcDir}/fine-jboss-logging/src/main/java",
"${srcDir}/fine-jboss-logging/src/main/resources"
]
sourceSets.main.java.outputDir = file('build/classes/3')
@ -78,7 +75,6 @@ String essentialVersion = findProperty("essentialVersion")
//
dependencies{
compileOnly "com.fr.essential:fine-essential:${essentialVersion}"
compile fileTree(dir:"${srcDir}/fine-jboss-logging/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar')
compile fileTree(dir:System.getenv("JAVA_HOME"),include:"lib/tools.jar")
compile group: "com.fr.third.server", name: "servlet-api", version: "3.0"

4
build.third_step3.gradle

@ -26,7 +26,6 @@ sourceSets{
srcDirs=[
"${srcDir}/fine-itext/src/main/java",
"${srcDir}/fine-jedis/src/main/java",
"${srcDir}/fine-jboss-logging/src/main/java"
]
}
}
@ -59,7 +58,6 @@ String essentialVersion = findProperty("essentialVersion")
//
dependencies{
compileOnly "com.fr.essential:fine-essential:${essentialVersion}"
compile fileTree(dir:"${srcDir}/fine-jboss-logging/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar')
compile fileTree(dir:System.getenv("JAVA_HOME"),include:"lib/tools.jar")
compile group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
@ -85,8 +83,6 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
with dataContent.call("${srcDir}/fine-itext/src/main/resources")
with dataContent.call("${srcDir}/fine-jedis/src/main/java")
with dataContent.call("${srcDir}/fine-jedis/src/main/resources")
with dataContent.call("${srcDir}/fine-jboss-logging/src/main/java")
with dataContent.call("${srcDir}/fine-jboss-logging/src/main/resources")
into "${classesDir}"
}
}

4
build.third_step4-jdk11.gradle

@ -32,7 +32,6 @@ sourceSets{
java{
srcDirs=[
"${srcDir}/fine-itext-old/src/main/java",
// "${srcDir}/fine-hibernate/src/main/java",
"${srcDir}/fine-spring/src/main/java"
]
}
@ -44,8 +43,6 @@ def resourceDirs = [
"${srcDir}/fine-itext-old/src/main/java",
"${srcDir}/fine-itext-old/src/main/resources",
"${srcDir}/fine-spring/src/main/java",
// "${srcDir}/fine-hibernate/src/main/java",
// "${srcDir}/fine-hibernate/src/main/resources",
"${srcDir}/fine-spring/src/main/resources"
]
@ -79,7 +76,6 @@ String essentialVersion = findProperty("essentialVersion")
//
dependencies{
compileOnly "com.fr.essential:fine-essential:${essentialVersion}"
// compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/fine-spring/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar')
compile fileTree(dir:System.getenv("JAVA_HOME"),include:"lib/tools.jar")

4
build.third_step4.gradle

@ -25,7 +25,6 @@ sourceSets{
java{
srcDirs=[
"${srcDir}/fine-itext-old/src/main/java",
// "${srcDir}/fine-hibernate/src/main/java",
"${srcDir}/fine-spring/src/main/java"
]
}
@ -60,7 +59,6 @@ String essentialVersion = findProperty("essentialVersion")
//
dependencies{
compileOnly "com.fr.essential:fine-essential:${essentialVersion}"
// compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/fine-spring/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar')
compile fileTree(dir:System.getenv("JAVA_HOME"),include:"lib/tools.jar")
@ -86,8 +84,6 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
println "------------------------------------------------copyfiles"
with dataContent.call("${srcDir}/fine-itext-old/src/main/java")
with dataContent.call("${srcDir}/fine-itext-old/src/main/resources")
// with dataContent.call("${srcDir}/fine-hibernate/src")
// with dataContent.call("${srcDir}/fine-hibernate/resources")
with dataContent.call("${srcDir}/fine-spring/src/main/java")
with dataContent.call("${srcDir}/fine-spring/src/main/resources")
into "${classesDir}"

8
build.third_step5-jdk11.gradle

@ -25,7 +25,7 @@ sourceSets{
java{
srcDirs=[
// "${srcDir}/fine-itext-old/src",
"${srcDir}/fine-hibernate/src/main/java",
// "${srcDir}/fine-hibernate/src/main/java",
// "${srcDir}/fine-spring/src"
]
}
@ -37,8 +37,8 @@ def resourceDirs = [
// "${srcDir}/fine-itext-old/src",
// "${srcDir}/fine-spring/src",
// "${srcDir}/fine-spring/resources",
"${srcDir}/fine-hibernate/src/main/java",
"${srcDir}/fine-hibernate/src/main/resources"
// "${srcDir}/fine-hibernate/src/main/java",
// "${srcDir}/fine-hibernate/src/main/resources"
]
sourceSets.main.java.outputDir = file('build/classes/5')
@ -71,7 +71,7 @@ String essentialVersion = findProperty("essentialVersion")
//
dependencies{
compileOnly "com.fr.essential:fine-essential:${essentialVersion}"
compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar')
// compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar')
// compile fileTree(dir:"${srcDir}/fine-spring/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar')
compile fileTree(dir:System.getenv("JAVA_HOME"),include:"lib/tools.jar")

8
build.third_step5.gradle

@ -25,7 +25,7 @@ sourceSets{
java{
srcDirs=[
// "${srcDir}/fine-itext-old/src",
"${srcDir}/fine-hibernate/src/main/java",
// "${srcDir}/fine-hibernate/src/main/java",
// "${srcDir}/fine-spring/src"
]
}
@ -60,7 +60,7 @@ String essentialVersion = findProperty("essentialVersion")
//
dependencies{
compileOnly "com.fr.essential:fine-essential:${essentialVersion}"
compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar')
// compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar')
// compile fileTree(dir:"${srcDir}/fine-spring/lib",include:'**/*.jar')
compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar')
compile fileTree(dir:System.getenv("JAVA_HOME"),include:"lib/tools.jar")
@ -85,8 +85,8 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
copy{
println "------------------------------------------------copyfiles"
// with dataContent.call("${srcDir}/fine-itext-old/src")
with dataContent.call("${srcDir}/fine-hibernate/src/main/java")
with dataContent.call("${srcDir}/fine-hibernate/src/main/resources")
// with dataContent.call("${srcDir}/fine-hibernate/src/main/java")
// with dataContent.call("${srcDir}/fine-hibernate/src/main/resources")
// with dataContent.call("${srcDir}/fine-spring/src")
// with dataContent.call("${srcDir}/fine-spring/resources")
into "${classesDir}"

6
fine-classmate/.gitignore vendored

@ -1,6 +0,0 @@
*.iml
.idea/
.DS_Store
.project
.classpath
*.gradle

6
fine-classmate/README.md

@ -1,6 +0,0 @@
# fine-classmate
改包名的classmate(1.3.0),以下模块需要依赖该模块:
- fine-hibernate

18
fine-classmate/pom.xml

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fr.third</groupId>
<artifactId>step1</artifactId>
<version>${revision}</version>
<relativePath>../base-third-project/base-third-step1</relativePath>
</parent>
<artifactId>fine-classmate</artifactId>
<version>${revision}</version>
</project>

115
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/AnnotationConfiguration.java

@ -1,115 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.util.ClassKey;
/**
* Interface for object that determines handling of annotations in regards
* to inheritance, overrides.
*/
@SuppressWarnings("serial")
public abstract class AnnotationConfiguration implements Serializable
{
/**
* Method called to figure out how to handle instances of specified annotation
* type when used as class annotation.
*/
public abstract AnnotationInclusion getInclusionForClass(Class<? extends Annotation> annotationType);
/**
* Method called to figure out how to handle instances of specified annotation
* type when used as constructor annotation.
*<p>
* Note that constructor annotations can never be inherited so this just determines
* between inclusion or non-inclusion.
*/
public abstract AnnotationInclusion getInclusionForConstructor(Class<? extends Annotation> annotationType);
/**
* Method called to figure out how to handle instances of specified annotation
* type when used as field annotation.
*<p>
* Note that field annotations can never be inherited so this just determines
* between inclusion or non-inclusion.
*/
public abstract AnnotationInclusion getInclusionForField(Class<? extends Annotation> annotationType);
/**
* Method called to figure out how to handle instances of specified annotation
* type when used as method annotation.
*<p>
* Note that method annotations can be inherited for member methods, but not for static
* methods; for static methods thereby this just determines between inclusion and
* non-inclusion.
*/
public abstract AnnotationInclusion getInclusionForMethod(Class<? extends Annotation> annotationType);
/**
* Method called to figure out how to handle instances of specified annotation
* type when used as parameter annotation.
*<p>
* Note that parameter annotations can be inherited for member methods, but not for static
* methods; for static methods thereby this just determines between inclusion and
* non-inclusion.
*/
public abstract AnnotationInclusion getInclusionForParameter(Class<? extends Annotation> annotationType);
/**
* Simple implementation that can be configured with default behavior
* for unknown annotations, as well as explicit behaviors for
* enumerated annotation types. Same default is used for both class and
* member method annotations (constructor, field and static method
* annotations are never inherited)
*/
public static class StdConfiguration extends AnnotationConfiguration implements Serializable
{
protected final AnnotationInclusion _defaultInclusion;
protected final HashMap<ClassKey,AnnotationInclusion> _inclusions = new HashMap<ClassKey,AnnotationInclusion>();
public StdConfiguration(AnnotationInclusion defaultBehavior)
{
_defaultInclusion = defaultBehavior;
}
@Override
public AnnotationInclusion getInclusionForClass(Class<? extends Annotation> annotationType) {
return _inclusionFor(annotationType);
}
@Override
public AnnotationInclusion getInclusionForConstructor(Class<? extends Annotation> annotationType) {
return _inclusionFor(annotationType);
}
@Override
public AnnotationInclusion getInclusionForField(Class<? extends Annotation> annotationType) {
return getInclusionForClass(annotationType);
}
@Override
public AnnotationInclusion getInclusionForMethod(Class<? extends Annotation> annotationType) {
return getInclusionForClass(annotationType);
}
@Override
public AnnotationInclusion getInclusionForParameter(Class<? extends Annotation> annotationType) {
return getInclusionForClass(annotationType);
}
public void setInclusion(Class<? extends Annotation> annotationType, AnnotationInclusion incl)
{
_inclusions.put(new ClassKey(annotationType), incl);
}
protected AnnotationInclusion _inclusionFor(Class<? extends Annotation> annotationType)
{
ClassKey key = new ClassKey(annotationType);
AnnotationInclusion beh = _inclusions.get(key);
return (beh == null) ? _defaultInclusion : beh;
}
}
}

44
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/AnnotationInclusion.java

@ -1,44 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
/**
* Enumeration that defines different settings for handling behavior
* of individual annotations
*/
public enum AnnotationInclusion
{
/**
* Value that indicates that annotation is to be ignored, not included
* in resolved bean information.
* Applicable to all member types.
*/
DONT_INCLUDE,
/**
* Value that indicates that annotation is to be included in results, but
* only if directly associated with included member (or attached mix-in);
* will not inherit from supertypes.
* Applicable only to member methods; if used with other members will
* mean basic inclusion.
*/
INCLUDE_BUT_DONT_INHERIT,
/**
* Value that indicates that annotation is to be included in results, and
* values from overridden members are inherited only if the annotation is
* marked with the {@link java.lang.annotation.Inherited} annotation.
* Applicable only to member methods; if used with other members will
* mean basic inclusion.
*/
INCLUDE_AND_INHERIT_IF_INHERITED,
/**
* Value that indicates that annotation is to be included in results; and
* values from overridden members are also inherited if not overridden
* by members of subtypes.
* Note that inheritance only matters with member methods; for other types
* it just means "include".
*/
INCLUDE_AND_INHERIT
;
}

100
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/AnnotationOverrides.java

@ -1,100 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.io.Serializable;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.util.ClassKey;
/**
* Interface for object that can provide mix-ins to override annotations.
*/
@SuppressWarnings("serial")
public abstract class AnnotationOverrides implements Serializable
{
/*
/**********************************************************************
/* Public API
/**********************************************************************
*/
/**
* Method called to find out which class(es) are to be used as source
* for annotations to mix in for given type.
*
* @return List of mix-in sources (starting with highest priority);
* can be null or empty list if no mix-ins are to be used.
*/
public List<Class<?>> mixInsFor(Class<?> beanClass) {
return mixInsFor(new ClassKey(beanClass));
}
public abstract List<Class<?>> mixInsFor(ClassKey beanClass);
/**
* Method for constructing builder for creating simple overrides provider
* that just uses direct assignments (target-to-override classes)
*/
public static StdBuilder builder() {
return new StdBuilder();
}
/*
/**********************************************************************
/* Helper types
/**********************************************************************
*/
/**
* To make it easy to use simple override implementation (where overrides
* are direct and explicit), here is a build that allow constructing
* such override instance.
*/
public static class StdBuilder
{
protected final HashMap<ClassKey,List<Class<?>>> _targetsToOverrides = new HashMap<ClassKey,List<Class<?>>>();
public StdBuilder() { }
public StdBuilder add(Class<?> target, Class<?> mixin) {
return add(new ClassKey(target), mixin);
}
public StdBuilder add(ClassKey target, Class<?> mixin)
{
List<Class<?>> mixins = _targetsToOverrides.get(target);
if (mixins == null) {
mixins = new ArrayList<Class<?>>();
_targetsToOverrides.put(target, mixins);
}
mixins.add(mixin);
return this;
}
/**
* Method that will construct a {@link AnnotationOverrides} instance using
* mappings that have been added using this builder
*/
public AnnotationOverrides build() {
return new StdImpl(_targetsToOverrides);
}
}
/**
* Simple implementation configured with explicit associations with
* target class as key, and overrides as ordered list of classes
* (with first entry having precedence over later ones).
*/
public static class StdImpl extends AnnotationOverrides
{
protected final HashMap<ClassKey,List<Class<?>>> _targetsToOverrides;
public StdImpl(HashMap<ClassKey,List<Class<?>>> overrides) {
_targetsToOverrides = new HashMap<ClassKey,List<Class<?>>>(overrides);
}
@Override
public List<Class<?>> mixInsFor(ClassKey target) {
return _targetsToOverrides.get(target);
}
}
}

132
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/Annotations.java

@ -1,132 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.util.*;
/**
* Container class used for storing set of annotations resolved for types (classes)
* as members (methods, fields, constructors).
*
* @author tatu
*/
@SuppressWarnings("serial")
public class Annotations implements Serializable, Iterable<Annotation>
{
private final Annotation[] NO_ANNOTATIONS = new Annotation[0];
protected LinkedHashMap<Class<? extends Annotation>,Annotation> _annotations;
/*
/**********************************************************************
/* Life-cycle
/**********************************************************************
*/
public Annotations() { }
/**
* Method for adding specified annotation, overriding existing value
* for the annotation type.
*/
public void add(Annotation override)
{
if (_annotations == null) {
_annotations = new LinkedHashMap<Class<? extends Annotation>,Annotation>();
}
_annotations.put(override.annotationType(), override);
}
/**
* Method for adding all annotations from specified set, as overrides
* to annotations this set has
*/
public void addAll(Annotations overrides)
{
if (_annotations == null) {
_annotations = new LinkedHashMap<Class<? extends Annotation>,Annotation>();
}
for (Annotation override : overrides._annotations.values()) {
_annotations.put(override.annotationType(), override);
}
}
/**
* Method for adding specified annotation if and only if no value
* exists for the annotation type.
*/
public void addAsDefault(Annotation defValue)
{
Class<? extends Annotation> type = defValue.annotationType();
if (_annotations == null) {
_annotations = new LinkedHashMap<Class<? extends Annotation>,Annotation>();
_annotations.put(type, defValue);
} else if (!_annotations.containsKey(type)) {
_annotations.put(type, defValue);
}
}
/*
/**********************************************************************
/* Accessors
/**********************************************************************
*/
@Override
public Iterator<Annotation> iterator()
{
if (_annotations == null) {
_annotations = new LinkedHashMap<Class<? extends Annotation>,Annotation>();
}
return _annotations.values().iterator();
}
public int size() {
return (_annotations == null) ? 0 : _annotations.size();
}
@SuppressWarnings("unchecked")
public <A extends Annotation> A get(Class<A> cls)
{
if (_annotations == null) {
return null;
}
return (A) _annotations.get(cls);
}
/**
* @since 1.1.1
*/
public Annotation[] asArray() {
if (_annotations == null || _annotations.isEmpty()) {
return NO_ANNOTATIONS;
}
return _annotations.values().toArray(new Annotation[_annotations.size()]);
}
/**
* @since 1.1.1
*/
public List<Annotation> asList() {
if (_annotations == null || _annotations.isEmpty()) {
return Collections.emptyList();
}
List<Annotation> l = new ArrayList<Annotation>(_annotations.size());
l.addAll(_annotations.values());
return l;
}
/*
/**********************************************************************
/* Standard method overrides
/**********************************************************************
*/
@Override public String toString()
{
if (_annotations == null) {
return "[null]";
}
return _annotations.toString();
}
}

10
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/Filter.java

@ -1,10 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
/**
* Interface that defines API for basic filtering objects, used to prune set
* of things to include in result sets like flattened member lists.
*/
public interface Filter<T>
{
public boolean include(T element);
}

25
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/GenericType.java

@ -1,25 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.io.Serializable;
/**
* This class is used to pass full generics type information, and
* avoid problems with type erasure (that basically removes most
* usable type references from runtime Class objects).
* It is based on ideas from
* <a href="http://gafter.blogspot.com/2006/12/super-type-tokens.html"
* >http://gafter.blogspot.com/2006/12/super-type-tokens.html</a>,
*<p>
* Usage is by sub-classing: here is one way to instantiate reference
* to generic type <code>List&lt;Integer></code>:
*<pre>
* GenericType type = new GenericType&lt;List&lt;Integer>>() { };
*</pre>
* which can be passed to methods that accept <code>GenericReference</code>.
*/
@SuppressWarnings("serial")
public abstract class GenericType<T>
implements Serializable, java.lang.reflect.Type
{
protected GenericType() { }
}

238
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/MemberResolver.java

@ -1,238 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.io.Serializable;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.members.RawField;
import com.fr.third.com.fasterxml.classmate.util.ClassKey;
import com.fr.third.com.fasterxml.classmate.members.HierarchicType;
import com.fr.third.com.fasterxml.classmate.members.RawConstructor;
import com.fr.third.com.fasterxml.classmate.members.RawMethod;
/**
* Builder class used to completely resolve members (fields, methods,
* constructors) of {@link ResolvedType}s (generics-aware classes).
*/
@SuppressWarnings("serial")
public class MemberResolver implements Serializable
{
/**
* Type resolved needed for resolving types of member objects
* (method argument and return; field types; constructor argument types)
*/
protected final TypeResolver _typeResolver;
/*
/**********************************************************************
/* Modifiable configuration
/**********************************************************************
*/
/**
* Configuration setting that determines whether members from
* {@link java.lang.Object} are included or not; by default
* false meaning that they are not.
*/
protected boolean _cfgIncludeLangObject;
/**
* Filter used for determining whether given
* field (static or member)
* is to be included in aggregation of all
* fields.
*/
protected Filter<RawField> _fieldFilter;
/**
* Filter used for determining whether given
* method (static or member)
* is to be included in aggregation of all
* methods.
*/
protected Filter<RawMethod> _methodFilter;
/**
* Filter used for determining whether given
* constructor
* is to be included in aggregation of all
* constructors.
*/
protected Filter<RawConstructor> _constructorFilter;
/*
/**********************************************************************
/* Life cycle (construct and config)
/**********************************************************************
*/
/**
* Constructor for resolver that does not include <code>java.lang.Object</code>
* in type hierarchy
*/
public MemberResolver(TypeResolver typeResolver)
{
_typeResolver = typeResolver;
}
/**
* Configuration method for specifying whether members of <code>java.lang.Object</code>
* are to be included in resolution; if false, no members from {@link java.lang.Object}
* are to be included; if true, will be included.
*/
public MemberResolver setIncludeLangObject(boolean state) {
_cfgIncludeLangObject = state;
return this;
}
public MemberResolver setFieldFilter(Filter<RawField> f) {
_fieldFilter = f;
return this;
}
public MemberResolver setMethodFilter(Filter<RawMethod> f) {
_methodFilter = f;
return this;
}
public MemberResolver setConstructorFilter(Filter<RawConstructor> f) {
_constructorFilter = f;
return this;
}
/*
/**********************************************************************
/* Public API
/**********************************************************************
*/
/**
* Method for constructing hierarchy object needed to fully resolve
* member information, including basic type flattening as well as
* addition of mix-in types in appropriate positions.
*
* @param mainType Resolved type that is the starting point (i.e. the leaf class)
* for member resolution.
* @param annotationConfig Configuration of annotation types; which ones to include, how to inherit
* @param annotationOverrides Definitions of annotation overrides to use, if any (may be null)
*/
public ResolvedTypeWithMembers resolve(final ResolvedType mainType,
AnnotationConfiguration annotationConfig,
AnnotationOverrides annotationOverrides)
{
// First: flatten basic type hierarchy (highest to lowest precedence)
HashSet<ClassKey> seenTypes = new HashSet<ClassKey>();
ArrayList<ResolvedType> types = new ArrayList<ResolvedType>();
_gatherTypes(mainType, seenTypes, types);
// Second step: inject mix-ins (keeping order from highest to lowest)
HierarchicType[] htypes;
HierarchicType mainHierarchicType = null;
// Third step: add mix-ins (if any), reverse order (lowest to highest precedence)
if (annotationOverrides == null) { // just create hierarchic instances:
int len = types.size();
htypes = new HierarchicType[len];
for (int i = 0; i < len; ++i) {
// false -> not a mix-in
htypes[i] = new HierarchicType(types.get(i), false, i);
}
mainHierarchicType = htypes[0];
} else { // need to add mix-ins, reorder
ArrayList<HierarchicType> typesWithMixins = new ArrayList<HierarchicType>();
for (ResolvedType type : types) {
// First add mix-ins (which override type itself)
List<Class<?>> m = annotationOverrides.mixInsFor(type.getErasedType());
if (m != null) {
for (Class<?> mixinClass : m) {
_addOverrides(typesWithMixins, seenTypes, mixinClass);
}
}
// Then actual type:
HierarchicType ht = new HierarchicType(type, false, typesWithMixins.size());
if (mainHierarchicType == null) {
mainHierarchicType = ht;
}
typesWithMixins.add(ht);
}
htypes = typesWithMixins.toArray(new HierarchicType[typesWithMixins.size()]);
}
// And that's about all we need to do; rest computed lazily
return new ResolvedTypeWithMembers(_typeResolver, annotationConfig, mainHierarchicType, htypes,
_constructorFilter, _fieldFilter, _methodFilter);
}
private void _addOverrides(List<HierarchicType> typesWithOverrides, Set<ClassKey> seenTypes, Class<?> override)
{
ClassKey key = new ClassKey(override);
if (!seenTypes.contains(key)) {
seenTypes.add(key);
ResolvedType resolvedOverride = _typeResolver.resolve(override);
typesWithOverrides.add(new HierarchicType(resolvedOverride, true, typesWithOverrides.size()));
for (ResolvedType r : resolvedOverride.getImplementedInterfaces()) { // interfaces?
_addOverrides(typesWithOverrides, seenTypes, r);
}
ResolvedType superClass = resolvedOverride.getParentClass();
_addOverrides(typesWithOverrides, seenTypes, superClass);
}
}
private void _addOverrides(List<HierarchicType> typesWithOverrides, Set<ClassKey> seenTypes, ResolvedType override)
{
if (override == null) return;
// first: may need to exclude Object.class:
Class<?> raw = override.getErasedType();
if (!_cfgIncludeLangObject && Object.class == raw) return;
ClassKey key = new ClassKey(raw);
if (!seenTypes.contains(key)) {
seenTypes.add(key);
typesWithOverrides.add(new HierarchicType(override, true, typesWithOverrides.size()));
for (ResolvedType r : override.getImplementedInterfaces()) { // interfaces?
_addOverrides(typesWithOverrides, seenTypes, r);
}
ResolvedType superClass = override.getParentClass();
if (superClass != null) {
_addOverrides(typesWithOverrides, seenTypes, superClass);
}
}
}
/*
/**********************************************************************
/* Internal methods
/**********************************************************************
*/
protected void _gatherTypes(ResolvedType currentType, Set<ClassKey> seenTypes, List<ResolvedType> types)
{
// may get called with null if no parent type
if (currentType == null) {
return;
}
Class<?> raw = currentType.getErasedType();
// Also, don't include Object.class unless that's ok
if (!_cfgIncludeLangObject && raw == Object.class) {
return;
}
// Finally, only include first instance of an interface, so:
ClassKey key = new ClassKey(currentType.getErasedType());
if (seenTypes.contains(key)) {
return;
}
// If all good so far, append
seenTypes.add(key);
types.add(currentType);
/* and check supertypes; starting with interfaces. Why interfaces?
* So that "highest" interfaces get priority; otherwise we'd recurse
* super-class stack and actually start with the bottom. Usually makes
* little difference, but in cases where it does this seems like the
* correct order.
*/
for (ResolvedType t : currentType.getImplementedInterfaces()) {
_gatherTypes(t, seenTypes, types);
}
// and then superclass
_gatherTypes(currentType.getParentClass(), seenTypes, types);
}
}

403
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/ResolvedType.java

@ -1,403 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import com.fr.third.com.fasterxml.classmate.members.RawConstructor;
import com.fr.third.com.fasterxml.classmate.members.RawField;
import com.fr.third.com.fasterxml.classmate.members.RawMethod;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public abstract class ResolvedType
implements Type
{
public final static ResolvedType[] NO_TYPES = new ResolvedType[0];
protected final static RawConstructor[] NO_CONSTRUCTORS = new RawConstructor[0];
protected final static RawField[] NO_FIELDS = new RawField[0];
protected final static RawMethod[] NO_METHODS = new RawMethod[0];
protected final Class<?> _erasedType;
/**
* Type bindings active when resolving members (methods, fields,
* constructors) of this type
*/
protected final TypeBindings _typeBindings;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
protected ResolvedType(Class<?> cls, TypeBindings bindings)
{
_erasedType = cls;
_typeBindings = (bindings == null) ? TypeBindings.emptyBindings() : bindings;
}
/**
* Method that can be used to check if call to {@link TypeResolver#resolveSubtype(ResolvedType, Class)}
* may ever succeed; if false, it will fail with an exception, if true, it may succeed.
*/
public abstract boolean canCreateSubtypes();
/**
* Method that can be used to check if call to {@link TypeResolver#resolveSubtype(ResolvedType, Class)}
* will succeed for specific type; if false, it will fail with an exception; if tru it
* will succeed.
*/
public final boolean canCreateSubtype(Class<?> subtype) {
return canCreateSubtypes() && _erasedType.isAssignableFrom(subtype);
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
/**
* Returns type-erased Class<?> that this resolved type has.
*/
public Class<?> getErasedType() { return _erasedType; }
/**
* Returns parent class of this type, if it has one; primitive types
* and interfaces have no parent class, nor does Object type
* {@link java.lang.Object}.
* Also, placeholders for cyclic (recursive) types return null for
* this method.
*/
public abstract ResolvedType getParentClass();
/**
* Accessor that must be used to find out actual type in
* case of "self-reference"; case where type refers
* recursive to itself (like, <code>T implements Comparable&lt;T></code>).
* For all other types returns null but for self-references "real" type.
* Separate accessor is provided to avoid accidental infinite loops.
*/
public abstract ResolvedType getSelfReferencedType();
/**
* Method that can be used to access element type of array types; will return
* null for non-array types, and non-null type for array types.
*/
public abstract ResolvedType getArrayElementType();
/**
* Returns ordered list of interfaces (in declaration order) that this type
* implements.
*
* @return List of interfaces this type implements, if any; empty list if none
*/
public abstract List<ResolvedType> getImplementedInterfaces();
/**
* Returns list of generic type declarations for this type, in order they
* are declared in class description.
*/
public List<ResolvedType> getTypeParameters() {
return _typeBindings.getTypeParameters();
}
/**
* Method for accessing bindings of type variables to resolved types in context
* of this type. It has same number of entries as return List of
* {@link #getTypeParameters}, accessible using declared name to which they
* bind; for example, {@link java.util.Map} has 2 type bindings; one for
* key type (name "K", from Map.java) and one for value type
* (name "V", from Map.java).
*/
public TypeBindings getTypeBindings() { return _typeBindings; }
/**
* Method that will try to find type parameterization this type
* has for specified super type
*
* @return List of type parameters for specified supertype (which may
* be empty, if supertype is not a parametric type); null if specified
* type is not a super type of this type
*/
public List<ResolvedType> typeParametersFor(Class<?> erasedSupertype)
{
ResolvedType type = findSupertype(erasedSupertype);
if (type != null) {
return type.getTypeParameters();
}
// nope; doesn't look like we extend or implement super type in question
return null;
}
/**
* Method for finding super type of this type that has specified type
* erased signature. If supertype is an interface which is implemented
* using multiple inheritance paths, preference is given to interfaces
* implemented "highest up the stack" (directly implemented interfaces
* over interfaces superclass implements).
*/
public ResolvedType findSupertype(Class<?> erasedSupertype)
{
if (erasedSupertype == _erasedType) {
return this;
}
// Check super interfaces first:
if (erasedSupertype.isInterface()) {
for (ResolvedType it : getImplementedInterfaces()) {
ResolvedType type = it.findSupertype(erasedSupertype);
if (type != null) {
return type;
}
}
}
// and if not found, super class and its supertypes
ResolvedType pc = getParentClass();
if (pc != null) {
ResolvedType type = pc.findSupertype(erasedSupertype);
if (type != null) {
return type;
}
}
// nope; doesn't look like we extend or implement super type in question
return null;
}
/*
/**********************************************************************
/* Accessors for simple properties
/**********************************************************************
*/
public abstract boolean isInterface();
public final boolean isConcrete() { return !isAbstract(); }
public abstract boolean isAbstract();
/**
* Method that indicates whether this type is an array type.
*/
public abstract boolean isArray();
/**
* Method that indicates whether this type is one of small number of primitive
* Java types; not including array types of primitive types but just basic
* primitive types.
*/
public abstract boolean isPrimitive();
public final boolean isInstanceOf(Class<?> type) {
return type.isAssignableFrom(_erasedType);
}
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
public List<RawConstructor> getConstructors() { return Collections.emptyList(); }
public List<RawField> getMemberFields() { return Collections.emptyList(); }
public List<RawMethod> getMemberMethods() { return Collections.emptyList(); }
public List<RawField> getStaticFields() { return Collections.emptyList(); }
public List<RawMethod> getStaticMethods() { return Collections.emptyList(); }
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
/**
* Method that returns full generic signature of the type; suitable
* as signature for things like ASM package.
*/
public String getSignature() {
StringBuilder sb = new StringBuilder();
return appendSignature(sb).toString();
}
/**
* Method that returns type erased signature of the type; suitable
* as non-generic signature some packages need
*/
public String getErasedSignature() {
StringBuilder sb = new StringBuilder();
return appendErasedSignature(sb).toString();
}
/**
* Human-readable full description of type, which includes specification
* of super types (in brief format)
*/
public String getFullDescription() {
StringBuilder sb = new StringBuilder();
return appendFullDescription(sb).toString();
}
/**
* Human-readable brief description of type, which does not include
* information about super types.
*/
public String getBriefDescription() {
StringBuilder sb = new StringBuilder();
return appendBriefDescription(sb).toString();
}
public abstract StringBuilder appendBriefDescription(StringBuilder sb);
public abstract StringBuilder appendFullDescription(StringBuilder sb);
public abstract StringBuilder appendSignature(StringBuilder sb);
public abstract StringBuilder appendErasedSignature(StringBuilder sb);
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public String toString() {
return getBriefDescription();
}
@Override public int hashCode() {
return _erasedType.getName().hashCode() + _typeBindings.hashCode();
}
@Override public boolean equals(Object o)
{
if (o == this) return true;
// sub-types must be same:
if (o == null || o.getClass() != getClass()) return false;
// Should be possible to actually implement here...
ResolvedType other = (ResolvedType) o;
if (other._erasedType != _erasedType) {
return false;
}
// and type bindings must match as well
return _typeBindings.equals(other._typeBindings);
}
/*
/**********************************************************************
/* Helper methods for sub-classes; string construction
/**********************************************************************
*/
protected StringBuilder _appendClassSignature(StringBuilder sb)
{
sb.append('L');
sb = _appendClassName(sb);
int count = _typeBindings.size();
if (count > 0) {
sb.append('<');
for (int i = 0; i < count; ++i) {
sb = _typeBindings.getBoundType(i).appendErasedSignature(sb);
}
sb.append('>');
}
sb.append(';');
return sb;
}
protected StringBuilder _appendErasedClassSignature(StringBuilder sb)
{
sb.append('L');
sb = _appendClassName(sb);
sb.append(';');
return sb;
}
protected StringBuilder _appendClassDescription(StringBuilder sb)
{
sb.append(_erasedType.getName());
int count = _typeBindings.size();
if (count > 0) {
sb.append('<');
for (int i = 0; i < count; ++i) {
if (i > 0) {
sb.append(',');
}
sb = _typeBindings.getBoundType(i).appendBriefDescription(sb);
}
sb.append('>');
}
return sb;
}
protected StringBuilder _appendClassName(StringBuilder sb)
{
String name = _erasedType.getName();
for (int i = 0, len = name.length(); i < len; ++i) {
char c = name.charAt(i);
if (c == '.') c = '/';
sb.append(c);
}
return sb;
}
/*
/**********************************************************************
/* Helper methods for sub-classes; gathering members
/**********************************************************************
*/
/**
* @param statics Whether to return static methods (true) or member methods (false)
*/
protected RawField[] _getFields(boolean statics)
{
ArrayList<RawField> fields = new ArrayList<RawField>();
for (Field f : _erasedType.getDeclaredFields()) {
// Only skip synthetic fields, which should not really be exposed
if (!f.isSynthetic()) {
if (Modifier.isStatic(f.getModifiers()) == statics) {
fields.add(new RawField(this, f));
}
}
}
if (fields.isEmpty()) {
return NO_FIELDS;
}
return fields.toArray(new RawField[fields.size()]);
}
/**
* @param statics Whether to return static methods (true) or member methods (false)
*/
protected RawMethod[] _getMethods(boolean statics)
{
ArrayList<RawMethod> methods = new ArrayList<RawMethod>();
for (Method m : _erasedType.getDeclaredMethods()) {
// Only skip synthetic fields, which should not really be exposed
if (!m.isSynthetic()) {
if (Modifier.isStatic(m.getModifiers()) == statics) {
methods.add(new RawMethod(this, m));
}
}
}
if (methods.isEmpty()) {
return NO_METHODS;
}
return methods.toArray(new RawMethod[methods.size()]);
}
protected RawConstructor[] _getConstructors()
{
ArrayList<RawConstructor> ctors = new ArrayList<RawConstructor>();
for (Constructor<?> c : _erasedType.getDeclaredConstructors()) {
// Only skip synthetic fields, which should not really be exposed
if (!c.isSynthetic()) {
ctors.add(new RawConstructor(this, c));
}
}
if (ctors.isEmpty()) {
return NO_CONSTRUCTORS;
}
return ctors.toArray(new RawConstructor[ctors.size()]);
}
}

721
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/ResolvedTypeWithMembers.java

@ -1,721 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.lang.annotation.Annotation;
import java.lang.annotation.Inherited;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.members.HierarchicType;
import com.fr.third.com.fasterxml.classmate.members.RawConstructor;
import com.fr.third.com.fasterxml.classmate.members.RawField;
import com.fr.third.com.fasterxml.classmate.members.RawMethod;
import com.fr.third.com.fasterxml.classmate.members.ResolvedConstructor;
import com.fr.third.com.fasterxml.classmate.members.ResolvedField;
import com.fr.third.com.fasterxml.classmate.members.ResolvedMethod;
import com.fr.third.com.fasterxml.classmate.util.MethodKey;
/**
* Class that contains information about fully resolved members of a
* type; resolution meaning that masking is handled for methods, and
* all inheritable annotations are flattened using optional overrides
* as well ("mix-in annotations").
* Instances are created by {@link MemberResolver}.
*<p>
* Note that instances are not thread-safe, as the expectation is that instances
* will not be shared (unlike raw members or resolved types)
*/
public class ResolvedTypeWithMembers
{
private final static ResolvedType[] NO_RESOLVED_TYPES = new ResolvedType[0];
private final static ResolvedMethod[] NO_RESOLVED_METHODS = new ResolvedMethod[0];
private final static ResolvedField[] NO_RESOLVED_FIELDS = new ResolvedField[0];
private final static ResolvedConstructor[] NO_RESOLVED_CONSTRUCTORS = new ResolvedConstructor[0];
/**
* Default annotation configuration is to ignore all annotations types.
*/
protected final static AnnotationConfiguration DEFAULT_ANNOTATION_CONFIG
= new AnnotationConfiguration.StdConfiguration(AnnotationInclusion.DONT_INCLUDE);
/**
* Need to be able to resolve member types still
*/
protected final TypeResolver _typeResolver;
/**
* Handler for resolving annotation information
*/
protected final AnnotationHandler _annotationHandler;
/**
* Leaf of the type hierarchy, i.e. type from which this hierarchy
* was generated.
*/
protected final HierarchicType _mainType;
/**
* All types that hierarchy contains, in order of increasing precedence
* (that is, later entries override members of earlier members)
*/
protected final HierarchicType[] _types;
/**
* Filter to use for selecting fields to include
*/
protected Filter<RawField> _fieldFilter;
/**
* Filter to use for selecting constructors to include
*/
protected Filter<RawConstructor> _constructorFilter;
/**
* Filter to use for selecting methods to include
*/
protected Filter<RawMethod> _methodFilter;
/*
/**********************************************************************
/* Lazily constructed members
/**********************************************************************
*/
protected ResolvedMethod[] _staticMethods = null;
protected ResolvedField[] _staticFields = null;
protected ResolvedMethod[] _memberMethods = null;
protected ResolvedField[] _memberFields = null;
protected ResolvedConstructor[] _constructors = null;
/*
/**********************************************************************
/* Life cycle at this point
/**********************************************************************
*/
public ResolvedTypeWithMembers(TypeResolver typeResolver, AnnotationConfiguration annotationConfig,
HierarchicType mainType, HierarchicType[] types,
Filter<RawConstructor> constructorFilter, Filter<RawField> fieldFilter, Filter<RawMethod> methodFilter)
{
_typeResolver = typeResolver;
_mainType = mainType;
_types = types;
if (annotationConfig == null) {
annotationConfig = DEFAULT_ANNOTATION_CONFIG;
}
_annotationHandler = new AnnotationHandler(annotationConfig);
_constructorFilter = constructorFilter;
_fieldFilter = fieldFilter;
_methodFilter = methodFilter;
}
/*
/**********************************************************************
/* Public API, access to component types
/**********************************************************************
*/
public int size() { return _types.length; }
/**
* Accessor for getting full type hierarchy as priority-ordered list, from
* the lowest precedence to highest precedence (main type, its mix-in overrides)
*/
public List<HierarchicType> allTypesAndOverrides() {
return Arrays.asList(_types);
}
/**
* Accessor for getting subset of type hierarchy which only contains main type
* and possible overrides (mix-ins) it has, but not supertypes or their overrides.
*/
public List<HierarchicType> mainTypeAndOverrides()
{
List<HierarchicType> l = Arrays.asList(_types);
int end = _mainType.getPriority() + 1;
if (end < l.size()) {
l = l.subList(0, end);
}
return l;
}
/**
* Accessor for finding just overrides for the main type (if any).
*/
public List<HierarchicType> overridesOnly()
{
int index = _mainType.getPriority();
if (index == 0) {
return Collections.emptyList();
}
List<HierarchicType> l = Arrays.asList(_types);
return l.subList(0, index);
}
/*
/**********************************************************************
/* Public API, actual resolution of members
/**********************************************************************
*/
/**
* Method for finding all static fields of the main type (except for ones
* possibly filtered out by filter) and applying annotation overrides, if any,
* to annotations.
*
* @since 1.2.0
*/
public ResolvedField[] getStaticFields()
{
if (_staticFields == null) {
_staticFields = resolveStaticFields();
}
return _staticFields;
}
/**
* Method for finding all static methods of the main type (except for ones
* possibly filtered out by filter) and applying annotation overrides, if any,
* to annotations.
*/
public ResolvedMethod[] getStaticMethods()
{
if (_staticMethods == null) {
_staticMethods = resolveStaticMethods();
}
return _staticMethods;
}
public ResolvedField[] getMemberFields()
{
if (_memberFields == null) {
_memberFields = resolveMemberFields();
}
return _memberFields;
}
public ResolvedMethod[] getMemberMethods()
{
if (_memberMethods == null) {
_memberMethods = resolveMemberMethods();
}
return _memberMethods;
}
public ResolvedConstructor[] getConstructors()
{
if (_constructors == null) {
_constructors = resolveConstructors();
}
return _constructors;
}
/*
/**********************************************************************
/* Internal methods: actual resolution
/**********************************************************************
*/
/**
* Method that will actually resolve full information (types, annotations)
* for constructors of the main type.
*/
protected ResolvedConstructor[] resolveConstructors()
{
// First get static methods for main type, filter
LinkedHashMap<MethodKey, ResolvedConstructor> constructors = new LinkedHashMap<MethodKey, ResolvedConstructor>();
for (RawConstructor constructor : _mainType.getType().getConstructors()) {
// no filter for constructors (yet?)
if (_constructorFilter == null || _constructorFilter.include(constructor)) {
constructors.put(constructor.createKey(), resolveConstructor(constructor));
}
}
// then apply overrides (mix-ins):
for (HierarchicType type : overridesOnly()) {
for (RawConstructor raw : type.getType().getConstructors()) {
ResolvedConstructor constructor = constructors.get(raw.createKey());
// must override something, otherwise to ignore
if (constructor != null) {
for (Annotation ann : raw.getAnnotations()) {
if (_annotationHandler.includeMethodAnnotation(ann)) {
constructor.applyOverride(ann);
}
}
// and parameter annotations
Annotation[][] params = raw.getRawMember().getParameterAnnotations();
for (int i = 0; i < params.length; i++) {
for (Annotation annotation : params[i]) {
if (_annotationHandler.includeParameterAnnotation(annotation)) {
constructor.applyParamOverride(i, annotation);
}
}
}
}
}
}
if (constructors.size() == 0) {
return NO_RESOLVED_CONSTRUCTORS;
}
return constructors.values().toArray(new ResolvedConstructor[constructors.size()]);
}
/**
* Method for fully resolving field definitions and associated annotations.
* Neither field definitions nor associated annotations inherit, but we may
* still need to add annotation overrides, as well as filter out filters
* and annotations that caller is not interested in.
*/
protected ResolvedField[] resolveMemberFields()
{
LinkedHashMap<String, ResolvedField> fields = new LinkedHashMap<String, ResolvedField>();
/* Fields need different handling: must start from bottom; and annotations only get added
* as overrides, never as defaults. And sub-classes fully mask fields. This makes
* handling bit simpler than that of member methods.
*/
for (int typeIndex = _types.length; --typeIndex >= 0; ) {
HierarchicType thisType = _types[typeIndex];
// If it's just a mix-in, add annotations as overrides
if (thisType.isMixin()) {
for (RawField raw : thisType.getType().getMemberFields()) {
if ((_fieldFilter != null) && !_fieldFilter.include(raw)) {
continue;
}
ResolvedField field = fields.get(raw.getName());
if (field != null) {
for (Annotation ann : raw.getAnnotations()) {
if (_annotationHandler.includeMethodAnnotation(ann)) {
field.applyOverride(ann);
}
}
}
}
} else { // If actual type, add fields, masking whatever might have existed before:
for (RawField field : thisType.getType().getMemberFields()) {
if ((_fieldFilter != null) && !_fieldFilter.include(field)) {
continue;
}
fields.put(field.getName(), resolveField(field));
}
}
}
// and that's it?
if (fields.size() == 0) {
return NO_RESOLVED_FIELDS;
}
return fields.values().toArray(new ResolvedField[fields.size()]);
}
protected ResolvedMethod[] resolveMemberMethods()
{
LinkedHashMap<MethodKey, ResolvedMethod> methods = new LinkedHashMap<MethodKey, ResolvedMethod>();
LinkedHashMap<MethodKey, Annotations> overrides = new LinkedHashMap<MethodKey, Annotations>();
LinkedHashMap<MethodKey, Annotations[]> paramOverrides = new LinkedHashMap<MethodKey, Annotations[]>();
/* Member methods are handled from top to bottom; and annotations are tracked
* alongside (for overrides), as well as "merged down" for inheritable
* annotations.
*/
for (HierarchicType type : allTypesAndOverrides()) {
for (RawMethod method : type.getType().getMemberMethods()) {
// First: ignore methods caller is not interested
if (_methodFilter != null && !_methodFilter.include(method)) {
continue;
}
MethodKey key = method.createKey();
ResolvedMethod old = methods.get(key);
// Ok, now, mix-ins only contribute annotations; whereas 'real' types methods
if (type.isMixin()) { // mix-in: only get annotations
for (Annotation ann : method.getAnnotations()) {
// If already have a method, must be inheritable to include
if (old != null) {
if (!methodCanInherit(ann)) {
continue;
}
// and if so, apply as default (i.e. do not override)
old.applyDefault(ann);
} else { // If no method, need to add to annotation override map
Annotations oldAnn = overrides.get(key);
if (oldAnn == null) {
oldAnn = new Annotations();
oldAnn.add(ann);
overrides.put(key, oldAnn);
} else {
oldAnn.addAsDefault(ann);
}
}
}
// override argument annotations
final Annotation[][] argAnnotations = method.getRawMember().getParameterAnnotations();
if (old == null) { // no method (yet), add argument annotations to override map
Annotations[] oldParamAnns = paramOverrides.get(key);
if (oldParamAnns == null) { // no existing argument annotations for method
oldParamAnns = new Annotations[argAnnotations.length];
for (int i = 0; i < argAnnotations.length; i++) {
oldParamAnns[i] = new Annotations();
for (final Annotation annotation : argAnnotations[i]) {
if (parameterCanInherit(annotation)) {
oldParamAnns[i].add(annotation);
}
}
}
paramOverrides.put(key, oldParamAnns);
} else {
for (int i = 0; i < argAnnotations.length; i++) {
for (final Annotation annotation : argAnnotations[i]) {
if (parameterCanInherit(annotation)) {
oldParamAnns[i].addAsDefault(annotation);
}
}
}
}
} else { // already have a method, apply argument annotations as defaults
for (int i = 0; i < argAnnotations.length; i++) {
for (final Annotation annotation : argAnnotations[i]) {
if (parameterCanInherit(annotation)) {
old.applyParamDefault(i, annotation);
}
}
}
}
} else { // "real" methods; add if not present, possibly add defaults as well
if (old == null) { // new one to add
ResolvedMethod newMethod = resolveMethod(method);
methods.put(key, newMethod);
// But we may also have annotation overrides, so:
Annotations overrideAnn = overrides.get(key);
if (overrideAnn != null) {
newMethod.applyOverrides(overrideAnn);
}
// and apply parameter annotation overrides
Annotations[] annotations = paramOverrides.get(key);
if (annotations != null) {
for (int i = 0; i < annotations.length; i++) {
newMethod.applyParamOverrides(i, annotations[i]);
}
}
} else { // method masked by something else? can only contribute annotations
for (Annotation ann : method.getAnnotations()) {
if (methodCanInherit(ann)) {
old.applyDefault(ann);
}
}
// and parameter annotations
final Annotation[][] parameterAnnotations = method.getRawMember().getParameterAnnotations();
for (int i = 0; i < parameterAnnotations.length; i++) {
for (final Annotation annotation : parameterAnnotations[i]) {
if (parameterCanInherit(annotation)) {
old.applyParamDefault(i, annotation);
}
}
}
}
}
}
}
if (methods.size() == 0) {
return NO_RESOLVED_METHODS;
}
return methods.values().toArray(new ResolvedMethod[methods.size()]);
}
/**
* Method for fully resolving static field definitions and associated annotations.
* Neither field definitions nor associated annotations inherit, but we may
* still need to add annotation overrides, as well as filter out filters
* and annotations that caller is not interested in.
*
* @since 1.2.0
*/
protected ResolvedField[] resolveStaticFields()
{
// First get static methods for main type, filter
LinkedHashMap<String, ResolvedField> fields = new LinkedHashMap<String, ResolvedField>();
for (RawField field : _mainType.getType().getStaticFields()) {
if (_fieldFilter == null || _fieldFilter.include(field)) {
fields.put(field.getName(), resolveField(field));
}
}
// then apply overrides (mix-ins):
for (HierarchicType type : overridesOnly()) {
for (RawField raw : type.getType().getStaticFields()) {
ResolvedField field = fields.get(raw.getName());
// must override something, otherwise to ignore
if (field != null) {
for (Annotation ann : raw.getAnnotations()) {
if (_annotationHandler.includeFieldAnnotation(ann)) {
field.applyOverride(ann);
}
}
}
}
}
// and that's it?
if (fields.isEmpty()) {
return NO_RESOLVED_FIELDS;
}
return fields.values().toArray(new ResolvedField[ fields.size()]);
}
/**
* Method that will actually resolve full information (types, annotations)
* for static methods, using configured filter.
*/
protected ResolvedMethod[] resolveStaticMethods()
{
// First get static methods for main type, filter
LinkedHashMap<MethodKey, ResolvedMethod> methods = new LinkedHashMap<MethodKey, ResolvedMethod>();
for (RawMethod method : _mainType.getType().getStaticMethods()) {
if (_methodFilter == null || _methodFilter.include(method)) {
methods.put(method.createKey(), resolveMethod(method));
}
}
// then apply overrides (mix-ins):
for (HierarchicType type : overridesOnly()) {
for (RawMethod raw : type.getType().getStaticMethods()) {
ResolvedMethod method = methods.get(raw.createKey());
// must override something, otherwise to ignore
if (method != null) {
for (Annotation ann : raw.getAnnotations()) {
if (_annotationHandler.includeMethodAnnotation(ann)) {
method.applyOverride(ann);
}
}
}
}
}
if (methods.size() == 0) {
return NO_RESOLVED_METHODS;
}
return methods.values().toArray(new ResolvedMethod[methods.size()]);
}
/*
/**********************************************************************
/* Helper methods
/**********************************************************************
*/
/**
* Method for resolving individual constructor completely
*/
protected ResolvedConstructor resolveConstructor(RawConstructor raw)
{
final ResolvedType context = raw.getDeclaringType();
final TypeBindings bindings = context.getTypeBindings();
Constructor<?> ctor = raw.getRawMember();
Type[] rawTypes = ctor.getGenericParameterTypes();
ResolvedType[] argTypes;
if (rawTypes == null || rawTypes.length == 0) {
argTypes = NO_RESOLVED_TYPES;
} else {
argTypes = new ResolvedType[rawTypes.length];
for (int i = 0, len = rawTypes.length; i < len; ++i) {
argTypes[i] = _typeResolver.resolve(bindings, rawTypes[i]);
}
}
// And then annotations
Annotations anns = new Annotations();
for (Annotation ann : ctor.getAnnotations()) {
if (_annotationHandler.includeConstructorAnnotation(ann)) {
anns.add(ann);
}
}
ResolvedConstructor constructor = new ResolvedConstructor(context, anns, ctor, argTypes);
// and parameter annotations
Annotation[][] annotations = ctor.getParameterAnnotations();
for (int i = 0; i < argTypes.length; i++) {
for (Annotation ann : annotations[i]) {
constructor.applyParamOverride(i, ann);
}
}
return constructor;
}
/**
* Method for resolving individual field completely
*/
protected ResolvedField resolveField(RawField raw)
{
final ResolvedType context = raw.getDeclaringType();
Field field = raw.getRawMember();
ResolvedType type = _typeResolver.resolve(context.getTypeBindings(), field.getGenericType());
// And then annotations
Annotations anns = new Annotations();
for (Annotation ann : field.getAnnotations()) {
if (_annotationHandler.includeFieldAnnotation(ann)) {
anns.add(ann);
}
}
return new ResolvedField(context, anns, field, type);
}
/**
* Method for resolving individual method completely
*/
protected ResolvedMethod resolveMethod(RawMethod raw)
{
final ResolvedType context = raw.getDeclaringType();
final TypeBindings bindings = context.getTypeBindings();
Method m = raw.getRawMember();
Type rawType = m.getGenericReturnType();
ResolvedType rt = (rawType == Void.TYPE) ? null : _typeResolver.resolve(bindings, rawType);
Type[] rawTypes = m.getGenericParameterTypes();
ResolvedType[] argTypes;
if (rawTypes == null || rawTypes.length == 0) {
argTypes = NO_RESOLVED_TYPES;
} else {
argTypes = new ResolvedType[rawTypes.length];
for (int i = 0, len = rawTypes.length; i < len; ++i) {
argTypes[i] = _typeResolver.resolve(bindings, rawTypes[i]);
}
}
// And then annotations
Annotations anns = new Annotations();
for (Annotation ann : m.getAnnotations()) {
if (_annotationHandler.includeMethodAnnotation(ann)) {
anns.add(ann);
}
}
ResolvedMethod method = new ResolvedMethod(context, anns, m, rt, argTypes);
// and argument annotations
Annotation[][] annotations = m.getParameterAnnotations();
for (int i = 0; i < argTypes.length; i++) {
for (Annotation ann : annotations[i]) {
method.applyParamOverride(i, ann);
}
}
return method;
}
protected boolean methodCanInherit(Annotation annotation) {
AnnotationInclusion annotationInclusion = _annotationHandler.methodInclusion(annotation);
if (annotationInclusion == AnnotationInclusion.INCLUDE_AND_INHERIT_IF_INHERITED) {
return annotation.annotationType().isAnnotationPresent(Inherited.class);
}
return (annotationInclusion == AnnotationInclusion.INCLUDE_AND_INHERIT);
}
protected boolean parameterCanInherit(Annotation annotation) {
AnnotationInclusion annotationInclusion = _annotationHandler.parameterInclusion(annotation);
if (annotationInclusion == AnnotationInclusion.INCLUDE_AND_INHERIT_IF_INHERITED) {
return annotation.annotationType().isAnnotationPresent(Inherited.class);
}
return (annotationInclusion == AnnotationInclusion.INCLUDE_AND_INHERIT);
}
/*
/**********************************************************************
/* Helper types
/**********************************************************************
*/
/**
* Helper class we use to reduce number of calls to {@link AnnotationConfiguration};
* mostly because determination may be expensive.
*/
private final static class AnnotationHandler
{
private final AnnotationConfiguration _annotationConfig;
private HashMap<Class<? extends Annotation>, AnnotationInclusion> _fieldInclusions;
private HashMap<Class<? extends Annotation>, AnnotationInclusion> _constructorInclusions;
private HashMap<Class<? extends Annotation>, AnnotationInclusion> _methodInclusions;
private HashMap<Class<? extends Annotation>, AnnotationInclusion> _parameterInclusions;
public AnnotationHandler(AnnotationConfiguration annotationConfig) {
_annotationConfig = annotationConfig;
}
public boolean includeConstructorAnnotation(Annotation ann)
{
Class<? extends Annotation> annType = ann.annotationType();
if (_constructorInclusions == null) {
_constructorInclusions = new HashMap<Class<? extends Annotation>, AnnotationInclusion>();
} else {
AnnotationInclusion incl = _constructorInclusions.get(annType);
if (incl != null) {
return (incl != AnnotationInclusion.DONT_INCLUDE);
}
}
AnnotationInclusion incl = _annotationConfig.getInclusionForConstructor(annType);
_constructorInclusions.put(annType, incl);
return (incl != AnnotationInclusion.DONT_INCLUDE);
}
public boolean includeFieldAnnotation(Annotation ann)
{
Class<? extends Annotation> annType = ann.annotationType();
if (_fieldInclusions == null) {
_fieldInclusions = new HashMap<Class<? extends Annotation>, AnnotationInclusion>();
} else {
AnnotationInclusion incl = _fieldInclusions.get(annType);
if (incl != null) {
return (incl != AnnotationInclusion.DONT_INCLUDE);
}
}
AnnotationInclusion incl = _annotationConfig.getInclusionForField(annType);
_fieldInclusions.put(annType, incl);
return (incl != AnnotationInclusion.DONT_INCLUDE);
}
public boolean includeMethodAnnotation(Annotation ann)
{
return methodInclusion(ann) != AnnotationInclusion.DONT_INCLUDE;
}
public AnnotationInclusion methodInclusion(Annotation ann)
{
Class<? extends Annotation> annType = ann.annotationType();
if (_methodInclusions == null) {
_methodInclusions = new HashMap<Class<? extends Annotation>, AnnotationInclusion>();
} else {
AnnotationInclusion incl = _methodInclusions.get(annType);
if (incl != null) {
return incl;
}
}
AnnotationInclusion incl = _annotationConfig.getInclusionForMethod(annType);
_methodInclusions.put(annType, incl);
return incl;
}
public boolean includeParameterAnnotation(Annotation ann)
{
return parameterInclusion(ann) != AnnotationInclusion.DONT_INCLUDE;
}
public AnnotationInclusion parameterInclusion(Annotation ann)
{
Class<? extends Annotation> annType = ann.annotationType();
if (_parameterInclusions == null) {
_parameterInclusions = new HashMap<Class<? extends Annotation>, AnnotationInclusion>();
} else {
AnnotationInclusion incl = _parameterInclusions.get(annType);
if (incl != null) {
return incl;
}
}
AnnotationInclusion incl = _annotationConfig.getInclusionForParameter(annType);
_parameterInclusions.put(annType, incl);
return incl;
}
}
}

237
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/TypeBindings.java

@ -1,237 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.lang.reflect.TypeVariable;
import java.util.*;
/**
* Helper class used for storing binding of local type variables to
* matching resolved types, in context of a single class.
*/
public final class TypeBindings
{
private final static String[] NO_STRINGS = new String[0];
private final static ResolvedType[] NO_TYPES = new ResolvedType[0];
private final static TypeBindings EMPTY = new TypeBindings(NO_STRINGS, NO_TYPES, null);
/**
* Array of type (type variable) names.
*/
private final String[] _names;
/**
* Types matching names
*/
private final ResolvedType[] _types;
/**
* Names of potentially unresolved type variables.
*
* @since 2.3
*/
private final String[] _unboundVariables;
private final int _hashCode;
/*
/**********************************************************************
/* Construction
/**********************************************************************
*/
private TypeBindings(String[] names, ResolvedType[] types, String[] uvars)
{
_names = (names == null) ? NO_STRINGS : names;
_types = (types == null) ? NO_TYPES : types;
if (_names.length != _types.length) {
throw new IllegalArgumentException("Mismatching names ("+_names.length+"), types ("+_types.length+")");
}
int h = 1;
for (int i = 0, len = _types.length; i < len; ++i) {
h += _types[i].hashCode();
}
_unboundVariables = uvars;
_hashCode = h;
}
public static TypeBindings emptyBindings() {
return EMPTY;
}
/**
* Factory method for constructing bindings for given class using specified type
* parameters.
*/
public static TypeBindings create(Class<?> erasedType, List<ResolvedType> typeList)
{
ResolvedType[] types = (typeList == null || typeList.isEmpty()) ?
NO_TYPES : typeList.toArray(new ResolvedType[typeList.size()]);
return create(erasedType, types);
}
public static TypeBindings create(Class<?> erasedType, ResolvedType[] types)
{
if (types == null) {
types = NO_TYPES;
}
TypeVariable<?>[] vars = erasedType.getTypeParameters();
String[] names;
if (vars == null || vars.length == 0) {
names = NO_STRINGS;
} else {
int len = vars.length;
names = new String[len];
for (int i = 0; i < len; ++i) {
names[i] = vars[i].getName();
}
}
// Check here to give better error message
if (names.length != types.length) {
throw new IllegalArgumentException("Can not create TypeBinding for class "+erasedType.getName()
+" with "+types.length+" type parameter"
+((types.length == 1) ? "" : "s")+": class expects "+names.length);
}
return new TypeBindings(names, types, null);
}
/**
* Method for creating an instance that has same bindings as this object,
* plus an indicator for additional type variable that may be unbound within
* this context; this is needed to resolve recursive self-references.
*
* @since 1.3 (renamed from "withAdditionalBinding" in 1.2)
*/
public TypeBindings withUnboundVariable(String name)
{
int len = (_unboundVariables == null) ? 0 : _unboundVariables.length;
String[] names = (len == 0)
? new String[1] : Arrays.copyOf(_unboundVariables, len+1);
names[len] = name;
return new TypeBindings(_names, _types, names);
}
/*
/**********************************************************************
/* Accessors
/**********************************************************************
*/
/**
* Find type bound to specified name, if there is one; returns bound type if so, null if not.
*/
public ResolvedType findBoundType(String name)
{
for (int i = 0, len = _names.length; i < len; ++i) {
if (name.equals(_names[i])) {
return _types[i];
}
}
return null;
}
public boolean isEmpty() {
return (_types.length == 0);
}
/**
* Returns number of bindings contained
*/
public int size() {
return _types.length;
}
public String getBoundName(int index)
{
if (index < 0 || index >= _names.length) {
return null;
}
return _names[index];
}
public ResolvedType getBoundType(int index)
{
if (index < 0 || index >= _types.length) {
return null;
}
return _types[index];
}
/**
* Accessor for getting bound types in declaration order
*/
public List<ResolvedType> getTypeParameters()
{
if (_types.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_types);
}
/**
* @since 2.3
*/
public boolean hasUnbound(String name) {
if (_unboundVariables != null) {
for (int i = _unboundVariables.length; --i >= 0; ) {
if (name.equals(_unboundVariables[i])) {
return true;
}
}
}
return false;
}
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public String toString()
{
if (_types.length == 0) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append('<');
for (int i = 0, len = _types.length; i < len; ++i) {
if (i > 0) {
sb.append(',');
}
sb = _types[i].appendBriefDescription(sb);
}
sb.append('>');
return sb.toString();
}
@Override public int hashCode() { return _hashCode; }
@Override public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
TypeBindings other = (TypeBindings) o;
int len = _types.length;
if (len != other.size()) {
return false;
}
ResolvedType[] otherTypes = other._types;
for (int i = 0; i < len; ++i) {
if (!otherTypes[i].equals(_types[i])) {
return false;
}
}
return true;
}
/*
/**********************************************************************
/* Package accessible methods
/**********************************************************************
*/
protected ResolvedType[] typeParameterArray() {
return _types;
}
}

552
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/TypeResolver.java

@ -1,552 +0,0 @@
package com.fr.third.com.fasterxml.classmate;
import java.io.Serializable;
import java.lang.reflect.*;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.util.ClassKey;
import com.fr.third.com.fasterxml.classmate.util.ClassStack;
import com.fr.third.com.fasterxml.classmate.util.ResolvedTypeCache;
import com.fr.third.com.fasterxml.classmate.types.ResolvedArrayType;
import com.fr.third.com.fasterxml.classmate.types.ResolvedInterfaceType;
import com.fr.third.com.fasterxml.classmate.types.ResolvedObjectType;
import com.fr.third.com.fasterxml.classmate.types.ResolvedPrimitiveType;
import com.fr.third.com.fasterxml.classmate.types.ResolvedRecursiveType;
import com.fr.third.com.fasterxml.classmate.types.TypePlaceHolder;
/**
* Object that is used for resolving generic type information of a class
* so that it is accessible using simple API. Resolved types are also starting
* point for accessing resolved (generics aware) return and argument types
* of class members (methods, fields, constructors).
*<p>
* Note that resolver instances are stateful in that resolvers cache resolved
* types for efficiency. Since this is internal state and not directly visible
* to callers, access to state is fully synchronized so that access from
* multiple threads is safe.
*/
@SuppressWarnings("serial")
public class TypeResolver implements Serializable
{
private final static ResolvedType[] NO_TYPES = new ResolvedType[0];
/*
/**********************************************************************
/* Pre-created instances
/**********************************************************************
*/
/**
* We will also need to return "unknown" type for cases where type variable binding
* is not found ('raw' instances of generic types); easiest way is to
* pre-create type for <code>java.lang.Object</code>
*/
private final static ResolvedObjectType sJavaLangObject =
ResolvedObjectType.create(Object.class, null, null, null);
/**
* Since number of primitive types is small, and they are frequently needed,
* let's actually pre-create them for efficient reuse. Same goes for limited number
* of other "standard" types...
*/
protected final static HashMap<ClassKey, ResolvedType> _primitiveTypes;
static {
_primitiveTypes = new HashMap<ClassKey, ResolvedType>(16);
for (ResolvedPrimitiveType type : ResolvedPrimitiveType.all()) {
_primitiveTypes.put(new ClassKey(type.getErasedType()), type);
}
// should we include "void"? might as well...
_primitiveTypes.put(new ClassKey(Void.TYPE), ResolvedPrimitiveType.voidType());
// and at least java.lang.Object should be added too.
_primitiveTypes.put(new ClassKey(Object.class), sJavaLangObject);
// but most other types can be added dynamically
}
/*
/**********************************************************************
/* Caching
/**********************************************************************
*/
/**
* Simple cache of types resolved by this resolved; capped to last 200 resolved types.
* Caching works because type instances themselves are mostly immutable;
* and properly synchronized in cases where transient data (raw members) are
* accessed.
*/
protected final ResolvedTypeCache _resolvedTypes = new ResolvedTypeCache(200);
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
public TypeResolver() { }
/*
/**********************************************************************
/* Factory methods, with explicit parameterization
/**********************************************************************
*/
/**
* Factory method for resolving given base type
* using specified types as type parameters.
* Sample usage would be:
*<pre>
* ResolvedType type = TypeResolver.resolve(List.class, Integer.class);
*</pre>
* which would be equivalent to
*<pre>
* ResolvedType type = TypeResolver.resolve(new GenericType&lt;List&lt;Integer>>() { });
*</pre>
* Note that you can mix different types of type parameters, whether already
* resolved ({@link ResolvedType}), type-erased ({@link java.lang.Class}) or
* generic type reference ({@link GenericType}).
*/
public ResolvedType resolve(Type type, Type... typeParameters)
{
boolean noParams = (typeParameters == null || typeParameters.length == 0);
TypeBindings bindings;
Class<?> rawBase;
if (type instanceof Class<?>) {
bindings = TypeBindings.emptyBindings();
if (noParams) {
return _fromClass(null, (Class<?>) type, bindings);
}
rawBase = (Class<?>) type;
} else if (type instanceof GenericType<?>) {
bindings = TypeBindings.emptyBindings();
if (noParams) {
return _fromGenericType(null, (GenericType<?>) type, bindings);
}
ResolvedType rt = _fromAny(null, type, bindings);
rawBase = rt.getErasedType();
} else if (type instanceof ResolvedType) {
ResolvedType rt = (ResolvedType) type;
if (noParams) {
return rt;
}
bindings = rt.getTypeBindings();
rawBase = rt.getErasedType();
} else {
bindings = TypeBindings.emptyBindings();
if (noParams) {
return resolve(bindings, type);
}
// Quite convoluted... but necessary to find Class<?> underlying it all
ResolvedType rt = _fromAny(null, type, bindings);
rawBase = rt.getErasedType();
}
// Next: resolve type parameters
int len = typeParameters.length;
ResolvedType[] resolvedParams = new ResolvedType[len];
for (int i = 0; i < len; ++i) {
resolvedParams[i] = _fromAny(null, typeParameters[i], bindings);
}
return _fromClass(null, rawBase, TypeBindings.create(rawBase, resolvedParams));
}
/**
* Factory method for constructing array type of given element type.
*/
public ResolvedArrayType arrayType(Type elementType)
{
ResolvedType resolvedElementType = resolve(TypeBindings.emptyBindings(), elementType);
// Arrays are cumbersome for some reason:
Object emptyArray = Array.newInstance(resolvedElementType.getErasedType(), 0);
// Should we try to use cache? It's bit tricky, so let's not bother yet
return new ResolvedArrayType(emptyArray.getClass(), TypeBindings.emptyBindings(),
resolvedElementType);
}
/**
* Factory method for resolving specified Java {@link java.lang.reflect.Type}, given
* {@link TypeBindings} needed to resolve any type variables.
*<p>
* Use of this method is discouraged (use if and only if you really know what you
* are doing!); but if used, type bindings passed should come from {@link ResolvedType}
* instance of declaring class (or interface).
*<p>
* NOTE: order of arguments was reversed for 0.8, to avoid problems with
* overload varargs method.
*/
public ResolvedType resolve(TypeBindings typeBindings, Type jdkType)
{
return _fromAny(null, jdkType, typeBindings);
}
/**
* Factory method for constructing sub-classing specified type; class specified
* as sub-class must be compatible according to basic Java inheritance rules
* (subtype must properly extend or implement specified supertype).
*<p>
* A typical use case here is to refine a generic type; for example, given
* that we have generic type like <code>List&ltInteger></code>, but we want
* a more specific implementation type like
* class <code>ArrayList</code> but with same parameterization (here just <code>Integer</code>),
* we could achieve it by:
*<pre>
* ResolvedType mapType = typeResolver.resolve(List.class, Integer.class);
* ResolveType concreteMapType = typeResolver.resolveSubType(mapType, ArrayList.class);
*</pre>
* (in this case, it would have been simpler to resolve directly; but in some
* cases we are handled supertype and want to refine it, in which case steps
* would be the same but separated by other code)
*<p>
* Note that this method will fail if extension can not succeed; either because
* this type is not extendable (sub-classable) -- which is true for primitive
* and array types -- or because given class is not a subtype of this type.
* To check whether subtyping could succeed, you can call
* {@link ResolvedType#canCreateSubtypes()} to see if supertype can ever
* be extended.
*
* @param supertype Type to subtype (extend)
* @param subtype Type-erased sub-class or sub-interface
*
* @return Resolved subtype
*
* @throws IllegalArgumentException If this type can be extended in general, but not into specified sub-class
* @throws UnsupportedOperationException If this type can not be sub-classed
*/
public ResolvedType resolveSubtype(ResolvedType supertype, Class<?> subtype)
throws IllegalArgumentException, UnsupportedOperationException
{
// first: if it's a recursive reference, find out referred-to type
ResolvedType refType = supertype.getSelfReferencedType();
if (refType != null) {
supertype = refType;
}
// Then, trivial check for case where subtype is supertype...
if (supertype.getErasedType() == subtype) {
return supertype;
}
if (!supertype.canCreateSubtypes()) {
throw new UnsupportedOperationException("Can not subtype primitive or array types (type "+supertype.getFullDescription()+")");
}
// In general, must be able to subtype as per JVM rules:
Class<?> superclass = supertype.getErasedType();
if (!superclass.isAssignableFrom(subtype)) {
throw new IllegalArgumentException("Can not sub-class "+supertype.getBriefDescription()
+" into "+subtype.getName());
}
// Ok, then, let us instantiate type with placeholders
ResolvedType resolvedSubtype;
int paramCount = subtype.getTypeParameters().length;
TypePlaceHolder[] placeholders;
if (paramCount == 0) { // no generics
placeholders = null;
resolvedSubtype = resolve(subtype);
} else {
placeholders = new TypePlaceHolder[paramCount];
for (int i = 0; i < paramCount; ++i) {
placeholders[i] = new TypePlaceHolder(i);
}
resolvedSubtype = resolve(subtype, placeholders);
}
ResolvedType rawSupertype = resolvedSubtype.findSupertype(superclass);
if (rawSupertype == null) { // sanity check, should never occur
throw new IllegalArgumentException("Internal error: unable to locate supertype ("+subtype.getName()+") for type "+supertype.getBriefDescription());
}
// Ok, then, let's find and verify type assignments
_resolveTypePlaceholders(supertype, rawSupertype);
// And then re-construct, if necessary
if (paramCount == 0) { // if no type parameters, fine as is
return resolvedSubtype;
}
// but with type parameters, need to reconstruct
ResolvedType[] typeParams = new ResolvedType[paramCount];
for (int i = 0; i < paramCount; ++i) {
ResolvedType t = placeholders[i].actualType();
/* Is it ok for it to be left unassigned? For now let's not
* allow that
*/
if (t == null) {
throw new IllegalArgumentException("Failed to find type parameter #"+(i+1)+"/"
+paramCount+" for "+subtype.getName());
}
typeParams[i] = t;
}
return resolve(subtype, typeParams);
}
/*
/**********************************************************************
/* Misc other methods
/**********************************************************************
*/
/**
* Helper method that can be used to checked whether given resolved type
* (with erased type of <code>java.lang.Object</code>) is a placeholder
* for "self-reference"; these are nasty recursive ("self") types
* needed with some interfaces
*/
public static boolean isSelfReference(ResolvedType type)
{
return (type instanceof ResolvedRecursiveType);
}
/*
/**********************************************************************
/* Internal methods, second-level factory methods
/**********************************************************************
*/
private ResolvedType _fromAny(ClassStack context, Type mainType, TypeBindings typeBindings)
{
if (mainType instanceof Class<?>) {
return _fromClass(context, (Class<?>) mainType, typeBindings);
}
if (mainType instanceof ResolvedType) {
return (ResolvedType) mainType;
}
if (mainType instanceof ParameterizedType) {
return _fromParamType(context, (ParameterizedType) mainType, typeBindings);
}
if (mainType instanceof GenericType<?>) {
return _fromGenericType(context, (GenericType<?>) mainType, typeBindings);
}
if (mainType instanceof GenericArrayType) {
return _fromArrayType(context, (GenericArrayType) mainType, typeBindings);
}
if (mainType instanceof TypeVariable<?>) {
return _fromVariable(context, (TypeVariable<?>) mainType, typeBindings);
}
if (mainType instanceof WildcardType) {
return _fromWildcard(context, (WildcardType) mainType, typeBindings);
}
// should never get here...
throw new IllegalArgumentException("Unrecognized type class: "+mainType.getClass().getName());
}
private ResolvedType _fromClass(ClassStack context, Class<?> rawType, TypeBindings typeBindings)
{
// First: a primitive type perhaps?
ResolvedType type = _primitiveTypes.get(new ClassKey(rawType));
if (type != null) {
return type;
}
// Second: recursive reference?
if (context == null) {
context = new ClassStack(rawType);
} else {
ClassStack prev = context.find(rawType);
if (prev != null) {
// Self-reference: needs special handling, then...
ResolvedRecursiveType selfRef = new ResolvedRecursiveType(rawType, typeBindings);
prev.addSelfReference(selfRef);
return selfRef;
}
// no, can just add
context = context.child(rawType);
}
// If not, already recently resolved?
ResolvedType[] typeParameters = typeBindings.typeParameterArray();
ResolvedTypeCache.Key key = _resolvedTypes.key(rawType, typeParameters);
type = _resolvedTypes.find(key);
if (type == null) {
type = _constructType(context, rawType, typeBindings);
_resolvedTypes.put(key, type);
}
context.resolveSelfReferences(type);
return type;
}
/**
* Factory method for resolving given generic type, defined by using sub-class
* instance of {@link GenericType}
*/
private ResolvedType _fromGenericType(ClassStack context, GenericType<?> generic, TypeBindings typeBindings)
{
/* To allow multiple levels of inheritance (just in case someone
* wants to go to town with inheritance of GenericType),
* we better resolve the whole thing; then dig out
* type parameterization...
*/
ResolvedType type = _fromClass(context, generic.getClass(), typeBindings);
ResolvedType genType = type.findSupertype(GenericType.class);
if (genType == null) { // sanity check; shouldn't occur
throw new IllegalArgumentException("Unparameterized GenericType instance ("+generic.getClass().getName()+")");
}
TypeBindings b = genType.getTypeBindings();
ResolvedType[] params = b.typeParameterArray();
if (params.length == 0) {
throw new IllegalArgumentException("Unparameterized GenericType instance ("+generic.getClass().getName()+")");
}
return params[0];
}
private ResolvedType _constructType(ClassStack context, Class<?> rawType, TypeBindings typeBindings)
{
// Ok: no easy shortcut, let's figure out type of type...
if (rawType.isArray()) {
ResolvedType elementType = _fromAny(context, rawType.getComponentType(), typeBindings);
return new ResolvedArrayType(rawType, typeBindings, elementType);
}
// For other types super interfaces are needed...
if (rawType.isInterface()) {
return new ResolvedInterfaceType(rawType, typeBindings,
_resolveSuperInterfaces(context, rawType, typeBindings));
}
return new ResolvedObjectType(rawType, typeBindings,
_resolveSuperClass(context, rawType, typeBindings),
_resolveSuperInterfaces(context, rawType, typeBindings));
}
private ResolvedType[] _resolveSuperInterfaces(ClassStack context, Class<?> rawType, TypeBindings typeBindings)
{
Type[] types = rawType.getGenericInterfaces();
if (types == null || types.length == 0) {
return NO_TYPES;
}
int len = types.length;
ResolvedType[] resolved = new ResolvedType[len];
for (int i = 0; i < len; ++i) {
resolved[i] = _fromAny(context, types[i], typeBindings);
}
return resolved;
}
/**
* NOTE: return type changed in 1.0.1 from {@link ResolvedObjectType} to
* {@link ResolvedType}, since it was found that other types may
* be returned...
*
* @return Usually a {@link ResolvedObjectType}, but possibly also
* {@link ResolvedRecursiveType}
*/
private ResolvedType _resolveSuperClass(ClassStack context, Class<?> rawType, TypeBindings typeBindings)
{
Type parent = rawType.getGenericSuperclass();
if (parent == null) {
return null;
}
return _fromAny(context, parent, typeBindings);
}
private ResolvedType _fromParamType(ClassStack context, ParameterizedType ptype, TypeBindings parentBindings)
{
/* First: what is the actual base type? One odd thing is that 'getRawType'
* returns Type, not Class<?> as one might expect. But let's assume it is
* always of type Class: if not, need to add more code to resolve it...
*/
Class<?> rawType = (Class<?>) ptype.getRawType();
Type[] params = ptype.getActualTypeArguments();
int len = params.length;
ResolvedType[] types = new ResolvedType[len];
for (int i = 0; i < len; ++i) {
types[i] = _fromAny(context, params[i], parentBindings);
}
// Ok: this gives us current bindings for this type:
TypeBindings newBindings = TypeBindings.create(rawType, types);
return _fromClass(context, rawType, newBindings);
}
private ResolvedType _fromArrayType(ClassStack context, GenericArrayType arrayType, TypeBindings typeBindings)
{
ResolvedType elementType = _fromAny(context, arrayType.getGenericComponentType(), typeBindings);
// Figuring out raw class for generic array is actually bit tricky...
Object emptyArray = Array.newInstance(elementType.getErasedType(), 0);
return new ResolvedArrayType(emptyArray.getClass(), typeBindings, elementType);
}
private ResolvedType _fromWildcard(ClassStack context, WildcardType wildType, TypeBindings typeBindings)
{
/* Similar to challenges with TypeVariable, we may have multiple upper bounds.
* But it is also possible that if upper bound defaults to Object, we might want to
* consider lower bounds instead?
* For now, we won't try anything more advanced; above is just for future reference.
*/
return _fromAny(context, wildType.getUpperBounds()[0], typeBindings);
}
private ResolvedType _fromVariable(ClassStack context, TypeVariable<?> variable, TypeBindings typeBindings)
{
// ideally should find it via bindings:
String name = variable.getName();
ResolvedType type = typeBindings.findBoundType(name);
if (type != null) {
return type;
}
/* but if not, use bounds... note that approach here is simplistic; not taking
* into account possible multiple bounds, nor consider upper bounds.
*/
/* 02-Mar-2011, tatu: As per issue#4, need to avoid self-reference cycles here;
* can be handled by (temporarily) adding binding:
*/
if (typeBindings.hasUnbound(name)) {
return sJavaLangObject;
}
typeBindings = typeBindings.withUnboundVariable(name);
Type[] bounds = variable.getBounds();
return _fromAny(context, bounds[0], typeBindings);
}
/*
/**********************************************************************
/* Internal methods, replacing and verifying type placeholders
/**********************************************************************
*/
/**
* Method called to verify that types match; and if there are
*/
private void _resolveTypePlaceholders(ResolvedType expectedType, ResolvedType actualType)
throws IllegalArgumentException
{
List<ResolvedType> expectedTypes = expectedType.getTypeParameters();
List<ResolvedType> actualTypes = actualType.getTypeParameters();
for (int i = 0, len = expectedTypes.size(); i < len; ++i) {
ResolvedType exp = expectedTypes.get(i);
ResolvedType act = actualTypes.get(i);
if (!_typesMatch(exp, act)) {
throw new IllegalArgumentException("Type parameter #"+(i+1)+"/"+len+" differs; expected "
+exp.getBriefDescription()+", got "+act.getBriefDescription());
}
}
}
private boolean _typesMatch(ResolvedType exp, ResolvedType act)
{
// Simple equality check, except for one thing: place holders for 'act'
if (act instanceof TypePlaceHolder) {
((TypePlaceHolder) act).actualType(exp);
return true;
}
// but due to recursive nature can't call equality...
if (exp.getErasedType() != act.getErasedType()) {
return false;
}
// But we can check type parameters "blindly"
List<ResolvedType> expectedTypes = exp.getTypeParameters();
List<ResolvedType> actualTypes = act.getTypeParameters();
for (int i = 0, len = expectedTypes.size(); i < len; ++i) {
ResolvedType exp2 = expectedTypes.get(i);
ResolvedType act2 = actualTypes.get(i);
if (!_typesMatch(exp2, act2)) {
return false;
}
}
return true;
}
/*
/**********************************************************************
/* Helper classes
/**********************************************************************
*/
}

68
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/HierarchicType.java

@ -1,68 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.ResolvedTypeWithMembers;
/**
* Container class used to enclose information about a single {@link ResolvedType}
* that is part of {@link ResolvedTypeWithMembers}.
*/
public final class HierarchicType
{
/**
* Whether this type instance represents a mix-in; if so, it can only result in
* addition of annotations but not in addition of actual members.
*/
protected final boolean _isMixin;
protected final ResolvedType _type;
/**
* Relative priority of this type in hierarchy; higher priority members can override
* lower priority members. Priority values are unique and are based on type index
* (starting from 0), although they are not to be used for indexing.
*/
protected final int _priority;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
public HierarchicType(ResolvedType type, boolean mixin, int priority)
{
_type = type;
_isMixin = mixin;
_priority = priority;
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
public ResolvedType getType() { return _type; }
public Class<?> getErasedType() { return _type.getErasedType(); }
public boolean isMixin() { return _isMixin; }
public int getPriority() { return _priority; }
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public String toString() { return _type.toString(); }
@Override public int hashCode() { return _type.hashCode(); }
@Override
public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
HierarchicType other = (HierarchicType) o;
return _type.equals(other._type);
}
}

61
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawConstructor.java

@ -1,61 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.reflect.Constructor;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.util.MethodKey;
public final class RawConstructor extends RawMember
{
protected final Constructor<?> _constructor;
protected final int _hashCode;
public RawConstructor(ResolvedType context, Constructor<?> constructor)
{
super(context);
_constructor = constructor;
_hashCode = (_constructor == null ? 0 : _constructor.hashCode());
}
/**
* Although constructors are different from other methods, we can use
* {@link MethodKey} easily.
*/
public MethodKey createKey()
{
String name = "<init>"; // do not use _constructor.getName() to allow for 'mix-ins'
Class<?>[] argTypes = _constructor.getParameterTypes(); // return of Constructor#getParameterTypes will never be null
return new MethodKey(name, argTypes);
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
@Override
public Constructor<?> getRawMember() {
return _constructor;
}
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public int hashCode()
{
return _hashCode;
}
@Override public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
RawConstructor other = (RawConstructor) o;
return (other._constructor == _constructor);
}
}

58
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawField.java

@ -1,58 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
public final class RawField extends RawMember
{
protected final Field _field;
private final int _hashCode;
public RawField(ResolvedType context, Field field)
{
super(context);
_field = field;
_hashCode = (_field == null ? 0 : _field.hashCode());
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
@Override
public Field getRawMember() {
return _field;
}
public boolean isTransient() {
return Modifier.isTransient(getModifiers());
}
public boolean isVolatile() {
return Modifier.isVolatile(getModifiers());
}
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
RawField other = (RawField) o;
return (other._field == _field);
}
@Override public int hashCode()
{
return _hashCode;
}
}

98
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawMember.java

@ -1,98 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
/**
* Base class for all "raw" member (field, method, constructor) types; raw means that
* actual types are not yet resolved, but relationship to declaring type is
* retained for eventual resolution.
* Instances are typically created by {@link ResolvedType}
* when requested, and form the input to eventual full flattening of type members.
*/
public abstract class RawMember
{
/**
* {@link ResolvedType} (class with generic type parameters) that declared
* this member
*/
protected final ResolvedType _declaringType;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
protected RawMember(ResolvedType context)
{
_declaringType = context;
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
public final ResolvedType getDeclaringType() {
return _declaringType;
}
public abstract Member getRawMember();
public String getName() {
return getRawMember().getName();
}
public boolean isStatic() {
return Modifier.isStatic(getModifiers());
}
public boolean isFinal() {
return Modifier.isFinal(getModifiers());
}
public boolean isPrivate() {
return Modifier.isPrivate(getModifiers());
}
public boolean isProtected() {
return Modifier.isProtected(getModifiers());
}
public boolean isPublic() {
return Modifier.isPublic(getModifiers());
}
public Annotation[] getAnnotations() {
return ((AnnotatedElement) getRawMember()).getAnnotations();
}
/*
/**********************************************************************
/* Standard method overrides
/**********************************************************************
*/
// make abstract to force implementation by sub-class
@Override public abstract boolean equals(Object o);
@Override public abstract int hashCode();
@Override public String toString() {
return getName();
}
/*
/**********************************************************************
/* Package methods
/**********************************************************************
*/
protected final int getModifiers() { return getRawMember().getModifiers(); }
}

74
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/RawMethod.java

@ -1,74 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.util.MethodKey;
public final class RawMethod extends RawMember
{
protected final Method _method;
protected final int _hashCode;
public RawMethod(ResolvedType context, Method method)
{
super(context);
_method = method;
_hashCode = (_method == null ? 0 : _method.hashCode());
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
@Override
public Method getRawMember() {
return _method;
}
public boolean isAbstract() {
return Modifier.isAbstract(getModifiers());
}
public boolean isStrict() {
return Modifier.isStrict(getModifiers());
}
public boolean isNative() {
return Modifier.isNative(getModifiers());
}
public boolean isSynchronized() {
return Modifier.isSynchronized(getModifiers());
}
public MethodKey createKey()
{
String name = _method.getName();
Class<?>[] argTypes = _method.getParameterTypes(); // return of Method#getParameterTypes will never be null
return new MethodKey(name, argTypes);
}
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public int hashCode()
{
return _hashCode;
}
@Override public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
RawMethod other = (RawMethod) o;
return (other._method == _method);
}
}

26
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedConstructor.java

@ -1,26 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.reflect.Constructor;
import com.fr.third.com.fasterxml.classmate.Annotations;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
/**
* Class that represents a constructor that has fully resolved generic
* type information and annotation information.
*/
public final class ResolvedConstructor extends ResolvedParameterizedMember<Constructor<?>>
{
public ResolvedConstructor(ResolvedType context, Annotations ann, Constructor<?> constructor,
ResolvedType[] argumentTypes)
{
super(context, ann, constructor, null, argumentTypes);
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
}

36
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedField.java

@ -1,36 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import com.fr.third.com.fasterxml.classmate.Annotations;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
public final class ResolvedField extends ResolvedMember<Field>
implements Comparable<ResolvedField>
{
public ResolvedField(ResolvedType context, Annotations ann,
Field field, ResolvedType type)
{
super(context, ann, field, type);
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
public boolean isTransient() {
return Modifier.isTransient(getModifiers());
}
public boolean isVolatile() {
return Modifier.isVolatile(getModifiers());
}
@Override
public int compareTo(ResolvedField other) {
return getName().compareTo(other.getName());
}
}

156
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedMember.java

@ -1,156 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import com.fr.third.com.fasterxml.classmate.Annotations;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
/**
* Fully type-resolved equivalent of {@link RawMember}. Only members "that matter" (ones not
* overridden, or filtered out) are resolved, since resolution process can add non-trivial
* overhead.
*/
public abstract class ResolvedMember<T extends Member>
{
/**
* {@link ResolvedType} (class with generic type parameters) that declared
* this member
*/
protected final ResolvedType _declaringType;
protected final Annotations _annotations;
protected final T _member;
protected final ResolvedType _type;
protected final int _hashCode;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
protected ResolvedMember(ResolvedType context, Annotations ann, T member, ResolvedType type)
{
_declaringType = context;
_annotations = ann;
_member = member;
_type = type;
_hashCode = (_member == null ? 0 : _member.hashCode());
}
public void applyOverride(Annotation override)
{
_annotations.add(override);
}
public void applyOverrides(Annotations overrides)
{
_annotations.addAll(overrides);
}
public void applyDefault(Annotation override)
{
_annotations.addAsDefault(override);
}
public <A extends Annotation> A get(Class<A> cls)
{
return _annotations.get(cls);
}
public Annotations getAnnotations()
{
return _annotations;
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
public final ResolvedType getDeclaringType() {
return _declaringType;
}
/**
* Returns type of this member; if it has one, for methods this is the
* return type, for fields field type, and for constructors null.
*/
public ResolvedType getType() {
return _type;
}
/**
* Returns JDK object that represents member.
*/
public T getRawMember() {
return _member;
}
public String getName() {
return getRawMember().getName();
}
public boolean isStatic() {
return Modifier.isStatic(getModifiers());
}
public boolean isFinal() {
return Modifier.isFinal(getModifiers());
}
public boolean isPrivate() {
return Modifier.isPrivate(getModifiers());
}
public boolean isProtected() {
return Modifier.isProtected(getModifiers());
}
public boolean isPublic() {
return Modifier.isPublic(getModifiers());
}
/*
/**********************************************************************
/* Standard method overrides
/**********************************************************************
*/
@Override public String toString() {
return getName();
}
/*
/**********************************************************************
/* Package methods
/**********************************************************************
*/
protected final int getModifiers() { return getRawMember().getModifiers(); }
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override public int hashCode() {
return _hashCode;
}
@Override public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
ResolvedMember<?> other = (ResolvedMember<?>) o;
return (other._member == _member);
}
}

65
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedMethod.java

@ -1,65 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import com.fr.third.com.fasterxml.classmate.Annotations;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
public final class ResolvedMethod extends ResolvedParameterizedMember<Method>
implements Comparable<ResolvedMethod>
{
public ResolvedMethod(ResolvedType context, Annotations ann, Method method,
ResolvedType returnType, ResolvedType[] argumentTypes)
{
super(context, ann, method, returnType, argumentTypes);
}
/*
/**********************************************************************
/* Simple accessors from base class
/**********************************************************************
*/
public boolean isAbstract() {
return Modifier.isAbstract(getModifiers());
}
public boolean isStrict() {
return Modifier.isStrict(getModifiers());
}
public boolean isNative() {
return Modifier.isNative(getModifiers());
}
public boolean isSynchronized() {
return Modifier.isSynchronized(getModifiers());
}
/*
/**********************************************************************
/* Extended API
/**********************************************************************
*/
public ResolvedType getReturnType() { return getType(); }
/*
/**********************************************************************
/* Standard method override
/**********************************************************************
*/
@Override
public int compareTo(ResolvedMethod other)
{
// primary sort by name (alphabetic); secondary by arg count (ascending)
int diff = getName().compareTo(other.getName());
if (diff == 0) {
// subtract fine, no fear of overflow here
diff = getArgumentCount() - other.getArgumentCount();
}
return diff;
}
}

81
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/ResolvedParameterizedMember.java

@ -1,81 +0,0 @@
package com.fr.third.com.fasterxml.classmate.members;
import com.fr.third.com.fasterxml.classmate.Annotations;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
/**
* Base type for resolved members that take some parameters (e.g. methods and constructors).
*/
public abstract class ResolvedParameterizedMember<T extends Member> extends ResolvedMember<T> {
protected final ResolvedType[] _paramTypes;
protected final Annotations[] _paramAnnotations;
protected ResolvedParameterizedMember(ResolvedType context, Annotations ann,
T member, ResolvedType type, ResolvedType[] argumentTypes) {
super(context, ann, member, type);
_paramTypes = argumentTypes == null ? ResolvedType.NO_TYPES : argumentTypes;
_paramAnnotations = new Annotations[_paramTypes.length];
}
public Annotations getParameterAnnotations(int index) {
if (index >= _paramTypes.length)
throw new IndexOutOfBoundsException("No parameter at index " + index + ", this is greater than the total number of parameters");
if (_paramAnnotations[index] == null) {
_paramAnnotations[index] = new Annotations();
}
return _paramAnnotations[index];
}
public void applyParamOverride(int index, Annotation override)
{
if (index >= _paramAnnotations.length)
return;
getParameterAnnotations(index).add(override);
}
public void applyParamOverrides(int index, Annotations overrides)
{
if (index >= _paramAnnotations.length)
return;
getParameterAnnotations(index).addAll(overrides);
}
public void applyParamDefault(int index, Annotation defaultValue)
{
if (index >= _paramAnnotations.length)
return;
getParameterAnnotations(index).addAsDefault(defaultValue);
}
public <A extends Annotation> A getParam(int index, Class<A> cls)
{
if (index >= _paramAnnotations.length)
return null;
return _paramAnnotations[index].get(cls);
}
/**
* Returns number of arguments method takes.
*/
public int getArgumentCount() {
return _paramTypes.length;
}
public ResolvedType getArgumentType(int index)
{
if (index < 0 || index >= _paramTypes.length) {
return null;
}
return _paramTypes[index];
}
}

5
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/members/package-info.java

@ -1,5 +0,0 @@
/**
* Package that contains implementations of various member types
* (methods, fields, constructors)
*/
package com.fr.third.com.fasterxml.classmate.members;

13
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/package-info.java

@ -1,13 +0,0 @@
/**
* Package that contains main public interface of ClassMate
* package.
*<p>
* Most commonly resolution starts with {@link com.fr.third.com.fasterxml.classmate.TypeResolver},
* using its <code>resolve()</code> method, which returns a
* {@link com.fr.third.com.fasterxml.classmate.ResolvedType} instance.
* These type objects contain all necessary information about type itself;
* but if type information on members (fields, methods, constructors, static
* members) is needed, {@link com.fr.third.com.fasterxml.classmate.MemberResolver} can
* resolve types for members: it takes {@link com.fr.third.com.fasterxml.classmate.ResolvedType}s.
*/
package com.fr.third.com.fasterxml.classmate;

108
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedArrayType.java

@ -1,108 +0,0 @@
package com.fr.third.com.fasterxml.classmate.types;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.TypeBindings;
public final class ResolvedArrayType extends ResolvedType
{
protected final ResolvedType _elementType;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
public ResolvedArrayType(Class<?> erased, TypeBindings bindings,
ResolvedType elementType)
{
super(erased, bindings);
_elementType = elementType;
}
@Override
public boolean canCreateSubtypes() {
return false;
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
@Override
public ResolvedType getParentClass() { return null; }
@Override
public ResolvedType getSelfReferencedType() { return null; }
@Override
public List<ResolvedType> getImplementedInterfaces() {
return Collections.emptyList();
}
/*
/**********************************************************************
/* Simple property accessors
/**********************************************************************
*/
@Override
public boolean isInterface() {
return false;
}
@Override
public boolean isAbstract() { return false; }
@Override
public ResolvedType getArrayElementType() { return _elementType; }
@Override
public boolean isArray() { return true; }
@Override
public boolean isPrimitive() { return false; }
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
// defaults are fine (nothing to access)
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
@Override
public StringBuilder appendSignature(StringBuilder sb) {
sb.append('[');
return _elementType.appendSignature(sb);
}
@Override
public StringBuilder appendErasedSignature(StringBuilder sb) {
sb.append('[');
return _elementType.appendErasedSignature(sb);
}
@Override
public StringBuilder appendBriefDescription(StringBuilder sb)
{
sb = _elementType.appendBriefDescription(sb);
sb.append("[]");
return sb;
}
@Override
public StringBuilder appendFullDescription(StringBuilder sb) {
return appendBriefDescription(sb);
}
}

162
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedInterfaceType.java

@ -1,162 +0,0 @@
package com.fr.third.com.fasterxml.classmate.types;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.TypeBindings;
import com.fr.third.com.fasterxml.classmate.members.RawField;
import com.fr.third.com.fasterxml.classmate.members.RawMethod;
public class ResolvedInterfaceType extends ResolvedType
{
/**
* List of interfaces this type implements; may be empty but never null
*/
protected final ResolvedType[] _superInterfaces;
/**
* Interfaces can have static final (constant) fields.
*/
protected RawField[] _constantFields;
/**
* Interface methods are all public and abstract.
*/
protected RawMethod[] _memberMethods;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
public ResolvedInterfaceType(Class<?> erased, TypeBindings bindings,
ResolvedType[] superInterfaces)
{
super(erased, bindings);
_superInterfaces = (superInterfaces == null ? NO_TYPES : superInterfaces);
}
@Override
public boolean canCreateSubtypes() {
return true;
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
@Override
public ResolvedType getParentClass() {
// interfaces do not have parent class, just interfaces
return null;
}
@Override
public ResolvedType getSelfReferencedType() { return null; }
@Override
public List<ResolvedType> getImplementedInterfaces() {
return (_superInterfaces.length == 0) ?
Collections.<ResolvedType>emptyList() : Arrays.asList(_superInterfaces);
}
@Override
public ResolvedType getArrayElementType() { // interfaces are never arrays, so:
return null;
}
/*
/**********************************************************************
/* Simple property accessors
/**********************************************************************
*/
@Override
public boolean isInterface() { return true; }
@Override
public boolean isAbstract() { return true; }
@Override
public boolean isArray() { return false; }
@Override
public boolean isPrimitive() { return false; }
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
@Override
public synchronized List<RawField> getStaticFields()
{
// Interfaces can have static fields, but only as static constants...
if (_constantFields == null) {
_constantFields = _getFields(true);
}
if (_constantFields.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_constantFields);
}
@Override
public synchronized List<RawMethod> getMemberMethods()
{
if (_memberMethods == null) {
_memberMethods = _getMethods(false);
}
if (_memberMethods.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_memberMethods);
}
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
@Override
public StringBuilder appendSignature(StringBuilder sb) {
return _appendClassSignature(sb);
}
@Override
public StringBuilder appendErasedSignature(StringBuilder sb) {
return _appendErasedClassSignature(sb);
}
@Override
public StringBuilder appendBriefDescription(StringBuilder sb) {
return _appendClassDescription(sb);
}
@Override
public StringBuilder appendFullDescription(StringBuilder sb)
{
sb = _appendClassDescription(sb);
// interfaces 'extend' other interfaces...
int count = _superInterfaces.length;
if (count > 0) {
sb.append(" extends ");
for (int i = 0; i < count; ++i) {
if (i > 0) {
sb.append(",");
}
sb = _superInterfaces[i].appendBriefDescription(sb);
}
}
return sb;
}
}

287
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedObjectType.java

@ -1,287 +0,0 @@
package com.fr.third.com.fasterxml.classmate.types;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.TypeBindings;
import com.fr.third.com.fasterxml.classmate.members.RawConstructor;
import com.fr.third.com.fasterxml.classmate.members.RawField;
import com.fr.third.com.fasterxml.classmate.members.RawMethod;
/**
* Type implementation for classes that do not represent interfaces,
* primitive or array types.
*/
public class ResolvedObjectType extends ResolvedType
{
/**
* While fundamentally super class has to be {@link ResolvedObjectType}
* (or null for {@link java.lang.Object}), we may need to hold on to
* a {@link ResolvedRecursiveType} occasionally.
*/
protected final ResolvedType _superClass;
/**
* List of interfaces this type implements; may be empty but never null
*/
protected final ResolvedType[] _superInterfaces;
/**
* Modifiers of the underlying class.
*/
protected final int _modifiers;
/**
* Constructors declared by the resolved Object class.
*/
protected RawConstructor[] _constructors;
protected RawField[] _memberFields;
protected RawField[] _staticFields;
protected RawMethod[] _memberMethods;
protected RawMethod[] _staticMethods;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
public ResolvedObjectType(Class<?> erased, TypeBindings bindings,
ResolvedType superClass, List<ResolvedType> interfaces)
{
this(erased, bindings, superClass,
(interfaces == null || interfaces.isEmpty()) ? NO_TYPES :
interfaces.toArray(new ResolvedType[interfaces.size()]));
}
public ResolvedObjectType(Class<?> erased, TypeBindings bindings,
ResolvedType superClass, ResolvedType[] interfaces)
{
super(erased, bindings);
/* 19-Aug-2014, tatu: bit unclean, but has to do for now.
* Problem is, there is no common super-type, nor can we yet
* force or coerce recursive types. Rather, they may only get
* resolved only slightly after construction. So... need to
* keep a reference.
*/
if (superClass != null) {
if (!(superClass instanceof ResolvedObjectType)
&& !(superClass instanceof ResolvedRecursiveType)
) {
throw new IllegalArgumentException("Unexpected parent type for "
+erased.getName()+": "+superClass.getClass().getName());
}
}
_superClass = superClass;
_superInterfaces = (interfaces == null) ? NO_TYPES : interfaces;
_modifiers = erased.getModifiers();
}
@Deprecated // since 1.1; removed from 1.2 -- kept for binary backwards compatibility
public ResolvedObjectType(Class<?> erased, TypeBindings bindings,
ResolvedObjectType superClass, List<ResolvedType> interfaces)
{
this(erased, bindings, (ResolvedType) superClass, interfaces);
}
@Deprecated // since 1.1; removed from 1.2 -- kept for binary backwards compatibility
public ResolvedObjectType(Class<?> erased, TypeBindings bindings,
ResolvedObjectType superClass, ResolvedType[] interfaces)
{
this(erased, bindings, (ResolvedType) superClass, interfaces);
}
public static ResolvedObjectType create(Class<?> erased, TypeBindings bindings,
ResolvedType superClass, List<ResolvedType> interfaces)
{
return new ResolvedObjectType(erased, bindings, superClass, interfaces);
}
@Override
public boolean canCreateSubtypes() {
return true;
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
@Override
public ResolvedObjectType getParentClass() {
/* 19-Aug-2014, tatu: Ugly does it... sigh.
* But can't be helped because ResolvedRecursiveType is typically only
* resolved after instances of this type have been constructed.
* This means that resolution will need to be done somewhat dynamically.
*/
if (_superClass == null) {
return null;
}
if (_superClass instanceof ResolvedObjectType) {
return (ResolvedObjectType) _superClass;
}
ResolvedType rt = ((ResolvedRecursiveType) _superClass).getSelfReferencedType();
if (!(rt instanceof ResolvedObjectType)) {
throw new IllegalStateException("Internal error: self-referential parent type ("
+_superClass+") does not resolve into proper ResolvedObjectType, but instead to: "
+rt);
}
return (ResolvedObjectType) rt;
}
@Override
public ResolvedType getSelfReferencedType() { return null; }
@Override
public List<ResolvedType> getImplementedInterfaces() {
return (_superInterfaces.length == 0) ?
Collections.<ResolvedType>emptyList() : Arrays.asList(_superInterfaces);
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
@Override
public final ResolvedType getArrayElementType() { return null; }
/*
/**********************************************************************
/* Simple property accessors
/**********************************************************************
*/
@Override
public final boolean isInterface() { return false; }
@Override
public boolean isAbstract() {
return Modifier.isAbstract(_modifiers);
}
@Override
public final boolean isArray() { return false; }
@Override
public final boolean isPrimitive() { return false; }
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
@Override
public synchronized List<RawField> getMemberFields()
{
if (_memberFields == null) {
_memberFields = _getFields(false);
}
if (_memberFields.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_memberFields);
}
@Override
public synchronized List<RawField> getStaticFields()
{
if (_staticFields == null) {
_staticFields = _getFields(true);
}
if (_staticFields.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_staticFields);
}
@Override
public synchronized List<RawMethod> getMemberMethods()
{
if (_memberMethods == null) {
_memberMethods = _getMethods(false);
}
if (_memberMethods.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_memberMethods);
}
@Override
public synchronized List<RawMethod> getStaticMethods()
{
if (_staticMethods == null) {
_staticMethods = _getMethods(true);
}
if (_staticMethods.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_staticMethods);
}
@Override
public List<RawConstructor> getConstructors()
{
if (_constructors == null) {
_constructors = _getConstructors();
}
if (_constructors.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(_constructors);
}
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
@Override
public StringBuilder appendSignature(StringBuilder sb) {
return _appendClassSignature(sb);
}
@Override
public StringBuilder appendErasedSignature(StringBuilder sb) {
return _appendErasedClassSignature(sb);
}
@Override
public StringBuilder appendBriefDescription(StringBuilder sb) {
return _appendClassDescription(sb);
}
@Override
public StringBuilder appendFullDescription(StringBuilder sb)
{
sb = _appendClassDescription(sb);
if (_superClass != null) {
sb.append(" extends ");
sb = _superClass.appendBriefDescription(sb);
}
// interfaces 'extend' other interfaces...
int count = _superInterfaces.length;
if (count > 0) {
sb.append(" implements ");
for (int i = 0; i < count; ++i) {
if (i > 0) {
sb.append(",");
}
sb = _superInterfaces[i].appendBriefDescription(sb);
}
}
return sb;
}
}

157
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedPrimitiveType.java

@ -1,157 +0,0 @@
package com.fr.third.com.fasterxml.classmate.types;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.TypeBindings;
/**
* Type used for Java primitive types (which does not include arrays here).
*<p>
* Since set of primitive types is bounded, constructor is defined as protected,
* and class final; that is, new primitive types are not to be constructed
* by calling applications.
*/
public final class ResolvedPrimitiveType extends ResolvedType
{
private final static ResolvedPrimitiveType VOID = new ResolvedPrimitiveType(Void.TYPE, 'V', "void");
/**
* Primitive types have single-character Signature, easy and efficient
* to just store here
*/
protected final String _signature;
/**
* Human-readable description should be simple as well
*/
protected final String _description;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
protected ResolvedPrimitiveType(Class<?> erased, char sig, String desc)
{
super(erased, TypeBindings.emptyBindings());
_signature = String.valueOf(sig);
_description = desc;
}
public static List<ResolvedPrimitiveType> all()
{
ArrayList<ResolvedPrimitiveType> all = new ArrayList<ResolvedPrimitiveType>();
all.add(new ResolvedPrimitiveType(Boolean.TYPE, 'Z', "boolean"));
all.add(new ResolvedPrimitiveType(Byte.TYPE, 'B', "byte"));
all.add(new ResolvedPrimitiveType(Short.TYPE, 'S', "short"));
all.add(new ResolvedPrimitiveType(Character.TYPE, 'C', "char"));
all.add(new ResolvedPrimitiveType(Integer.TYPE, 'I', "int"));
all.add(new ResolvedPrimitiveType(Long.TYPE, 'J', "long"));
all.add(new ResolvedPrimitiveType(Float.TYPE, 'F', "float"));
all.add(new ResolvedPrimitiveType(Double.TYPE, 'D', "double"));
return all;
}
public static ResolvedPrimitiveType voidType()
{
return VOID;
}
@Override
public boolean canCreateSubtypes() {
return false;
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
@Override
public ResolvedType getSelfReferencedType() { return null; }
@Override
public ResolvedType getParentClass() { return null; }
/*
/**********************************************************************
/* Simple property accessors
/**********************************************************************
*/
@Override
public boolean isInterface() { return false; }
@Override
public boolean isAbstract() { return false; }
@Override
public ResolvedType getArrayElementType() { return null; }
@Override
public boolean isArray() { return false; }
@Override
public boolean isPrimitive() { return true; }
@Override
public List<ResolvedType> getImplementedInterfaces() {
return Collections.emptyList();
}
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
// Primitive types are simple; no fields, no methods, no constructors
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
@Override
public String getSignature() {
return _signature;
}
@Override
public String getErasedSignature() {
return _signature;
}
@Override
public String getFullDescription() {
return _description;
}
@Override
public StringBuilder appendSignature(StringBuilder sb) {
sb.append(_signature);
return sb;
}
@Override
public StringBuilder appendErasedSignature(StringBuilder sb) {
sb.append(_signature);
return sb;
}
@Override
public StringBuilder appendFullDescription(StringBuilder sb) {
sb.append(_description);
return sb;
}
@Override
public StringBuilder appendBriefDescription(StringBuilder sb) {
sb.append(_description);
return sb;
}
}

149
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/ResolvedRecursiveType.java

@ -1,149 +0,0 @@
package com.fr.third.com.fasterxml.classmate.types;
import java.lang.reflect.Modifier;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.TypeBindings;
import com.fr.third.com.fasterxml.classmate.members.RawConstructor;
import com.fr.third.com.fasterxml.classmate.members.RawField;
import com.fr.third.com.fasterxml.classmate.members.RawMethod;
/**
* Specialized type placeholder used in cases where type definition is
* recursive; to avoid infinite loop, reference that would be "back" in
* hierarchy is represented by an instance of this class.
* Underlying information is achievable (for full resolution), but
* not exposed using super type (parent) accessors; and has special
* handling when used for constructing descriptions.
*/
public class ResolvedRecursiveType extends ResolvedType
{
/**
* Actual fully resolved type; assigned once resolution is complete
*/
protected ResolvedType _referencedType;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
public ResolvedRecursiveType(Class<?> erased, TypeBindings bindings)
{
super(erased, bindings);
}
@Override
public boolean canCreateSubtypes() {
return _referencedType.canCreateSubtypes();
}
public void setReference(ResolvedType ref)
{
// sanity check; should not be called multiple times
if (_referencedType != null) {
throw new IllegalStateException("Trying to re-set self reference; old value = "+_referencedType+", new = "+ref);
}
_referencedType = ref;
}
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
/**
* To avoid infinite loops, will return null;
*/
@Override
public ResolvedType getParentClass() {
return null;
}
@Override
public ResolvedType getSelfReferencedType() { return _referencedType; }
/**
* To avoid infinite loops, will return empty list
*/
@Override
public List<ResolvedType> getImplementedInterfaces() {
return Collections.<ResolvedType>emptyList();
}
/**
* To avoid infinite loops, will return null type
*/
@Override
public ResolvedType getArrayElementType() { // interfaces are never arrays, so:
return null;
}
/*
/**********************************************************************
/* Simple property accessors
/**********************************************************************
*/
@Override
public boolean isInterface() { return _erasedType.isInterface(); }
@Override
public boolean isAbstract() { return Modifier.isAbstract(_erasedType.getModifiers()); }
@Override
public boolean isArray() { return _erasedType.isArray(); }
@Override
public boolean isPrimitive() { return false; }
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
@Override
public List<RawField> getMemberFields() { return _referencedType.getMemberFields(); }
@Override
public List<RawField> getStaticFields() { return _referencedType.getStaticFields(); }
@Override
public List<RawMethod> getStaticMethods() { return _referencedType.getStaticMethods(); }
@Override
public List<RawMethod> getMemberMethods() { return _referencedType.getMemberMethods(); }
@Override
public List<RawConstructor> getConstructors() { return _referencedType.getConstructors(); }
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
@Override
public StringBuilder appendSignature(StringBuilder sb) {
// to avoid infinite recursion, only print type erased version
return appendErasedSignature(sb);
}
@Override
public StringBuilder appendErasedSignature(StringBuilder sb) {
return _appendErasedClassSignature(sb);
}
@Override
public StringBuilder appendBriefDescription(StringBuilder sb) {
return _appendClassDescription(sb);
}
@Override
public StringBuilder appendFullDescription(StringBuilder sb)
{
// should never get called, but just in case, only print brief description
return appendBriefDescription(sb);
}
}

101
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/TypePlaceHolder.java

@ -1,101 +0,0 @@
package com.fr.third.com.fasterxml.classmate.types;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.TypeBindings;
/**
* Placeholder used for resolving type assignments to figure out
* type parameters for subtypes.
*/
public class TypePlaceHolder extends ResolvedType
{
protected final int _ordinal;
/**
* Type assigned during wildcard resolution
*/
protected ResolvedType _actualType;
public TypePlaceHolder(int ordinal)
{
super(Object.class, TypeBindings.emptyBindings());
_ordinal = ordinal;
}
@Override
public boolean canCreateSubtypes() { return false; }
public ResolvedType actualType() { return _actualType; }
public void actualType(ResolvedType t) { _actualType = t; }
/*
/**********************************************************************
/* Accessors for related types
/**********************************************************************
*/
@Override
public ResolvedType getParentClass() { return null; }
@Override
public ResolvedType getSelfReferencedType() { return null; }
@Override
public List<ResolvedType> getImplementedInterfaces() { return Collections.<ResolvedType>emptyList(); }
@Override
public ResolvedType getArrayElementType() { return null; }
/*
/**********************************************************************
/* Simple property accessors
/**********************************************************************
*/
@Override
public boolean isInterface() { return false; }
@Override
public boolean isAbstract() { return true; }
@Override
public boolean isArray() { return false; }
@Override
public boolean isPrimitive() { return false; }
/*
/**********************************************************************
/* Accessors for raw (minimally procesed) members
/**********************************************************************
*/
/*
/**********************************************************************
/* String representations
/**********************************************************************
*/
@Override
public StringBuilder appendSignature(StringBuilder sb) {
return _appendClassSignature(sb);
}
@Override
public StringBuilder appendErasedSignature(StringBuilder sb) {
return _appendErasedClassSignature(sb);
}
@Override
public StringBuilder appendBriefDescription(StringBuilder sb) {
sb.append('<').append(_ordinal).append('>');
return sb;
}
@Override
public StringBuilder appendFullDescription(StringBuilder sb) {
return appendBriefDescription(sb);
}
}

5
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/types/package-info.java

@ -1,5 +0,0 @@
/**
* Package that contains {@link com.fr.third.com.fasterxml.classmate.ResolvedType}
* implementation classes.
*/
package com.fr.third.com.fasterxml.classmate.types;

69
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/ClassKey.java

@ -1,69 +0,0 @@
package com.fr.third.com.fasterxml.classmate.util;
import java.io.Serializable;
/**
* Helper class used as key when we need efficient Class-to-value lookups.
*/
@SuppressWarnings("serial")
public class ClassKey
implements Comparable<ClassKey>, Serializable
{
private final String _className;
private final Class<?> _class;
/**
* Let's cache hash code straight away, since we are almost certain to need it.
*/
private final int _hashCode;
public ClassKey(Class<?> clz)
{
_class = clz;
_className = clz.getName();
_hashCode = _className.hashCode();
}
/*
/**********************************************************************
/* Comparable
/**********************************************************************
*/
@Override
public int compareTo(ClassKey other)
{
// Just need to sort by name, ok to collide (unless used in TreeMap/Set!)
return _className.compareTo(other._className);
}
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
@Override
public boolean equals(Object o)
{
if (o == this) return true;
if (o == null) return false;
if (o.getClass() != getClass()) return false;
ClassKey other = (ClassKey) o;
/* Is it possible to have different Class object for same name + class loader combo?
* Let's assume answer is no: if this is wrong, will need to uncomment following functionality
*/
/*
return (other._className.equals(_className))
&& (other._class.getClassLoader() == _class.getClassLoader());
*/
return other._class == _class;
}
@Override public int hashCode() { return _hashCode; }
@Override public String toString() { return _className; }
}

72
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/ClassStack.java

@ -1,72 +0,0 @@
package com.fr.third.com.fasterxml.classmate.util;
import java.util.ArrayList;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
import com.fr.third.com.fasterxml.classmate.types.ResolvedRecursiveType;
/**
* Simple helper class used to keep track of 'call stack' for classes being referenced
* (as well as unbound variables)
*/
public final class ClassStack
{
protected final ClassStack _parent;
protected final Class<?> _current;
private ArrayList<ResolvedRecursiveType> _selfRefs;
public ClassStack(Class<?> rootType) {
this(null, rootType);
}
private ClassStack(ClassStack parent, Class<?> curr) {
_parent = parent;
_current = curr;
}
/**
* @return New stack frame, if addition is ok; null if not
*/
public ClassStack child(Class<?> cls)
{
return new ClassStack(this, cls);
}
/**
* Method called to indicate that there is a self-reference from
* deeper down in stack pointing into type this stack frame represents.
*/
public void addSelfReference(ResolvedRecursiveType ref)
{
if (_selfRefs == null) {
_selfRefs = new ArrayList<ResolvedRecursiveType>();
}
_selfRefs.add(ref);
}
/**
* Method called when type that this stack frame represents is
* fully resolved, allowing self-references to be completed
* (if there are any)
*/
public void resolveSelfReferences(ResolvedType resolved)
{
if (_selfRefs != null) {
for (ResolvedRecursiveType ref : _selfRefs) {
ref.setReference(resolved);
}
}
}
public ClassStack find(Class<?> cls)
{
if (_current == cls) return this;
for (ClassStack curr = _parent; curr != null; curr = curr._parent) {
if (curr._current == cls) {
return curr;
}
}
return null;
}
}

71
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/MethodKey.java

@ -1,71 +0,0 @@
package com.fr.third.com.fasterxml.classmate.util;
import java.io.Serializable;
/**
* Helper class needed when storing methods in maps.
* Immutable.
*/
@SuppressWarnings("serial")
public class MethodKey implements Serializable
{
private static final Class<?>[] NO_CLASSES = new Class[0];
private final String _name;
private final Class<?>[] _argumentTypes;
private final int _hashCode;
public MethodKey(String name)
{
_name = name;
_argumentTypes = NO_CLASSES;
_hashCode = name.hashCode();
}
public MethodKey(String name, Class<?>[] argTypes)
{
_name = name;
_argumentTypes = argTypes;
_hashCode = name.hashCode() + argTypes.length;
}
/*
/**********************************************************************
/* Standard methods
/**********************************************************************
*/
/**
* Equality means name is the same and argument type erasures as well.
*/
@Override public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
MethodKey other = (MethodKey) o;
Class<?>[] otherArgs = other._argumentTypes;
int len = _argumentTypes.length;
if (otherArgs.length != len) return false;
for (int i = 0; i < len; ++i) {
if (otherArgs[i] != _argumentTypes[i]) return false;
}
return _name.equals(other._name);
}
@Override public int hashCode() { return _hashCode; }
@Override public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append(_name);
sb.append('(');
for (int i = 0, len = _argumentTypes.length; i < len; ++i) {
if (i > 0) sb.append(',');
sb.append(_argumentTypes[i].getName());
}
sb.append(')');
return sb.toString();
}
}

141
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/ResolvedTypeCache.java

@ -1,141 +0,0 @@
package com.fr.third.com.fasterxml.classmate.util;
import java.io.Serializable;
import java.util.*;
import com.fr.third.com.fasterxml.classmate.ResolvedType;
/**
* Simple LRU cache used for storing up to specified number of most recently accessed
* {@link ResolvedType} instances.
* Since usage pattern is such that caller needs synchronization, cache access methods
* are fully synchronized so that caller need not do explicit synchronization.
*/
@SuppressWarnings("serial")
public class ResolvedTypeCache implements Serializable
{
protected final CacheMap _map;
public ResolvedTypeCache(int maxEntries) {
_map = new CacheMap(maxEntries);
}
/**
* Helper method for constructing reusable cache keys
*/
public Key key(Class<?> simpleType) {
return new Key(simpleType);
}
/**
* Helper method for constructing reusable cache keys
*/
public Key key(Class<?> simpleType, ResolvedType[] tp) {
return new Key(simpleType, tp);
}
public synchronized ResolvedType find(Key key) {
return _map.get(key);
}
public synchronized int size() {
return _map.size();
}
public synchronized void put(Key key, ResolvedType type) {
_map.put(key, type);
}
/*
/**********************************************************************
/* Methods for unit tests
/**********************************************************************
*/
public void add(ResolvedType type)
{
List<ResolvedType> tp = type.getTypeParameters();
ResolvedType[] tpa = tp.toArray(new ResolvedType[tp.size()]);
put(key(type.getErasedType(), tpa), type);
}
/*
/**********************************************************************
/* Helper classes
/**********************************************************************
*/
/**
* Key used for type entries.
*/
public static class Key
{
private final Class<?> _erasedType;
private final ResolvedType[] _typeParameters;
private final int _hashCode;
public Key(Class<?> simpleType) {
this(simpleType, null);
}
public Key(Class<?> erasedType, ResolvedType[] tp)
{
// let's not hold on type empty arrays
if (tp != null && tp.length == 0) {
tp = null;
}
_erasedType = erasedType;
_typeParameters = tp;
int h = erasedType.getName().hashCode();
if (tp != null) {
h += tp.length;
}
_hashCode = h;
}
@Override
public int hashCode() { return _hashCode; }
@Override
public boolean equals(Object o)
{
if (o == this) return true;
if (o == null || o.getClass() != getClass()) return false;
Key other = (Key) o;
if (other._erasedType != _erasedType) return false;
ResolvedType[] otherTP = other._typeParameters;
if (_typeParameters == null) {
return (otherTP == null);
}
if (otherTP == null || otherTP.length != _typeParameters.length) {
return false;
}
for (int i = 0, len = _typeParameters.length; i < len; ++i) {
if (!_typeParameters[i].equals(otherTP[i])) {
return false;
}
}
return true;
}
}
/**
* Simple sub-class to get LRU cache
*/
private final static class CacheMap
extends LinkedHashMap<ResolvedTypeCache.Key, ResolvedType>
{
protected final int _maxEntries;
public CacheMap(int maxEntries) {
_maxEntries = maxEntries;
}
@Override
protected boolean removeEldestEntry(Map.Entry<Key, ResolvedType> eldest) {
return size() > _maxEntries;
}
}
}

4
fine-classmate/src/main/java/com/fr/third/com/fasterxml/classmate/util/package-info.java

@ -1,4 +0,0 @@
/**
* Various utility classes used by ClassMate.
*/
package com.fr.third.com.fasterxml.classmate.util;

2
fine-druid/pom.xml

@ -28,7 +28,7 @@
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-hibernate</artifactId>
<version>${revision}</version>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>

6
fine-ehcache/pom.xml vendored

@ -18,17 +18,17 @@
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-hibernate</artifactId>
<version>${revision}</version>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-jboss-logging</artifactId>
<version>${revision}</version>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-jboss-transaction-api</artifactId>
<version>${revision}</version>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.essential</groupId>

6
fine-hibernate/.gitignore vendored

@ -1,6 +0,0 @@
*.iml
.idea/
.DS_Store
.project
.classpath
*.gradle

9
fine-hibernate/README.md

@ -1,9 +0,0 @@
# fine-hibernate
改包名的hibernate(5.1.0.Final),包括:
- hibernate-commons-annotations
- hibernate-core
- hibernate-entitymanager
- hibernate-java8
- hibernate-jpamodelgen

BIN
fine-hibernate/lib/ant-1.8.2.jar

Binary file not shown.

BIN
fine-hibernate/lib/antlr-3.5.2-complete.jar

Binary file not shown.

BIN
fine-hibernate/lib/cdi-api-1.1-PFD.jar

Binary file not shown.

BIN
fine-hibernate/lib/dom4j-1.6.1.jar

Binary file not shown.

BIN
fine-hibernate/lib/jandex-2.0.3.Final.jar

Binary file not shown.

BIN
fine-hibernate/lib/jboss-jacc-api_1.4_spec-1.0.2.Final.jar

Binary file not shown.

BIN
fine-hibernate/lib/junit-4.12.jar

Binary file not shown.

BIN
fine-hibernate/lib/slf4j-api-1.7.7.jar

Binary file not shown.

BIN
fine-hibernate/lib/slf4j-simple-1.6.2.jar

Binary file not shown.

BIN
fine-hibernate/lib/validation-api-1.1.0.Final.jar

Binary file not shown.

118
fine-hibernate/pom.xml

@ -1,118 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fr.third</groupId>
<artifactId>step5</artifactId>
<version>${revision}</version>
<relativePath>../base-third-project/base-third-step5</relativePath>
</parent>
<artifactId>fine-hibernate</artifactId>
<version>${revision}</version>
<dependencies>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-jboss-logging</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-jboss-transaction-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fr.essential</groupId>
<artifactId>fine-jpa</artifactId>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.essential</groupId>
<artifactId>fine-antlr-old</artifactId>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-classmate</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fr.essential</groupId>
<artifactId>fine-javaassist</artifactId>
<version>${essentialVersion}</version>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-jaxb</artifactId>
<version>${revision}</version>
</dependency>
<!-->以下是lib的本地jar包依赖<-->
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>ant</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/ant-1.8.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>antlr</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/antlr-3.5.2-complete.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>cdi</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/cdi-api-1.1-PFD.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>dom4j</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/dom4j-1.6.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>jandex</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/jandex-2.0.3.Final.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>jboss-jacc-api</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/jboss-jacc-api_1.4_spec-1.0.2.Final.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>slf4j</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/slf4j-api-1.7.7.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>validation</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/validation-api-1.1.0.Final.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>junit</artifactId>
<version>local</version>
<scope>system</scope>
<systemPath>${basedir}/lib/junit-4.12.jar</systemPath>
</dependency>
</dependencies>
</project>

35
fine-hibernate/src/main/java/com/fr/third/org/hibernate/AnnotationException.java

@ -1,35 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Annotation related exception.
*
* The EJB3 EG will probably set a generic exception. I'll then use this one.
*
* @author Emmanuel Bernard
*/
public class AnnotationException extends MappingException {
/**
* Constructs an AnnotationException using the given message and cause.
*
* @param msg The message explaining the reason for the exception.
* @param cause The underlying cause.
*/
public AnnotationException(String msg, Throwable cause) {
super( msg, cause );
}
/**
* Constructs an AnnotationException using the given message.
*
* @param msg The message explaining the reason for the exception.
*/
public AnnotationException(String msg) {
super( msg );
}
}

46
fine-hibernate/src/main/java/com/fr/third/org/hibernate/AssertionFailure.java

@ -1,46 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import com.fr.third.org.hibernate.internal.CoreMessageLogger;
import com.fr.third.org.jboss.logging.Logger;
/**
* Indicates failure of an assertion: a possible bug in Hibernate.
*
* @author Gavin King
*/
public class AssertionFailure extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
AssertionFailure.class.getName()
);
/**
* Creates an instance of AssertionFailure using the given message.
*
* @param message The message explaining the reason for the exception
*/
public AssertionFailure(String message) {
super( message );
LOG.failed( this );
}
/**
* Creates an instance of AssertionFailure using the given message and underlying cause.
*
* @param message The message explaining the reason for the exception
* @param cause The underlying cause.
*/
public AssertionFailure(String message, Throwable cause) {
super( message, cause );
LOG.failed( cause );
}
}

104
fine-hibernate/src/main/java/com/fr/third/org/hibernate/BaseSessionEventListener.java

@ -1,104 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* A no-op implementation of SessionEventListener. Intended as a convenient base class for developing
* SessionEventListener implementations.
*
* @author Steve Ebersole
*/
@SuppressWarnings("UnusedDeclaration")
public class BaseSessionEventListener implements SessionEventListener {
@Override
public void transactionCompletion(boolean successful) {
}
@Override
public void jdbcConnectionAcquisitionStart() {
}
@Override
public void jdbcConnectionAcquisitionEnd() {
}
@Override
public void jdbcConnectionReleaseStart() {
}
@Override
public void jdbcConnectionReleaseEnd() {
}
@Override
public void jdbcPrepareStatementStart() {
}
@Override
public void jdbcPrepareStatementEnd() {
}
@Override
public void jdbcExecuteStatementStart() {
}
@Override
public void jdbcExecuteStatementEnd() {
}
@Override
public void jdbcExecuteBatchStart() {
}
@Override
public void jdbcExecuteBatchEnd() {
}
@Override
public void cachePutStart() {
}
@Override
public void cachePutEnd() {
}
@Override
public void cacheGetStart() {
}
@Override
public void cacheGetEnd(boolean hit) {
}
@Override
public void flushStart() {
}
@Override
public void flushEnd(int numberOfEntities, int numberOfCollections) {
}
@Override
public void partialFlushStart() {
}
@Override
public void partialFlushEnd(int numberOfEntities, int numberOfCollections) {
}
@Override
public void dirtyCalculationStart() {
}
@Override
public void dirtyCalculationEnd(boolean dirty) {
}
@Override
public void end() {
}
}

212
fine-hibernate/src/main/java/com/fr/third/org/hibernate/BasicQueryContract.java

@ -1,212 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import com.fr.third.org.hibernate.type.Type;
/**
* Defines the aspects of query definition that apply to all forms of querying.
*
* @author Steve Ebersole
*/
public interface BasicQueryContract {
/**
* Obtain the FlushMode in effect for this query. By default, the query inherits the FlushMode of the Session
* from which is originates.
*
* @return The query FlushMode.
*
* @see Session#getFlushMode()
* @see FlushMode
*/
public FlushMode getFlushMode();
/**
* (Re)set the current FlushMode in effect for this query.
*
* @param flushMode The new FlushMode to use.
*
* @return {@code this}, for method chaining
*
* @see #getFlushMode()
*/
public BasicQueryContract setFlushMode(FlushMode flushMode);
/**
* Obtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session
* from which is originates.
*
* NOTE: The CacheMode here only effects reading/writing of the query cache, not the
* entity/collection caches.
*
* @return The query CacheMode.
*
* @see Session#getCacheMode()
* @see CacheMode
*/
public CacheMode getCacheMode();
/**
* (Re)set the current CacheMode in effect for this query.
*
* @param cacheMode The new CacheMode to use.
*
* @return {@code this}, for method chaining
*
* @see #getCacheMode()
*/
public BasicQueryContract setCacheMode(CacheMode cacheMode);
/**
* Are the results of this query eligible for second level query caching? This is different that second level
* caching of any returned entities and collections.
*
* NOTE: the query being "eligible" for caching does not necessarily mean its results will be cached. Second level
* query caching still has to be enabled on the {@link SessionFactory} for this to happen. Usually that is
* controlled by the {@code hibernate.cache.use_query_cache} configuration setting.
*
* @return {@code true} if the query results are eligible for caching, {@code false} otherwise.
*
* @see com.fr.third.org.hibernate.cfg.AvailableSettings#USE_QUERY_CACHE
*/
public boolean isCacheable();
/**
* Enable/disable second level query (result) caching for this query.
*
* @param cacheable Should the query results be cacheable?
*
* @return {@code this}, for method chaining
*
* @see #isCacheable
*/
public BasicQueryContract setCacheable(boolean cacheable);
/**
* Obtain the name of the second level query cache region in which query results will be stored (if they are
* cached, see the discussion on {@link #isCacheable()} for more information). {@code null} indicates that the
* default region should be used.
*
* @return The specified cache region name into which query results should be placed; {@code null} indicates
* the default region.
*/
public String getCacheRegion();
/**
* Set the name of the cache region where query results should be cached (if cached at all).
*
* @param cacheRegion the name of a query cache region, or {@code null} to indicate that the default region
* should be used.
*
* @return {@code this}, for method chaining
*
* @see #getCacheRegion()
*/
public BasicQueryContract setCacheRegion(String cacheRegion);
/**
* Obtain the query timeout <b>in seconds</b>. This value is eventually passed along to the JDBC query via
* {@link java.sql.Statement#setQueryTimeout(int)}. Zero indicates no timeout.
*
* @return The timeout <b>in seconds</b>
*
* @see java.sql.Statement#getQueryTimeout()
* @see java.sql.Statement#setQueryTimeout(int)
*/
public Integer getTimeout();
/**
* Set the query timeout <b>in seconds</b>.
*
* NOTE it is important to understand that any value set here is eventually passed directly through to the JDBC
* Statement which expressly disallows negative values. So negative values should be avoided as a general rule.
*
* @param timeout the timeout <b>in seconds</b>
*
* @return {@code this}, for method chaining
*
* @see #getTimeout()
*/
public BasicQueryContract setTimeout(int timeout);
/**
* Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC
* query via {@link java.sql.Statement#setFetchSize(int)}. As defined b y JDBC, this value is a hint to the
* driver to indicate how many rows to fetch from the database when more rows are needed.
*
* NOTE : JDBC expressly defines this value as a hint. It may or may not have any effect on the actual
* query execution and ResultSet processing depending on the driver.
*
* @return The timeout <b>in seconds</b>
*
* @see java.sql.Statement#getFetchSize()
* @see java.sql.Statement#setFetchSize(int)
*/
public Integer getFetchSize();
/**
* Sets a JDBC fetch size hint for the query.
*
* @param fetchSize the fetch size hint
*
* @return {@code this}, for method chaining
*
* @see #getFetchSize()
*/
public BasicQueryContract setFetchSize(int fetchSize);
/**
* Should entities and proxies loaded by this Query be put in read-only mode? If the
* read-only/modifiable setting was not initialized, then the default
* read-only/modifiable setting for the persistence context is returned instead.
* @see Query#setReadOnly(boolean)
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly()
*
* The read-only/modifiable setting has no impact on entities/proxies returned by the
* query that existed in the session before the query was executed.
*
* @return true, entities and proxies loaded by the query will be put in read-only mode
* false, entities and proxies loaded by the query will be put in modifiable mode
*/
public boolean isReadOnly();
/**
* Set the read-only/modifiable mode for entities and proxies
* loaded by this Query. This setting overrides the default setting
* for the persistence context.
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly()
*
* To set the default read-only/modifiable setting used for
* entities and proxies that are loaded into the session:
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#setDefaultReadOnly(boolean)
* @see com.fr.third.org.hibernate.Session#setDefaultReadOnly(boolean)
*
* Read-only entities are not dirty-checked and snapshots of persistent
* state are not maintained. Read-only entities can be modified, but
* changes are not persisted.
*
* When a proxy is initialized, the loaded entity will have the same
* read-only/modifiable setting as the uninitialized
* proxy has, regardless of the session's current setting.
*
* The read-only/modifiable setting has no impact on entities/proxies
* returned by the query that existed in the session before the query was executed.
*
* @return {@code this}, for method chaining
*
* @param readOnly true, entities and proxies loaded by the query will be put in read-only mode
* false, entities and proxies loaded by the query will be put in modifiable mode
*/
public BasicQueryContract setReadOnly(boolean readOnly);
/**
* Return the Hibernate types of the query results.
*
* @return an array of types
*/
public Type[] getReturnTypes();
}

178
fine-hibernate/src/main/java/com/fr/third/org/hibernate/Cache.java

@ -1,178 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.Serializable;
/**
* Provides an API for querying/managing the second level cache regions.
* <p/>
* CAUTION: None of these methods respect any isolation or transactional
* semantics associated with the underlying caches. Specifically, evictions
* perform an immediate "hard" removal outside any transactions and/or locking
* scheme(s).
*
* @author Steve Ebersole
*/
public interface Cache {
/**
* Determine whether the cache contains data for the given entity "instance".
* <p/>
* The semantic here is whether the cache contains data visible for the
* current call context.
*
* @param entityClass The entity class.
* @param identifier The entity identifier
*
* @return True if the underlying cache contains corresponding data; false
* otherwise.
*/
public boolean containsEntity(Class entityClass, Serializable identifier);
/**
* Determine whether the cache contains data for the given entity "instance".
* <p/>
* The semantic here is whether the cache contains data visible for the
* current call context.
*
* @param entityName The entity name.
* @param identifier The entity identifier
*
* @return True if the underlying cache contains corresponding data; false otherwise.
*/
public boolean containsEntity(String entityName, Serializable identifier);
/**
* Evicts the entity data for a particular entity "instance".
*
* @param entityClass The entity class.
* @param identifier The entity identifier
*/
public void evictEntity(Class entityClass, Serializable identifier);
/**
* Evicts the entity data for a particular entity "instance".
*
* @param entityName The entity name.
* @param identifier The entity identifier
*/
public void evictEntity(String entityName, Serializable identifier);
/**
* Evicts all entity data from the given region (i.e. for all entities of
* type).
*
* @param entityClass The entity class.
*/
public void evictEntityRegion(Class entityClass);
/**
* Evicts all entity data from the given region (i.e. for all entities of
* type).
*
* @param entityName The entity name.
*/
public void evictEntityRegion(String entityName);
/**
* Evict data from all entity regions.
*/
public void evictEntityRegions();
/**
* Evicts all naturalId data from the given region (i.e. for all entities of
* type).
*
* @param naturalIdClass The naturalId class.
*/
@SuppressWarnings( {"UnusedDeclaration"})
public void evictNaturalIdRegion(Class naturalIdClass);
/**
* Evicts all naturalId data from the given region (i.e. for all entities of
* type).
*
* @param naturalIdName The naturalId name.
*/
public void evictNaturalIdRegion(String naturalIdName);
/**
* Evict data from all naturalId regions.
*/
public void evictNaturalIdRegions();
/**
* Determine whether the cache contains data for the given collection.
* <p/>
* The semantic here is whether the cache contains data visible for the
* current call context.
*
* @param role The name of the collection role (in form
* [owner-entity-name].[collection-property-name]) whose regions should be
* evicted.
* @param ownerIdentifier The identifier of the owning entity
*
* @return True if the underlying cache contains corresponding data; false otherwise.
*/
@SuppressWarnings( {"UnusedDeclaration"})
public boolean containsCollection(String role, Serializable ownerIdentifier);
/**
* Evicts the cache data for the given identified collection instance.
*
* @param role The "collection role" (in form [owner-entity-name].[collection-property-name]).
* @param ownerIdentifier The identifier of the owning entity
*/
public void evictCollection(String role, Serializable ownerIdentifier);
/**
* Evicts all entity data from the given region (i.e. evicts cached data
* for all of the specified collection role).
*
* @param role The "collection role" (in form [owner-entity-name].[collection-property-name]).
*/
public void evictCollectionRegion(String role);
/**
* Evict data from all collection regions.
*/
public void evictCollectionRegions();
/**
* Determine whether the cache contains data for the given query.
* <p/>
* The semantic here is whether the cache contains any data for the given
* region name since query result caches are not transactionally isolated.
*
* @param regionName The cache name given to the query.
*
* @return True if the underlying cache contains corresponding data; false otherwise.
*/
@SuppressWarnings( {"UnusedDeclaration"})
public boolean containsQuery(String regionName);
/**
* Evicts all cached query results from the default region.
*/
public void evictDefaultQueryRegion();
/**
* Evicts all cached query results under the given name.
*
* @param regionName The cache name associated to the queries being cached.
*/
public void evictQueryRegion(String regionName);
/**
* Evict data from all query regions.
*/
public void evictQueryRegions();
/**
* Evict all data from the cache.
*/
public void evictAllRegions();
}

94
fine-hibernate/src/main/java/com/fr/third/org/hibernate/CacheMode.java

@ -1,94 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Locale;
/**
* Controls how the session interacts with the second-level cache and query cache.
*
* @author Gavin King
* @author Strong Liu
* @see Session#setCacheMode(CacheMode)
*/
public enum CacheMode {
/**
* The session may read items from the cache, and add items to the cache.
*/
NORMAL( true, true ),
/**
* The session will never interact with the cache, except to invalidate
* cache items when updates occur.
*/
IGNORE( false, false ),
/**
* The session may read items from the cache, but will not add items,
* except to invalidate items when updates occur.
*/
GET( false, true ),
/**
* The session will never read items from the cache, but will add items
* to the cache as it reads them from the database.
*/
PUT( true, false ),
/**
* The session will never read items from the cache, but will add items
* to the cache as it reads them from the database. In this mode, the
* effect of <tt>hibernate.cache.use_minimal_puts</tt> is bypassed, in
* order to <em>force</em> a cache refresh.
*/
REFRESH( true, false );
private final boolean isPutEnabled;
private final boolean isGetEnabled;
private CacheMode( boolean isPutEnabled, boolean isGetEnabled) {
this.isPutEnabled = isPutEnabled;
this.isGetEnabled = isGetEnabled;
}
/**
* Does this cache mode indicate that reads are allowed?
*
* @return {@code true} if cache reads are allowed; {@code false} otherwise.
*/
public boolean isGetEnabled() {
return isGetEnabled;
}
/**
* Does this cache mode indicate that writes are allowed?
*
* @return {@code true} if cache writes are allowed; {@code false} otherwise.
*/
public boolean isPutEnabled() {
return isPutEnabled;
}
/**
* Used to interpret externalized forms of this enum.
*
* @param setting The externalized form.
*
* @return The matching enum value.
*
* @throws MappingException Indicates the external form was not recognized as a valid enum value.
*/
public static CacheMode interpretExternalSetting(String setting) {
if (setting == null) {
return null;
}
try {
return CacheMode.valueOf( setting.toUpperCase(Locale.ROOT) );
}
catch ( IllegalArgumentException e ) {
throw new MappingException( "Unknown Cache Mode: " + setting );
}
}
}

46
fine-hibernate/src/main/java/com/fr/third/org/hibernate/CallbackException.java

@ -1,46 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Intended to be thrown from {@link com.fr.third.org.hibernate.classic.Lifecycle} and {@link Interceptor} callbacks.
* <p/>
* IMPL NOTE : This is a legacy exception type from back in the day before Hibernate moved to a untyped (runtime)
* exception strategy.
*
* @author Gavin King
*/
public class CallbackException extends HibernateException {
/**
* Creates a CallbackException using the given underlying cause.
*
* @param cause The underlying cause
*/
public CallbackException(Exception cause) {
this( "An exception occurred in a callback", cause );
}
/**
* Creates a CallbackException using the given message.
*
* @param message The message explaining the reason for the exception
*/
public CallbackException(String message) {
super( message );
}
/**
* Creates a CallbackException using the given message and underlying cause.
*
* @param message The message explaining the reason for the exception
* @param cause The underlying cause
*/
public CallbackException(String message, Exception cause) {
super( message, cause );
}
}

35
fine-hibernate/src/main/java/com/fr/third/org/hibernate/ConnectionAcquisitionMode.java

@ -1,35 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Indicates the manner in which JDBC Connections should be acquired. Inverse to
* {@link com.fr.third.org.hibernate.ConnectionReleaseMode}.
*
* @author Steve Ebersole
*/
public enum ConnectionAcquisitionMode {
/**
* The Connection will be acquired as soon as the Hibernate Session is opened. This
* also circumvents ConnectionReleaseMode, as the Connection will then be held until the
* Session is closed.
*/
IMMEDIATELY,
/**
* The legacy behavior. A Connection is only acquired when (if) it is actually needed.
*/
AS_NEEDED;
public static ConnectionAcquisitionMode interpret(String value) {
if ( value != null
&& ( "immediate".equalsIgnoreCase( value ) || "immediately".equalsIgnoreCase( value ) ) ) {
return IMMEDIATELY;
}
return AS_NEEDED;
}
}

51
fine-hibernate/src/main/java/com/fr/third/org/hibernate/ConnectionReleaseMode.java

@ -1,51 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Locale;
/**
* Defines the various policies by which Hibernate might release its underlying
* JDBC connection. Inverse of {@link ConnectionAcquisitionMode}.
*
* @author Steve Ebersole
*/
public enum ConnectionReleaseMode{
/**
* Indicates that JDBC connection should be aggressively released after each
* SQL statement is executed. In this mode, the application <em>must</em>
* explicitly close all iterators and scrollable results. This mode may
* only be used with a JTA datasource.
*/
AFTER_STATEMENT,
/**
* Indicates that JDBC connections should be released after each transaction
* ends (works with both JTA-registered synch and HibernateTransaction API).
* This mode may not be used with an application server JTA datasource.
* <p/>
* This is the default mode starting in 3.1; was previously {@link #ON_CLOSE}.
*/
AFTER_TRANSACTION,
/**
* Indicates that connections should only be released when the Session is explicitly closed
* or disconnected; this is the legacy (Hibernate2 and pre-3.1) behavior.
*/
ON_CLOSE;
/**
* Alias for {@link ConnectionReleaseMode#valueOf(String)} using upper-case version of the incoming name.
*
* @param name The name to parse
*
* @return The matched enum value.
*/
public static ConnectionReleaseMode parse(final String name) {
return ConnectionReleaseMode.valueOf( name.toUpperCase(Locale.ROOT) );
}
}

566
fine-hibernate/src/main/java/com/fr/third/org/hibernate/Criteria.java

@ -1,566 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.List;
import com.fr.third.org.hibernate.criterion.CriteriaSpecification;
import com.fr.third.org.hibernate.criterion.Criterion;
import com.fr.third.org.hibernate.criterion.Order;
import com.fr.third.org.hibernate.criterion.Projection;
import com.fr.third.org.hibernate.sql.JoinType;
import com.fr.third.org.hibernate.transform.ResultTransformer;
/**
* <tt>Criteria</tt> is a simplified API for retrieving entities
* by composing <tt>Criterion</tt> objects. This is a very
* convenient approach for functionality like "search" screens
* where there is a variable number of conditions to be placed
* upon the result set.<br>
* <br>
* The <tt>Session</tt> is a factory for <tt>Criteria</tt>.
* <tt>Criterion</tt> instances are usually obtained via
* the factory methods on <tt>Restrictions</tt>. eg.
* <pre>
* List cats = session.createCriteria(Cat.class)
* .add( Restrictions.like("name", "Iz%") )
* .add( Restrictions.gt( "weight", new Float(minWeight) ) )
* .addOrder( Order.asc("age") )
* .list();
* </pre>
* You may navigate associations using <tt>createAlias()</tt> or
* <tt>createCriteria()</tt>.
* <pre>
* List cats = session.createCriteria(Cat.class)
* .createCriteria("kittens")
* .add( Restrictions.like("name", "Iz%") )
* .list();
* </pre>
* <pre>
* List cats = session.createCriteria(Cat.class)
* .createAlias("kittens", "kit")
* .add( Restrictions.like("kit.name", "Iz%") )
* .list();
* </pre>
* You may specify projection and aggregation using <tt>Projection</tt>
* instances obtained via the factory methods on <tt>Projections</tt>.
* <pre>
* List cats = session.createCriteria(Cat.class)
* .setProjection( Projections.projectionList()
* .add( Projections.rowCount() )
* .add( Projections.avg("weight") )
* .add( Projections.max("weight") )
* .add( Projections.min("weight") )
* .add( Projections.groupProperty("color") )
* )
* .addOrder( Order.asc("color") )
* .list();
* </pre>
*
* @see Session#createCriteria(java.lang.Class)
* @see com.fr.third.org.hibernate.criterion.Restrictions
* @see com.fr.third.org.hibernate.criterion.Projections
* @see com.fr.third.org.hibernate.criterion.Order
* @see com.fr.third.org.hibernate.criterion.Criterion
* @see com.fr.third.org.hibernate.criterion.Projection
* @see com.fr.third.org.hibernate.criterion.DetachedCriteria a disconnected version of this API
* @author Gavin King
*/
public interface Criteria extends CriteriaSpecification {
/**
* Get the alias of the entity encapsulated by this criteria instance.
*
* @return The alias for the encapsulated entity.
*/
public String getAlias();
/**
* Used to specify that the query results will be a projection (scalar in
* nature). Implicitly specifies the {@link #PROJECTION} result transformer.
* <p/>
* The individual components contained within the given
* {@link Projection projection} determines the overall "shape" of the
* query result.
*
* @param projection The projection representing the overall "shape" of the
* query results.
* @return this (for method chaining)
*/
public Criteria setProjection(Projection projection);
/**
* Add a {@link Criterion restriction} to constrain the results to be
* retrieved.
*
* @param criterion The {@link Criterion criterion} object representing the
* restriction to be applied.
* @return this (for method chaining)
*/
public Criteria add(Criterion criterion);
/**
* Add an {@link Order ordering} to the result set.
*
* @param order The {@link Order order} object representing an ordering
* to be applied to the results.
* @return this (for method chaining)
*/
public Criteria addOrder(Order order);
/**
* Specify an association fetching strategy for an association or a
* collection of values.
*
* @param associationPath a dot separated property path
* @param mode The fetch mode for the referenced association
*
* @return this (for method chaining)
*
* @throws HibernateException Indicates a problem applying the given fetch mode
*/
public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;
/**
* Set the lock mode of the current entity.
*
* @param lockMode The lock mode to be applied
*
* @return this (for method chaining)
*/
public Criteria setLockMode(LockMode lockMode);
/**
* Set the lock mode of the aliased entity.
*
* @param alias The previously assigned alias representing the entity to
* which the given lock mode should apply.
* @param lockMode The lock mode to be applied
*
* @return this (for method chaining)
*/
public Criteria setLockMode(String alias, LockMode lockMode);
/**
* Join an association, assigning an alias to the joined association.
* <p/>
* Functionally equivalent to {@link #createAlias(String, String, JoinType )} using
* {@link JoinType#INNER_JOIN} for the joinType.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
*
* @return this (for method chaining)
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createAlias(String associationPath, String alias) throws HibernateException;
/**
* Join an association using the specified join-type, assigning an alias
* to the joined association.
* <p/>
* The joinType is expected to be one of {@link JoinType#INNER_JOIN} (the default),
* {@link JoinType#FULL_JOIN}, or {@link JoinType#LEFT_OUTER_JOIN}.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
*
* @return this (for method chaining)
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createAlias(String associationPath, String alias, JoinType joinType) throws HibernateException;
/**
* Join an association using the specified join-type, assigning an alias
* to the joined association.
* <p/>
* The joinType is expected to be one of {@link #INNER_JOIN} (the default),
* {@link #FULL_JOIN}, or {@link #LEFT_JOIN}.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
*
* @return this (for method chaining)
*
* @throws HibernateException Indicates a problem creating the sub criteria
* @deprecated use {@link #createAlias(String, String, com.fr.third.org.hibernate.sql.JoinType)}
*/
@Deprecated
public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException;
/**
* Join an association using the specified join-type, assigning an alias
* to the joined association.
* <p/>
* The joinType is expected to be one of {@link JoinType#INNER_JOIN} (the default),
* {@link JoinType#FULL_JOIN}, or {@link JoinType#LEFT_OUTER_JOIN}.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause)
*
* @return this (for method chaining)
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createAlias(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException;
/**
* Join an association using the specified join-type, assigning an alias
* to the joined association.
* <p/>
* The joinType is expected to be one of {@link #INNER_JOIN} (the default),
* {@link #FULL_JOIN}, or {@link #LEFT_JOIN}.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause)
*
* @return this (for method chaining)
*
* @throws HibernateException Indicates a problem creating the sub criteria
* @deprecated use {@link #createAlias(String, String, JoinType, Criterion)}
*/
@Deprecated
public Criteria createAlias(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity.
* <p/>
* Functionally equivalent to {@link #createCriteria(String, com.fr.third.org.hibernate.sql.JoinType)} using
* {@link JoinType#INNER_JOIN} for the joinType.
*
* @param associationPath A dot-separated property path
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createCriteria(String associationPath) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, using the
* specified join type.
*
* @param associationPath A dot-separated property path
* @param joinType The type of join to use.
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createCriteria(String associationPath, JoinType joinType) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, using the
* specified join type.
*
* @param associationPath A dot-separated property path
* @param joinType The type of join to use.
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
* @deprecated use {@link #createAlias(String, String, com.fr.third.org.hibernate.sql.JoinType)}
*/
@Deprecated
public Criteria createCriteria(String associationPath, int joinType) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
* assigning the given alias.
* <p/>
* Functionally equivalent to {@link #createCriteria(String, String, com.fr.third.org.hibernate.sql.JoinType)} using
* {@link JoinType#INNER_JOIN} for the joinType.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createCriteria(String associationPath, String alias) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
* assigning the given alias and using the specified join type.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createCriteria(String associationPath, String alias, JoinType joinType) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
* assigning the given alias and using the specified join type.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
* @deprecated use {@link #createCriteria(String, com.fr.third.org.hibernate.sql.JoinType)}
*/
@Deprecated
public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
* assigning the given alias and using the specified join type.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause)
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
*/
public Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException;
/**
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
* assigning the given alias and using the specified join type.
*
* @param associationPath A dot-separated property path
* @param alias The alias to assign to the joined association (for later reference).
* @param joinType The type of join to use.
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause)
*
* @return the created "sub criteria"
*
* @throws HibernateException Indicates a problem creating the sub criteria
* @deprecated use {@link #createCriteria(String, String, com.fr.third.org.hibernate.sql.JoinType, com.fr.third.org.hibernate.criterion.Criterion)}
*/
@Deprecated
public Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException;
/**
* Set a strategy for handling the query results. This determines the
* "shape" of the query result.
*
* @param resultTransformer The transformer to apply
* @return this (for method chaining)
*
* @see #ROOT_ENTITY
* @see #DISTINCT_ROOT_ENTITY
* @see #ALIAS_TO_ENTITY_MAP
* @see #PROJECTION
*/
public Criteria setResultTransformer(ResultTransformer resultTransformer);
/**
* Set a limit upon the number of objects to be retrieved.
*
* @param maxResults the maximum number of results
* @return this (for method chaining)
*/
public Criteria setMaxResults(int maxResults);
/**
* Set the first result to be retrieved.
*
* @param firstResult the first result to retrieve, numbered from <tt>0</tt>
* @return this (for method chaining)
*/
public Criteria setFirstResult(int firstResult);
/**
* Was the read-only/modifiable mode explicitly initialized?
*
* @return true, the read-only/modifiable mode was explicitly initialized; false, otherwise.
*
* @see Criteria#setReadOnly(boolean)
*/
public boolean isReadOnlyInitialized();
/**
* Should entities and proxies loaded by this Criteria be put in read-only mode? If the
* read-only/modifiable setting was not initialized, then the default
* read-only/modifiable setting for the persistence context is returned instead.
* @see Criteria#setReadOnly(boolean)
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly()
*
* The read-only/modifiable setting has no impact on entities/proxies returned by the
* Criteria that existed in the session before the Criteria was executed.
*
* @return true, entities and proxies loaded by the criteria will be put in read-only mode
* false, entities and proxies loaded by the criteria will be put in modifiable mode
* @throws IllegalStateException if <code>isReadOnlyInitialized()</code> returns <code>false</code>
* and this Criteria is not associated with a session.
* @see Criteria#isReadOnlyInitialized()
*/
public boolean isReadOnly();
/**
* Set the read-only/modifiable mode for entities and proxies
* loaded by this Criteria. This setting overrides the default setting
* for the persistence context.
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly()
*
* To set the default read-only/modifiable setting used for
* entities and proxies that are loaded into the session:
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#setDefaultReadOnly(boolean)
* @see com.fr.third.org.hibernate.Session#setDefaultReadOnly(boolean)
*
* Read-only entities are not dirty-checked and snapshots of persistent
* state are not maintained. Read-only entities can be modified, but
* changes are not persisted.
*
* When a proxy is initialized, the loaded entity will have the same
* read-only/modifiable setting as the uninitialized
* proxy has, regardless of the session's current setting.
*
* The read-only/modifiable setting has no impact on entities/proxies
* returned by the criteria that existed in the session before the criteria was executed.
*
* @param readOnly true, entities and proxies loaded by the criteria will be put in read-only mode
* false, entities and proxies loaded by the criteria will be put in modifiable mode
* @return {@code this}, for method chaining
*/
public Criteria setReadOnly(boolean readOnly);
/**
* Set a fetch size for the underlying JDBC query.
*
* @param fetchSize the fetch size
* @return this (for method chaining)
*
* @see java.sql.Statement#setFetchSize
*/
public Criteria setFetchSize(int fetchSize);
/**
* Set a timeout for the underlying JDBC query.
*
* @param timeout The timeout value to apply.
* @return this (for method chaining)
*
* @see java.sql.Statement#setQueryTimeout
*/
public Criteria setTimeout(int timeout);
/**
* Enable caching of this query result, provided query caching is enabled
* for the underlying session factory.
*
* @param cacheable Should the result be considered cacheable; default is
* to not cache (false).
* @return this (for method chaining)
*/
public Criteria setCacheable(boolean cacheable);
/**
* Set the name of the cache region to use for query result caching.
*
* @param cacheRegion the name of a query cache region, or <tt>null</tt>
* for the default query cache
* @return this (for method chaining)
*
* @see #setCacheable
*/
public Criteria setCacheRegion(String cacheRegion);
/**
* Add a comment to the generated SQL.
*
* @param comment a human-readable string
* @return this (for method chaining)
*/
public Criteria setComment(String comment);
/**
* Add a DB query hint to the SQL. These differ from JPA's {@link com.fr.third.javax.persistence.QueryHint}, which is specific
* to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the
* vendor-specific hints, such as Oracle's optimizers. Multiple query hints are supported; the Dialect will
* determine concatenation and placement.
*
* @param hint The database specific query hint to add.
* @return this (for method chaining)
*/
public Criteria addQueryHint(String hint);
/**
* Override the flush mode for this particular query.
*
* @param flushMode The flush mode to use.
* @return this (for method chaining)
*/
public Criteria setFlushMode(FlushMode flushMode);
/**
* Override the cache mode for this particular query.
*
* @param cacheMode The cache mode to use.
* @return this (for method chaining)
*/
public Criteria setCacheMode(CacheMode cacheMode);
/**
* Get the results.
*
* @return The list of matched query results.
*
* @throws HibernateException Indicates a problem either translating the criteria to SQL,
* exeucting the SQL or processing the SQL results.
*/
public List list() throws HibernateException;
/**
* Get the results as an instance of {@link ScrollableResults}.
*
* @return The {@link ScrollableResults} representing the matched
* query results.
*
* @throws HibernateException Indicates a problem either translating the criteria to SQL,
* exeucting the SQL or processing the SQL results.
*/
public ScrollableResults scroll() throws HibernateException;
/**
* Get the results as an instance of {@link ScrollableResults} based on the
* given scroll mode.
*
* @param scrollMode Indicates the type of underlying database cursor to
* request.
*
* @return The {@link ScrollableResults} representing the matched
* query results.
*
* @throws HibernateException Indicates a problem either translating the criteria to SQL,
* exeucting the SQL or processing the SQL results.
*/
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException;
/**
* Convenience method to return a single instance that matches
* the query, or null if the query returns no results.
*
* @return the single result or <tt>null</tt>
* @throws HibernateException if there is more than one matching result
*/
public Object uniqueResult() throws HibernateException;
}

157
fine-hibernate/src/main/java/com/fr/third/org/hibernate/CustomEntityDirtinessStrategy.java

@ -1,157 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import com.fr.third.org.hibernate.persister.entity.EntityPersister;
import com.fr.third.org.hibernate.type.Type;
/**
* During a flush cycle, Hibernate needs to determine which of the entities associated with a {@link Session}.
* Dirty entities are the ones that get {@literal UPDATE}ed to the database.
* <p/>
* In some circumstances, that process of determining whether an entity is dirty can take a significant time as
* by default Hibernate must check each of the entity's attribute values one-by-one. Oftentimes applications
* already have knowledge of an entity's dirtiness and using that information instead would be more performant.
* The purpose of this contract then is to allow applications such a plug-in point.
*
* @author Steve Ebersole
*/
public interface CustomEntityDirtinessStrategy {
/**
* Is this strategy capable of telling whether the given entity is dirty? A return of {@code true} means that
* {@link #isDirty} will be called next as the definitive means to determine whether the entity is dirty.
*
* @param entity The entity to be check.
* @param persister The persister corresponding to the given entity
* @param session The session from which this check originates.
*
* @return {@code true} indicates the dirty check can be done; {@code false} indicates it cannot.
*/
public boolean canDirtyCheck(Object entity, EntityPersister persister, Session session);
/**
* The callback used by Hibernate to determine if the given entity is dirty. Only called if the previous
* {@link #canDirtyCheck} returned {@code true}
*
* @param entity The entity to check.
* @param persister The persister corresponding to the given entity
* @param session The session from which this check originates.
*
* @return {@code true} indicates the entity is dirty; {@link false} indicates the entity is not dirty.
*/
public boolean isDirty(Object entity, EntityPersister persister, Session session);
/**
* Callback used by Hibernate to signal that the entity dirty flag should be cleared. Generally this
* happens after previous dirty changes were written to the database.
*
* @param entity The entity to reset
* @param persister The persister corresponding to the given entity
* @param session The session from which this call originates.
*/
public void resetDirty(Object entity, EntityPersister persister, Session session);
/**
* Callback used to hook into Hibernate algorithm for determination of which attributes have changed. Applications
* wanting to hook in to this would call back into the given {@link DirtyCheckContext#doDirtyChecking}
* method passing along an appropriate {@link AttributeChecker} implementation.
*
* @param entity The entity being checked
* @param persister The persister corresponding to the given entity
* @param session The session from which this call originates.
* @param dirtyCheckContext The callback context
*/
public void findDirty(Object entity, EntityPersister persister, Session session, DirtyCheckContext dirtyCheckContext);
/**
* A callback to drive dirty checking. Handed to the {@link CustomEntityDirtinessStrategy#findDirty} method
* so that it can callback on to it if it wants to handle dirty checking rather than using Hibernate's default
* checking
*
* @see CustomEntityDirtinessStrategy#findDirty
*/
public static interface DirtyCheckContext {
/**
* The callback to indicate that dirty checking (the dirty attribute determination phase) should be handled
* by the calling {@link CustomEntityDirtinessStrategy} using the given {@link AttributeChecker}.
*
* @param attributeChecker The delegate usable by the context for determining which attributes are dirty.
*/
public void doDirtyChecking(AttributeChecker attributeChecker);
}
/**
* Responsible for identifying when attributes are dirty.
*/
public static interface AttributeChecker {
/**
* Do the attribute dirty check.
*
* @param attributeInformation Information about the attribute which is useful to help determine if it is
* dirty.
*
* @return {@code true} indicates the attribute value has changed; {@code false} indicates it has not.
*/
public boolean isDirty(AttributeInformation attributeInformation);
}
/**
* Provides {@link AttributeChecker} with meta information about the attributes being checked.
*/
@SuppressWarnings( {"UnusedDeclaration"})
public static interface AttributeInformation {
/**
* Get a reference to the persister for the entity containing this attribute.
*
* @return The entity persister.
*/
public EntityPersister getContainingPersister();
/**
* Many of Hibernate internals use arrays to define information about attributes. This value
* provides this index into those arrays for this particular attribute.
* <p/>
* It can be useful if needing to leverage those Hibernate internals.
*
* @return The attribute index.
*/
public int getAttributeIndex();
/**
* Get the name of this attribute.
*
* @return The attribute name
*/
public String getName();
/**
* Get the mapping type of this attribute.
*
* @return The mapping type.
*/
public Type getType();
/**
* Get the current value of this attribute.
*
* @return The attributes current value
*/
public Object getCurrentValue();
/**
* Get the loaded value of this attribute.
* <p/>
* <b>NOTE : A call to this method may require hitting the database in cases where the loaded state is
* not known. In those cases the db hit is incurred only once per entity, not for each attribute.</b>
*
* @return The attributes loaded value
*/
public Object getLoadedValue();
}
}

128
fine-hibernate/src/main/java/com/fr/third/org/hibernate/DuplicateMappingException.java

@ -1,128 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Raised whenever a duplicate for a certain type occurs. Duplicate class, table, property name etc.
*
* @author Max Rydahl Andersen
* @author Steve Ebersole
*/
public class DuplicateMappingException extends MappingException {
/**
* Enumeration of the types of things that can be duplicated.
*/
public static enum Type {
/**
* A duplicate entity definition was encountered.
*/
ENTITY( "entity" ),
/**
* A duplicate collection role was encountered
*/
COLLECTION( "collection" ),
/**
* A duplicate table definition was encountered.
*/
TABLE( "table" ),
/**
* A duplicate property/attribute definition was encountered.
*/
PROPERTY( "property" ),
/**
* A duplicate column definition was encountered.
*/
COLUMN( "column" ),
/**
* A duplicate column definition was encountered.
*/
COLUMN_BINDING( "column-binding" ),
/**
* A duplicate named entity graph was encountered
*/
NAMED_ENTITY_GRAPH( "NamedEntityGraph" ),
/**
* A duplicate named query (ql or native) was encountered
*/
QUERY( "query" ),
/**
* A duplicate ResultSetMapping was encountered
*/
RESULT_SET_MAPPING( "ResultSetMapping" ),
/**
* A duplicate NamedStoredProcedureQuery was encountered
*/
PROCEDURE( "NamedStoredProcedureQuery" );
private final String text;
Type(String text) {
this.text = text;
}
}
private final String name;
private final String type;
/**
* Creates a DuplicateMappingException using the given type and name.
*
* @param type The type of the duplicated thing.
* @param name The name of the duplicated thing.
*/
public DuplicateMappingException(Type type, String name) {
this( type.text, name );
}
/**
* Creates a DuplicateMappingException using the given type and name.
*
* @param type The type of the duplicated thing.
* @param name The name of the duplicated thing.
*
* @deprecated Use the for taking {@link Type} instead.
*/
@Deprecated
public DuplicateMappingException(String type, String name) {
this( "Duplicate " + type + " mapping " + name, type, name );
}
/**
* Creates a DuplicateMappingException using the given customMessage, type and name.
*
* @param customMessage A custom exception message explaining the exception condition
* @param type The type of the duplicated thing.
* @param name The name of the duplicated thing.
*/
public DuplicateMappingException(String customMessage, Type type, String name) {
this( customMessage, type.name(), name );
}
/**
* Creates a DuplicateMappingException using the given customMessage, type and name.
*
* @param customMessage A custom exception message explaining the exception condition
* @param type The type of the duplicated thing.
* @param name The name of the duplicated thing.
*
* @deprecated Use the for taking {@link Type} instead.
*/
@Deprecated
public DuplicateMappingException(String customMessage, String type, String name) {
super( customMessage );
this.type=type;
this.name=name;
}
public String getType() {
return type;
}
public String getName() {
return name;
}
}

134
fine-hibernate/src/main/java/com/fr/third/org/hibernate/EmptyInterceptor.java

@ -1,134 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.Serializable;
import java.util.Iterator;
import com.fr.third.org.hibernate.type.Type;
/**
* An interceptor that does nothing. May be used as a base class for application-defined custom interceptors.
*
* @author Gavin King
*/
public class EmptyInterceptor implements Interceptor, Serializable {
/**
* The singleton reference.
*/
public static final Interceptor INSTANCE = new EmptyInterceptor();
protected EmptyInterceptor() {
}
@Override
public void onDelete(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {}
@Override
public boolean onFlushDirty(
Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types) {
return false;
}
@Override
public boolean onLoad(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
return false;
}
@Override
public boolean onSave(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
return false;
}
@Override
public void postFlush(Iterator entities) {
}
@Override
public void preFlush(Iterator entities) {
}
@Override
public Boolean isTransient(Object entity) {
return null;
}
@Override
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) {
return null;
}
@Override
public int[] findDirty(
Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types) {
return null;
}
@Override
public String getEntityName(Object object) {
return null;
}
@Override
public Object getEntity(String entityName, Serializable id) {
return null;
}
@Override
public void afterTransactionBegin(Transaction tx) {
}
@Override
public void afterTransactionCompletion(Transaction tx) {
}
@Override
public void beforeTransactionCompletion(Transaction tx) {
}
@Override
public String onPrepareStatement(String sql) {
return sql;
}
@Override
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
}
@Override
public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
}
@Override
public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
}
}

61
fine-hibernate/src/main/java/com/fr/third/org/hibernate/EntityMode.java

@ -1,61 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Locale;
/**
* Defines the representation modes available for entities.
*
* @author Steve Ebersole
*/
public enum EntityMode {
/**
* The {@code pojo} entity mode describes an entity model made up of entity classes (loosely) following
* the java bean convention.
*/
POJO( "pojo" ),
/**
* The {@code dynamic-map} entity mode describes an entity model defined using {@link java.util.Map} references.
*/
MAP( "dynamic-map" );
private final String externalName;
private EntityMode(String externalName) {
this.externalName = externalName;
}
public String getExternalName() {
return externalName;
}
@Override
public String toString() {
return externalName;
}
/**
* Legacy-style entity-mode name parsing. <b>Case insensitive</b>
*
* @param entityMode The entity mode name to evaluate
*
* @return The appropriate entity mode; {@code null} for incoming {@code entityMode} param is treated by returning
* {@link #POJO}.
*/
public static EntityMode parse(String entityMode) {
if ( entityMode == null ) {
return POJO;
}
if ( MAP.externalName.equalsIgnoreCase( entityMode ) ) {
return MAP;
}
return valueOf( entityMode.toUpperCase( Locale.ENGLISH ) );
}
}

24
fine-hibernate/src/main/java/com/fr/third/org/hibernate/EntityNameResolver.java

@ -1,24 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Contract for resolving an entity-name from a given entity instance.
*
* @author Steve Ebersole
*/
public interface EntityNameResolver {
/**
* Given an entity instance, determine its entity-name.
*
* @param entity The entity instance.
*
* @return The corresponding entity-name, or null if this impl does not know how to perform resolution
* for the given entity instance.
*/
public String resolveEntityName(Object entity);
}

50
fine-hibernate/src/main/java/com/fr/third/org/hibernate/FetchMode.java

@ -1,50 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Represents an association fetching strategy. This is used
* together with the <tt>Criteria</tt> API to specify runtime
* fetching strategies.<br>
* <br>
* For HQL queries, use the <tt>FETCH</tt> keyword instead.
*
* @see Criteria#setFetchMode(java.lang.String, FetchMode)
*
* @author Gavin King
*/
public enum FetchMode {
/**
* Default to the setting configured in the mapping file.
*/
DEFAULT,
/**
* Fetch using an outer join. Equivalent to <tt>fetch="join"</tt>.
*/
JOIN,
/**
* Fetch eagerly, using a separate select. Equivalent to
* <tt>fetch="select"</tt>.
*/
SELECT;
/**
* Fetch lazily. Equivalent to <tt>outer-join="false"</tt>.
*
* @deprecated use <tt>FetchMode.SELECT</tt>
*/
@Deprecated
public static final FetchMode LAZY = SELECT;
/**
* Fetch eagerly, using an outer join. Equivalent to <tt>outer-join="true"</tt>.
*
* @deprecated use <tt>FetchMode.JOIN</tt>
*/
@Deprecated
public static final FetchMode EAGER = JOIN;
}

72
fine-hibernate/src/main/java/com/fr/third/org/hibernate/Filter.java

@ -1,72 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Collection;
import com.fr.third.org.hibernate.engine.spi.FilterDefinition;
/**
* Type definition of Filter. Filter defines the user's view into enabled dynamic filters,
* allowing them to set filter parameter values.
*
* @author Steve Ebersole
*/
public interface Filter {
/**
* Get the name of this filter.
*
* @return This filter's name.
*/
public String getName();
/**
* Get the filter definition containing additional information about the
* filter (such as default-condition and expected parameter names/types).
*
* @return The filter definition
*/
public FilterDefinition getFilterDefinition();
/**
* Set the named parameter's value for this filter.
*
* @param name The parameter's name.
* @param value The value to be applied.
* @return This FilterImpl instance (for method chaining).
*/
public Filter setParameter(String name, Object value);
/**
* Set the named parameter's value list for this filter. Used
* in conjunction with IN-style filter criteria.
*
* @param name The parameter's name.
* @param values The values to be expanded into an SQL IN list.
* @return This FilterImpl instance (for method chaining).
*/
public Filter setParameterList(String name, Collection values);
/**
* Set the named parameter's value list for this filter. Used
* in conjunction with IN-style filter criteria.
*
* @param name The parameter's name.
* @param values The values to be expanded into an SQL IN list.
* @return This FilterImpl instance (for method chaining).
*/
public Filter setParameterList(String name, Object[] values);
/**
* Perform validation of the filter state. This is used to verify the
* state of the filter after its enablement and before its use.
*
* @throws HibernateException If the state is not currently valid.
*/
public void validate() throws HibernateException;
}

113
fine-hibernate/src/main/java/com/fr/third/org/hibernate/FlushMode.java

@ -1,113 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Locale;
/**
* Represents a flushing strategy. The flush process synchronizes
* database state with session state by detecting state changes
* and executing SQL statements.
*
* @see Session#setFlushMode(FlushMode)
* @see Query#setFlushMode(FlushMode)
* @see Criteria#setFlushMode(FlushMode)
*
* @author Gavin King
*/
public enum FlushMode {
/**
* The {@link Session} is never flushed unless {@link Session#flush}
* is explicitly called by the application. This mode is very
* efficient for read only transactions.
*
* @deprecated use {@link #MANUAL} instead.
*/
@Deprecated
NEVER ( 0 ),
/**
* The {@link Session} is only ever flushed when {@link Session#flush}
* is explicitly called by the application. This mode is very
* efficient for read only transactions.
*/
MANUAL( 0 ),
/**
* The {@link Session} is flushed when {@link Transaction#commit}
* is called.
*/
COMMIT(5 ),
/**
* The {@link Session} is sometimes flushed before query execution
* in order to ensure that queries never return stale state. This
* is the default flush mode.
*/
AUTO(10 ),
/**
* The {@link Session} is flushed before every query. This is
* almost always unnecessary and inefficient.
*/
ALWAYS(20 );
private final int level;
private FlushMode(int level) {
this.level = level;
}
/**
* Checks to see if {@code this} flush mode is less than the given flush mode.
*
* @param other THe flush mode value to be checked against {@code this}
*
* @return {@code true} indicates {@code other} is less than {@code this}; {@code false} otherwise
*/
public boolean lessThan(FlushMode other) {
return this.level < other.level;
}
/**
* Checks to see if the given mode is the same as {@link #MANUAL}.
*
* @param mode The mode to check
*
* @return true/false
*
* @deprecated Just use equality check against {@link #MANUAL}. Legacy from before this was an enum
*/
@Deprecated
public static boolean isManualFlushMode(FlushMode mode) {
return MANUAL.level == mode.level;
}
/**
* Interprets an external representation of the flush mode. {@code null} is returned as {@code null}, otherwise
* {@link FlushMode#valueOf(String)} is used with the upper-case version of the incoming value. An unknown,
* non-null value results in a MappingException being thrown.
*
* @param externalName The external representation
*
* @return The interpreted FlushMode value.
*
* @throws MappingException Indicates an unrecognized external representation
*/
public static FlushMode interpretExternalSetting(String externalName) {
if ( externalName == null ) {
return null;
}
try {
return FlushMode.valueOf( externalName.toUpperCase(Locale.ROOT) );
}
catch ( IllegalArgumentException e ) {
throw new MappingException( "unknown FlushMode : " + externalName );
}
}
}

183
fine-hibernate/src/main/java/com/fr/third/org/hibernate/Hibernate.java

@ -1,183 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Iterator;
import com.fr.third.org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
import com.fr.third.org.hibernate.collection.spi.PersistentCollection;
import com.fr.third.org.hibernate.engine.HibernateIterator;
import com.fr.third.org.hibernate.engine.jdbc.LobCreator;
import com.fr.third.org.hibernate.engine.jdbc.spi.JdbcServices;
import com.fr.third.org.hibernate.engine.spi.PersistentAttributeInterceptable;
import com.fr.third.org.hibernate.engine.spi.PersistentAttributeInterceptor;
import com.fr.third.org.hibernate.engine.spi.SessionImplementor;
import com.fr.third.org.hibernate.proxy.HibernateProxy;
import com.fr.third.org.hibernate.proxy.LazyInitializer;
/**
* <ul>
* <li>Provides access to the full range of Hibernate built-in types. <tt>Type</tt>
* instances may be used to bind values to query parameters.
* <li>A factory for new <tt>Blob</tt>s and <tt>Clob</tt>s.
* <li>Defines static methods for manipulation of proxies.
* </ul>
*
* @author Gavin King
* @see java.sql.Clob
* @see java.sql.Blob
* @see com.fr.third.org.hibernate.type.Type
*/
public final class Hibernate {
/**
* Cannot be instantiated.
*/
private Hibernate() {
throw new UnsupportedOperationException();
}
/**
* Force initialization of a proxy or persistent collection.
* <p/>
* Note: This only ensures intialization of a proxy object or collection;
* it is not guaranteed that the elements INSIDE the collection will be initialized/materialized.
*
* @param proxy a persistable object, proxy, persistent collection or <tt>null</tt>
* @throws HibernateException if we can't initialize the proxy at this time, eg. the <tt>Session</tt> was closed
*/
public static void initialize(Object proxy) throws HibernateException {
if ( proxy == null ) {
return;
}
if ( proxy instanceof HibernateProxy ) {
( (HibernateProxy) proxy ).getHibernateLazyInitializer().initialize();
}
else if ( proxy instanceof PersistentCollection ) {
( (PersistentCollection) proxy ).forceInitialization();
}
}
/**
* Check if the proxy or persistent collection is initialized.
*
* @param proxy a persistable object, proxy, persistent collection or <tt>null</tt>
* @return true if the argument is already initialized, or is not a proxy or collection
*/
@SuppressWarnings("SimplifiableIfStatement")
public static boolean isInitialized(Object proxy) {
if ( proxy instanceof HibernateProxy ) {
return !( (HibernateProxy) proxy ).getHibernateLazyInitializer().isUninitialized();
}
else if ( proxy instanceof PersistentCollection ) {
return ( (PersistentCollection) proxy ).wasInitialized();
}
else {
return true;
}
}
/**
* Get the true, underlying class of a proxied persistent class. This operation
* will initialize a proxy by side-effect.
*
* @param proxy a persistable object or proxy
* @return the true class of the instance
* @throws HibernateException
*/
public static Class getClass(Object proxy) {
if ( proxy instanceof HibernateProxy ) {
return ( (HibernateProxy) proxy ).getHibernateLazyInitializer()
.getImplementation()
.getClass();
}
else {
return proxy.getClass();
}
}
/**
* Obtain a lob creator for the given session.
*
* @param session The session for which to obtain a lob creator
*
* @return The log creator reference
*/
public static LobCreator getLobCreator(Session session) {
return getLobCreator( (SessionImplementor) session );
}
/**
* Obtain a lob creator for the given session.
*
* @param session The session for which to obtain a lob creator
*
* @return The log creator reference
*/
public static LobCreator getLobCreator(SessionImplementor session) {
return session.getFactory()
.getServiceRegistry()
.getService( JdbcServices.class )
.getLobCreator( session );
}
/**
* Close an {@link Iterator} instances obtained from {@link com.fr.third.org.hibernate.Query#iterate()} immediately
* instead of waiting until the session is closed or disconnected.
*
* @param iterator an Iterator created by iterate()
*
* @throws HibernateException Indicates a problem closing the Hibernate iterator.
* @throws IllegalArgumentException If the Iterator is not a "Hibernate Iterator".
*
* @see Query#iterate()
*/
public static void close(Iterator iterator) throws HibernateException {
if ( iterator instanceof HibernateIterator ) {
( (HibernateIterator) iterator ).close();
}
else {
throw new IllegalArgumentException( "not a Hibernate iterator" );
}
}
/**
* Check if the property is initialized. If the named property does not exist
* or is not persistent, this method always returns <tt>true</tt>.
*
* @param proxy The potential proxy
* @param propertyName the name of a persistent attribute of the object
* @return true if the named property of the object is not listed as uninitialized; false otherwise
*/
public static boolean isPropertyInitialized(Object proxy, String propertyName) {
final Object entity;
if ( proxy instanceof HibernateProxy ) {
final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
if ( li.isUninitialized() ) {
return false;
}
else {
entity = li.getImplementation();
}
}
else {
entity = proxy;
}
if ( entity instanceof PersistentAttributeInterceptable ) {
PersistentAttributeInterceptor interceptor = ( (PersistentAttributeInterceptable) entity ).$$_hibernate_getInterceptor();
if ( interceptor != null && interceptor instanceof LazyAttributeLoadingInterceptor ) {
return ( (LazyAttributeLoadingInterceptor) interceptor ).isAttributeLoaded( propertyName );
}
}
return true;
}
}

33
fine-hibernate/src/main/java/com/fr/third/org/hibernate/HibernateError.java

@ -1,33 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Marks a group of exceptions that generally indicate an internal Hibernate error or bug.
*
* @author Steve Ebersole
*/
public class HibernateError extends HibernateException {
/**
* Constructs HibernateError with the condition message.
*
* @param message Message explaining the exception/error condition
*/
public HibernateError(String message) {
super( message );
}
/**
* Constructs HibernateError with the condition message and cause.
*
* @param message Message explaining the exception/error condition
* @param cause The underlying cause.
*/
public HibernateError(String message, Throwable cause) {
super( message, cause );
}
}

47
fine-hibernate/src/main/java/com/fr/third/org/hibernate/HibernateException.java

@ -1,47 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* The base exception type for Hibernate exceptions.
* <p/>
* Note that all {@link java.sql.SQLException SQLExceptions} will be wrapped in some form of
* {@link JDBCException}.
*
* @see JDBCException
*
* @author Gavin King
*/
public class HibernateException extends RuntimeException {
/**
* Constructs a HibernateException using the given exception message.
*
* @param message The message explaining the reason for the exception
*/
public HibernateException(String message) {
super( message );
}
/**
* Constructs a HibernateException using the given message and underlying cause.
*
* @param cause The underlying cause.
*/
public HibernateException(Throwable cause) {
super( cause );
}
/**
* Constructs a HibernateException using the given message and underlying cause.
*
* @param message The message explaining the reason for the exception.
* @param cause The underlying cause.
*/
public HibernateException(String message, Throwable cause) {
super( message, cause );
}
}

60
fine-hibernate/src/main/java/com/fr/third/org/hibernate/IdentifierLoadAccess.java

@ -1,60 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.Serializable;
/**
* Loads an entity by its primary identifier.
*
* @author Eric Dalquist
* @author Steve Ebersole
*/
public interface IdentifierLoadAccess<T> {
/**
* Specify the {@link LockOptions} to use when retrieving the entity.
*
* @param lockOptions The lock options to use.
*
* @return {@code this}, for method chaining
*/
IdentifierLoadAccess<T> with(LockOptions lockOptions);
/**
* Specify the {@link CacheMode} to use when retrieving the entity.
*
* @param cacheMode The CacheMode to use.
*
* @return {@code this}, for method chaining
*/
IdentifierLoadAccess<T> with(CacheMode cacheMode);
/**
* Return the persistent instance with the given identifier, assuming that the instance exists. This method
* might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.
*
* You should not use this method to determine if an instance exists; to check for existence, use {@link #load}
* instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an
* actual error.
*
* @param id The identifier for which to obtain a reference
*
* @return the persistent instance or proxy
*/
T getReference(Serializable id);
/**
* Return the persistent instance with the given identifier, or null if there is no such persistent instance.
* If the instance is already associated with the session, return that instance, initializing it if needed. This
* method never returns an uninitialized instance.
*
* @param id The identifier
*
* @return The persistent instance or {@code null}
*/
T load(Serializable id);
}

23
fine-hibernate/src/main/java/com/fr/third/org/hibernate/Incubating.java

@ -1,23 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
/**
* @author Steve Ebersole
*/
@Target({PACKAGE, TYPE, METHOD})
@Retention(CLASS)
public @interface Incubating {
}

77
fine-hibernate/src/main/java/com/fr/third/org/hibernate/InstantiationException.java

@ -1,77 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Thrown if Hibernate can't instantiate a class at runtime.
*
* @author Gavin King
*/
public class InstantiationException extends HibernateException {
private final Class clazz;
/**
* Constructs a InstantiationException.
*
* @param message A message explaining the exception condition
* @param clazz The Class we are attempting to instantiate
* @param cause The underlying exception
*/
public InstantiationException(String message, Class clazz, Throwable cause) {
super( message, cause );
this.clazz = clazz;
}
/**
* Constructs a InstantiationException.
*
* @param message A message explaining the exception condition
* @param clazz The Class we are attempting to instantiate
*/
public InstantiationException(String message, Class clazz) {
this( message, clazz, null );
}
/**
* Constructs a InstantiationException.
*
* @param message A message explaining the exception condition
* @param clazz The Class we are attempting to instantiate
* @param cause The underlying exception
*/
public InstantiationException(String message, Class clazz, Exception cause) {
super( message, cause );
this.clazz = clazz;
}
/**
* Returns the Class we were attempting to instantiate.
*
* @deprecated Use {@link #getUninstantiatableClass} instead
*
* @return The class we are unable to instantiate
*/
@Deprecated
public Class getPersistentClass() {
return clazz;
}
/**
* Returns the Class we were attempting to instantiate.
*
* @return The class we are unable to instantiate
*/
public Class getUninstantiatableClass() {
return clazz;
}
@Override
public String getMessage() {
return super.getMessage() + " : " + clazz.getName();
}
}

276
fine-hibernate/src/main/java/com/fr/third/org/hibernate/Interceptor.java

@ -1,276 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.Serializable;
import java.util.Iterator;
import com.fr.third.org.hibernate.type.Type;
/**
* Allows user code to inspect and/or change property values.
*
* Inspection occurs before property values are written and after they are read
* from the database.
*
* There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance
* might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be
* serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped
* interceptors should implement <tt>readResolve()</tt>.
*
* The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to
* be lazily initialized).
*
* Instead of implementing this interface directly, it is usually better to extend <tt>EmptyInterceptor</tt>
* and override only the callback methods of interest.
*
* @see SessionBuilder#interceptor(Interceptor)
* @see SharedSessionBuilder#interceptor()
* @see com.fr.third.org.hibernate.cfg.Configuration#setInterceptor(Interceptor)
* @see EmptyInterceptor
*
* @author Gavin King
*/
public interface Interceptor {
/**
* Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will
* be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be
* an empty uninitialized instance of the class.
* <p/>
* NOTE: The indexes across the <tt>state</tt>, <tt>propertyNames</tt> and <tt>types</tt> arrays match.
*
* @param entity The entity instance being loaded
* @param id The identifier value being loaded
* @param state The entity state (which will be pushed into the entity instance)
* @param propertyNames The names of the entity properties, corresponding to the <tt>state</tt>.
* @param types The types of the entity properties, corresponding to the <tt>state</tt>.
*
* @return {@code true} if the user modified the <tt>state</tt> in any way.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
/**
* Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected
* <tt>currentState</tt>, which will be propagated to both the database and the persistent object.
* Note that not all flushes end in actual synchronization with the database, in which case the
* new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to
* the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>.
* <p/>
* NOTE: The indexes across the <tt>currentState</tt>, <tt>previousState</tt>, <tt>propertyNames</tt> and
* <tt>types</tt> arrays match.
*
* @param entity The entity instance detected as being dirty and being flushed
* @param id The identifier of the entity
* @param currentState The entity's current state
* @param previousState The entity's previous (load time) state.
* @param propertyNames The names of the entity properties
* @param types The types of the entity properties
*
* @return {@code true} if the user modified the <tt>currentState</tt> in any way.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
boolean onFlushDirty(
Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types) throws CallbackException;
/**
* Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for
* the SQL <tt>INSERT</tt> and propagated to the persistent object.
*
* @param entity The entity instance whose state is being inserted
* @param id The identifier of the entity
* @param state The state of the entity which will be inserted
* @param propertyNames The names of the entity properties.
* @param types The types of the entity properties
*
* @return <tt>true</tt> if the user modified the <tt>state</tt> in any way.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
/**
* Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>.
*
* @param entity The entity instance being deleted
* @param id The identifier of the entity
* @param state The state of the entity
* @param propertyNames The names of the entity properties.
* @param types The types of the entity properties
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
/**
* Called before a collection is (re)created.
*
* @param collection The collection instance.
* @param key The collection key value.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
void onCollectionRecreate(Object collection, Serializable key) throws CallbackException;
/**
* Called before a collection is deleted.
*
* @param collection The collection instance.
* @param key The collection key value.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
void onCollectionRemove(Object collection, Serializable key) throws CallbackException;
/**
* Called before a collection is updated.
*
* @param collection The collection instance.
* @param key The collection key value.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
void onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
/**
* Called before a flush.
*
* @param entities The entities to be flushed.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
void preFlush(Iterator entities) throws CallbackException;
/**
* Called after a flush that actually ends in execution of the SQL statements required to synchronize
* in-memory state with the database.
*
* @param entities The entities that were flushed.
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
void postFlush(Iterator entities) throws CallbackException;
/**
* Called to distinguish between transient and detached entities. The return value determines the
* state of the entity with respect to the current session.
* <ul>
* <li><tt>Boolean.TRUE</tt> - the entity is transient
* <li><tt>Boolean.FALSE</tt> - the entity is detached
* <li><tt>null</tt> - Hibernate uses the <tt>unsaved-value</tt> mapping and other heuristics to
* determine if the object is unsaved
* </ul>
* @param entity a transient or detached entity
* @return Boolean or <tt>null</tt> to choose default behaviour
*/
Boolean isTransient(Object entity);
/**
* Called from <tt>flush()</tt>. The return value determines whether the entity is updated
* <ul>
* <li>an array of property indices - the entity is dirty
* <li>an empty array - the entity is not dirty
* <li><tt>null</tt> - use Hibernate's default dirty-checking algorithm
* </ul>
*
* @param entity The entity for which to find dirty properties.
* @param id The identifier of the entity
* @param currentState The current entity state as taken from the entity instance
* @param previousState The state of the entity when it was last synchronized (generally when it was loaded)
* @param propertyNames The names of the entity properties.
* @param types The types of the entity properties
*
* @return array of dirty property indices or {@code null} to indicate Hibernate should perform default behaviour
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
int[] findDirty(
Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types);
/**
* Instantiate the entity class. Return <tt>null</tt> to indicate that Hibernate should use
* the default constructor of the class. The identifier property of the returned instance
* should be initialized with the given identifier.
*
* @param entityName the name of the entity
* @param entityMode The type of entity instance to be returned.
* @param id the identifier of the new instance
*
* @return an instance of the class, or <tt>null</tt> to choose default behaviour
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException;
/**
* Get the entity name for a persistent or transient instance.
*
* @param object an entity instance
*
* @return the name of the entity
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
String getEntityName(Object object) throws CallbackException;
/**
* Get a fully loaded entity instance that is cached externally.
*
* @param entityName the name of the entity
* @param id the instance identifier
*
* @return a fully initialized entity
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
Object getEntity(String entityName, Serializable id) throws CallbackException;
/**
* Called when a Hibernate transaction is begun via the Hibernate <tt>Transaction</tt>
* API. Will not be called if transactions are being controlled via some other
* mechanism (CMT, for example).
*
* @param tx The Hibernate transaction facade object
*/
void afterTransactionBegin(Transaction tx);
/**
* Called before a transaction is committed (but not before rollback).
*
* @param tx The Hibernate transaction facade object
*/
void beforeTransactionCompletion(Transaction tx);
/**
* Called after a transaction is committed or rolled back.
*
* @param tx The Hibernate transaction facade object
*/
void afterTransactionCompletion(Transaction tx);
/**
* Called when sql string is being prepared.
* @param sql sql to be prepared
* @return original or modified sql
*
* @deprecated Supply a {@link com.fr.third.org.hibernate.resource.jdbc.spi.StatementInspector} instead, if you wish
* to inspect and alter SQL statements.
*/
@Deprecated
String onPrepareStatement(String sql);
}

132
fine-hibernate/src/main/java/com/fr/third/org/hibernate/InvalidMappingException.java

@ -1,132 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import com.fr.third.org.hibernate.boot.jaxb.Origin;
import com.fr.third.org.hibernate.internal.util.xml.XmlDocument;
/**
* Thrown when a mapping is found to be invalid.
*
* Similar to MappingException, but this contains more info about the path and type of
* mapping (e.g. file, resource or url)
*
* @author Max Rydahl Andersen
* @author Steve Ebersole
*/
public class InvalidMappingException extends MappingException {
private final String path;
private final String type;
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param type The type of invalid mapping document
* @param path The path (type specific) of the invalid mapping document
* @param cause The underlying cause
*/
public InvalidMappingException(String customMessage, String type, String path, Throwable cause) {
super( customMessage, cause );
this.type = type;
this.path = path;
}
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param type The type of invalid mapping document
* @param path The path (type specific) of the invalid mapping document
*/
public InvalidMappingException(String customMessage, String type, String path) {
super( customMessage );
this.type=type;
this.path=path;
}
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param xmlDocument The document that was invalid
* @param cause The underlying cause
*/
public InvalidMappingException(String customMessage, XmlDocument xmlDocument, Throwable cause) {
this( customMessage, xmlDocument.getOrigin().getType(), xmlDocument.getOrigin().getName(), cause );
}
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param xmlDocument The document that was invalid
*/
public InvalidMappingException(String customMessage, XmlDocument xmlDocument) {
this( customMessage, xmlDocument.getOrigin().getType(), xmlDocument.getOrigin().getName() );
}
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param origin The origin of the invalid mapping document
*/
public InvalidMappingException(String customMessage, Origin origin) {
this( customMessage, origin.getType().getLegacyTypeText(), origin.getName() );
}
/**
* Constructs an InvalidMappingException using the given information and a standard message.
*
* @param type The type of invalid mapping document
* @param path The path (type specific) of the invalid mapping document
*/
public InvalidMappingException(String type, String path) {
this( "Could not parse mapping document from " + type + (path==null?"":" " + path), type, path );
}
/**
* Constructs an InvalidMappingException using the given information and a standard message.
*
* @param type The type of invalid mapping document
* @param path The path (type specific) of the invalid mapping document
* @param cause The underlying cause
*/
public InvalidMappingException(String type, String path, Throwable cause) {
this( "Could not parse mapping document from " + type + (path==null?"":" " + path), type, path, cause );
}
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param origin The origin of the invalid mapping document
* @param cause The underlying cause
*/
public InvalidMappingException(String customMessage, com.fr.third.org.hibernate.internal.util.xml.Origin origin, Exception cause) {
this( customMessage, origin.getType(), origin.getName(), cause );
}
/**
* Constructs an InvalidMappingException using the given information.
*
* @param customMessage The custom message explaining the exception condition
* @param origin The origin of the invalid mapping document
*/
public InvalidMappingException(String customMessage, com.fr.third.org.hibernate.internal.util.xml.Origin origin) {
this( customMessage, origin, null );
}
public String getType() {
return type;
}
public String getPath() {
return path;
}
}

85
fine-hibernate/src/main/java/com/fr/third/org/hibernate/JDBCException.java

@ -1,85 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.sql.SQLException;
/**
* Wraps a {@link SQLException}. Indicates that an exception occurred during a JDBC call.
*
* @author Gavin King
*
* @see java.sql.SQLException
*/
public class JDBCException extends HibernateException {
private final SQLException sqlException;
private final String sql;
/**
* Constructs a JDBCException using the given information.
*
* @param message The message explaining the exception condition
* @param cause The underlying cause
*/
public JDBCException(String message, SQLException cause) {
this( message, cause, null );
}
/**
* Constructs a JDBCException using the given information.
*
* @param message The message explaining the exception condition
* @param cause The underlying cause
* @param sql The sql being executed when the exception occurred
*/
public JDBCException(String message, SQLException cause, String sql) {
super( message, cause );
this.sqlException = cause;
this.sql = sql;
}
/**
* Get the X/Open or ANSI SQL SQLState error code from the underlying {@link SQLException}.
*
* @return The X/Open or ANSI SQL SQLState error code; may return null.
*
* @see java.sql.SQLException#getSQLState()
*/
public String getSQLState() {
return sqlException.getSQLState();
}
/**
* Get the vendor specific error code from the underlying {@link SQLException}.
*
* @return The vendor specific error code
*
* @see java.sql.SQLException#getErrorCode()
*/
public int getErrorCode() {
return sqlException.getErrorCode();
}
/**
* Get the underlying {@link SQLException}.
*
* @return The SQLException
*/
public SQLException getSQLException() {
return sqlException;
}
/**
* Get the actual SQL statement being executed when the exception occurred.
*
* @return The SQL statement; may return null.
*/
public String getSQL() {
return sql;
}
}

39
fine-hibernate/src/main/java/com/fr/third/org/hibernate/LazyInitializationException.java

@ -1,39 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import com.fr.third.org.hibernate.internal.CoreMessageLogger;
import com.fr.third.org.jboss.logging.Logger;
/**
* Indicates an attempt to access not-yet-fetched data outside of a session context.
*
* For example, when an uninitialized proxy or collection is accessed after the session was closed.
*
* @see Hibernate#initialize(java.lang.Object)
* @see Hibernate#isInitialized(java.lang.Object)
* @author Gavin King
*/
public class LazyInitializationException extends HibernateException {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
LazyInitializationException.class.getName()
);
/**
* Constructs a LazyInitializationException using the given message.
*
* @param message A message explaining the exception condition
*/
public LazyInitializationException(String message) {
super( message );
LOG.trace( message, this );
}
}

78
fine-hibernate/src/main/java/com/fr/third/org/hibernate/LobHelper.java

@ -1,78 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.InputStream;
import java.io.Reader;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.NClob;
/**
* A {@link Session session's} helper for creating LOB data.
*
* @author Steve Ebersole
*/
public interface LobHelper {
/**
* Create a new {@link Blob} from bytes.
*
* @param bytes a byte array
*
* @return the created Blob
*/
public Blob createBlob(byte[] bytes);
/**
* Create a new {@link Blob} from stream data.
*
* @param stream a binary stream
* @param length the number of bytes in the stream
* @return the create Blob
*/
public Blob createBlob(InputStream stream, long length);
/**
* Create a new {@link java.sql.Clob} from content.
*
* @param string The string data
*
* @return The created {@link java.sql.Clob}
*/
public Clob createClob(String string);
/**
* Create a new {@link Clob} from character reader.
*
* @param reader a character stream
* @param length the number of characters in the stream
*
* @return The created {@link Clob}
*/
public Clob createClob(Reader reader, long length);
/**
* Create a new {@link NClob} from content.
*
* @param string The string data
*
* @return The created {@link NClob}
*/
public NClob createNClob(String string);
/**
* Create a new {@link NClob} from character reader.
*
* @param reader a character stream
* @param length the number of characters in the stream
*
* @return The created {@link NClob}
*/
public NClob createNClob(Reader reader, long length);
}

158
fine-hibernate/src/main/java/com/fr/third/org/hibernate/LockMode.java

@ -1,158 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Instances represent a lock mode for a row of a relational
* database table. It is not intended that users spend much
* time worrying about locking since Hibernate usually
* obtains exactly the right lock level automatically.
* Some "advanced" users may wish to explicitly specify lock
* levels.
*
* @author Gavin King
*
* @see Session#lock(Object, LockMode)
*/
public enum LockMode {
/**
* No lock required. If an object is requested with this lock
* mode, a <tt>READ</tt> lock will be obtained if it is
* necessary to actually read the state from the database,
* rather than pull it from a cache.<br>
* <br>
* This is the "default" lock mode.
*/
NONE( 0, "none" ),
/**
* A shared lock. Objects in this lock mode were read from
* the database in the current transaction, rather than being
* pulled from a cache.
*/
READ( 5, "read" ),
/**
* An upgrade lock. Objects loaded in this lock mode are
* materialized using an SQL <tt>select ... for update</tt>.
*
* @deprecated instead use PESSIMISTIC_WRITE
*/
@Deprecated
UPGRADE( 10, "upgrade" ),
/**
* Attempt to obtain an upgrade lock, using an Oracle-style
* <tt>select for update nowait</tt>. The semantics of
* this lock mode, once obtained, are the same as
* <tt>UPGRADE</tt>.
*/
UPGRADE_NOWAIT( 10, "upgrade-nowait" ),
/**
* Attempt to obtain an upgrade lock, using an Oracle-style
* <tt>select for update skip locked</tt>. The semantics of
* this lock mode, once obtained, are the same as
* <tt>UPGRADE</tt>.
*/
UPGRADE_SKIPLOCKED( 10, "upgrade-skiplocked" ),
/**
* A <tt>WRITE</tt> lock is obtained when an object is updated
* or inserted. This lock mode is for internal use only and is
* not a valid mode for <tt>load()</tt> or <tt>lock()</tt> (both
* of which throw exceptions if WRITE is specified).
*/
WRITE( 10, "write" ),
/**
* Similar to {@link #UPGRADE} except that, for versioned entities,
* it results in a forced version increment.
*
* @deprecated instead use PESSIMISTIC_FORCE_INCREMENT
*/
@Deprecated
FORCE( 15, "force" ),
/**
* start of com.fr.third.javax.persistence.LockModeType equivalent modes
*/
/**
* Optimistically assume that transaction will not experience contention for
* entities. The entity version will be verified near the transaction end.
*/
OPTIMISTIC( 6, "optimistic" ),
/**
* Optimistically assume that transaction will not experience contention for
* entities. The entity version will be verified and incremented near the transaction end.
*/
OPTIMISTIC_FORCE_INCREMENT( 7, "optimistic_force_increment" ),
/**
* Implemented as PESSIMISTIC_WRITE.
* TODO: introduce separate support for PESSIMISTIC_READ
*/
PESSIMISTIC_READ( 12, "pessimistic_read" ),
/**
* Transaction will obtain a database lock immediately.
* TODO: add PESSIMISTIC_WRITE_NOWAIT
*/
PESSIMISTIC_WRITE( 13, "pessimistic_write" ),
/**
* Transaction will immediately increment the entity version.
*/
PESSIMISTIC_FORCE_INCREMENT( 17, "pessimistic_force_increment" );
private final int level;
private final String externalForm;
private LockMode(int level, String externalForm) {
this.level = level;
this.externalForm = externalForm;
}
/**
* Check if this lock mode is more restrictive than the given lock mode.
*
* @param mode LockMode to check
*
* @return true if this lock mode is more restrictive than given lock mode
*/
public boolean greaterThan(LockMode mode) {
return level > mode.level;
}
/**
* Check if this lock mode is less restrictive than the given lock mode.
*
* @param mode LockMode to check
*
* @return true if this lock mode is less restrictive than given lock mode
*/
public boolean lessThan(LockMode mode) {
return level < mode.level;
}
public String toExternalForm() {
return externalForm;
}
public static LockMode fromExternalForm(String externalForm) {
if ( externalForm == null ) {
return NONE;
}
for ( LockMode lockMode : LockMode.values() ) {
if ( lockMode.externalForm.equalsIgnoreCase( externalForm ) ) {
return lockMode;
}
}
throw new IllegalArgumentException( "Unable to interpret LockMode reference from incoming external form : " + externalForm );
}
}

300
fine-hibernate/src/main/java/com/fr/third/org/hibernate/LockOptions.java

@ -1,300 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Contains locking details (LockMode, Timeout and Scope).
*
* @author Scott Marlow
*/
public class LockOptions implements Serializable {
/**
* Represents LockMode.NONE (timeout + scope do not apply).
*/
public static final LockOptions NONE = new LockOptions(LockMode.NONE);
/**
* Represents LockMode.READ (timeout + scope do not apply).
*/
public static final LockOptions READ = new LockOptions(LockMode.READ);
/**
* Represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked).
*/
@SuppressWarnings("deprecation")
public static final LockOptions UPGRADE = new LockOptions(LockMode.UPGRADE);
/**
* Indicates that the database should not wait at all to acquire the pessimistic lock.
* @see #getTimeOut
*/
public static final int NO_WAIT = 0;
/**
* Indicates that there is no timeout for the acquisition.
* @see #getTimeOut
*/
public static final int WAIT_FOREVER = -1;
/**
* Indicates that rows that are already locked should be skipped.
* @see #getTimeOut()
*/
public static final int SKIP_LOCKED = -2;
private LockMode lockMode = LockMode.NONE;
private int timeout = WAIT_FOREVER;
private Map<String,LockMode> aliasSpecificLockModes;
/**
* Constructs a LockOptions with all default options.
*/
public LockOptions() {
}
/**
* Constructs a LockOptions with the given lock mode.
*
* @param lockMode The lock mode to use
*/
public LockOptions( LockMode lockMode) {
this.lockMode = lockMode;
}
/**
* Retrieve the overall lock mode in effect for this set of options.
* <p/>
* In certain contexts (hql and criteria), lock-modes can be defined in an
* even more granular {@link #setAliasSpecificLockMode(String, LockMode) per-alias} fashion
*
* @return The overall lock mode.
*/
public LockMode getLockMode() {
return lockMode;
}
/**
* Set the overall {@link LockMode} to be used. The default is
* {@link LockMode#NONE}
*
* @param lockMode The new overall lock mode to use.
*
* @return this (for method chaining).
*/
public LockOptions setLockMode(LockMode lockMode) {
this.lockMode = lockMode;
return this;
}
/**
* Specify the {@link LockMode} to be used for a specific query alias.
*
* @param alias used to reference the LockMode.
* @param lockMode The lock mode to apply to the given alias
* @return this LockRequest instance for operation chaining.
*
* @see Query#setLockMode(String, LockMode)
* @see Criteria#setLockMode(LockMode)
* @see Criteria#setLockMode(String, LockMode)
*/
public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode) {
if ( aliasSpecificLockModes == null ) {
aliasSpecificLockModes = new HashMap<String,LockMode>();
}
aliasSpecificLockModes.put( alias, lockMode );
return this;
}
/**
* Get the {@link LockMode} explicitly specified for the given alias via
* {@link #setAliasSpecificLockMode}
* <p/>
* Differs from {@link #getEffectiveLockMode} in that here we only return
* explicitly specified alias-specific lock modes.
*
* @param alias The alias for which to locate the explicit lock mode.
*
* @return The explicit lock mode for that alias.
*/
public LockMode getAliasSpecificLockMode(String alias) {
if ( aliasSpecificLockModes == null ) {
return null;
}
return aliasSpecificLockModes.get( alias );
}
/**
* Determine the {@link LockMode} to apply to the given alias. If no
* mode was explicitly {@link #setAliasSpecificLockMode set}, the
* {@link #getLockMode overall mode} is returned. If the overall lock mode is
* <tt>null</tt> as well, {@link LockMode#NONE} is returned.
* <p/>
* Differs from {@link #getAliasSpecificLockMode} in that here we fallback to we only return
* the overall lock mode.
*
* @param alias The alias for which to locate the effective lock mode.
*
* @return The effective lock mode.
*/
public LockMode getEffectiveLockMode(String alias) {
LockMode lockMode = getAliasSpecificLockMode( alias );
if ( lockMode == null ) {
lockMode = this.lockMode;
}
return lockMode == null ? LockMode.NONE : lockMode;
}
/**
* Does this LockOptions object define alias-specific lock modes?
*
* @return {@code true} if this LockOptions object define alias-specific lock modes; {@code false} otherwise.
*/
public boolean hasAliasSpecificLockModes() {
return aliasSpecificLockModes != null
&& ! aliasSpecificLockModes.isEmpty();
}
/**
* Get the number of aliases that have specific lock modes defined.
*
* @return the number of explicitly defined alias lock modes.
*/
public int getAliasLockCount() {
if ( aliasSpecificLockModes == null ) {
return 0;
}
return aliasSpecificLockModes.size();
}
/**
* Iterator for accessing Alias (key) and LockMode (value) as Map.Entry.
*
* @return Iterator for accessing the Map.Entry's
*/
public Iterator getAliasLockIterator() {
if ( aliasSpecificLockModes == null ) {
return Collections.emptyList().iterator();
}
return aliasSpecificLockModes.entrySet().iterator();
}
/**
* Currently needed for follow-on locking.
*
* @return The greatest of all requested lock modes.
*/
public LockMode findGreatestLockMode() {
LockMode lockModeToUse = getLockMode();
if ( lockModeToUse == null ) {
lockModeToUse = LockMode.NONE;
}
if ( aliasSpecificLockModes == null ) {
return lockModeToUse;
}
for ( LockMode lockMode : aliasSpecificLockModes.values() ) {
if ( lockMode.greaterThan( lockModeToUse ) ) {
lockModeToUse = lockMode;
}
}
return lockModeToUse;
}
/**
* Retrieve the current timeout setting.
* <p/>
* The timeout is the amount of time, in milliseconds, we should instruct the database
* to wait for any requested pessimistic lock acquisition.
* <p/>
* {@link #NO_WAIT}, {@link #WAIT_FOREVER} or {@link #SKIP_LOCKED} represent 3 "magic" values.
*
* @return timeout in milliseconds, {@link #NO_WAIT}, {@link #WAIT_FOREVER} or {@link #SKIP_LOCKED}
*/
public int getTimeOut() {
return timeout;
}
/**
* Set the timeout setting.
* <p/>
* See {@link #getTimeOut} for a discussion of meaning.
*
* @param timeout The new timeout setting.
*
* @return this (for method chaining).
*
* @see #getTimeOut
*/
public LockOptions setTimeOut(int timeout) {
this.timeout = timeout;
return this;
}
private boolean scope;
/**
* Retrieve the current lock scope setting.
* <p/>
* "scope" is a JPA defined term. It is basically a cascading of the lock to associations.
*
* @return true if locking will be extended to owned associations
*/
public boolean getScope() {
return scope;
}
/**
* Set the scope.
*
* @param scope The new scope setting
*
* @return this (for method chaining).
*/
public LockOptions setScope(boolean scope) {
this.scope = scope;
return this;
}
/**
* Make a copy.
*
* @return The copy
*/
public LockOptions makeCopy() {
final LockOptions copy = new LockOptions();
copy( this, copy );
return copy;
}
/**
* Perform a shallow copy.
*
* @param source Source for the copy (copied from)
* @param destination Destination for the copy (copied to)
*
* @return destination
*/
public static LockOptions copy(LockOptions source, LockOptions destination) {
destination.setLockMode( source.getLockMode() );
destination.setScope( source.getScope() );
destination.setTimeOut( source.getTimeOut() );
if ( source.aliasSpecificLockModes != null ) {
destination.aliasSpecificLockModes = new HashMap<String,LockMode>( source.aliasSpecificLockModes );
}
return destination;
}
}

44
fine-hibernate/src/main/java/com/fr/third/org/hibernate/MappingException.java

@ -1,44 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* An exception that occurs while reading mapping sources (xml/annotations),usually as a result of something
* screwy in the O-R mappings.
*
* @author Gavin King
*/
public class MappingException extends HibernateException {
/**
* Constructs a MappingException using the given information.
*
* @param message A message explaining the exception condition
* @param cause The underlying cause
*/
public MappingException(String message, Throwable cause) {
super( message, cause );
}
/**
* Constructs a MappingException using the given information.
*
* @param cause The underlying cause
*/
public MappingException(Throwable cause) {
super( cause );
}
/**
* Constructs a MappingException using the given information.
*
* @param message A message explaining the exception condition
*/
public MappingException(String message) {
super( message );
}
}

76
fine-hibernate/src/main/java/com/fr/third/org/hibernate/MappingNotFoundException.java

@ -1,76 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Thrown when a resource for a mapping could not be found.
*
* @author Max Rydahl Andersen
*
* @deprecated Use {@link com.fr.third.org.hibernate.boot.MappingNotFoundException} instead.
*/
@Deprecated
public class MappingNotFoundException extends MappingException {
private final String path;
private final String type;
/**
* Constructs a MappingNotFoundException using the given information.
*
* @param customMessage A message explaining the exception condition
* @param type The type of mapping that could not be found
* @param path The path (type specific) of the mapping that could not be found
* @param cause The underlying cause
*/
public MappingNotFoundException(String customMessage, String type, String path, Throwable cause) {
super( customMessage, cause );
this.type = type;
this.path = path;
}
/**
* Constructs a MappingNotFoundException using the given information.
*
* @param customMessage A message explaining the exception condition
* @param type The type of mapping that could not be found
* @param path The path (type specific) of the mapping that could not be found
*/
public MappingNotFoundException(String customMessage, String type, String path) {
super( customMessage );
this.type = type;
this.path = path;
}
/**
* Constructs a MappingNotFoundException using the given information, using a standard message.
*
* @param type The type of mapping that could not be found
* @param path The path (type specific) of the mapping that could not be found
*/
public MappingNotFoundException(String type, String path) {
this( type + ": " + path + " not found", type, path );
}
/**
* Constructs a MappingNotFoundException using the given information, using a standard message.
*
* @param type The type of mapping that could not be found
* @param path The path (type specific) of the mapping that could not be found
* @param cause The underlying cause
*/
public MappingNotFoundException(String type, String path, Throwable cause) {
this( type + ": " + path + " not found", type, path, cause );
}
public String getType() {
return type;
}
public String getPath() {
return path;
}
}

119
fine-hibernate/src/main/java/com/fr/third/org/hibernate/MultiIdentifierLoadAccess.java

@ -1,119 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.io.Serializable;
import java.util.List;
/**
* Loads multiple entities at once by identifiers, ultimately via one of the
* {@link #multiLoad} methods, using the various options specified (if any)
*
* @author Steve Ebersole
*/
public interface MultiIdentifierLoadAccess<T> {
/**
* Specify the {@link LockOptions} to use when retrieving the entity.
*
* @param lockOptions The lock options to use.
*
* @return {@code this}, for method chaining
*/
MultiIdentifierLoadAccess<T> with(LockOptions lockOptions);
/**
* Specify the {@link CacheMode} to use when retrieving the entity.
*
* @param cacheMode The CacheMode to use.
*
* @return {@code this}, for method chaining
*/
MultiIdentifierLoadAccess<T> with(CacheMode cacheMode);
/**
* Specify a batch size for loading the entities (how many at a time). The default is
* to use a batch sizing strategy defined by the Dialect in use. Any greater-than-one
* value here will override that default behavior. If giving an explicit value here,
* care should be taken to not exceed the capabilities of of the underlying database.
* <p/>
* Note that overall a batch-size is considered a hint. How the underlying loading
* mechanism interprets that is completely up to that underlying loading mechanism.
*
* @param batchSize The batch size
*
* @return {@code this}, for method chaining
*/
MultiIdentifierLoadAccess<T> withBatchSize(int batchSize);
/**
* Specify whether we should check the Session to see whether it already contains any of the
* entities to be loaded in a managed state <b>for the purpose of not including those
* ids to the batch-load SQL</b>.
*
* @param enabled {@code true} enables this checking; {@code false} (the default) disables it.
*
* @return {@code this}, for method chaining
*/
MultiIdentifierLoadAccess<T> enableSessionCheck(boolean enabled);
/**
* Should the multi-load operation be allowed to return entities that are locally
* deleted? A locally deleted entity is one which has been passed to this
* Session's {@link Session#delete} / {@link Session#remove} method, but not
* yet flushed. The default behavior is to handle them as null in the return
* (see {@link #enableOrderedReturn}).
*
* @param enabled {@code true} enables returning the deleted entities;
* {@code false} (the default) disables it.
*
* @return {@code this}, for method chaining
*/
MultiIdentifierLoadAccess<T> enableReturnOfDeletedEntities(boolean enabled);
/**
* Should the return List be ordered and positional in relation to the
* incoming ids? If enabled (the default), the return List is ordered and
* positional relative to the incoming ids. In other words, a request to
* {@code multiLoad([2,1,3])} will return {@code [Entity#2, Entity#1, Entity#3]}.
* <p/>
* An important distinction is made here in regards to the handling of
* unknown entities depending on this "ordered return" setting. If enabled
* a null is inserted into the List at the proper position(s). If disabled,
* the nulls are not put into the return List. In other words, consumers of
* the returned ordered List would need to be able to handle null elements.
*
* @param enabled {@code true} (the default) enables ordering;
* {@code false} disables it.
*
* @return {@code this}, for method chaining
*/
MultiIdentifierLoadAccess<T> enableOrderedReturn(boolean enabled);
/**
* Perform a load of multiple entities by identifiers. See {@link #enableOrderedReturn}
* and {@link #enableReturnOfDeletedEntities} for options which effect
* the size and "shape" of the return list.
*
* @param ids The ids to load
* @param <K> The identifier type
*
* @return The persistent entities.
*/
<K extends Serializable> List<T> multiLoad(K... ids);
/**
* Perform a load of multiple entities by identifiers. See {@link #enableOrderedReturn}
* and {@link #enableReturnOfDeletedEntities} for options which effect
* the size and "shape" of the return list.
*
* @param ids The ids to load
* @param <K> The identifier type
*
* @return The persistent entities.
*/
<K extends Serializable> List<T> multiLoad(List<K> ids);
}

82
fine-hibernate/src/main/java/com/fr/third/org/hibernate/MultiTenancyStrategy.java

@ -1,82 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
import java.util.Locale;
import java.util.Map;
import com.fr.third.org.hibernate.cfg.Environment;
import com.fr.third.org.hibernate.internal.CoreMessageLogger;
import com.fr.third.org.jboss.logging.Logger;
/**
* Describes the methods for multi-tenancy understood by Hibernate.
*
* @author Steve Ebersole
*/
public enum MultiTenancyStrategy {
/**
* Multi-tenancy implemented by use of discriminator columns.
*/
DISCRIMINATOR,
/**
* Multi-tenancy implemented as separate schemas.
*/
SCHEMA,
/**
* Multi-tenancy implemented as separate databases.
*/
DATABASE,
/**
* No multi-tenancy.
*/
NONE;
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
MultiTenancyStrategy.class.getName()
);
/**
* Does this strategy indicate a requirement for the specialized
* {@link com.fr.third.org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider}, rather than the
* traditional {@link com.fr.third.org.hibernate.engine.jdbc.connections.spi.ConnectionProvider}?
*
* @return {@code true} indicates a MultiTenantConnectionProvider is required; {@code false} indicates it is not.
*/
public boolean requiresMultiTenantConnectionProvider() {
return this == DATABASE || this == SCHEMA;
}
/**
* Extract the MultiTenancyStrategy from the setting map.
*
* @param properties The map of settings.
*
* @return The selected strategy. {@link #NONE} is always the default.
*/
public static MultiTenancyStrategy determineMultiTenancyStrategy(Map properties) {
final Object strategy = properties.get( Environment.MULTI_TENANT );
if ( strategy == null ) {
return MultiTenancyStrategy.NONE;
}
if ( MultiTenancyStrategy.class.isInstance( strategy ) ) {
return (MultiTenancyStrategy) strategy;
}
final String strategyName = strategy.toString();
try {
return MultiTenancyStrategy.valueOf( strategyName.toUpperCase(Locale.ROOT) );
}
catch ( RuntimeException e ) {
LOG.warn( "Unknown multi tenancy strategy [ " +strategyName +" ], using MultiTenancyStrategy.NONE." );
return MultiTenancyStrategy.NONE;
}
}
}

76
fine-hibernate/src/main/java/com/fr/third/org/hibernate/NaturalIdLoadAccess.java

@ -1,76 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package com.fr.third.org.hibernate;
/**
* Loads an entity by its natural identifier.
*
* @author Eric Dalquist
* @author Steve Ebersole
*
* @see com.fr.third.org.hibernate.annotations.NaturalId
*/
public interface NaturalIdLoadAccess<T> {
/**
* Specify the {@link LockOptions} to use when retrieving the entity.
*
* @param lockOptions The lock options to use.
*
* @return {@code this}, for method chaining
*/
public NaturalIdLoadAccess<T> with(LockOptions lockOptions);
/**
* Add a NaturalId attribute value.
*
* @param attributeName The entity attribute name that is marked as a NaturalId
* @param value The value of the attribute
*
* @return {@code this}, for method chaining
*/
public NaturalIdLoadAccess<T> using(String attributeName, Object value);
/**
* For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing
* lookups? The default is to perform "synchronization" (for correctness).
* <p/>
* "synchronization" here indicates updating the natural-id -> pk cross reference maintained as part of the
* session. When enabled, prior to performing the lookup, Hibernate will check all entities of the given
* type associated with the session to see if its natural-id values have changed and, if so, update the
* cross reference. There is a performance impact associated with this, so if application developers are
* certain the natural-ids in play have not changed, this setting can be disabled to circumvent that impact.
* However, disabling this setting when natural-ids values have changed can result in incorrect results!
*
* @param enabled Should synchronization be performed? {@code true} indicates synchronization will be performed;
* {@code false} indicates it will be circumvented.
*
* @return {@code this}, for method chaining
*/
public NaturalIdLoadAccess<T> setSynchronizationEnabled(boolean enabled);
/**
* Return the persistent instance with the natural id value(s) defined by the call(s) to {@link #using}. This
* method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.
*
* You should not use this method to determine if an instance exists; to check for existence, use {@link #load}
* instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an
* actual error.
*
* @return the persistent instance or proxy
*/
public T getReference();
/**
* Return the persistent instance with the natural id value(s) defined by the call(s) to {@link #using}, or
* {@code null} if there is no such persistent instance. If the instance is already associated with the session,
* return that instance, initializing it if needed. This method never returns an uninitialized instance.
*
* @return The persistent instance or {@code null}
*/
public T load();
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save