├── .gradle ├── 5.2.1 │ ├── executionHistory │ │ ├── executionHistory.bin │ │ └── executionHistory.lock │ ├── fileChanges │ │ └── last-build.bin │ ├── fileContent │ │ └── fileContent.lock │ ├── fileHashes │ │ ├── fileHashes.bin │ │ ├── fileHashes.lock │ │ └── resourceHashesCache.bin │ ├── gc.properties │ └── javaCompile │ │ ├── classAnalysis.bin │ │ ├── jarAnalysis.bin │ │ ├── javaCompile.lock │ │ └── taskHistory.bin ├── buildOutputCleanup │ ├── buildOutputCleanup.lock │ ├── cache.properties │ └── outputFiles.bin └── vcs-1 │ └── gc.properties ├── .idea ├── .gitignore ├── .name ├── gradle.xml ├── misc.xml └── vcs.xml ├── README.md ├── build.gradle ├── build ├── classes │ └── java │ │ ├── main │ │ └── org │ │ │ └── springframework │ │ │ └── core │ │ │ ├── ConstantException.class │ │ │ ├── Constants.class │ │ │ ├── ControlFlow.class │ │ │ ├── ControlFlowFactory$Jdk13ControlFlow.class │ │ │ ├── ControlFlowFactory$Jdk14ControlFlow.class │ │ │ ├── ControlFlowFactory$Jdk18ControlFlow.class │ │ │ ├── ControlFlowFactory.class │ │ │ ├── ErrorCoded.class │ │ │ ├── JdkVersion.class │ │ │ ├── NestedCheckedException.class │ │ │ ├── NestedRuntimeException.class │ │ │ ├── OrderComparator.class │ │ │ ├── Ordered.class │ │ │ └── io │ │ │ ├── AbstractResource.class │ │ │ ├── ClassPathResource.class │ │ │ ├── DefaultResourceLoader.class │ │ │ ├── FileSystemResource.class │ │ │ ├── InputStreamResource.class │ │ │ ├── InputStreamSource.class │ │ │ ├── Resource.class │ │ │ ├── ResourceEditor.class │ │ │ ├── ResourceLoader.class │ │ │ └── UrlResource.class │ │ └── test │ │ └── org │ │ └── springframework │ │ └── core │ │ ├── AbstractControlFlowTests$One.class │ │ ├── AbstractControlFlowTests$Two.class │ │ ├── AbstractControlFlowTests.class │ │ ├── ConstantsTests$A.class │ │ ├── ConstantsTests.class │ │ ├── DefaultControlFlowTests.class │ │ ├── Jdk13ControlFlowTests.class │ │ ├── Jdk14ControlFlowTests.class │ │ ├── Jdk18ControlFlowTests.class │ │ ├── NestedCheckedExceptionTests$1.class │ │ ├── NestedCheckedExceptionTests$2.class │ │ └── NestedCheckedExceptionTests.class ├── reports │ └── tests │ │ └── test │ │ ├── classes │ │ └── org.springframework.core.ConstantsTests.html │ │ ├── css │ │ ├── base-style.css │ │ └── style.css │ │ ├── index.html │ │ ├── js │ │ └── report.js │ │ └── packages │ │ └── org.springframework.core.html └── test-results │ └── test │ ├── TEST-org.springframework.core.ConstantsTests.xml │ └── binary │ ├── output.bin │ ├── output.bin.idx │ └── results.bin ├── docs └── image │ └── overview.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main └── java │ └── org │ └── springframework │ ├── beans │ ├── BeanUtils.java │ ├── BeanWrapper.java │ ├── BeanWrapperImpl.java │ ├── BeansException.java │ ├── CachedIntrospectionResults.java │ ├── FatalBeanException.java │ ├── MethodInvocationException.java │ ├── MutablePropertyValues.java │ ├── NotWritablePropertyException.java │ ├── NullValueInNestedPathException.java │ ├── PropertyAccessException.java │ ├── PropertyAccessExceptionsException.java │ ├── PropertyValue.java │ ├── PropertyValues.java │ ├── PropertyValuesEditor.java │ ├── README.md │ ├── TypeMismatchException.java │ ├── package.html │ └── propertyeditors │ │ ├── ClassEditor.java │ │ ├── CustomBooleanEditor.java │ │ ├── CustomDateEditor.java │ │ ├── CustomNumberEditor.java │ │ ├── FileEditor.java │ │ ├── LocaleEditor.java │ │ ├── PropertiesEditor.java │ │ ├── README.md │ │ ├── StringArrayPropertyEditor.java │ │ ├── StringTrimmerEditor.java │ │ ├── URLEditor.java │ │ └── package.html │ ├── core │ ├── ConstantException.java │ ├── Constants.java │ ├── ControlFlow.java │ ├── ControlFlowFactory.java │ ├── ErrorCoded.java │ ├── JdkVersion.java │ ├── NestedCheckedException.java │ ├── NestedRuntimeException.java │ ├── OrderComparator.java │ ├── Ordered.java │ ├── README.md │ ├── io │ │ ├── AbstractResource.java │ │ ├── ClassPathResource.java │ │ ├── DefaultResourceLoader.java │ │ ├── FileSystemResource.java │ │ ├── InputStreamResource.java │ │ ├── InputStreamSource.java │ │ ├── README.md │ │ ├── Resource.java │ │ ├── ResourceEditor.java │ │ ├── ResourceLoader.java │ │ ├── UrlResource.java │ │ └── package.html │ └── package.html │ └── util │ └── StringUtils.java └── test └── java └── org └── springframework └── core ├── AbstractControlFlowTests.java ├── ConstantsTests.java ├── DefaultControlFlowTests.java ├── Jdk13ControlFlowTests.java ├── Jdk14ControlFlowTests.java ├── Jdk18ControlFlowTests.java └── NestedCheckedExceptionTests.java /.gradle/5.2.1/executionHistory/executionHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/executionHistory/executionHistory.bin -------------------------------------------------------------------------------- /.gradle/5.2.1/executionHistory/executionHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/executionHistory/executionHistory.lock -------------------------------------------------------------------------------- /.gradle/5.2.1/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gradle/5.2.1/fileContent/fileContent.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/fileContent/fileContent.lock -------------------------------------------------------------------------------- /.gradle/5.2.1/fileHashes/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/fileHashes/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/5.2.1/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /.gradle/5.2.1/fileHashes/resourceHashesCache.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/fileHashes/resourceHashesCache.bin -------------------------------------------------------------------------------- /.gradle/5.2.1/gc.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/gc.properties -------------------------------------------------------------------------------- /.gradle/5.2.1/javaCompile/classAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/javaCompile/classAnalysis.bin -------------------------------------------------------------------------------- /.gradle/5.2.1/javaCompile/jarAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/javaCompile/jarAnalysis.bin -------------------------------------------------------------------------------- /.gradle/5.2.1/javaCompile/javaCompile.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/javaCompile/javaCompile.lock -------------------------------------------------------------------------------- /.gradle/5.2.1/javaCompile/taskHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/5.2.1/javaCompile/taskHistory.bin -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/buildOutputCleanup.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/buildOutputCleanup/buildOutputCleanup.lock -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Sat Oct 26 21:00:47 KST 2019 2 | gradle.version=5.2.1 3 | -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/outputFiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/buildOutputCleanup/outputFiles.bin -------------------------------------------------------------------------------- /.gradle/vcs-1/gc.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/.gradle/vcs-1/gc.properties -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Default ignored files 3 | /workspace.xml -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | springframework -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 스프링 프레임워크 1.0 까보면서 좀 파악해보기 2 | 3 | 4 | 5 | ![overview](./docs/image/overview.gif) 6 | 7 | 8 | ## 패키지들 9 | 10 | --- 11 | 12 | - aop 13 | - beans : 자바빈을 생성하기 위한 인터페이스와 클래스들을 포함한다 14 | 다른 스프링 패키지들에서 가장 많이 사용하는 패키지 (작업중) 15 | - context 16 | - core : 예외 처리를 가능하게 하고, 프레임워크에 속하지 않는 핵심 인터페이스들을 제공하는 기본적인 클래스 (완료) 17 | - dao 18 | - ejb 19 | - jdbc 20 | - jndi 21 | - mail 22 | - metadata 23 | - orm 24 | - remoting 25 | - scheduling 26 | - transaction 27 | - ui 28 | - util 29 | - validation 30 | - web 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group 'org' 6 | version '1.0-SNAPSHOT' 7 | 8 | sourceCompatibility = 1.8 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | 16 | compile group: 'commons-logging', name: 'commons-logging', version: '1.2' 17 | compile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1' 18 | 19 | testCompile group: 'junit', name: 'junit', version: '4.12' 20 | } 21 | -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ConstantException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ConstantException.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/Constants.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ControlFlow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ControlFlow.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ControlFlowFactory$Jdk13ControlFlow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ControlFlowFactory$Jdk13ControlFlow.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ControlFlowFactory$Jdk14ControlFlow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ControlFlowFactory$Jdk14ControlFlow.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ControlFlowFactory$Jdk18ControlFlow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ControlFlowFactory$Jdk18ControlFlow.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ControlFlowFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ControlFlowFactory.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/ErrorCoded.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/ErrorCoded.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/JdkVersion.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/JdkVersion.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/NestedCheckedException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/NestedCheckedException.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/NestedRuntimeException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/NestedRuntimeException.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/OrderComparator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/OrderComparator.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/Ordered.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/Ordered.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/AbstractResource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/AbstractResource.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/ClassPathResource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/ClassPathResource.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/DefaultResourceLoader.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/DefaultResourceLoader.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/FileSystemResource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/FileSystemResource.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/InputStreamResource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/InputStreamResource.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/InputStreamSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/InputStreamSource.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/Resource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/Resource.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/ResourceEditor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/ResourceEditor.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/ResourceLoader.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/ResourceLoader.class -------------------------------------------------------------------------------- /build/classes/java/main/org/springframework/core/io/UrlResource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/main/org/springframework/core/io/UrlResource.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/AbstractControlFlowTests$One.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/AbstractControlFlowTests$One.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/AbstractControlFlowTests$Two.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/AbstractControlFlowTests$Two.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/AbstractControlFlowTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/AbstractControlFlowTests.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/ConstantsTests$A.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/ConstantsTests$A.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/ConstantsTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/ConstantsTests.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/DefaultControlFlowTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/DefaultControlFlowTests.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/Jdk13ControlFlowTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/Jdk13ControlFlowTests.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/Jdk14ControlFlowTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/Jdk14ControlFlowTests.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/Jdk18ControlFlowTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/Jdk18ControlFlowTests.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/NestedCheckedExceptionTests$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/NestedCheckedExceptionTests$1.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/NestedCheckedExceptionTests$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/NestedCheckedExceptionTests$2.class -------------------------------------------------------------------------------- /build/classes/java/test/org/springframework/core/NestedCheckedExceptionTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/classes/java/test/org/springframework/core/NestedCheckedExceptionTests.class -------------------------------------------------------------------------------- /build/reports/tests/test/classes/org.springframework.core.ConstantsTests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - Class org.springframework.core.ConstantsTests 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Class org.springframework.core.ConstantsTests

14 | 17 |
18 | 19 | 20 | 52 | 58 | 59 |
21 |
22 | 23 | 24 | 30 | 36 | 42 | 48 | 49 |
25 |
26 |
2
27 |

tests

28 |
29 |
31 |
32 |
0
33 |

failures

34 |
35 |
37 |
38 |
0
39 |

ignored

40 |
41 |
43 |
44 |
0.004s
45 |

duration

46 |
47 |
50 |
51 |
53 |
54 |
100%
55 |

successful

56 |
57 |
60 |
61 |
62 | 67 |
68 |

Tests

69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 |
TestDurationResult
propertyToConstantNamePrefix0.004spassed
testConstants0spassed
88 |
89 |
90 | 99 |
100 | 101 | 102 | -------------------------------------------------------------------------------- /build/reports/tests/test/css/base-style.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | font-family: sans-serif; 6 | font-size: 12pt; 7 | } 8 | 9 | body, a, a:visited { 10 | color: #303030; 11 | } 12 | 13 | #content { 14 | padding-left: 50px; 15 | padding-right: 50px; 16 | padding-top: 30px; 17 | padding-bottom: 30px; 18 | } 19 | 20 | #content h1 { 21 | font-size: 160%; 22 | margin-bottom: 10px; 23 | } 24 | 25 | #footer { 26 | margin-top: 100px; 27 | font-size: 80%; 28 | white-space: nowrap; 29 | } 30 | 31 | #footer, #footer a { 32 | color: #a0a0a0; 33 | } 34 | 35 | #line-wrapping-toggle { 36 | vertical-align: middle; 37 | } 38 | 39 | #label-for-line-wrapping-toggle { 40 | vertical-align: middle; 41 | } 42 | 43 | ul { 44 | margin-left: 0; 45 | } 46 | 47 | h1, h2, h3 { 48 | white-space: nowrap; 49 | } 50 | 51 | h2 { 52 | font-size: 120%; 53 | } 54 | 55 | ul.tabLinks { 56 | padding-left: 0; 57 | padding-top: 10px; 58 | padding-bottom: 10px; 59 | overflow: auto; 60 | min-width: 800px; 61 | width: auto !important; 62 | width: 800px; 63 | } 64 | 65 | ul.tabLinks li { 66 | float: left; 67 | height: 100%; 68 | list-style: none; 69 | padding-left: 10px; 70 | padding-right: 10px; 71 | padding-top: 5px; 72 | padding-bottom: 5px; 73 | margin-bottom: 0; 74 | -moz-border-radius: 7px; 75 | border-radius: 7px; 76 | margin-right: 25px; 77 | border: solid 1px #d4d4d4; 78 | background-color: #f0f0f0; 79 | } 80 | 81 | ul.tabLinks li:hover { 82 | background-color: #fafafa; 83 | } 84 | 85 | ul.tabLinks li.selected { 86 | background-color: #c5f0f5; 87 | border-color: #c5f0f5; 88 | } 89 | 90 | ul.tabLinks a { 91 | font-size: 120%; 92 | display: block; 93 | outline: none; 94 | text-decoration: none; 95 | margin: 0; 96 | padding: 0; 97 | } 98 | 99 | ul.tabLinks li h2 { 100 | margin: 0; 101 | padding: 0; 102 | } 103 | 104 | div.tab { 105 | } 106 | 107 | div.selected { 108 | display: block; 109 | } 110 | 111 | div.deselected { 112 | display: none; 113 | } 114 | 115 | div.tab table { 116 | min-width: 350px; 117 | width: auto !important; 118 | width: 350px; 119 | border-collapse: collapse; 120 | } 121 | 122 | div.tab th, div.tab table { 123 | border-bottom: solid #d0d0d0 1px; 124 | } 125 | 126 | div.tab th { 127 | text-align: left; 128 | white-space: nowrap; 129 | padding-left: 6em; 130 | } 131 | 132 | div.tab th:first-child { 133 | padding-left: 0; 134 | } 135 | 136 | div.tab td { 137 | white-space: nowrap; 138 | padding-left: 6em; 139 | padding-top: 5px; 140 | padding-bottom: 5px; 141 | } 142 | 143 | div.tab td:first-child { 144 | padding-left: 0; 145 | } 146 | 147 | div.tab td.numeric, div.tab th.numeric { 148 | text-align: right; 149 | } 150 | 151 | span.code { 152 | display: inline-block; 153 | margin-top: 0em; 154 | margin-bottom: 1em; 155 | } 156 | 157 | span.code pre { 158 | font-size: 11pt; 159 | padding-top: 10px; 160 | padding-bottom: 10px; 161 | padding-left: 10px; 162 | padding-right: 10px; 163 | margin: 0; 164 | background-color: #f7f7f7; 165 | border: solid 1px #d0d0d0; 166 | min-width: 700px; 167 | width: auto !important; 168 | width: 700px; 169 | } 170 | 171 | span.wrapped pre { 172 | word-wrap: break-word; 173 | white-space: pre-wrap; 174 | word-break: break-all; 175 | } 176 | 177 | label.hidden { 178 | display: none; 179 | } -------------------------------------------------------------------------------- /build/reports/tests/test/css/style.css: -------------------------------------------------------------------------------- 1 | 2 | #summary { 3 | margin-top: 30px; 4 | margin-bottom: 40px; 5 | } 6 | 7 | #summary table { 8 | border-collapse: collapse; 9 | } 10 | 11 | #summary td { 12 | vertical-align: top; 13 | } 14 | 15 | .breadcrumbs, .breadcrumbs a { 16 | color: #606060; 17 | } 18 | 19 | .infoBox { 20 | width: 110px; 21 | padding-top: 15px; 22 | padding-bottom: 15px; 23 | text-align: center; 24 | } 25 | 26 | .infoBox p { 27 | margin: 0; 28 | } 29 | 30 | .counter, .percent { 31 | font-size: 120%; 32 | font-weight: bold; 33 | margin-bottom: 8px; 34 | } 35 | 36 | #duration { 37 | width: 125px; 38 | } 39 | 40 | #successRate, .summaryGroup { 41 | border: solid 2px #d0d0d0; 42 | -moz-border-radius: 10px; 43 | border-radius: 10px; 44 | } 45 | 46 | #successRate { 47 | width: 140px; 48 | margin-left: 35px; 49 | } 50 | 51 | #successRate .percent { 52 | font-size: 180%; 53 | } 54 | 55 | .success, .success a { 56 | color: #008000; 57 | } 58 | 59 | div.success, #successRate.success { 60 | background-color: #bbd9bb; 61 | border-color: #008000; 62 | } 63 | 64 | .failures, .failures a { 65 | color: #b60808; 66 | } 67 | 68 | .skipped, .skipped a { 69 | color: #c09853; 70 | } 71 | 72 | div.failures, #successRate.failures { 73 | background-color: #ecdada; 74 | border-color: #b60808; 75 | } 76 | 77 | ul.linkList { 78 | padding-left: 0; 79 | } 80 | 81 | ul.linkList li { 82 | list-style: none; 83 | margin-bottom: 5px; 84 | } 85 | -------------------------------------------------------------------------------- /build/reports/tests/test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - Test Summary 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Test Summary

14 |
15 | 16 | 17 | 49 | 55 | 56 |
18 |
19 | 20 | 21 | 27 | 33 | 39 | 45 | 46 |
22 |
23 |
2
24 |

tests

25 |
26 |
28 |
29 |
0
30 |

failures

31 |
32 |
34 |
35 |
0
36 |

ignored

37 |
38 |
40 |
41 |
0.004s
42 |

duration

43 |
44 |
47 |
48 |
50 |
51 |
100%
52 |

successful

53 |
54 |
57 |
58 |
59 | 67 |
68 |

Packages

69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |
PackageTestsFailuresIgnoredDurationSuccess rate
83 | org.springframework.core 84 | 2000.004s100%
93 |
94 |
95 |

Classes

96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |
ClassTestsFailuresIgnoredDurationSuccess rate
110 | org.springframework.core.ConstantsTests 111 | 2000.004s100%
120 |
121 |
122 | 131 |
132 | 133 | 134 | -------------------------------------------------------------------------------- /build/reports/tests/test/js/report.js: -------------------------------------------------------------------------------- 1 | (function (window, document) { 2 | "use strict"; 3 | 4 | var tabs = {}; 5 | 6 | function changeElementClass(element, classValue) { 7 | if (element.getAttribute("className")) { 8 | element.setAttribute("className", classValue); 9 | } else { 10 | element.setAttribute("class", classValue); 11 | } 12 | } 13 | 14 | function getClassAttribute(element) { 15 | if (element.getAttribute("className")) { 16 | return element.getAttribute("className"); 17 | } else { 18 | return element.getAttribute("class"); 19 | } 20 | } 21 | 22 | function addClass(element, classValue) { 23 | changeElementClass(element, getClassAttribute(element) + " " + classValue); 24 | } 25 | 26 | function removeClass(element, classValue) { 27 | changeElementClass(element, getClassAttribute(element).replace(classValue, "")); 28 | } 29 | 30 | function initTabs() { 31 | var container = document.getElementById("tabs"); 32 | 33 | tabs.tabs = findTabs(container); 34 | tabs.titles = findTitles(tabs.tabs); 35 | tabs.headers = findHeaders(container); 36 | tabs.select = select; 37 | tabs.deselectAll = deselectAll; 38 | tabs.select(0); 39 | 40 | return true; 41 | } 42 | 43 | function getCheckBox() { 44 | return document.getElementById("line-wrapping-toggle"); 45 | } 46 | 47 | function getLabelForCheckBox() { 48 | return document.getElementById("label-for-line-wrapping-toggle"); 49 | } 50 | 51 | function findCodeBlocks() { 52 | var spans = document.getElementById("tabs").getElementsByTagName("span"); 53 | var codeBlocks = []; 54 | for (var i = 0; i < spans.length; ++i) { 55 | if (spans[i].className.indexOf("code") >= 0) { 56 | codeBlocks.push(spans[i]); 57 | } 58 | } 59 | return codeBlocks; 60 | } 61 | 62 | function forAllCodeBlocks(operation) { 63 | var codeBlocks = findCodeBlocks(); 64 | 65 | for (var i = 0; i < codeBlocks.length; ++i) { 66 | operation(codeBlocks[i], "wrapped"); 67 | } 68 | } 69 | 70 | function toggleLineWrapping() { 71 | var checkBox = getCheckBox(); 72 | 73 | if (checkBox.checked) { 74 | forAllCodeBlocks(addClass); 75 | } else { 76 | forAllCodeBlocks(removeClass); 77 | } 78 | } 79 | 80 | function initControls() { 81 | if (findCodeBlocks().length > 0) { 82 | var checkBox = getCheckBox(); 83 | var label = getLabelForCheckBox(); 84 | 85 | checkBox.onclick = toggleLineWrapping; 86 | checkBox.checked = false; 87 | 88 | removeClass(label, "hidden"); 89 | } 90 | } 91 | 92 | function switchTab() { 93 | var id = this.id.substr(1); 94 | 95 | for (var i = 0; i < tabs.tabs.length; i++) { 96 | if (tabs.tabs[i].id === id) { 97 | tabs.select(i); 98 | break; 99 | } 100 | } 101 | 102 | return false; 103 | } 104 | 105 | function select(i) { 106 | this.deselectAll(); 107 | 108 | changeElementClass(this.tabs[i], "tab selected"); 109 | changeElementClass(this.headers[i], "selected"); 110 | 111 | while (this.headers[i].firstChild) { 112 | this.headers[i].removeChild(this.headers[i].firstChild); 113 | } 114 | 115 | var h2 = document.createElement("H2"); 116 | 117 | h2.appendChild(document.createTextNode(this.titles[i])); 118 | this.headers[i].appendChild(h2); 119 | } 120 | 121 | function deselectAll() { 122 | for (var i = 0; i < this.tabs.length; i++) { 123 | changeElementClass(this.tabs[i], "tab deselected"); 124 | changeElementClass(this.headers[i], "deselected"); 125 | 126 | while (this.headers[i].firstChild) { 127 | this.headers[i].removeChild(this.headers[i].firstChild); 128 | } 129 | 130 | var a = document.createElement("A"); 131 | 132 | a.setAttribute("id", "ltab" + i); 133 | a.setAttribute("href", "#tab" + i); 134 | a.onclick = switchTab; 135 | a.appendChild(document.createTextNode(this.titles[i])); 136 | 137 | this.headers[i].appendChild(a); 138 | } 139 | } 140 | 141 | function findTabs(container) { 142 | return findChildElements(container, "DIV", "tab"); 143 | } 144 | 145 | function findHeaders(container) { 146 | var owner = findChildElements(container, "UL", "tabLinks"); 147 | return findChildElements(owner[0], "LI", null); 148 | } 149 | 150 | function findTitles(tabs) { 151 | var titles = []; 152 | 153 | for (var i = 0; i < tabs.length; i++) { 154 | var tab = tabs[i]; 155 | var header = findChildElements(tab, "H2", null)[0]; 156 | 157 | header.parentNode.removeChild(header); 158 | 159 | if (header.innerText) { 160 | titles.push(header.innerText); 161 | } else { 162 | titles.push(header.textContent); 163 | } 164 | } 165 | 166 | return titles; 167 | } 168 | 169 | function findChildElements(container, name, targetClass) { 170 | var elements = []; 171 | var children = container.childNodes; 172 | 173 | for (var i = 0; i < children.length; i++) { 174 | var child = children.item(i); 175 | 176 | if (child.nodeType === 1 && child.nodeName === name) { 177 | if (targetClass && child.className.indexOf(targetClass) < 0) { 178 | continue; 179 | } 180 | 181 | elements.push(child); 182 | } 183 | } 184 | 185 | return elements; 186 | } 187 | 188 | // Entry point. 189 | 190 | window.onload = function() { 191 | initTabs(); 192 | initControls(); 193 | }; 194 | } (window, window.document)); -------------------------------------------------------------------------------- /build/reports/tests/test/packages/org.springframework.core.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - Package org.springframework.core 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Package org.springframework.core

14 | 16 |
17 | 18 | 19 | 51 | 57 | 58 |
20 |
21 | 22 | 23 | 29 | 35 | 41 | 47 | 48 |
24 |
25 |
2
26 |

tests

27 |
28 |
30 |
31 |
0
32 |

failures

33 |
34 |
36 |
37 |
0
38 |

ignored

39 |
40 |
42 |
43 |
0.004s
44 |

duration

45 |
46 |
49 |
50 |
52 |
53 |
100%
54 |

successful

55 |
56 |
59 |
60 |
61 | 66 |
67 |

Classes

68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
ClassTestsFailuresIgnoredDurationSuccess rate
81 | ConstantsTests 82 | 2000.004s100%
90 |
91 |
92 | 101 |
102 | 103 | 104 | -------------------------------------------------------------------------------- /build/test-results/test/TEST-org.springframework.core.ConstantsTests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build/test-results/test/binary/output.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/test-results/test/binary/output.bin -------------------------------------------------------------------------------- /build/test-results/test/binary/output.bin.idx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /build/test-results/test/binary/results.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/build/test-results/test/binary/results.bin -------------------------------------------------------------------------------- /docs/image/overview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/docs/image/overview.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arahansa/learn_spring_1.0_toJava8/1e9432eebbdd09a3ec11cc313c2b19c8227403c8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'springframework' 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/BeanUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import java.beans.PropertyDescriptor; 20 | import java.lang.reflect.Constructor; 21 | import java.lang.reflect.InvocationTargetException; 22 | import java.util.Arrays; 23 | import java.util.List; 24 | 25 | /** 26 | * Static convenience methods for JavaBeans, for instantiating beans, 27 | * copying bean properties, etc. 28 | * 29 | * 자바빈즈, 빈 인스턴스화, 빈 속성들을 복사하기 위한 정적 편리 메소드들. 30 | * 31 | *

Mainly for use within the framework, but to some degree also 32 | * useful for application classes. 33 | * 34 | * 주로 어플리케이션내에서 사용되지만, 어플리케이션 클래스들에서도 어느정도는 유용하기도합니다. 35 | * 36 | * @author Rod Johnson 37 | * @author Juergen Hoeller 38 | * @version $Id: BeanUtils.java,v 1.15 2004/03/18 02:46:12 trisberg Exp $ 39 | */ 40 | public abstract class BeanUtils { 41 | 42 | /** 43 | * Convenience method to instantiate a class using its no-arg constructor. 44 | * As this method doesn't try to load classes by name, it should avoid class-loading issues. 45 | * @param clazz class to instantiate 46 | * @return the new instance 47 | */ 48 | public static Object instantiateClass(Class clazz) throws BeansException { 49 | try { 50 | return clazz.newInstance(); 51 | } 52 | catch (InstantiationException ex) { 53 | throw new FatalBeanException("Could not instantiate class [" + clazz.getName() + 54 | "]; Is it an interface or an abstract class? Does it have a no-arg constructor?", ex); 55 | } 56 | catch (IllegalAccessException ex) { 57 | throw new FatalBeanException("Could not instantiate class [" + clazz.getName() + 58 | "]; has class definition changed? Is there a public no-arg constructor?", ex); 59 | } 60 | } 61 | 62 | /** 63 | * Convenience method to instantiate a class using the given constructor. 64 | * As this method doesn't try to load classes by name, it should avoid class-loading issues. 65 | * @param constructor constructor to instantiate 66 | * @return the new instance 67 | */ 68 | public static Object instantiateClass(Constructor constructor, Object[] arguments) throws BeansException { 69 | try { 70 | return constructor.newInstance(arguments); 71 | } 72 | catch (IllegalArgumentException ex) { 73 | throw new FatalBeanException("Illegal arguments when trying to instantiate constructor: " + constructor, ex); 74 | } 75 | catch (InstantiationException ex) { 76 | throw new FatalBeanException("Could not instantiate class [" + constructor.getDeclaringClass().getName() + 77 | "]; is it an interface or an abstract class?", ex); 78 | } 79 | catch (IllegalAccessException ex) { 80 | throw new FatalBeanException("Could not instantiate class [" + constructor.getDeclaringClass().getName() + 81 | "]; has class definition changed? Is there a public constructor?", ex); 82 | } 83 | catch (InvocationTargetException ex) { 84 | throw new FatalBeanException("Could not instantiate class [" + constructor.getDeclaringClass().getName() + 85 | "]; constructor threw exception", ex.getTargetException()); 86 | } 87 | } 88 | 89 | /** 90 | * Determine if the given type is assignable from the given value, 91 | * assuming setting by reflection. Considers primitive wrapper classes 92 | * as assignable to the corresponding primitive types. 93 | *

For example used in a bean factory's constructor resolution. 94 | * @param type the target type 95 | * @param value the value that should be assigned to the type 96 | * @return if the type is assignable from the value 97 | */ 98 | public static boolean isAssignable(Class type, Object value) { 99 | return (type.isInstance(value) || 100 | (!type.isPrimitive() && value == null) || 101 | (type.equals(boolean.class) && value instanceof Boolean) || 102 | (type.equals(byte.class) && value instanceof Byte) || 103 | (type.equals(char.class) && value instanceof Character) || 104 | (type.equals(short.class) && value instanceof Short) || 105 | (type.equals(int.class) && value instanceof Integer) || 106 | (type.equals(long.class) && value instanceof Long) || 107 | (type.equals(float.class) && value instanceof Float) || 108 | (type.equals(double.class) && value instanceof Double)); 109 | } 110 | 111 | /** 112 | * Check if the given class represents a "simple" property, 113 | * i.e. a primitive, a String, a Class, or a corresponding array. 114 | * Used to determine properties to check for a "simple" dependency-check. 115 | * @see org.springframework.beans.factory.support.RootBeanDefinition#DEPENDENCY_CHECK_SIMPLE 116 | * @see org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#dependencyCheck 117 | */ 118 | public static boolean isSimpleProperty(Class clazz) { 119 | return clazz.isPrimitive() || isPrimitiveArray(clazz) || isPrimitiveWrapperArray(clazz) || 120 | clazz.equals(String.class) || clazz.equals(String[].class) || 121 | clazz.equals(Class.class) || clazz.equals(Class[].class); 122 | } 123 | 124 | /** 125 | * Check if the given class represents a primitive array, 126 | * i.e. boolean, byte, char, short, int, long, float, or double. 127 | */ 128 | public static boolean isPrimitiveArray(Class clazz) { 129 | return boolean[].class.equals(clazz) || byte[].class.equals(clazz) || char[].class.equals(clazz) || 130 | short[].class.equals(clazz) || int[].class.equals(clazz) || long[].class.equals(clazz) || 131 | float[].class.equals(clazz) || double[].class.equals(clazz); 132 | } 133 | 134 | /** 135 | * Check if the given class represents an array of primitive wrappers, 136 | * i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double. 137 | */ 138 | public static boolean isPrimitiveWrapperArray(Class clazz) { 139 | return Boolean[].class.equals(clazz) || Byte[].class.equals(clazz) || Character[].class.equals(clazz) || 140 | Short[].class.equals(clazz) || Integer[].class.equals(clazz) || Long[].class.equals(clazz) || 141 | Float[].class.equals(clazz) || Double[].class.equals(clazz); 142 | } 143 | 144 | /** 145 | * Copy the property values of the given source bean into the target bean. 146 | * @param source source bean 147 | * @param target target bean 148 | * @throws IllegalArgumentException if the classes of source and target do not match 149 | */ 150 | public static void copyProperties(Object source, Object target) 151 | throws IllegalArgumentException, BeansException { 152 | copyProperties(source, target, null); 153 | } 154 | 155 | /** 156 | * Copy the property values of the given source bean into the given target bean, 157 | * ignoring the given ignoreProperties. 158 | * @param source source bean 159 | * @param target target bean 160 | * @param ignoreProperties array of property names to ignore 161 | * @throws IllegalArgumentException if the classes of source and target do not match 162 | */ 163 | public static void copyProperties(Object source, Object target, String[] ignoreProperties) 164 | throws IllegalArgumentException, BeansException { 165 | if (source == null || target == null || !source.getClass().isInstance(target)) { 166 | throw new IllegalArgumentException("Target must an instance of source"); 167 | } 168 | List ignoreList = (ignoreProperties != null) ? Arrays.asList(ignoreProperties) : null; 169 | BeanWrapper sourceBw = new BeanWrapperImpl(source); 170 | BeanWrapper targetBw = new BeanWrapperImpl(target); 171 | MutablePropertyValues values = new MutablePropertyValues(); 172 | for (int i = 0; i < sourceBw.getPropertyDescriptors().length; i++) { 173 | PropertyDescriptor sourceDesc = sourceBw.getPropertyDescriptors()[i]; 174 | String name = sourceDesc.getName(); 175 | PropertyDescriptor targetDesc = targetBw.getPropertyDescriptor(name); 176 | if (targetDesc.getWriteMethod() != null && targetDesc.getReadMethod() != null && 177 | (ignoreProperties == null || (!ignoreList.contains(name)))) { 178 | values.addPropertyValue(new PropertyValue(name, sourceBw.getPropertyValue(name))); 179 | } 180 | } 181 | targetBw.setPropertyValues(values); 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/BeanWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import java.beans.PropertyDescriptor; 20 | import java.beans.PropertyEditor; 21 | import java.util.Map; 22 | 23 | /** 24 | * The central interface of Spring's low-level JavaBeans infrastructure. 25 | * Typically not directly used by application code but rather implicitly 26 | * via a BeanFactory or a DataBinder. 27 | * 28 | * 스프링 로우레벨 자바빈즈 인프라스트럭쳐의 핵심 인터페이스입니다. 29 | * 일반적으로 어플리케이션 코드에서 직접적으로 사용되지 않으며, 30 | * 암시적으로 BeanFactory 나 DataBinder 에서 사용됩니다. 31 | * 32 | *

To be implemented by classes that can manipulate Java beans. 33 | * Implementing classes have the ability to get and set property values 34 | * (individually or in bulk), get property descriptors and query the 35 | * readability and writability of properties. 36 | * 37 | * 클래스에 의해 구현됨으로써 자바빈즈를 생성할 수 있습니다. 38 | * 클래스를 구현하여 프로퍼티값을 겟,셋할 수 있고, 프로퍼티 설명자를 얻을 수 있으며, 39 | * 속성이 읽고 쓰기가 가능한지 질의할 수 있습니다. 40 | * 41 | *

This interface supports nested properties enabling the setting 42 | * of properties on subproperties to an unlimited depth. 43 | * 44 | * 이 인터페이스는 속성의 하위 속성을 설정함으로써 무한대의 깊이를 가질 수 있게하는 45 | * 중첩된 속성(nested properties)를 지원합니다. 46 | * 47 | *

If a property update causes an exception, a PropertyVetoException will be 48 | * thrown. Bulk updates continue after exceptions are encountered, throwing an 49 | * exception wrapping all exceptions encountered during the update. 50 | * 51 | * 프로퍼티 업데이트가 예외를 발생시키면 PropertyVetoException 이 던져지게 됩니다. 52 | * Bulk 업데이트는 예외가 던져진 이후에 업데이트 도중에 만난 모든 예외를 wrapping 한 예외를 던지게 됩니다. 53 | * 54 | *

BeanWrapper implementations can be used repeatedly, with their "target" 55 | * or wrapped object changed. 56 | * 57 | * @author Rod Johnson 58 | * @since 13 April 2001 59 | * @version $Id: BeanWrapper.java,v 1.12 2004/03/19 07:40:12 jhoeller Exp $ 60 | * @see org.springframework.beans.factory.BeanFactory 61 | * @see org.springframework.validation.DataBinder 62 | */ 63 | public interface BeanWrapper { 64 | 65 | /** 66 | * Path separator for nested properties. 67 | * Follows normal Java conventions: getFoo().getBar() would be "foo.bar". 68 | */ 69 | String NESTED_PROPERTY_SEPARATOR = "."; 70 | 71 | 72 | /** 73 | * Change the wrapped object. Implementations are required 74 | * to allow the type of the wrapped object to change. 75 | * @param obj wrapped object that we are manipulating 76 | */ 77 | void setWrappedInstance(Object obj) throws BeansException; 78 | 79 | /** 80 | * Return the bean wrapped by this object (cannot be null). 81 | * @return the bean wrapped by this object 82 | */ 83 | Object getWrappedInstance(); 84 | 85 | /** 86 | * Convenience method to return the class of the wrapped object. 87 | * @return the class of the wrapped object 88 | */ 89 | Class getWrappedClass(); 90 | 91 | /** 92 | * Register the given custom property editor for all properties of the 93 | * given type. 94 | * @param requiredType type of the property 95 | * @param propertyEditor editor to register 96 | */ 97 | void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor); 98 | 99 | /** 100 | * Register the given custom property editor for the given type and 101 | * property, or for all properties of the given type. 102 | * @param requiredType type of the property, can be null if a property is 103 | * given but should be specified in any case for consistency checking 104 | * @param propertyPath path of the property (name or nested path), or 105 | * null if registering an editor for all properties of the given type 106 | * @param propertyEditor editor to register 107 | */ 108 | void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor); 109 | 110 | /** 111 | * Find a custom property editor for the given type and property. 112 | * @param requiredType type of the property, can be null if a property is 113 | * given but should be specified in any case for consistency checking 114 | * @param propertyPath path of the property (name or nested path), or 115 | * null if looking for an editor for all properties of the given type 116 | * @return the registered editor, or null if none 117 | */ 118 | PropertyEditor findCustomEditor(Class requiredType, String propertyPath); 119 | 120 | 121 | /** 122 | * Get the value of a property. 123 | * @param propertyName name of the property to get the value of 124 | * @return the value of the property. 125 | * @throws FatalBeanException if there is no such property, if the property 126 | * isn't readable, or if the property getter throws an exception. 127 | */ 128 | Object getPropertyValue(String propertyName) throws BeansException; 129 | 130 | /** 131 | * Set a property value. This method is provided for convenience only. 132 | * The setPropertyValue(PropertyValue) method is more powerful. 133 | * @param propertyName name of the property to set value of 134 | * @param value the new value 135 | */ 136 | void setPropertyValue(String propertyName, Object value) throws BeansException; 137 | 138 | /** 139 | * Update a property value. 140 | * This is the preferred way to update an individual property. 141 | * @param pv object containing new property value 142 | */ 143 | void setPropertyValue(PropertyValue pv) throws BeansException; 144 | 145 | /** 146 | * Perform a bulk update from a Map. 147 | *

Bulk updates from PropertyValues are more powerful: This method is 148 | * provided for convenience. Behaviour will be identical to that of 149 | * the setPropertyValues(PropertyValues) method. 150 | * @param map Map to take properties from. Contains property value objects, 151 | * keyed by property name 152 | */ 153 | void setPropertyValues(Map map) throws BeansException; 154 | 155 | /** 156 | * The preferred way to perform a bulk update. 157 | *

Note that performing a bulk update differs from performing a single update, 158 | * in that an implementation of this class will continue to update properties 159 | * if a recoverable error (such as a vetoed property change or a type mismatch, 160 | * but not an invalid fieldname or the like) is encountered, throwing a 161 | * PropertyAccessExceptionsException containing all the individual errors. 162 | * This exception can be examined later to see all binding errors. 163 | * Properties that were successfully updated stay changed. 164 | *

Does not allow unknown fields. 165 | * Equivalent to setPropertyValues(pvs, false, null). 166 | * @param pvs PropertyValues to set on the target object 167 | */ 168 | void setPropertyValues(PropertyValues pvs) throws BeansException; 169 | 170 | /** 171 | * Perform a bulk update with full control over behavior. 172 | * Note that performing a bulk update differs from performing a single update, 173 | * in that an implementation of this class will continue to update properties 174 | * if a recoverable error (such as a vetoed property change or a type mismatch, 175 | * but not an invalid fieldname or the like) is encountered, throwing a 176 | * PropertyAccessExceptionsException containing all the individual errors. 177 | * This exception can be examined later to see all binding errors. 178 | * Properties that were successfully updated stay changed. 179 | *

Does not allow unknown fields. 180 | * @param pvs PropertyValues to set on the target object 181 | * @param ignoreUnknown should we ignore unknown values (not found in the bean!?) 182 | */ 183 | void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) 184 | throws BeansException; 185 | 186 | 187 | /** 188 | * Get the PropertyDescriptors identified on this object 189 | * (standard JavaBeans introspection). 190 | * @return the PropertyDescriptors identified on this object 191 | */ 192 | PropertyDescriptor[] getPropertyDescriptors() throws BeansException; 193 | 194 | /** 195 | * Get the property descriptor for a particular property. 196 | * @param propertyName property to check status for 197 | * @return the property descriptor for a particular property 198 | * @throws FatalBeanException if there is no such property 199 | */ 200 | PropertyDescriptor getPropertyDescriptor(String propertyName) throws BeansException; 201 | 202 | /** 203 | * Return whether this property is readable. 204 | * Returns false if the property doesn't exist. 205 | * @param propertyName property to check status for 206 | * @return whether this property is readable 207 | */ 208 | boolean isReadableProperty(String propertyName); 209 | 210 | /** 211 | * Return whether this property is writable. 212 | * Returns false if the property doesn't exist. 213 | * @param propertyName property to check status for 214 | * @return whether this property is writable 215 | */ 216 | boolean isWritableProperty(String propertyName); 217 | 218 | } 219 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import org.springframework.core.NestedRuntimeException; 20 | 21 | /** 22 | * Abstract superclass for all exceptions thrown in the beans package 23 | * and subpackages. 24 | * 25 | * 빈, 서브패키지에서의 던져지는 모든 예외들에 대한 추상클래스 26 | * 27 | * 28 | * 29 | *

Note that this is a runtime (unchecked) exception. Beans exceptions 30 | * are usually fatal; there is no reason for them to be checked. 31 | * 32 | * @author Rod Johnson 33 | */ 34 | public abstract class BeansException extends NestedRuntimeException { 35 | 36 | /** 37 | * Constructs a BeansException with the specified message. 38 | * @param msg the detail message 39 | */ 40 | public BeansException(String msg) { 41 | super(msg); 42 | } 43 | 44 | /** 45 | * Constructs a BeansException with the specified message 46 | * and root cause. 47 | * @param msg the detail message 48 | * @param ex the root cause 49 | */ 50 | public BeansException(String msg, Throwable ex) { 51 | super(msg, ex); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/CachedIntrospectionResults.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import org.apache.commons.logging.Log; 20 | import org.apache.commons.logging.LogFactory; 21 | 22 | import java.beans.BeanInfo; 23 | import java.beans.IntrospectionException; 24 | import java.beans.Introspector; 25 | import java.beans.PropertyDescriptor; 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | 29 | /** 30 | * Class to cache PropertyDescriptor information for a Java class. 31 | * Package-visible; not for use by application code. 32 | * 33 | * 자바클래스를 위한 PropertyDescriptor 정보를 캐시하기 위한 클래스입니다. 34 | * 35 | *

Necessary as Introspector.getBeanInfo() in JDK 1.3 will return a new 36 | * deep copy of the BeanInfo every time we ask for it. We take the opportunity 37 | * to hash property descriptors by method name for fast lookup. 38 | * 39 | *

Information is cached statically, so we don't need to create new 40 | * objects of this class for every JavaBean we manipulate. Thus this class 41 | * implements the factory design pattern, using a private constructor 42 | * and a public static forClass() method to obtain instances. 43 | * 44 | * @author Rod Johnson 45 | * @since 05 May 2001 46 | * @version $Id: CachedIntrospectionResults.java,v 1.8 2004/03/19 07:40:13 jhoeller Exp $ 47 | */ 48 | final class CachedIntrospectionResults { 49 | 50 | private static final Log logger = LogFactory.getLog(CachedIntrospectionResults.class); 51 | 52 | /** Map keyed by class containing CachedIntrospectionResults */ 53 | private static HashMap classCache = new HashMap(); 54 | 55 | /** 56 | * We might use this from the EJB tier, so we don't want to use synchronization. 57 | * Object references are atomic, so we can live with doing the occasional 58 | * unnecessary lookup at startup only. 59 | */ 60 | protected static CachedIntrospectionResults forClass(Class clazz) throws BeansException { 61 | Object results = classCache.get(clazz); 62 | if (results == null) { 63 | // can throw BeansException 64 | results = new CachedIntrospectionResults(clazz); 65 | classCache.put(clazz, results); 66 | } 67 | else { 68 | if (logger.isDebugEnabled()) { 69 | logger.debug("Using cached introspection results for class " + clazz.getName()); 70 | } 71 | } 72 | return (CachedIntrospectionResults) results; 73 | } 74 | 75 | 76 | private BeanInfo beanInfo; 77 | 78 | /** Property descriptors keyed by property name */ 79 | private Map propertyDescriptorMap; 80 | 81 | /** 82 | * Create new CachedIntrospectionResults instance fot the given class. 83 | */ 84 | private CachedIntrospectionResults(Class clazz) throws FatalBeanException { 85 | try { 86 | logger.debug("Getting BeanInfo for class [" + clazz.getName() + "]"); 87 | this.beanInfo = Introspector.getBeanInfo(clazz); 88 | 89 | logger.debug("Caching PropertyDescriptors for class [" + clazz.getName() + "]"); 90 | this.propertyDescriptorMap = new HashMap(); 91 | // This call is slow so we do it once 92 | PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors(); 93 | for (int i = 0; i < pds.length; i++) { 94 | logger.debug("Found property '" + pds[i].getName() + "' of type [" + pds[i].getPropertyType() + 95 | "]; editor=[" + pds[i].getPropertyEditorClass() + "]"); 96 | this.propertyDescriptorMap.put(pds[i].getName(), pds[i]); 97 | } 98 | } 99 | catch (IntrospectionException ex) { 100 | throw new FatalBeanException("Cannot get BeanInfo for object of class [" + clazz.getName() + "]", ex); 101 | } 102 | } 103 | 104 | protected BeanInfo getBeanInfo() { 105 | return beanInfo; 106 | } 107 | 108 | protected Class getBeanClass() { 109 | return beanInfo.getBeanDescriptor().getBeanClass(); 110 | } 111 | 112 | protected PropertyDescriptor getPropertyDescriptor(String propertyName) throws BeansException { 113 | PropertyDescriptor pd = (PropertyDescriptor) this.propertyDescriptorMap.get(propertyName); 114 | if (pd == null) { 115 | throw new FatalBeanException("No property '" + propertyName + "' in class [" + getBeanClass().getName() + "]", null); 116 | } 117 | return pd; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/FatalBeanException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | /** 20 | * Thrown on an unrecoverable problem encountered in the 21 | * beans packages or sub-packages, e.g. bad class or field. 22 | * 23 | * 빈/하위 패키지에서 나쁜 클래스나 필드같은 복구불가능한 문제에 직면했을 때 던져지는 예외 24 | * 25 | * @author Rod Johnson 26 | * @version $Revision: 1.4 $ 27 | */ 28 | public class FatalBeanException extends BeansException { 29 | 30 | /** 31 | * Constructs a FatalBeanException with the specified message. 32 | * @param msg the detail message 33 | */ 34 | public FatalBeanException(String msg) { 35 | super(msg); 36 | } 37 | 38 | /** 39 | * Constructs a FatalBeanException with the specified message 40 | * and root cause. 41 | * @param msg the detail message 42 | * @param ex root cause 43 | */ 44 | public FatalBeanException(String msg, Throwable ex) { 45 | super(msg, ex); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/MethodInvocationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import java.beans.PropertyChangeEvent; 20 | 21 | /** 22 | * Thrown when a method getter or setter throws an exception, 23 | * analogous to an InvocationTargetException. 24 | * @author Rod Johnson 25 | * @version $Revision: 1.6 $ 26 | */ 27 | public class MethodInvocationException extends PropertyAccessException { 28 | 29 | /** 30 | * Constructor to use when an exception results from a PropertyChangeEvent. 31 | * @param ex Throwable raised by invoked method 32 | * @param propertyChangeEvent PropertyChangeEvent that resulted in an exception 33 | */ 34 | public MethodInvocationException(Throwable ex, PropertyChangeEvent propertyChangeEvent) { 35 | super("Property '" + propertyChangeEvent.getPropertyName() + "' threw exception", propertyChangeEvent, ex); 36 | } 37 | 38 | public String getErrorCode() { 39 | return "methodInvocation"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/MutablePropertyValues.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2002-2004 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.springframework.beans; 19 | 20 | import org.springframework.util.StringUtils; 21 | 22 | import java.util.*; 23 | 24 | /** 25 | * Default implementation of the PropertyValues interface. 26 | * Allows simple manipulation of properties, and provides constructors 27 | * to support deep copy and construction from a Map. 28 | * 29 | * PropertyValues 에 대한 기본 구현체로 properties 에 대한 단순한 생성과 맵으로부터의 구성 딥카피를 지원하기 위한 생성자의 제공을 허용합니다. 30 | * 31 | * @author Rod Johnson 32 | * @since 13 May 2001 33 | * @version $Id: MutablePropertyValues.java,v 1.6 2004/03/18 02:46:12 trisberg Exp $ 34 | */ 35 | public class MutablePropertyValues implements PropertyValues { 36 | 37 | /** List of PropertyValue objects */ 38 | private List propertyValuesList; 39 | 40 | /** 41 | * Creates a new empty MutablePropertyValues object. 42 | * Property values can be added with the addPropertyValue methods. 43 | * @see #addPropertyValue(PropertyValue) 44 | * @see #addPropertyValue(String, Object) 45 | */ 46 | public MutablePropertyValues() { 47 | this.propertyValuesList = new ArrayList(10); 48 | } 49 | 50 | /** 51 | * Deep copy constructor. Guarantees PropertyValue references 52 | * are independent, although it can't deep copy objects currently 53 | * referenced by individual PropertyValue objects 54 | */ 55 | public MutablePropertyValues(PropertyValues other) { 56 | this(); 57 | if (other != null) { 58 | PropertyValue[] pvs = other.getPropertyValues(); 59 | this.propertyValuesList = new ArrayList(pvs.length); 60 | for (int i = 0; i < pvs.length; i++) { 61 | addPropertyValue(new PropertyValue(pvs[i].getName(), pvs[i].getValue())); 62 | } 63 | } 64 | } 65 | 66 | /** 67 | * Construct a new PropertyValues object from a Map. 68 | * @param map Map with property values keyed by property name, 69 | * which must be a String 70 | */ 71 | public MutablePropertyValues(Map map) { 72 | Set keys = map.keySet(); 73 | this.propertyValuesList = new ArrayList(keys.size()); 74 | Iterator itr = keys.iterator(); 75 | while (itr.hasNext()) { 76 | String key = (String) itr.next(); 77 | addPropertyValue(new PropertyValue(key, map.get(key))); 78 | } 79 | } 80 | 81 | /** 82 | * Add a PropertyValue object, replacing any existing one 83 | * for the respective property. 84 | * @param pv PropertyValue object to add 85 | */ 86 | public void addPropertyValue(PropertyValue pv) { 87 | for (int i = 0; i < this.propertyValuesList.size(); i++) { 88 | PropertyValue currentPv = (PropertyValue) this.propertyValuesList.get(i); 89 | if (currentPv.getName().equals(pv.getName())) { 90 | this.propertyValuesList.set(i, pv); 91 | return; 92 | } 93 | } 94 | this.propertyValuesList.add(pv); 95 | } 96 | 97 | /** 98 | * Overloaded version of addPropertyValue that takes 99 | * a property name and a property value. 100 | * @param propertyName name of the property 101 | * @param propertyValue value of the property 102 | * @see #addPropertyValue(PropertyValue) 103 | */ 104 | public void addPropertyValue(String propertyName, Object propertyValue) { 105 | addPropertyValue(new PropertyValue(propertyName, propertyValue)); 106 | } 107 | 108 | /** 109 | * Remove the given PropertyValue, if contained. 110 | * @param pv the PropertyValue to remove 111 | */ 112 | public void removePropertyValue(PropertyValue pv) { 113 | this.propertyValuesList.remove(pv); 114 | } 115 | 116 | /** 117 | * Overloaded version of removePropertyValue that takes 118 | * a property name. 119 | * @param propertyName name of the property 120 | * @see #removePropertyValue(PropertyValue) 121 | */ 122 | public void removePropertyValue(String propertyName) { 123 | removePropertyValue(getPropertyValue(propertyName)); 124 | } 125 | 126 | /** 127 | * Modify a PropertyValue object held in this object. 128 | * Indexed from 0. 129 | */ 130 | public void setPropertyValueAt(PropertyValue pv, int i) { 131 | this.propertyValuesList.set(i, pv); 132 | } 133 | 134 | public PropertyValue[] getPropertyValues() { 135 | return (PropertyValue[]) this.propertyValuesList.toArray(new PropertyValue[0]); 136 | } 137 | 138 | public PropertyValue getPropertyValue(String propertyName) { 139 | for (int i = 0; i < this.propertyValuesList.size(); i++) { 140 | PropertyValue pv = (PropertyValue) this.propertyValuesList.get(i); 141 | if (pv.getName().equals(propertyName)) { 142 | return pv; 143 | } 144 | } 145 | return null; 146 | } 147 | 148 | public boolean contains(String propertyName) { 149 | return getPropertyValue(propertyName) != null; 150 | } 151 | 152 | public PropertyValues changesSince(PropertyValues old) { 153 | MutablePropertyValues changes = new MutablePropertyValues(); 154 | if (old == this) 155 | return changes; 156 | 157 | // For each property value in the new set 158 | for (int i = 0; i < this.propertyValuesList.size(); i++) { 159 | PropertyValue newPv = (PropertyValue) this.propertyValuesList.get(i); 160 | // If there wasn't an old one, add it 161 | PropertyValue pvOld = old.getPropertyValue(newPv.getName()); 162 | if (pvOld == null) { 163 | changes.addPropertyValue(newPv); 164 | } 165 | else if (!pvOld.equals(newPv)) { 166 | // It's changed 167 | changes.addPropertyValue(newPv); 168 | } 169 | } 170 | return changes; 171 | } 172 | 173 | public String toString() { 174 | PropertyValue[] pvs = getPropertyValues(); 175 | StringBuffer sb = new StringBuffer("MutablePropertyValues: length=" + pvs.length + "; "); 176 | sb.append(StringUtils.arrayToDelimitedString(pvs, ",")); 177 | return sb.toString(); 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/NotWritablePropertyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | /** 20 | * Exception thrown on an attempt to set the value of a property 21 | * that isn't writable, because there's no setter method. 22 | * @author Rod Johnson 23 | */ 24 | public class NotWritablePropertyException extends BeansException { 25 | 26 | /** 27 | * Creates new NotWritablePropertyException. 28 | */ 29 | public NotWritablePropertyException(String propertyName, Class beanClass) { 30 | super("Property '" + propertyName + "' is not writable in bean class [" + beanClass.getName() + "]"); 31 | } 32 | 33 | /** 34 | * Creates new NotWritablePropertyException with a root cause. 35 | */ 36 | public NotWritablePropertyException(String propertyName, Class beanClass, Throwable ex) { 37 | super("Property '" + propertyName + "' is not writable in bean class [" + beanClass.getName() + "]", ex); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/NullValueInNestedPathException.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2002-2004 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.springframework.beans; 19 | 20 | /** 21 | * Exception thrown when navigation of a valid nested property 22 | * path encounters a null pointer exception. For example, 23 | * navigating spouse.age fails because the spouse property of the 24 | * target object has a null value. 25 | * @author Rod Johnson 26 | */ 27 | public class NullValueInNestedPathException extends FatalBeanException { 28 | 29 | private String property; 30 | 31 | private Class clazz; 32 | 33 | /** 34 | * Constructor for NullValueInNestedPathException. 35 | * @param clazz 36 | * @param propertyName 37 | */ 38 | public NullValueInNestedPathException(Class clazz, String propertyName) { 39 | super("Value of nested property '" + propertyName + "' is null in " + clazz, null); 40 | this.property = propertyName; 41 | this.clazz = clazz; 42 | } 43 | 44 | /** 45 | * @return the name of the offending property 46 | */ 47 | public String getPropertyName() { 48 | return property; 49 | } 50 | 51 | public Class getBeanClass() { 52 | return clazz; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/PropertyAccessException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import org.springframework.core.ErrorCoded; 20 | 21 | import java.beans.PropertyChangeEvent; 22 | 23 | /** 24 | * Superclass for exceptions related to a property access, 25 | * such as type mismatch or invocation target exception. 26 | * @author Rod Johnson 27 | * @version $Revision: 1.4 $ 28 | */ 29 | public abstract class PropertyAccessException extends BeansException implements ErrorCoded { 30 | 31 | private PropertyChangeEvent propertyChangeEvent; 32 | 33 | public PropertyAccessException(String msg, PropertyChangeEvent propertyChangeEvent) { 34 | super(msg); 35 | this.propertyChangeEvent = propertyChangeEvent; 36 | } 37 | 38 | public PropertyAccessException(String msg, PropertyChangeEvent propertyChangeEvent, Throwable ex) { 39 | super(msg, ex); 40 | this.propertyChangeEvent = propertyChangeEvent; 41 | } 42 | 43 | /** 44 | * Return the PropertyChangeEvent that resulted in the problem. 45 | */ 46 | public PropertyChangeEvent getPropertyChangeEvent() { 47 | return propertyChangeEvent; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/PropertyAccessExceptionsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import java.io.PrintStream; 20 | import java.io.PrintWriter; 21 | 22 | /** 23 | * Combined exception, composed of individual binding propertyAccessExceptions. 24 | * An object of this class is created at the beginning of the binding 25 | * process, and errors added to it as necessary. 26 | * 27 | *

The binding process continues when it encounters application-level 28 | * propertyAccessExceptions, applying those changes that can be applied and storing 29 | * rejected changes in an object of this class. 30 | * 31 | * @author Rod Johnson 32 | * @author Juergen Hoeller 33 | * @since 18 April 2001 34 | * @version $Id: PropertyAccessExceptionsException.java,v 1.5 2004/03/18 02:46:12 trisberg Exp $ 35 | */ 36 | public class PropertyAccessExceptionsException extends BeansException { 37 | 38 | /** BeanWrapper wrapping the target object for binding */ 39 | private final BeanWrapper beanWrapper; 40 | 41 | /** List of PropertyAccessException objects */ 42 | private final PropertyAccessException[] propertyAccessExceptions; 43 | 44 | /** 45 | * Create new empty PropertyAccessExceptionsException. 46 | * We'll add errors to it as we attempt to bind properties. 47 | */ 48 | protected PropertyAccessExceptionsException(BeanWrapper beanWrapper, 49 | PropertyAccessException[] propertyAccessExceptions) { 50 | super(""); 51 | this.beanWrapper = beanWrapper; 52 | this.propertyAccessExceptions = propertyAccessExceptions; 53 | } 54 | 55 | /** 56 | * Return the BeanWrapper that generated this exception. 57 | */ 58 | public BeanWrapper getBeanWrapper() { 59 | return beanWrapper; 60 | } 61 | 62 | /** 63 | * Return the object we're binding to. 64 | */ 65 | public Object getBindObject() { 66 | return this.beanWrapper.getWrappedInstance(); 67 | } 68 | 69 | /** 70 | * If this returns 0, no errors were encountered during binding. 71 | */ 72 | public int getExceptionCount() { 73 | return this.propertyAccessExceptions.length; 74 | } 75 | 76 | /** 77 | * Return an array of the propertyAccessExceptions stored in this object. 78 | * Will return the empty array (not null) if there were no errors. 79 | */ 80 | public PropertyAccessException[] getPropertyAccessExceptions() { 81 | return this.propertyAccessExceptions; 82 | } 83 | 84 | /** 85 | * Return the exception for this field, or null if there isn't one. 86 | */ 87 | public PropertyAccessException getPropertyAccessException(String propertyName) { 88 | for (int i = 0; i < this.propertyAccessExceptions.length; i++) { 89 | PropertyAccessException pae = this.propertyAccessExceptions[i]; 90 | if (propertyName.equals(pae.getPropertyChangeEvent().getPropertyName())) { 91 | return pae; 92 | } 93 | } 94 | return null; 95 | } 96 | 97 | public String getMessage() { 98 | StringBuffer sb = new StringBuffer(); 99 | sb.append(this.toString()); 100 | sb.append("; nested propertyAccessExceptions are: "); 101 | for (int i = 0; i < this.propertyAccessExceptions.length; i++) { 102 | PropertyAccessException pae = this.propertyAccessExceptions[i]; 103 | sb.append("["); 104 | sb.append(pae.getClass().getName()); 105 | sb.append(": "); 106 | sb.append(pae.getMessage()); 107 | sb.append(']'); 108 | if (i < this.propertyAccessExceptions.length - 1) { 109 | sb.append(", "); 110 | } 111 | } 112 | return sb.toString(); 113 | } 114 | 115 | public void printStackTrace(PrintStream ps) { 116 | ps.println(this); 117 | for (int i = 0; i < this.propertyAccessExceptions.length; i++) { 118 | PropertyAccessException pae = this.propertyAccessExceptions[i]; 119 | pae.printStackTrace(ps); 120 | } 121 | } 122 | 123 | public void printStackTrace(PrintWriter pw) { 124 | pw.println(this); 125 | for (int i = 0; i < this.propertyAccessExceptions.length; i++) { 126 | PropertyAccessException pae = this.propertyAccessExceptions[i]; 127 | pae.printStackTrace(pw); 128 | } 129 | } 130 | 131 | public String toString() { 132 | return "PropertyAccessExceptionsException (" + getExceptionCount() + " errors)"; 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/PropertyValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | /** 20 | * Class to hold information and value for an individual property. 21 | * Using an object here, rather than just storing all properties in a 22 | * map keyed by property name, allows for more flexibility, and the 23 | * ability to handle indexed properties etc in a special way if necessary. 24 | * 25 | * 각각의 속성들에 대한 정보와 값을 가지기 위한 클래스 26 | * 단지 프로퍼티 이름에 의한 맵을 가지고서 모든 속성들을 저장하는 것보다, 여기서 오브젝트를 사용함으로써, 27 | * 만약 필요하다면 인덱싱된 속성들을 다룰 수 있는 능력과, 좀 더 많은 유연함을 가질 수 있을 것이다 28 | * 29 | *

Note that the value doesn't need to be the final required type: 30 | * A BeanWrapper implementation should handle any necessary conversion, as 31 | * this object doesn't know anything about the objects it will be applied to. 32 | * 33 | * @author Rod Johnson 34 | * @since 13 May 2001 35 | * @version $Id: PropertyValue.java,v 1.3 2004/03/18 02:46:12 trisberg Exp $ 36 | */ 37 | public class PropertyValue { 38 | 39 | /** Property name */ 40 | private String name; 41 | 42 | /** Value of the property */ 43 | private Object value; 44 | 45 | /** 46 | * Creates new PropertyValue. 47 | * @param name name of the property 48 | * @param value value of the property (possibly before type conversion) 49 | */ 50 | public PropertyValue(String name, Object value) { 51 | if (name == null) { 52 | throw new IllegalArgumentException("Property name cannot be null"); 53 | } 54 | this.name = name; 55 | this.value = value; 56 | } 57 | 58 | /** 59 | * Return the name of the property. 60 | * @return the name of the property 61 | */ 62 | public String getName() { 63 | return name; 64 | } 65 | 66 | /** 67 | * Return the value of the property. 68 | *

Note that type conversion will not have occurred here. 69 | * It is the responsibility of the BeanWrapper implementation to 70 | * perform type conversion. 71 | * @return the value of the property 72 | */ 73 | public Object getValue() { 74 | return value; 75 | } 76 | 77 | public String toString() { 78 | return "PropertyValue: name='" + name + "'; value=[" + value + "]"; 79 | } 80 | 81 | public boolean equals(Object other) { 82 | if (this == other) { 83 | return true; 84 | } 85 | if (!(other instanceof PropertyValue)) { 86 | return false; 87 | } 88 | PropertyValue otherPv = (PropertyValue) other; 89 | return (this.name.equals(otherPv.name) && 90 | ((this.value == null && otherPv.value == null) || this.value.equals(otherPv.value))); 91 | } 92 | 93 | public int hashCode() { 94 | return this.name.hashCode() * 29 + (this.value != null ? this.value.hashCode() : 0); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/PropertyValues.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | /** 20 | * Object containing 0 or more PropertyValues comprising one update. 21 | * 0 혹은 많은 PropertyValue 들을 간직하는 객체 22 | * @author Rod Johnson 23 | * @since 13 May 2001 24 | * @version $Id: PropertyValues.java,v 1.3 2004/03/18 02:46:12 trisberg Exp $ 25 | */ 26 | public interface PropertyValues { 27 | 28 | /** 29 | * Return an array of the PropertyValue objects held in this object. 30 | * @return an array of the PropertyValue objects held in this object. 31 | */ 32 | PropertyValue[] getPropertyValues(); 33 | 34 | /** 35 | * Return the property value with the given name. 36 | * @param propertyName name to search for 37 | * @return pv or null 38 | */ 39 | PropertyValue getPropertyValue(String propertyName); 40 | 41 | /** 42 | * Is there a property value for this property? 43 | * @param propertyName name of the property we're interested in 44 | * @return whether there is a property value for this property 45 | */ 46 | boolean contains(String propertyName); 47 | 48 | /** 49 | * Return the changes since the previous PropertyValues. 50 | * Subclasses should also override equals. 51 | * @param old old property values 52 | * @return PropertyValues updated or new properties. 53 | * Return the empty PropertyValues if there are no changes. 54 | */ 55 | PropertyValues changesSince(PropertyValues old); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/PropertyValuesEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import org.springframework.beans.MutablePropertyValues; 20 | import org.springframework.beans.propertyeditors.PropertiesEditor; 21 | 22 | import java.beans.PropertyEditorSupport; 23 | import java.util.Properties; 24 | 25 | /** 26 | * Editor for PropertyValues objects. Not 27 | * a GUI editor. 28 | * 29 | * PropertyValues 를 위한 에디터로 GUI 에디터가 아니다 30 | * 31 | * 이 에디터는 사용가능하기전에 JavaBeans API 과 등록이 되어져야한다. 32 | * 이 패키지의 에디터들은 BeanWrapperImpl 에 의해 등록되어진다 33 | * 34 | *
NB: this editor must be registered with the JavaBeans API before it 35 | * will be available. Editors in this package are 36 | * registered by BeanWrapperImpl. 37 | *
The required format is defined in java.util.Properties documentation. 38 | * Each property must be on a new line. 39 | *
40 | * The present implementation relies on a PropertiesEditor. 41 | * @author Rod Johnson 42 | */ 43 | public class PropertyValuesEditor extends PropertyEditorSupport { 44 | 45 | 46 | /** 47 | * @see java.beans.PropertyEditor#setAsText(java.lang.String) 48 | */ 49 | public void setAsText(String s) throws IllegalArgumentException { 50 | PropertiesEditor pe = new PropertiesEditor(); 51 | pe.setAsText(s); 52 | Properties props = (Properties) pe.getValue(); 53 | setValue(new MutablePropertyValues(props)); 54 | } 55 | 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/README.md: -------------------------------------------------------------------------------- 1 | # beans 패키지 2 | 3 | 이 패키지는 자바빈을 생성하기 위한 인터페이스와 클래스들을 포함한다 4 | 다른 스프링 패키지들에서 가장 많이 사용하는 패키지일 것이다 5 | 6 | --- 7 | 8 | 하위패키지 9 | factory 10 | propertyeditors 11 | support 12 | 13 | --- 14 | 15 | - BeansException : 빈, 서브패키지에서의 던져지는 모든 예외들에 대한 추상클래스 16 | - BeanWrapper : 스프링 로우레벨 자바빈즈 인프라스트럭쳐의 핵심 인터페이스 17 | - BeanWrapperImpl : BeanWrapper 인터페이스의 의 기본구현체(중요) 18 | - FatalBeanException : 빈/하위 패키지에서 나쁜 클래스나 필드같은 복구불가능한 문제에 직면했을 때 던져지는 예외 19 | - MutablePropertyValues : PropertyValues 에 대한 기본 구현체로 properties 에 대한 단순한 생성과 맵으로부터의 구성 딥카피를 지원하기 위한 생성자의 제공을 허용합니다. 20 | - PropertyValue : 각각의 속성들에 대한 정보와 값을 가지기 위한 클래스 21 | 22 | - (I)PropertyValues : 0 혹은 많은 PropertyValue 들을 간직하는 객체 23 | - ProperyValuesEditor : PropertyValues 를 위한 에디터로 GUI 에디터가 아니다 -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/TypeMismatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans; 18 | 19 | import java.beans.PropertyChangeEvent; 20 | 21 | /** 22 | * Exception thrown on a type mismatch when trying to set a property. 23 | * @author Rod Johnson 24 | * @author Juergen Hoeller 25 | * @version $Revision: 1.5 $ 26 | */ 27 | public class TypeMismatchException extends PropertyAccessException { 28 | 29 | public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType) { 30 | super("Cannot convert property value of type [" + 31 | (propertyChangeEvent.getNewValue() != null ? 32 | propertyChangeEvent.getNewValue().getClass().getName() : null) + 33 | "] to required type [" + requiredType.getName() + "]" + 34 | (propertyChangeEvent.getPropertyName() != null ? 35 | " for property '" + propertyChangeEvent.getPropertyName() + "'" : ""), 36 | propertyChangeEvent); 37 | } 38 | 39 | public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable ex) { 40 | super("Failed to convert property value of type [" + 41 | (propertyChangeEvent.getNewValue() != null ? 42 | propertyChangeEvent.getNewValue().getClass().getName() : null) + 43 | "] to required type [" + requiredType.getName() + "]" + 44 | (propertyChangeEvent.getPropertyName() != null ? 45 | " for property '" + propertyChangeEvent.getPropertyName() + "'" : ""), 46 | propertyChangeEvent, ex); 47 | } 48 | 49 | public String getErrorCode() { 50 | return "typeMismatch"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This package contains interfaces and classes for manipulating Java beans. 5 | It is used by most other Spring packages. 6 | 7 |

A BeanWrapper object may be used to set and get bean properties, 8 | singly or in bulk. 9 | 10 |

The classes in this package are discussed in Chapter 11 of 11 | Expert One-On-One J2EE Design and Development 12 | by Rod Johnson (Wrox, 2002). 13 | 14 | 이 패키지는 자바빈을 생성하기 위한 인터페이스와 클래스들을 포함한다 15 | 다른 스프링 패키지들에서 가장 많이 사용하는 패키지일 것이다 16 | 17 | 하위패키지 18 | factory 19 | propertyeditors 20 | support 21 | 22 | ============================================================= 23 | 24 | BeansException : 빈, 서브패키지에서의 던져지는 모든 예외들에 대한 추상클래스 25 | BeanWrapper : 스프링 로우레벨 자바빈즈 인프라스트럭쳐의 핵심 인터페이스 26 | BeanWrapperImpl : BeanWrapper 인터페이스의 의 기본구현체(중요) 27 | FatalBeanException : 빈/하위 패키지에서 나쁜 클래스나 필드같은 복구불가능한 문제에 직면했을 때 던져지는 예외 28 | MutablePropertyValues : PropertyValues 에 대한 기본 구현체로 properties 에 대한 단순한 생성과 맵으로부터의 구성 딥카피를 지원하기 위한 생성자의 제공을 허용합니다. 29 | PropertyValue : 각각의 속성들에 대한 정보와 값을 가지기 위한 클래스 30 | (I) PropertyValues : 0 혹은 많은 PropertyValue 들을 간직하는 객체 31 | ProperyValuesEditor : PropertyValues 를 위한 에디터로 GUI 에디터가 아니다 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/ClassEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | 21 | /** 22 | * Editor for java.lang.Class, to directly feed a Class property 23 | * instead of using a String class name property. 24 | * @author Juergen Hoeller 25 | * @since 13.05.2003 26 | * @see Class 27 | */ 28 | public class ClassEditor extends PropertyEditorSupport { 29 | 30 | public void setAsText(String text) throws IllegalArgumentException { 31 | Class clazz = null; 32 | try { 33 | clazz = Class.forName(text, true, Thread.currentThread().getContextClassLoader()); 34 | } 35 | catch (ClassNotFoundException ex) { 36 | throw new IllegalArgumentException("Invalid class name [" + text + "]: " + ex.getMessage()); 37 | } 38 | setValue(clazz); 39 | } 40 | 41 | public String getAsText() { 42 | return ((Class) getValue()).getName(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/CustomBooleanEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | 21 | /** 22 | * Property editor for Boolean properties. 23 | * 24 | *

This is not meant to be used as system PropertyEditor but rather as 25 | * locale-specific Boolean editor within custom controller code, to parse 26 | * UI-caused boolean strings into Boolean properties of beans, and 27 | * evaluate them in the UI form. 28 | * 29 | *

In web MVC code, this editor will typically be registered with 30 | * binder.registerCustomEditor calls in an implementation of 31 | * BaseCommandController's initBinder method. 32 | * 33 | * @author Juergen Hoeller 34 | * @since 10.06.2003 35 | * @see org.springframework.validation.DataBinder#registerCustomEditor 36 | * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder 37 | * @see org.springframework.web.bind.BindInitializer#initBinder 38 | */ 39 | public class CustomBooleanEditor extends PropertyEditorSupport { 40 | 41 | private boolean allowEmpty; 42 | 43 | /** 44 | * Create a new instance. 45 | *

The allowEmpty parameter states if an empty String should 46 | * be allowed for parsing, i.e. get interpreted as null value. 47 | * Else, an IllegalArgumentException gets thrown in that case. 48 | * @param allowEmpty if empty strings should be allowed 49 | */ 50 | public CustomBooleanEditor(boolean allowEmpty) { 51 | this.allowEmpty = allowEmpty; 52 | } 53 | 54 | public void setAsText(String text) throws IllegalArgumentException { 55 | if (this.allowEmpty && text.trim().equals("")) { 56 | setValue(null); 57 | } 58 | else if (text.equalsIgnoreCase("true")) { 59 | setValue(Boolean.TRUE); 60 | } 61 | else if (text.equalsIgnoreCase("false")) { 62 | setValue(Boolean.FALSE); 63 | } 64 | else 65 | throw new IllegalArgumentException("Invalid Boolean value [" + text + "]"); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/CustomDateEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | import java.text.DateFormat; 21 | import java.text.ParseException; 22 | import java.util.Date; 23 | 24 | /** 25 | * PropertyEditor for Date, supporting a custom DateFormat. 26 | * 27 | *

This is not meant to be used as system PropertyEditor but rather as 28 | * locale-specific date editor within custom controller code, to parse 29 | * user-entered date strings into Date properties of beans, and render 30 | * them in the UI form. 31 | * 32 | *

In web MVC code, this editor will typically be registered with 33 | * binder.registerCustomEditor calls in an implementation of 34 | * BaseCommandController's initBinder method. 35 | * 36 | * @author Juergen Hoeller 37 | * @since 28.04.2003 38 | * @see org.springframework.validation.DataBinder#registerCustomEditor 39 | * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder 40 | * @see org.springframework.web.bind.BindInitializer#initBinder 41 | */ 42 | public class CustomDateEditor extends PropertyEditorSupport { 43 | 44 | private final DateFormat dateFormat; 45 | 46 | private final boolean allowEmpty; 47 | 48 | /** 49 | * Create a new instance, using the given DateFormat for 50 | * parsing and rendering. 51 | *

The allowEmpty parameter states if an empty String should 52 | * be allowed for parsing, i.e. get interpreted as null value. 53 | * Else, an IllegalArgumentException gets thrown in that case. 54 | * @param dateFormat DateFormat to use for parsing and rendering 55 | * @param allowEmpty if empty strings should be allowed 56 | */ 57 | public CustomDateEditor(DateFormat dateFormat, boolean allowEmpty) { 58 | this.dateFormat = dateFormat; 59 | this.allowEmpty = allowEmpty; 60 | } 61 | 62 | /** 63 | * Parse the Date from the given text, using the specified DateFormat. 64 | */ 65 | public void setAsText(String text) throws IllegalArgumentException { 66 | if (this.allowEmpty && text.trim().equals("")) { 67 | // treat empty String as null value 68 | setValue(null); 69 | } 70 | else { 71 | try { 72 | setValue(this.dateFormat.parse(text)); 73 | } 74 | catch (ParseException ex) { 75 | throw new IllegalArgumentException("Could not parse date: " + ex.getMessage()); 76 | } 77 | } 78 | } 79 | 80 | /** 81 | * Format the Date as String, using the specified DateFormat. 82 | */ 83 | public String getAsText() { 84 | return this.dateFormat.format((Date) getValue()); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/CustomNumberEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | import java.math.BigDecimal; 21 | import java.math.BigInteger; 22 | import java.text.NumberFormat; 23 | import java.text.ParseException; 24 | 25 | /** 26 | * Property editor for any Number subclass like Integer, Long, Float, Double. 27 | * Uses a given NumberFormat for (locale-specific) parsing and rendering. 28 | * 29 | *

This is not meant to be used as system PropertyEditor but rather as 30 | * locale-specific number editor within custom controller code, to parse 31 | * user-entered number strings into Number properties of beans, and render 32 | * them in the UI form. 33 | * 34 | *

In web MVC code, this editor will typically be registered with 35 | * binder.registerCustomEditor calls in an implementation of 36 | * BaseCommandController's initBinder method. 37 | * 38 | * @author Juergen Hoeller 39 | * @since 06.06.2003 40 | * @see org.springframework.validation.DataBinder#registerCustomEditor 41 | * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder 42 | * @see org.springframework.web.bind.BindInitializer#initBinder 43 | */ 44 | public class CustomNumberEditor extends PropertyEditorSupport { 45 | 46 | private Class numberClass; 47 | 48 | private NumberFormat numberFormat; 49 | 50 | private final boolean allowEmpty; 51 | 52 | /** 53 | * Create a new instance, using the given NumberFormat for 54 | * parsing and rendering. 55 | *

The allowEmpty parameter states if an empty String should 56 | * be allowed for parsing, i.e. get interpreted as null value. 57 | * Else, an IllegalArgumentException gets thrown in that case. 58 | * @param numberClass Number subclass to generate 59 | * @param numberFormat NumberFormat to use for parsing and rendering 60 | * @param allowEmpty if empty strings should be allowed 61 | * @throws IllegalArgumentException if an invalid numberClass has been specified 62 | */ 63 | public CustomNumberEditor(Class numberClass, NumberFormat numberFormat, boolean allowEmpty) 64 | throws IllegalArgumentException { 65 | if (!Number.class.isAssignableFrom(numberClass)) { 66 | throw new IllegalArgumentException("Property class must be a subclass of Number"); 67 | } 68 | this.numberClass = numberClass; 69 | this.numberFormat = numberFormat; 70 | this.allowEmpty = allowEmpty; 71 | } 72 | 73 | public void setAsText(String text) throws IllegalArgumentException { 74 | if (this.allowEmpty && text.trim().equals("")) { 75 | setValue(null); 76 | } 77 | else { 78 | try { 79 | Number number = this.numberFormat.parse(text); 80 | if (this.numberClass.isInstance(number)) { 81 | setValue(number); 82 | } 83 | else if (this.numberClass.equals(Short.class)) { 84 | setValue(new Short(number.shortValue())); 85 | } 86 | else if (this.numberClass.equals(Integer.class)) { 87 | setValue(new Integer(number.intValue())); 88 | } 89 | else if (this.numberClass.equals(Long.class)) { 90 | setValue(new Long(number.longValue())); 91 | } 92 | else if (this.numberClass.equals(BigInteger.class)) { 93 | setValue(BigInteger.valueOf(number.longValue())); 94 | } 95 | else if (this.numberClass.equals(Float.class)) { 96 | setValue(new Float(number.floatValue())); 97 | } 98 | else if (this.numberClass.equals(Double.class)) { 99 | setValue(new Double(number.doubleValue())); 100 | } 101 | else if (this.numberClass.equals(BigDecimal.class)) { 102 | setValue(new BigDecimal(Double.toString(number.doubleValue()))); 103 | } 104 | else { 105 | throw new IllegalArgumentException("Cannot convert [" + text + "] to [" + this.numberClass + "]"); 106 | } 107 | } 108 | catch (ParseException ex) { 109 | throw new IllegalArgumentException("Cannot parse number: " + ex.getMessage()); 110 | } 111 | } 112 | } 113 | 114 | public String getAsText() { 115 | return this.numberFormat.format(getValue()); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/FileEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | import java.io.File; 21 | 22 | /** 23 | * Editor for java.io.File, to directly feed a File property 24 | * instead of using a String file name property. 25 | * @author Juergen Hoeller 26 | * @since 09.12.2003 27 | * @see File 28 | */ 29 | public class FileEditor extends PropertyEditorSupport { 30 | 31 | public void setAsText(String text) throws IllegalArgumentException { 32 | setValue(new File(text)); 33 | } 34 | 35 | public String getAsText() { 36 | return ((File) getValue()).getAbsolutePath(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/LocaleEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import org.springframework.util.StringUtils; 20 | 21 | import java.beans.PropertyEditorSupport; 22 | import java.util.Locale; 23 | 24 | /** 25 | * Editor for java.util.Locale, to directly feed a Locale property. 26 | * Expects the same syntax as Locale.toString, i.e. language + optionally 27 | * country + optionally variant, separated by "_" (e.g. "en", "en_US"). 28 | * @author Juergen Hoeller 29 | * @since 26.05.2003 30 | */ 31 | public class LocaleEditor extends PropertyEditorSupport { 32 | 33 | public void setAsText(String text) { 34 | String[] parts = StringUtils.delimitedListToStringArray(text, "_"); 35 | String language = parts.length > 0 ? parts[0] : ""; 36 | String country = parts.length > 1 ? parts[1] : ""; 37 | String variant = parts.length > 2 ? parts[2] : ""; 38 | setValue(language.length() > 0 ? new Locale(language, country, variant) : null); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/PropertiesEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | import java.io.ByteArrayInputStream; 21 | import java.io.IOException; 22 | import java.util.ArrayList; 23 | import java.util.Iterator; 24 | import java.util.List; 25 | import java.util.Properties; 26 | 27 | /** 28 | * Editor for java.util.Properties objects. Handles conversion from String 29 | * to Properties object. 30 | * 31 | * java.util.Properties 객체들을 위한 에디터로, 문자열에서 Properties 객체로의 전환을 다룹니다. 32 | * 33 | *

This editor must be registered before it will be available. Standard 34 | * editors in this package are automatically registered by BeanWrapperImpl. 35 | * 36 | *

The required format is defined in java.util.Properties documentation. 37 | * Each property must be on a new line. 38 | * 39 | * @author Rod Johnson 40 | * @version $Id: PropertiesEditor.java,v 1.5 2004/03/18 02:46:13 trisberg Exp $ 41 | * @see org.springframework.beans.BeanWrapperImpl 42 | * @see java.util.Properties#load 43 | */ 44 | public class PropertiesEditor extends PropertyEditorSupport { 45 | 46 | /** 47 | * Any of these characters, if they're first after whitespace or first 48 | * on a line, mean that the line is a comment and should be ignored. 49 | */ 50 | public final static String COMMENT_MARKERS = "#!"; 51 | 52 | public void setAsText(String text) throws IllegalArgumentException { 53 | if (text == null) { 54 | throw new IllegalArgumentException("Cannot set Properties to null"); 55 | } 56 | Properties props = new Properties(); 57 | try { 58 | props.load(new ByteArrayInputStream(text.getBytes())); 59 | dropComments(props); 60 | } 61 | catch (IOException ex) { 62 | // shouldn't happen 63 | throw new IllegalArgumentException("Failed to parse [" + text + "] into Properties"); 64 | } 65 | setValue(props); 66 | } 67 | 68 | /** 69 | * Remove comment lines. We shouldn't need to do this, according to 70 | * java.util.Properties documentation, but if we don't we end up with 71 | * properties like "#this=is a comment" if we have whitespace before 72 | * the comment marker. 73 | */ 74 | private void dropComments(Properties props) { 75 | Iterator keys = props.keySet().iterator(); 76 | List commentKeys = new ArrayList(); 77 | while (keys.hasNext()) { 78 | String key = (String) keys.next(); 79 | // A comment line starts with one of our comment markers 80 | if (key.length() > 0 && COMMENT_MARKERS.indexOf(key.charAt(0)) != -1) { 81 | // We can't actually remove it as we'll get a 82 | // concurrent modification exception with the iterator 83 | commentKeys.add(key); 84 | } 85 | } 86 | for (Iterator it = commentKeys.iterator(); it.hasNext();) { 87 | String key = (String) it.next(); 88 | props.remove(key); 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/README.md: -------------------------------------------------------------------------------- 1 | # beans/propertyeditors 패키지 2 | 3 | Properties editors 는 문자열 값을 java.util.Properties 같은 객체 타입으로 변환하기 위해 사용됩니다 4 | 몇몇개의 에디터들은 BeanWrapperImpl에 의해 자동으로 등록되어집니다 5 | CustomXxxEditor 클래스들은 특정 바인딩 프로세스들을 위하여 수동 등록으로 의도되어졌습니다. 6 | 7 | --- 8 | 9 | - PropertiesEditor : java.util.Properties 객체들을 위한 에디터로, 문자열에서 Properties 객체로의 전환을 다룹니다. -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import org.springframework.util.StringUtils; 20 | 21 | import java.beans.PropertyEditorSupport; 22 | 23 | /** 24 | * Properties editor for String[] type. Strings must be in CSV format. 25 | * This property editor is automatically registered by BeanWrapperImpl. 26 | * @author Rod Johnson 27 | * @see org.springframework.beans.BeanWrapperImpl 28 | */ 29 | public class StringArrayPropertyEditor extends PropertyEditorSupport { 30 | 31 | public void setAsText(String s) throws IllegalArgumentException { 32 | String[] sa = StringUtils.commaDelimitedListToStringArray(s); 33 | setValue(sa); 34 | } 35 | 36 | public String getAsText() { 37 | String[] array = (String[]) this.getValue(); 38 | return StringUtils.arrayToCommaDelimitedString(array); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/StringTrimmerEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | 21 | /** 22 | * Property editor that trims Strings. 23 | * Allows to transform an empty string into a null value. 24 | * Needs to be explictly registered, e.g. for command binding. 25 | * @author Juergen Hoeller 26 | * @see org.springframework.validation.DataBinder#registerCustomEditor 27 | * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder 28 | * @see org.springframework.web.bind.BindInitializer#initBinder 29 | */ 30 | public class StringTrimmerEditor extends PropertyEditorSupport { 31 | 32 | private boolean emptyAsNull; 33 | 34 | /** 35 | * Create a new instance. 36 | * @param emptyAsNull whether to transform an empty string to null 37 | */ 38 | public StringTrimmerEditor(boolean emptyAsNull) { 39 | this.emptyAsNull = emptyAsNull; 40 | } 41 | 42 | public void setAsText(String text) throws IllegalArgumentException { 43 | if (text == null) { 44 | setValue(null); 45 | } 46 | else { 47 | String value = text.trim(); 48 | if (this.emptyAsNull && "".equals(value)) { 49 | setValue(null); 50 | } 51 | else { 52 | setValue(value); 53 | } 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/URLEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.beans.propertyeditors; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | import java.net.MalformedURLException; 21 | import java.net.URL; 22 | 23 | /** 24 | * Editor for java.net.URL, to directly feed a URL property 25 | * instead of using a String property. 26 | * @author Juergen Hoeller 27 | * @since 15.12.2003 28 | */ 29 | public class URLEditor extends PropertyEditorSupport { 30 | 31 | public void setAsText(String text) throws IllegalArgumentException { 32 | try { 33 | setValue(new URL(text)); 34 | } 35 | catch (MalformedURLException ex) { 36 | throw new IllegalArgumentException("Malformed URL: " + ex.getMessage()); 37 | } 38 | } 39 | 40 | public String getAsText() { 41 | return ((URL) getValue()).toExternalForm(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/beans/propertyeditors/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Properties editors used to convert from String values to object 5 | types such as java.util.Properties. 6 | 7 |

Some of these editors are registered automatically by BeanWrapperImpl. 8 | "CustomXxxEditor" classes are intended for manual registration in 9 | specific binding processes, as they are localized or the like. 10 | 11 | Properties editors 는 문자열 값을 java.util.Properties 같은 객체 타입으로 변환하기 위해 사용됩니다 12 | 몇몇개의 에디터들은 BeanWrapperImpl에 의해 자동으로 등록되어집니다 13 | CustomXxxEditor 클래스들은 특정 바인딩 프로세스들을 위하여 수동 등록으로 의도되어졌습니다. 14 | 15 | ================================================================ 16 | 17 | PropertiesEditor : java.util.Properties 객체들을 위한 에디터로, 문자열에서 Properties 객체로의 전환을 다룹니다. 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/ConstantException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | /** 20 | * Exception thrown when the Constants class is asked for an invalid 21 | * constant name. 22 | * @see org.springframework.core.Constants 23 | * @version $Id: ConstantException.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 24 | * @author Rod Johnson 25 | * @since 28-Apr-2003 26 | * 27 | * Constants 클래스가 유효하지 않은 상수 이름을 물어볼때 발생할 수 있는 예외 28 | */ 29 | public class ConstantException extends IllegalArgumentException { 30 | 31 | /** 32 | * Thrown when an invalid constant name is requested. 33 | * @param clazz class containing the constant definitions 34 | * @param field invalid constant name 35 | * @param message description of the problem 36 | */ 37 | public ConstantException(Class clazz, String field, String message) { 38 | super("Field '" + field + "' " + message + " in " + clazz); 39 | } 40 | 41 | /** 42 | * Thrown when an invalid constant value is looked up. 43 | * @param clazz class containing the constant definitions 44 | * @param namePrefix prefix of the searched constant names 45 | * @param value the looked up constant value 46 | */ 47 | public ConstantException(Class clazz, String namePrefix, Object value) { 48 | super("No '" + namePrefix + "' field with value '" + value + "' found in " + clazz); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.lang.reflect.Field; 20 | import java.lang.reflect.Modifier; 21 | import java.util.HashMap; 22 | import java.util.HashSet; 23 | import java.util.Iterator; 24 | import java.util.Map; 25 | import java.util.Set; 26 | 27 | /** 28 | * This class can be used to parse other classes containing constant definitions 29 | * in public static final members. The asXXXX() methods of this class allow these 30 | * constant values to be accessed via their string names. 31 | * 32 | *

Consider class Foo containing public final static int CONSTANT1 = 66; 33 | * An instance of this class wrapping Foo.class will return the 34 | * constant value of 66 from its asInt() method given the argument "CONSTANT1". 35 | * 36 | *

This class is ideal for use in PropertyEditors, enabling them to recognize 37 | * the same names as the constants themselves, and freeing them from 38 | * maintaining their own mapping. 39 | * 40 | * @version $Id: Constants.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 41 | * @author Rod Johnson 42 | * @author Juergen Hoeller 43 | * @since 16-Mar-2003 44 | * 45 | * 이 클래스는 다른 클래스들을 파싱하는데 사용될 수 있다. 46 | * 여기서 다른 클래스는 상수 정의를 public static final 필드로 정의한 것을 말한다. 47 | * asXXX 메서드는 이렇한 상수들을 문자열이름을 통해 접근할 수 있게 해준다. 48 | * 49 | */ 50 | public class Constants { 51 | 52 | /** Map from String field name to object value */ 53 | private final Map map = new HashMap(); 54 | 55 | /** Class analyzed */ 56 | private final Class clazz; 57 | 58 | /** 59 | * Create a new Constants converter class wrapping the given class. 60 | * All public static final variables will be exposed, whatever their type. 61 | * @param clazz class to analyze. 62 | */ 63 | public Constants(Class clazz) { 64 | this.clazz = clazz; 65 | Field[] fields = clazz.getFields(); 66 | for (int i = 0; i < fields.length; i++) { 67 | Field f = fields[i]; 68 | if (Modifier.isFinal(f.getModifiers()) && Modifier.isStatic(f.getModifiers()) && 69 | Modifier.isPublic(f.getModifiers())) { 70 | String name = f.getName(); 71 | try { 72 | Object value = f.get(null); 73 | this.map.put(name, value); 74 | } 75 | catch (IllegalAccessException ex) { 76 | // just leave this field and continue 77 | } 78 | } 79 | } 80 | } 81 | 82 | /** 83 | * Return the number of constants exposed. 84 | * @return int the number of constants exposed 85 | */ 86 | public int getSize() { 87 | return this.map.size(); 88 | } 89 | 90 | /** 91 | * Return a constant value cast to a Number. 92 | * @param code name of the field 93 | * @return long value if successful 94 | * @see #asObject 95 | * @throws ConstantException if the field name wasn't found or 96 | * if the type wasn't compatible with Number 97 | */ 98 | public Number asNumber(String code) throws ConstantException { 99 | Object o = asObject(code); 100 | if (!(o instanceof Number)) 101 | throw new ConstantException(this.clazz, code, "not a Number"); 102 | return (Number) o; 103 | } 104 | 105 | /** 106 | * Return a constant value as a String. 107 | * @param code name of the field 108 | * @return String string value if successful. 109 | * Works even if it's not a string (invokes toString()). 110 | * @see #asObject 111 | * @throws ConstantException if the field name wasn't found 112 | */ 113 | public String asString(String code) throws ConstantException { 114 | return asObject(code).toString(); 115 | } 116 | 117 | /** 118 | * Parse the given string (upper or lower case accepted) and return 119 | * the appropriate value if it's the name of a constant field in the 120 | * class we're analysing. 121 | * @throws ConstantException if there's no such field 122 | */ 123 | public Object asObject(String code) throws ConstantException { 124 | code = code.toUpperCase(); 125 | Object val = this.map.get(code); 126 | if (val == null) { 127 | throw new ConstantException(this.clazz, code, "not found"); 128 | } 129 | return val; 130 | } 131 | 132 | /** 133 | * Return all values of the given group of constants. 134 | * @param namePrefix prefix of the constant names to search 135 | * @return the set of values 136 | */ 137 | public Set getValues(String namePrefix) { 138 | namePrefix = namePrefix.toUpperCase(); 139 | Set values = new HashSet(); 140 | for (Iterator it = this.map.keySet().iterator(); it.hasNext();) { 141 | String code = (String) it.next(); 142 | if (code.startsWith(namePrefix)) { 143 | values.add(this.map.get(code)); 144 | } 145 | } 146 | return values; 147 | } 148 | 149 | /** 150 | * Return all values of the group of constants for the 151 | * given bean property name. 152 | * @param propertyName the name of the bean property 153 | * @return the set of values 154 | * @see #propertyToConstantNamePrefix 155 | */ 156 | public Set getValuesForProperty(String propertyName) { 157 | return getValues(propertyToConstantNamePrefix(propertyName)); 158 | } 159 | 160 | /** 161 | * Look up the given value within the given group of constants. 162 | * Will return the first match. 163 | * @param value constant value to look up 164 | * @param namePrefix prefix of the constant names to search 165 | * @return the name of the constant field 166 | * @throws ConstantException if the value wasn't found 167 | */ 168 | public String toCode(Object value, String namePrefix) throws ConstantException { 169 | namePrefix = namePrefix.toUpperCase(); 170 | for (Iterator it = this.map.entrySet().iterator(); it.hasNext();) { 171 | Map.Entry entry = (Map.Entry) it.next(); 172 | String key = (String) entry.getKey(); 173 | if (key.startsWith(namePrefix) && entry.getValue().equals(value)) { 174 | return key; 175 | } 176 | } 177 | throw new ConstantException(this.clazz, namePrefix, value); 178 | } 179 | 180 | /** 181 | * Look up the given value within the group of constants for 182 | * the given bean property name. Will return the first match. 183 | * @param value constant value to look up 184 | * @param propertyName the name of the bean property 185 | * @return the name of the constant field 186 | * @throws ConstantException if the value wasn't found 187 | * @see #propertyToConstantNamePrefix 188 | */ 189 | public String toCodeForProperty(Object value, String propertyName) throws ConstantException { 190 | return toCode(value, propertyToConstantNamePrefix(propertyName)); 191 | } 192 | 193 | /** 194 | * Convert the given bean property name to a constant name prefix. 195 | * Uses a common naming idiom: turning all lower case characters to 196 | * upper case, and prepending upper case characters with an underscore. 197 | *

Example: "imageSize" -> "IMAGE_SIZE". 198 | * @param propertyName the name of the bean property 199 | * @return the corresponding constant name prefix 200 | * @see #getValuesForProperty 201 | * @see #toCodeForProperty 202 | * 203 | * 주어진 빈 프로퍼티 이름을 상수이름으로 변환 204 | * 205 | */ 206 | public String propertyToConstantNamePrefix(String propertyName) { 207 | StringBuffer parsedPrefix = new StringBuffer(); 208 | for(int i = 0; i < propertyName.length(); i++) { 209 | char c = propertyName.charAt(i); 210 | if (Character.isUpperCase(c)) { 211 | parsedPrefix.append("_"); 212 | parsedPrefix.append(c); 213 | } 214 | else { 215 | parsedPrefix.append(Character.toUpperCase(c)); 216 | } 217 | } 218 | return parsedPrefix.toString(); 219 | } 220 | 221 | } 222 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/ControlFlow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | /** 20 | * Interface to be implemented by objects that can return information about 21 | * the current call stack. Useful in AOP (as in AspectJ cflow concept) 22 | * but not AOP-specific. 23 | * @author Rod Johnson 24 | * @version $Id: ControlFlow.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 25 | * 26 | * 현재 콜스택에 대한 정보를 리턴하는 오브젝트에 의해 구현될 인터페이스 27 | * AOP 에서 유용하겠지만, AOP 전용은 아니다 28 | */ 29 | public interface ControlFlow { 30 | 31 | boolean under(Class clazz); 32 | 33 | /** 34 | * Matches whole method name. 35 | */ 36 | boolean under(Class clazz, String methodName); 37 | 38 | boolean underToken(String token); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/ControlFlowFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.io.PrintWriter; 20 | import java.io.StringWriter; 21 | 22 | /** 23 | * Singleton factory to conceal automatic choice of Java 1.4 or 1.3 24 | * ControlFlow implementation class. We want to use the more efficient 25 | * Java 1.4 StackTraceElement if we can, and we don't want to impose 26 | * a runtime dependency on 1.4. 27 | * @author Rod Johnson 28 | * @version $Id: ControlFlowFactory.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 29 | * 30 | * 자바 1.4 나 1.3인지 선택하기 위한 싱글턴 팩토리 31 | * 우리는 사용할 수 있다면 좀 더 효과적인 1.4 스텍트레이스를 사용할 것이고 32 | * 우리는 1.4 에 대한 런타임 의존성을 노출하고 싶진 않다 33 | */ 34 | public abstract class ControlFlowFactory { 35 | 36 | public static ControlFlow createControlFlow() { 37 | return JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_18 ? 38 | new Jdk18ControlFlow() : 39 | new Jdk14ControlFlow(); 40 | } 41 | 42 | 43 | static class Jdk18ControlFlow implements ControlFlow{ 44 | private StackTraceElement[] stack; 45 | public Jdk18ControlFlow(){ 46 | stack = new Throwable().getStackTrace(); 47 | } 48 | public boolean under(Class clazz) { 49 | String className = clazz.getName(); 50 | for (int i = 0; i < stack.length; i++) { 51 | if (stack[i].getClassName().equals(className)) { 52 | return true; 53 | } 54 | } 55 | return false; 56 | } 57 | 58 | /** 59 | * Matches whole method name 60 | * @param clazz 61 | * @param methodName 62 | * @return 63 | */ 64 | public boolean under(Class clazz, String methodName) { 65 | String className = clazz.getName(); 66 | for (int i = 0; i < stack.length; i++) { 67 | if (stack[i].getClassName().equals(className) && stack[i].getMethodName().equals(methodName)) { 68 | return true; 69 | } 70 | } 71 | return false; 72 | } 73 | 74 | /** 75 | * Leave it up to the caller to decide what matches. 76 | * Caller must understand stack trace format, so there's less abstraction. 77 | * @param token 78 | * @return 79 | */ 80 | public boolean underToken(String token) { 81 | StringWriter sw = new StringWriter(); 82 | new Throwable().printStackTrace(new PrintWriter(sw)); 83 | //System.err.println(sw); 84 | String stackTrace = sw.toString(); 85 | return stackTrace.indexOf(token) != -1; 86 | } 87 | 88 | public String toString() { 89 | StringBuffer sb = new StringBuffer("Jdk18ControlFlow: "); 90 | for (int i = 0; i < stack.length; i++) { 91 | if (i > 0) 92 | sb.append("\n\t@"); 93 | sb.append(stack[i]); 94 | } 95 | return sb.toString(); 96 | } 97 | } 98 | 99 | /** 100 | * Utilities for cflow-style pointcuts. Note that such pointcuts are 101 | * 5-10 times more expensive to evaluate than other pointcuts, as they require 102 | * analysis of the stack trace (through constructing a new throwable). 103 | * However, they are useful in some cases. 104 | *

This implementation uses the StackTraceElement class introduced in Java 1.4. 105 | * @author Rod Johnson 106 | * @version $Id: ControlFlowFactory.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 107 | */ 108 | static class Jdk14ControlFlow implements ControlFlow { 109 | 110 | private StackTraceElement[] stack; 111 | 112 | public Jdk14ControlFlow() { 113 | stack = new Throwable().getStackTrace(); 114 | } 115 | 116 | public boolean under(Class clazz) { 117 | String className = clazz.getName(); 118 | for (int i = 0; i < stack.length; i++) { 119 | if (stack[i].getClassName().equals(className)) { 120 | return true; 121 | } 122 | } 123 | return false; 124 | } 125 | 126 | /** 127 | * Matches whole method name 128 | * @param clazz 129 | * @param methodName 130 | * @return 131 | */ 132 | public boolean under(Class clazz, String methodName) { 133 | String className = clazz.getName(); 134 | for (int i = 0; i < stack.length; i++) { 135 | if (stack[i].getClassName().equals(className) && stack[i].getMethodName().equals(methodName)) { 136 | return true; 137 | } 138 | } 139 | return false; 140 | } 141 | 142 | /** 143 | * Leave it up to the caller to decide what matches. 144 | * Caller must understand stack trace format, so there's less abstraction. 145 | * @param token 146 | * @return 147 | */ 148 | public boolean underToken(String token) { 149 | StringWriter sw = new StringWriter(); 150 | new Throwable().printStackTrace(new PrintWriter(sw)); 151 | //System.err.println(sw); 152 | String stackTrace = sw.toString(); 153 | return stackTrace.indexOf(token) != -1; 154 | } 155 | 156 | public String toString() { 157 | StringBuffer sb = new StringBuffer("Jdk14ControlFlow: "); 158 | for (int i = 0; i < stack.length; i++) { 159 | if (i > 0) 160 | sb.append("\n\t@"); 161 | sb.append(stack[i]); 162 | } 163 | return sb.toString(); 164 | } 165 | } 166 | 167 | 168 | /** 169 | * Java 1.3 version of utilities for cflow-style pointcuts. We can't 170 | * rely on the Java 1.4 StackTraceElement class. 171 | *

Note that such pointcuts are 10-15 times more expensive to evaluate under 172 | * JDK 1.3 than other pointcuts, as they require analysis of the stack trace 173 | * (through constructing a new throwable). However, they are useful in some cases. 174 | * @author Rod Johnson 175 | * @version $Id: ControlFlowFactory.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 176 | */ 177 | static class Jdk13ControlFlow implements ControlFlow { 178 | 179 | private String stackTrace; 180 | 181 | 182 | public Jdk13ControlFlow() { 183 | StringWriter sw = new StringWriter(); 184 | new Throwable().printStackTrace(new PrintWriter(sw)); 185 | stackTrace = sw.toString(); 186 | } 187 | 188 | public boolean under(Class clazz) { 189 | return stackTrace.indexOf(clazz.getName()) != -1; 190 | } 191 | 192 | /** 193 | * Matches whole method name 194 | * @param clazz 195 | * @param methodName 196 | * @return 197 | */ 198 | public boolean under(Class clazz, String methodName) { 199 | return stackTrace.indexOf(clazz.getName() + "." + methodName + "(") != -1; 200 | } 201 | 202 | /** 203 | * Leave it up to the caller to decide what matches. 204 | * Caller must understand stack trace format, so there's less abstraction. 205 | * @param token 206 | * @return 207 | */ 208 | public boolean underToken(String token) { 209 | return stackTrace.indexOf(token) != -1; 210 | } 211 | } 212 | 213 | } 214 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/ErrorCoded.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | /** 20 | * Interface that can be implemented by exceptions etc that are error coded. 21 | * The error code is a String, rather than a number, so it can be given 22 | * user-readable values, such as "object.failureDescription". 23 | * These codes will be resolved by a cMessageSource object. 24 | * 25 | *

This interface is necessary because both runtime and checked 26 | * exceptions are useful, and they cannot share a common, 27 | * framework-specific, superclass. 28 | * 29 | * @author Rod Johnson 30 | * @version $Id: ErrorCoded.java,v 1.3 2004/03/18 02:46:06 trisberg Exp $ 31 | * @see org.springframework.context.MessageSource 32 | * 33 | * 예외에 의해 구현될 인터페이스로 에러코드는 문자열, 숫자가 되어서 유저가 읽을 수 있는 값같은 것으로 변환될 것이다. 34 | * 에러코드는 MessageSource 에 의해 해석될 것이다 35 | * 36 | */ 37 | public interface ErrorCoded { 38 | 39 | /** 40 | * Return the error code associated with this failure. 41 | * The GUI can render this anyway it pleases, allowing for Int8ln etc. 42 | * @return a String error code associated with this failure, 43 | * or null if not error-coded 44 | */ 45 | String getErrorCode(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/JdkVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | /** 20 | * Class used to find the current JVM version. 21 | * Usually we want to find if we're in a 1.4 or higher JVM. 22 | * (Spring does not support 1.2 JVMs.) 23 | * @author Rod Johnson 24 | * @version $Id: JdkVersion.java,v 1.2 2004/03/18 02:46:06 trisberg Exp $ 25 | * 26 | * 현재 JVM version 을 찾기 위해 사용되는 클래스 27 | */ 28 | public class JdkVersion { 29 | 30 | public static final int JAVA_13 = 0; 31 | 32 | public static final int JAVA_14 = 1; 33 | 34 | public static final int JAVA_15 = 2; 35 | 36 | public static final int JAVA_18 = 3; 37 | 38 | private static int majorJavaVersion = JAVA_18; 39 | 40 | static { 41 | String javaVersion = System.getProperty("java.version"); 42 | // should look like "1.4.1_02" 43 | if (javaVersion.indexOf("1.4") != -1) { 44 | majorJavaVersion = JAVA_14; 45 | } 46 | else if (javaVersion.indexOf("1.5") != -1) { 47 | majorJavaVersion = JAVA_15; 48 | } 49 | // else leave as 1.3 default 50 | } 51 | 52 | /** 53 | * Get the major version code. This means we can do things like 54 | * if getJavaVersion() >= JAVA_14 55 | * @return a code comparable to the JAVA_XX codes in this 56 | * class. 57 | */ 58 | public static int getMajorJavaVersion() { 59 | return majorJavaVersion; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/NestedCheckedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.io.PrintStream; 20 | import java.io.PrintWriter; 21 | 22 | /** 23 | * Handy class for wrapping runtime Exceptions with a root cause. This time-honoured 24 | * technique is no longer necessary in Java 1.4, which provides built-in support for 25 | * exception nesting. Thus exceptions in applications written to use Java 1.4 need not 26 | * extend this class. 27 | * 28 | * 체크예외를 랩핑하기 위한 편의성 클래스 29 | * 30 | *

Abstract to force the programmer to extend the class. 31 | * printStackTrace() etc. are forwarded to the wrapped Exception. 32 | * The present assumption is that all application-specific exceptions that could be 33 | * displayed to humans (users, administrators etc.) will implement the ErrorCoded interface. 34 | * 35 | *

The similarity between this class and the NestedCheckedException class is unavoidable, 36 | * as Java forces these two classes to have different superclasses (ah, the inflexibility 37 | * of concrete inheritance!). 38 | * 39 | *

As discussed in Expert One-On-One J2EE Design and Development, 40 | * runtime exceptions are often a better alternative to checked exceptions. However, all exceptions 41 | * should preserve their stack trace, if caused by a lower-level exception. 42 | * 43 | * @author Rod Johnson 44 | * @version $Id: NestedCheckedException.java,v 1.6 2004/03/18 02:46:06 trisberg Exp $ 45 | * 46 | * 47 | */ 48 | public abstract class NestedCheckedException extends Exception { 49 | 50 | /** Root cause of this nested exception */ 51 | private Throwable cause; 52 | 53 | /** 54 | * Construct a ExceptionWrapperException with the specified detail message. 55 | * @param msg the detail message 56 | */ 57 | public NestedCheckedException(String msg) { 58 | super(msg); 59 | } 60 | 61 | /** 62 | * Construct a RemoteException with the specified detail message 63 | * and nested exception. 64 | * @param msg the detail message 65 | * @param ex the nested exception 66 | */ 67 | public NestedCheckedException(String msg, Throwable ex) { 68 | super(msg); 69 | this.cause = ex; 70 | } 71 | 72 | /** 73 | * Return the nested cause, or null if none. 74 | */ 75 | public Throwable getCause() { 76 | return cause; 77 | } 78 | 79 | /** 80 | * Return the detail message, including the message from the nested exception 81 | * if there is one. 82 | */ 83 | public String getMessage() { 84 | if (this.cause == null) { 85 | return super.getMessage(); 86 | } 87 | else { 88 | return super.getMessage() + "; nested exception is " + this.cause.getClass().getName() + 89 | ": " + this.cause.getMessage(); 90 | } 91 | } 92 | 93 | /** 94 | * Print the composite message and the embedded stack trace to the specified stream. 95 | * @param ps the print stream 96 | */ 97 | public void printStackTrace(PrintStream ps) { 98 | if (this.cause == null) { 99 | super.printStackTrace(ps); 100 | } 101 | else { 102 | ps.println(this); 103 | this.cause.printStackTrace(ps); 104 | } 105 | } 106 | 107 | /** 108 | * Prints the composite message and the embedded stack trace to the specified print writer. 109 | * @param pw the print writer 110 | */ 111 | public void printStackTrace(PrintWriter pw) { 112 | if (this.cause == null) { 113 | super.printStackTrace(pw); 114 | } 115 | else { 116 | pw.println(this); 117 | this.cause.printStackTrace(pw); 118 | } 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/NestedRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.io.PrintStream; 20 | import java.io.PrintWriter; 21 | 22 | /** 23 | * Handy class for wrapping runtime Exceptions with a root cause. This time-honoured 24 | * technique is no longer necessary in Java 1.4, which provides built-in support for 25 | * exception nesting. Thus exceptions in applications written to use Java 1.4 need not 26 | * extend this class. 27 | * 28 | *

Abstract to force the programmer to extend the class. 29 | * printStackTrace() etc. are forwarded to the wrapped Exception. 30 | * The present assumption is that all application-specific exceptions that could be 31 | * displayed to humans (users, administrators etc.) will implement the ErrorCoded interface. 32 | * 33 | *

The similarity between this class and the NestedCheckedException class is unavoidable, 34 | * as Java forces these two classes to have different superclasses (ah, the inflexibility 35 | * of concrete inheritance!). 36 | * 37 | *

As discussed in Expert One-On-One J2EE Design and Development, 38 | * runtime exceptions are often a better alternative to checked exceptions. However, all exceptions 39 | * should preserve their stack trace, if caused by a lower-level exception. 40 | * 41 | * @author Rod Johnson 42 | * @version $Id: NestedRuntimeException.java,v 1.6 2004/03/18 02:46:06 trisberg Exp $ 43 | */ 44 | public abstract class NestedRuntimeException extends RuntimeException { 45 | 46 | /** Root cause of this nested exception */ 47 | private Throwable cause; 48 | 49 | /** 50 | * Construct a ExceptionWrapperException with the specified detail message. 51 | * @param msg the detail message 52 | */ 53 | public NestedRuntimeException(String msg) { 54 | super(msg); 55 | } 56 | 57 | /** 58 | * Construct a RemoteException with the specified detail message and 59 | * nested exception. 60 | * @param msg the detail message 61 | * @param ex the nested exception 62 | */ 63 | public NestedRuntimeException(String msg, Throwable ex) { 64 | super(msg); 65 | this.cause = ex; 66 | } 67 | 68 | /** 69 | * Return the nested cause, or null if none. 70 | */ 71 | public Throwable getCause() { 72 | return cause; 73 | } 74 | 75 | /** 76 | * Return the detail message, including the message from the nested exception 77 | * if there is one. 78 | */ 79 | public String getMessage() { 80 | if (this.cause == null) { 81 | return super.getMessage(); 82 | } 83 | else { 84 | return super.getMessage() + "; nested exception is " + this.cause.getClass().getName() + 85 | ": " + this.cause.getMessage(); 86 | } 87 | } 88 | 89 | /** 90 | * Print the composite message and the embedded stack trace to the specified stream. 91 | * @param ps the print stream 92 | */ 93 | public void printStackTrace(PrintStream ps) { 94 | if (this.cause == null) { 95 | super.printStackTrace(ps); 96 | } 97 | else { 98 | ps.println(this); 99 | this.cause.printStackTrace(ps); 100 | } 101 | } 102 | 103 | /** 104 | * Print the composite message and the embedded stack trace to the specified writer. 105 | * @param pw the print writer 106 | */ 107 | public void printStackTrace(PrintWriter pw) { 108 | if (this.cause == null) { 109 | super.printStackTrace(pw); 110 | } 111 | else { 112 | pw.println(this); 113 | this.cause.printStackTrace(pw); 114 | } 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/OrderComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.util.Comparator; 20 | 21 | /** 22 | * Comparator implementation for Ordered objects, 23 | * sorting by order value ascending (resp. by priority descending). 24 | * 25 | *

Non-Ordered objects are treated as greatest order values, 26 | * thus ending up at the end of the list, in arbitrary order 27 | * (just like same order values of Ordered objects). 28 | * 29 | * 순서있는 객체들을 위한 비교구현체 30 | * 31 | * @author Juergen Hoeller 32 | * @since 07.04.2003 33 | * @see Ordered 34 | */ 35 | public class OrderComparator implements Comparator { 36 | 37 | public int compare(Object o1, Object o2) { 38 | int i1 = (o1 instanceof Ordered ? ((Ordered) o1).getOrder() : Integer.MAX_VALUE); 39 | int i2 = (o2 instanceof Ordered ? ((Ordered) o2).getOrder() : Integer.MAX_VALUE); 40 | 41 | // direct evaluation instead of Integer.compareTo to avoid unnecessary object creation 42 | if (i1 < i2) 43 | return -1; 44 | else if (i1 > i2) 45 | return 1; 46 | else 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/Ordered.java: -------------------------------------------------------------------------------- 1 | package org.springframework.core; 2 | 3 | /** 4 | * Interface that can be implemented by objects that should be 5 | * orderable, e.g. in a Collection. The actual order can be 6 | * interpreted as prioritization, the first object (with the 7 | * lowest order value) having the highest priority. 8 | * 9 | * @author Juergen Hoeller 10 | * @since 07.04.2003 11 | * 12 | * 순서가능한 오프젝트가 구현해야하는 인터페이스 예를 들자면 콜렉션 같은 13 | * 실제적 순서는 우선권에 의해 해석된다 14 | */ 15 | public interface Ordered { 16 | 17 | /** 18 | * Return the order value of this object, 19 | * higher value meaning greater in terms of sorting. 20 | * Normally starting with 0 or 1, Integer.MAX_VALUE 21 | * indicating greatest. 22 | * Same order values will result in arbitrary positions 23 | * for the affected objects. 24 | * 25 | *

Higher value can be interpreted as lower priority, 26 | * consequently the first object has highest priority 27 | * (somewhat analogous to Servlet "load-on-startup" values). 28 | * 29 | * @return the order value 30 | */ 31 | public int getOrder(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/README.md: -------------------------------------------------------------------------------- 1 | 2 | # core 패키지 3 | 4 | 예외 처리를 가능하게 하고, 프레임워크에 속하지 않는 핵심 인터페이스들을 제공하는 기본적인 클래스 5 | 6 | --- 7 | 8 | - ConstantException : Constants 클래스가 유효하지 않은 상수 이름을 물어볼때 발생할 수 있는 예외 9 | - Constants : 상수정의를 가진 다른 클래스들을 파싱하는 데 사용될 수 있다 10 | - (I) ControlFlow : 현재 콜스택에 대한 정보를 리턴하는 오브젝트에 의해 구현될 인터페이스 11 | - ControlFlowFactory : 자바 1.4 나 1.3인지 선택하기 위한 싱글턴 팩토리 12 | - (I) ErrorCoded : 예외에 의해 구현될 인터페이스로 에러코드는 문자열, 숫자가 되어서 유저가 읽을 수 있는 값같은 것으로 변환될 것이다. 13 | 14 | - JdkVersion : 현재 JVM version 을 찾기 위해 사용되는 클래스 15 | - NestedCheckedException : 체크예외를 랩핑하기 위한 편의성 클래스 16 | - NestedRuntimeException : 런타임예외를 랩핑하기 위한 편의성 클래스 17 | - OrderComparator : 순서있는 객체들을 위한 비교구현체 18 | - (I) Ordered { getOrder() } : 순서가능한 오프젝트가 구현해야하는 인터페이스 예를 들자면 콜렉션 같은 19 | 20 | ## 보유 패키지 21 | - io : 입출력에 관련된 패키지 -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/AbstractResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.File; 20 | import java.io.FileNotFoundException; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.net.URL; 24 | 25 | /** 26 | * Convenience base class for Resource implementations, 27 | * pre-implementing typical behavior. 28 | * 29 | * 자원구현체와 일반적 행동을 미리 구현(pre-implementing) 하기 위한 편의 클래스 30 | * 31 | *

The "exists" method will check whether a File or InputStream can 32 | * be opened; "isOpen" will always return false; "getURL" and "getFile" 33 | * throw an exception; and "toString" will return the description. 34 | * 35 | * @author Juergen Hoeller 36 | * @since 28.12.2003 37 | */ 38 | public abstract class AbstractResource implements Resource { 39 | 40 | protected static final String URL_PROTOCOL_FILE = "file"; 41 | 42 | /** 43 | * This implementation checks whether a File can be opened, 44 | * falling back to whether an InputStream can be opened. 45 | * This will cover both directories and content resources. 46 | */ 47 | public boolean exists() { 48 | // try file existence 49 | try { 50 | return getFile().exists(); 51 | } 52 | catch (IOException ex) { 53 | // fall back to stream existence 54 | try { 55 | InputStream is = getInputStream(); 56 | is.close(); 57 | return true; 58 | } 59 | catch (IOException ex2) { 60 | return false; 61 | } 62 | } 63 | } 64 | 65 | /** 66 | * This implementations always returns false. 67 | */ 68 | public boolean isOpen() { 69 | return false; 70 | } 71 | 72 | /** 73 | * This implementation throws a FileNotFoundException, assuming 74 | * that the resource cannot be resolved to a URL. 75 | */ 76 | public URL getURL() throws IOException { 77 | throw new FileNotFoundException(getDescription() + " cannot be resolved to URL"); 78 | } 79 | 80 | /** 81 | * This implementation throws a FileNotFoundException, assuming 82 | * that the resource cannot be resolved to an absolute file path. 83 | */ 84 | public File getFile() throws IOException { 85 | throw new FileNotFoundException(getDescription() + " cannot be resolved to absolute file path"); 86 | } 87 | 88 | /** 89 | * This implementation returns the description of this resource. 90 | * @see #getDescription 91 | */ 92 | public String toString() { 93 | return getDescription(); 94 | } 95 | 96 | /** 97 | * This implementation compares description strings. 98 | * @see #getDescription 99 | */ 100 | public boolean equals(Object obj) { 101 | return (obj instanceof Resource && ((Resource) obj).getDescription().equals(getDescription())); 102 | } 103 | 104 | /** 105 | * This implementation returns the description's hash code. 106 | * @see #getDescription 107 | */ 108 | public int hashCode() { 109 | return getDescription().hashCode(); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/ClassPathResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.File; 20 | import java.io.FileNotFoundException; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.net.URL; 24 | import java.net.URLDecoder; 25 | 26 | /** 27 | * Resource implementation for class path resources. 28 | * Uses either the Thread context class loader or a given 29 | * Class for loading resources. 30 | * 31 | * 클래스 패스의 자원들을 위한 리소스 구현체. 32 | * 불러오는 자원에 대한 클래스또는 쓰레드 컨텍스트에서 사용 33 | * 34 | * 35 | *

Supports resolution as File if the class path resource 36 | * resides in the file system, but not for resources in a JAR. 37 | * Always supports resolution as URL. 38 | * 39 | * @author Juergen Hoeller 40 | * @since 28.12.2003 41 | * @see Thread#getContextClassLoader 42 | * @see ClassLoader#getResourceAsStream 43 | * @see Class#getResourceAsStream 44 | */ 45 | public class ClassPathResource extends AbstractResource { 46 | 47 | private final String path; 48 | 49 | private Class clazz; 50 | 51 | /** 52 | * Create a new ClassPathResource for ClassLoader usage. 53 | * A leading slash will be removed, as the ClassLoader 54 | * resource access methods will not accept it. 55 | * @param path the absolute path within the classpath 56 | * @see ClassLoader#getResourceAsStream 57 | */ 58 | public ClassPathResource(String path) { 59 | if (path.startsWith("/")) { 60 | path = path.substring(1); 61 | } 62 | this.path = path; 63 | } 64 | 65 | /** 66 | * Create a new ClassPathResource for Class usage. 67 | * The path can be relative to the given class, 68 | * or absolute within the classpath via a leading slash. 69 | * @param path relative or absolute path within the classpath 70 | * @param clazz the class to load resources with 71 | * @see Class#getResourceAsStream 72 | */ 73 | public ClassPathResource(String path, Class clazz) { 74 | this.path = path; 75 | this.clazz = clazz; 76 | } 77 | 78 | public InputStream getInputStream() throws IOException { 79 | InputStream is = null; 80 | if (this.clazz != null) { 81 | is = this.clazz.getResourceAsStream(this.path); 82 | } 83 | else { 84 | ClassLoader ccl = Thread.currentThread().getContextClassLoader(); 85 | is = ccl.getResourceAsStream(this.path); 86 | } 87 | if (is == null) { 88 | throw new FileNotFoundException("Could not open " + getDescription()); 89 | } 90 | return is; 91 | } 92 | 93 | public URL getURL() throws IOException { 94 | URL url = null; 95 | if (this.clazz != null) { 96 | url = this.clazz.getResource(this.path); 97 | } 98 | else { 99 | ClassLoader ccl = Thread.currentThread().getContextClassLoader(); 100 | url = ccl.getResource(this.path); 101 | } 102 | if (url == null) { 103 | throw new FileNotFoundException(getDescription() + " cannot be resolved to URL " + 104 | "because it does not exist"); 105 | } 106 | return url; 107 | } 108 | 109 | public File getFile() throws IOException { 110 | URL url = getURL(); 111 | if (!URL_PROTOCOL_FILE.equals(url.getProtocol())) { 112 | throw new FileNotFoundException(getDescription() + " cannot be resolved to absolute file path " + 113 | "because it does not reside in the file system: URL=[" + url + "]"); 114 | } 115 | return new File(URLDecoder.decode(url.getFile())); 116 | } 117 | 118 | public String getDescription() { 119 | return "class path resource [" + this.path + "]"; 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/DefaultResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.net.MalformedURLException; 20 | import java.net.URL; 21 | 22 | /** 23 | * Default implementation of the ResourceLoader interface. 24 | * Used by ResourceEditor, but also suitable for standalone usage. 25 | * 26 | * ResourceLoader 인터페이스를 위한 기본적 구현체 27 | * ResourceEditor에 사용되며 또한 독립적인 사용에도 적합하다 28 | * 29 | *

Will return an UrlResource if the location value is a URL, and a 30 | * ClassPathResource if it is a non-URL path or a "classpath:" pseudo-URL. 31 | * 32 | * @author Juergen Hoeller 33 | * @since 10.03.2004 34 | * @see #CLASSPATH_URL_PREFIX 35 | * @see ResourceEditor 36 | * @see UrlResource 37 | * @see ClassPathResource 38 | */ 39 | public class DefaultResourceLoader implements ResourceLoader { 40 | 41 | public Resource getResource(String location) { 42 | if (location.startsWith(CLASSPATH_URL_PREFIX)) { 43 | return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length())); 44 | } 45 | else { 46 | try { 47 | // try URL 48 | URL url = new URL(location); 49 | return new UrlResource(url); 50 | } 51 | catch (MalformedURLException ex) { 52 | // no URL -> resolve resource path 53 | return getResourceByPath(location); 54 | } 55 | } 56 | } 57 | 58 | /** 59 | * Return a Resource handle for the resource at the given path. 60 | *

Default implementation supports class path locations. This should 61 | * be appropriate for standalone implementations but can be overridden, 62 | * e.g. for implementations targeted at a Servlet container. 63 | * @param path path to the resource 64 | * @return Resource handle 65 | * @see ClassPathResource 66 | * @see org.springframework.context.support.FileSystemXmlApplicationContext#getResourceByPath 67 | * @see org.springframework.web.context.support.XmlWebApplicationContext#getResourceByPath 68 | */ 69 | protected Resource getResourceByPath(String path) { 70 | return new ClassPathResource(path); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/FileSystemResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.File; 20 | import java.io.FileInputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.net.URL; 24 | 25 | /** 26 | * Resource implementation for java.io.File handles. 27 | * Obviously supports resolution as File, and also as URL. 28 | * 29 | * Java.io.File 을 다루기 위한 리소스 구현체로 File 에 대한 해석과 URL 까지 지원 30 | * 31 | * 32 | * @author Juergen Hoeller 33 | * @since 28.12.2003 34 | * @see File 35 | */ 36 | public class FileSystemResource extends AbstractResource { 37 | 38 | private final File file; 39 | 40 | /** 41 | * Create a new FileSystemResource. 42 | * @param file a File handle 43 | */ 44 | public FileSystemResource(File file) { 45 | this.file = file; 46 | } 47 | 48 | /** 49 | * Create a new FileSystemResource. 50 | * @param path a file path 51 | */ 52 | public FileSystemResource(String path) { 53 | this.file = new File(path); 54 | } 55 | 56 | public boolean exists() { 57 | return this.file.exists(); 58 | } 59 | 60 | public InputStream getInputStream() throws IOException { 61 | return new FileInputStream(this.file); 62 | } 63 | 64 | public URL getURL() throws IOException { 65 | return new URL(URL_PROTOCOL_FILE + ":" + this.file.getAbsolutePath()); 66 | } 67 | 68 | public File getFile() { 69 | return file; 70 | } 71 | 72 | public String getDescription() { 73 | return "file [" + this.file.getAbsolutePath() + "]"; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/InputStreamResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | /** 23 | * Resource implementation for a given InputStream. Should only 24 | * be used if no specific Resource implementation is applicable. 25 | * 26 | * 주어진 인풋스트림에 대한 리소스 구현체. 27 | * 어떠한 리소스 구현체도 해당하지 않은 경우에 사용? 28 | * 29 | *

In contrast to other Resource implementations, this is a descriptor 30 | * for an already opened resource - therefore returning true on 31 | * isOpen(). Do not use it if you need to keep the resource descriptor 32 | * somewhere, or if you need to read a stream multiple times. 33 | * 34 | * @author Juergen Hoeller 35 | * @since 28.12.2003 36 | */ 37 | public class InputStreamResource extends AbstractResource { 38 | 39 | private InputStream inputStream; 40 | 41 | private final String description; 42 | 43 | /** 44 | * Create a new InputStreamResource. 45 | * @param inputStream the InputStream to use 46 | * @param description where the InputStream comes from 47 | */ 48 | public InputStreamResource(InputStream inputStream, String description) { 49 | if (inputStream == null) { 50 | throw new IllegalArgumentException("inputStream must not be null"); 51 | } 52 | this.inputStream = inputStream; 53 | this.description = description; 54 | } 55 | 56 | public boolean exists() { 57 | return true; 58 | } 59 | 60 | public boolean isOpen() { 61 | return true; 62 | } 63 | 64 | /** 65 | * This implementation throws IllegalStateException if attempting to 66 | * read the underlying stream multiple times. 67 | */ 68 | public InputStream getInputStream() throws IOException, IllegalStateException { 69 | if (this.inputStream == null) { 70 | throw new IllegalStateException("InputStream has already been read - " + 71 | "do not use InputStreamResource if a stream needs to be read multiple times"); 72 | } 73 | InputStream result = this.inputStream; 74 | this.inputStream = null; 75 | return result; 76 | } 77 | 78 | public String getDescription() { 79 | return description; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/InputStreamSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | /** 23 | * Simple interface for objects that are sources for java.io.InputStreams. 24 | * Base interface for Spring's Resource interface. 25 | * 26 | * java.io.InputStreams 를 위한 소스 오브젝트에 대한 간단한 인터페이스로 Spring의 Resource 인터페이스에 대한 기반 인터페이스 27 | * 28 | * @author Juergen Hoeller 29 | * @since 20.01.2004 30 | * @see Resource 31 | */ 32 | public interface InputStreamSource { 33 | 34 | /** 35 | * Return an InputStream. 36 | * It is expected that each call creates a fresh stream. 37 | * @throws IOException if the stream could not be opened 38 | */ 39 | InputStream getInputStream() throws IOException; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/README.md: -------------------------------------------------------------------------------- 1 | 2 | # core/io 패키지 3 | 4 | Generic abstraction for (file-based) resources, used throughout the framework. 5 | 6 | 프레임워크내에서 사용되는 파일 기반 자원들을 위한 일반적인 추상화 7 | 8 | --- 9 | 10 | - AbstractResource : 자원구현체와 일반적 행동을 미리 구현(pre-implementing) 하기 위한 편의 클래스 11 | - ClassPathResource : 클래스 패스의 자원들을 위한 리소스 구현체 12 | - DefaultResourceLoader : ResourceLoader 인터페이스를 위한 기본적 구현체로 ResourceEditor에 사용되며 또한 독립적인 사용에도 적합하다 13 | - FileSystemResource : Java.io.File 을 다루기 위한 리소스 구현체로 File 에 대한 해석과 URL 까지 지원 14 | - InputStreamResource : 주어진 인풋스트림에 대한 리소스 구현체. 어떠한 리소스 구현체도 해당하지 않은 경우에 사용? 15 | 16 | - (I) InputStreamSource { getInputStream() } : java.io.InputStreams 를 위한 소스 오브젝트에 대한 간단한 인터페이스로 Spring의 Resource 인터페이스에 대한 기반 인터페이스 17 | - (I) Resource : 파일이나 클래스 패스같은 실제 resource 타입에 대한 추상층에서의 리소스 설명자들을 위한 인터페이스 18 | - ResourceEditor : 리소스 설명자들을 위한 에디터로 문자열 위치를 리소스 속성으로 자동으로 변환해준다. ( ${user.dir} -> 실제 위치 변환을 얘기하는 듯?) 19 | - (I) ResourceLoader { getResource } : resource들을 불러오는 객체에 의해 구현될 인터페이스로 ApplicationContext 는 이 기능을 제공해야 합니다 20 | - UrlResource : java.net.URL 을 위한 리소스 구현체로 특별히 URL, 또한 file: 프로토콜을 위한 File 을 지원합니다 -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.net.URL; 22 | 23 | /** 24 | * Interface for a resource descriptor that abstracts from the actual 25 | * type of resource, like file or class path resource. 26 | * 27 | *

An InputStream can be opened for every resource if it exists in 28 | * physical form, but a URL or File handle can just be returned for 29 | * certain resources. The actual behavior is implementation-specific. 30 | * 31 | * 파일이나 클래스 패스같은 실제 resource 타입에 대한 추상층에서의 리소스 설명자들을 위한 인터페이스 32 | * 33 | * @author Juergen Hoeller 34 | * @since 28.12.2003 35 | */ 36 | public interface Resource extends InputStreamSource { 37 | 38 | /** 39 | * Return whether this resource actually exists in physical form. 40 | */ 41 | boolean exists(); 42 | 43 | /** 44 | * Return whether this resource represents a handle with an open 45 | * stream. If true, the InputStream cannot be read multiple times, 46 | * and must be read and closed to avoid resource leaks. 47 | *

Will be false for all usual resource descriptors. 48 | */ 49 | boolean isOpen(); 50 | 51 | /** 52 | * Return a URL handle for this resource. 53 | * @throws IOException if the resource cannot be resolved as URL, 54 | * i.e. if the resource is not available as descriptor 55 | */ 56 | URL getURL() throws IOException; 57 | 58 | /** 59 | * Return a File handle for this resource. 60 | * @throws IOException if the resource cannot be resolved as absolute 61 | * file path, i.e. if the resource is not available in a file system 62 | */ 63 | File getFile() throws IOException; 64 | 65 | /** 66 | * Return a description for this resource, 67 | * to be used for error output when working with the resource. 68 | *

Implementations are also encouraged to return this value 69 | * from their toString method. 70 | * @see Object#toString 71 | */ 72 | String getDescription(); 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/ResourceEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | 21 | import org.apache.commons.logging.Log; 22 | import org.apache.commons.logging.LogFactory; 23 | 24 | /** 25 | * Editor for Resource descriptors, to convert String locations to Resource 26 | * properties automatically instead of using a String location property. 27 | * 28 | * 리소스 설명자들을 위한 에디터로 문자열 위치를 리소스 속성으로 자동으로 변환해준다. ( ${user.dir} -> 실제 위치 변환을 얘기하는 듯?) 29 | * 30 | *

The path may contain ${...} placeholders, to be resolved as 31 | * system properties: e.g. ${user.dir}. 32 | * 33 | *

Delegates to a ResourceLoader, by default DefaultResourceLoader. 34 | * 35 | * @author Juergen Hoeller 36 | * @since 28.12.2003 37 | * @see #PLACEHOLDER_PREFIX 38 | * @see #PLACEHOLDER_SUFFIX 39 | * @see #getResourceLoader 40 | * @see Resource 41 | * @see ResourceLoader 42 | * @see DefaultResourceLoader 43 | * @see System#getProperty(String) 44 | */ 45 | public class ResourceEditor extends PropertyEditorSupport { 46 | 47 | protected static final Log logger = LogFactory.getLog(ResourceEditor.class); 48 | 49 | public static final String PLACEHOLDER_PREFIX = "${"; 50 | 51 | public static final String PLACEHOLDER_SUFFIX = "}"; 52 | 53 | public void setAsText(String text) { 54 | setValue(getResourceLoader().getResource(resolvePath(text))); 55 | } 56 | 57 | /** 58 | * Resolve the given path, replacing placeholders with corresponding 59 | * system property values if necessary. 60 | * @param path the original file path 61 | * @return the resolved file path 62 | * @see #PLACEHOLDER_PREFIX 63 | * @see #PLACEHOLDER_SUFFIX 64 | */ 65 | protected String resolvePath(String path) { 66 | int startIndex = path.indexOf(PLACEHOLDER_PREFIX); 67 | if (startIndex != -1) { 68 | int endIndex = path.indexOf(PLACEHOLDER_SUFFIX, startIndex + PLACEHOLDER_PREFIX.length()); 69 | if (endIndex != -1) { 70 | String placeholder = path.substring(startIndex + PLACEHOLDER_PREFIX.length(), endIndex); 71 | String propVal = System.getProperty(placeholder); 72 | if (propVal != null) { 73 | return path.substring(0, startIndex) + propVal + path.substring(endIndex+1); 74 | } 75 | else { 76 | logger.warn("Could not resolve placeholder '" + placeholder + 77 | "' in file path [" + path + "] as system property"); 78 | } 79 | } 80 | } 81 | return path; 82 | } 83 | 84 | /** 85 | * Determine the ResourceLoader to use for converting the 86 | * property text to a Resource. Default is DefaultResourceLoader. 87 | * @see DefaultResourceLoader 88 | */ 89 | protected ResourceLoader getResourceLoader() { 90 | return new DefaultResourceLoader(); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | /** 20 | * Interface to be implemented by objects that can load resources. 21 | * An ApplicationContext is required to provide this functionality. 22 | * 23 | * resource들을 불러오는 객체에 의해 구현될 인터페이스로 ApplicationContext 는 이 기능을 제공해야 합니다 24 | * 25 | *

DefaultResourceLoader is a standalone implementation that is 26 | * usable outside an ApplicationContext, also used by ResourceEditor. 27 | * 28 | * @author Juergen Hoeller 29 | * @since 10.03.2004 30 | * @see DefaultResourceLoader 31 | * @see ResourceEditor 32 | * @see org.springframework.context.ApplicationContext 33 | */ 34 | public interface ResourceLoader { 35 | 36 | /** Pseudo URL prefix for loading from the class path */ 37 | String CLASSPATH_URL_PREFIX = "classpath:"; 38 | 39 | /** 40 | * Return a Resource handle for the specified resource. 41 | * The handle should always be a reusable resource descriptor, 42 | * allowing for multiple getInputStream calls. 43 | *

    44 | *
  • Must support fully qualified URLs, e.g. "file:C:/test.dat". 45 | *
  • Must support classpath pseudo-URLs, e.g. "classpath:test.dat". 46 | *
  • Should support relative file paths, e.g. "WEB-INF/test.dat". 47 | * (This will be implementation-specific, typically provided by an 48 | * ApplicationContext implementation.) 49 | *
50 | *

Note that a Resource handle does not imply an existing resource; 51 | * you need to invoke Resource's "exists" to check for existence. 52 | * @param location resource location 53 | * @return Resource handle 54 | * @see #CLASSPATH_URL_PREFIX 55 | * @see Resource#exists 56 | * @see Resource#getInputStream 57 | */ 58 | Resource getResource(String location); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/UrlResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core.io; 18 | 19 | import java.io.File; 20 | import java.io.FileNotFoundException; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.net.MalformedURLException; 24 | import java.net.URL; 25 | import java.net.URLDecoder; 26 | 27 | /** 28 | * Resource implementation for java.net.URL locators. 29 | * Obviously supports resolution as URL, and also as File 30 | * in case of the "file:" protocol. 31 | * 32 | * java.net.URL 을 위한 리소스 구현체로 특별히 URL, 또한 file: 프로토콜을 위한 File 을 지원합니다 33 | * 34 | * @author Juergen Hoeller 35 | * @since 28.12.2003 36 | * @see URL 37 | */ 38 | public class UrlResource extends AbstractResource { 39 | 40 | public static final String PROTOCOL_FILE = "file"; 41 | 42 | private final URL url; 43 | 44 | /** 45 | * Create a new UrlResource. 46 | * @param url a URL 47 | */ 48 | public UrlResource(URL url) { 49 | this.url = url; 50 | } 51 | 52 | /** 53 | * Create a new UrlResource. 54 | * @param path a URL path 55 | */ 56 | public UrlResource(String path) throws MalformedURLException { 57 | this.url = new URL(path); 58 | } 59 | 60 | public InputStream getInputStream() throws IOException { 61 | return this.url.openStream(); 62 | } 63 | 64 | public File getFile() throws IOException { 65 | if (PROTOCOL_FILE.equals(this.url.getProtocol())) { 66 | return new File(URLDecoder.decode(this.url.getFile())); 67 | } 68 | else { 69 | throw new FileNotFoundException(getDescription() + " cannot be resolved to absolute file path - " + 70 | "no 'file:' protocol"); 71 | } 72 | } 73 | 74 | public String getDescription() { 75 | return "URL [" + this.url + "]"; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/io/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generic abstraction for (file-based) resources, used throughout the framework. 5 | 6 | 프레임워크내에서 사용되는 파일 기반 자원들을 위한 일반적인 추상화 7 | 8 | AbstractResource : 자원구현체와 일반적 행동을 미리 구현(pre-implementing) 하기 위한 편의 클래스 9 | ClassPathResource : 클래스 패스의 자원들을 위한 리소스 구현체 10 | DefaultResourceLoader : ResourceLoader 인터페이스를 위한 기본적 구현체로 ResourceEditor에 사용되며 또한 독립적인 사용에도 적합하다 11 | FileSystemResource : Java.io.File 을 다루기 위한 리소스 구현체로 File 에 대한 해석과 URL 까지 지원 12 | InputStreamResource : 주어진 인풋스트림에 대한 리소스 구현체. 어떠한 리소스 구현체도 해당하지 않은 경우에 사용? 13 | (I) InputStreamSource { getInputStream() } : java.io.InputStreams 를 위한 소스 오브젝트에 대한 간단한 인터페이스로 Spring의 Resource 인터페이스에 대한 기반 인터페이스 14 | (I) Resource : 파일이나 클래스 패스같은 실제 resource 타입에 대한 추상층에서의 리소스 설명자들을 위한 인터페이스 15 | ResourceEditor : 리소스 설명자들을 위한 에디터로 문자열 위치를 리소스 속성으로 자동으로 변환해준다. ( ${user.dir} -> 실제 위치 변환을 얘기하는 듯?) 16 | (I) ResourceLoader { getResource } : resource들을 불러오는 객체에 의해 구현될 인터페이스로 ApplicationContext 는 이 기능을 제공해야 합니다 17 | UrlResource : java.net.URL 을 위한 리소스 구현체로 특별히 URL, 또한 file: 프로토콜을 위한 File 을 지원합니다 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/org/springframework/core/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Basic classes facilitating exception handling, and providing core interfaces 5 | that are not specific to any part of the framework. 6 | 7 | 예외 처리를 가능하게 하고, 프레임워크에 속하지 않는 핵심 인터페이스들을 제공하는 기본적인 클래스 8 | 9 | ================= 10 | 11 | ConstantException : Constants 클래스가 유효하지 않은 상수 이름을 물어볼때 발생할 수 있는 예외 12 | Constants : 상수정의를 가진 다른 클래스들을 파싱하는 데 사용될 수 있다 13 | (I) ControlFlow : 현재 콜스택에 대한 정보를 리턴하는 오브젝트에 의해 구현될 인터페이스 14 | ControlFlowFactory : 자바 1.4 나 1.3인지 선택하기 위한 싱글턴 팩토리 15 | (I) ErrorCoded : 예외에 의해 구현될 인터페이스로 에러코드는 문자열, 숫자가 되어서 유저가 읽을 수 있는 값같은 것으로 변환될 것이다. 16 | JdkVersion : 현재 JVM version 을 찾기 위해 사용되는 클래스 17 | NestedCheckedException : 체크예외를 랩핑하기 위한 편의성 클래스 18 | NestedRuntimeException : 런타임예외를 랩핑하기 위한 편의성 클래스 19 | OrderComparator : 순서있는 객체들을 위한 비교구현체 20 | (I) Ordered { getOrder() } : 순서가능한 오프젝트가 구현해야하는 인터페이스 예를 들자면 콜렉션 같은 21 | 22 | 보유 패키지 23 | io : 입출력에 관련된 패키지 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/AbstractControlFlowTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import junit.framework.TestCase; 20 | import org.junit.Test; 21 | 22 | import static org.junit.Assert.assertFalse; 23 | import static org.junit.Assert.assertTrue; 24 | 25 | /** 26 | * @author Rod Johnson 27 | * @version $Id: AbstractControlFlowTests.java,v 1.2 2004/03/18 03:01:13 trisberg Exp $ 28 | */ 29 | public abstract class AbstractControlFlowTests{ 30 | 31 | protected abstract ControlFlow createControlFlow(); 32 | 33 | /* 34 | * Class to test for boolean under(Class) 35 | */ 36 | @Test 37 | public void testUnderClassAndMethod() { 38 | System.out.println("testUnderClassAndMethod"); 39 | new One().test(); 40 | new Two().testing(); 41 | } 42 | 43 | /* 44 | public void testUnderPackage() { 45 | ControlFlow cflow = new ControlFlow(); 46 | assertFalse(cflow.underPackage("org.springframework.aop")); 47 | assertTrue(cflow.underPackage("org.springframework.aop.support")); 48 | assertFalse(cflow.underPackage("com.interface21")); 49 | } 50 | */ 51 | 52 | 53 | public class One { 54 | public void test() { 55 | ControlFlow cflow = createControlFlow(); 56 | assertTrue(cflow.under(One.class)); 57 | assertTrue(cflow.under(AbstractControlFlowTests.class)); 58 | assertFalse(cflow.under(Two.class)); 59 | assertTrue(cflow.under(One.class, "test")); 60 | assertFalse(cflow.under(One.class, "hashCode")); 61 | } 62 | 63 | } 64 | 65 | public class Two { 66 | public void testing() { 67 | ControlFlow cflow = createControlFlow(); 68 | assertTrue(cflow.under(Two.class)); 69 | assertTrue(cflow.under(AbstractControlFlowTests.class)); 70 | assertFalse(cflow.under(One.class)); 71 | assertFalse(cflow.under(Two.class, "test")); 72 | assertTrue(cflow.under(Two.class, "testing")); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/ConstantsTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.util.Set; 20 | 21 | import junit.framework.TestCase; 22 | import org.junit.Test; 23 | 24 | import static org.junit.Assert.assertEquals; 25 | import static org.junit.Assert.assertTrue; 26 | import static org.junit.Assert.fail; 27 | 28 | /** 29 | * @author Rod Johnson 30 | * @since 28-Apr-2003 31 | * @version $Revision: 1.2 $ 32 | */ 33 | public class ConstantsTests{ 34 | 35 | @Test 36 | public void propertyToConstantNamePrefix(){ 37 | Constants c = new Constants(A.class); 38 | 39 | String myPropertyNo = c.propertyToConstantNamePrefix("myPropertyNo"); 40 | assertEquals("MY_PROPERTY_NO", myPropertyNo); 41 | 42 | myPropertyNo = c.propertyToConstantNamePrefix("myPropertyNo1"); 43 | assertEquals("MY_PROPERTY_NO1", myPropertyNo); 44 | } 45 | 46 | 47 | @Test 48 | public void testConstants() { 49 | Constants c = new Constants(A.class); 50 | assertTrue(c.getSize() == 5); 51 | 52 | assertEquals(c.asNumber("DOG").intValue(), A.DOG); 53 | assertEquals(c.asNumber("dog").intValue(), A.DOG); 54 | assertEquals(c.asNumber("cat").intValue(), A.CAT); 55 | 56 | try { 57 | c.asNumber("bogus"); 58 | fail("Can't get bogus field"); 59 | } 60 | catch (ConstantException ex) { 61 | } 62 | 63 | assertTrue(c.asString("S1").equals(A.S1)); 64 | try { 65 | c.asNumber("S1"); 66 | fail("Wrong type"); 67 | } 68 | catch (ConstantException ex) { 69 | } 70 | 71 | Set values = c.getValues(""); 72 | assertEquals(5, values.size()); 73 | assertEquals(c.getSize(), values.size()); 74 | assertTrue(values.contains(Integer.valueOf(0))); 75 | assertTrue(values.contains(Integer.valueOf(66))); 76 | assertTrue(values.contains("")); 77 | 78 | values = c.getValues("D"); 79 | assertEquals(1, values.size()); 80 | assertTrue(values.contains(Integer.valueOf(0))); 81 | 82 | /** 83 | * public static final int MY_PROPERTY_NO = 1; 84 | * public static final int MY_PROPERTY_YES = 2; 85 | * 두개 리턴 86 | */ 87 | values = c.getValuesForProperty("myProperty"); 88 | assertEquals(2, values.size()); 89 | assertTrue(values.contains(Integer.valueOf(1))); 90 | assertTrue(values.contains(Integer.valueOf(2))); 91 | 92 | /** 93 | * toCode 는 첫번째 파라미터 값과 namePrefix 가 맞으면 필드명 리턴 94 | */ 95 | assertEquals(c.toCode(Integer.valueOf(0), ""), "DOG"); 96 | assertEquals(c.toCode(Integer.valueOf(0), "D"), "DOG"); 97 | assertEquals(c.toCode(Integer.valueOf(0), "DO"), "DOG"); 98 | assertEquals(c.toCode(Integer.valueOf(0), "DoG"), "DOG"); 99 | assertEquals(c.toCode(Integer.valueOf(66), ""), "CAT"); 100 | assertEquals(c.toCode(Integer.valueOf(66), "C"), "CAT"); 101 | assertEquals(c.toCode(Integer.valueOf(66), "ca"), "CAT"); 102 | assertEquals(c.toCode(Integer.valueOf(66), "cAt"), "CAT"); 103 | assertEquals(c.toCode("", ""), "S1"); 104 | assertEquals(c.toCode("", "s"), "S1"); 105 | assertEquals(c.toCode("", "s1"), "S1"); 106 | try { 107 | c.toCode("bogus", "bogus"); 108 | fail("Should have thrown ConstantException"); 109 | } 110 | catch (ConstantException ex) { 111 | // expected 112 | } 113 | 114 | /** 115 | * toCodeForProperty 는 Integer 값과 바뀐 필드명을 넣으면 실제 필드명 리턴 116 | */ 117 | assertEquals(c.toCodeForProperty(Integer.valueOf(1), "myProperty"), "MY_PROPERTY_NO"); 118 | assertEquals(c.toCodeForProperty(Integer.valueOf(2), "myProperty"), "MY_PROPERTY_YES"); 119 | try { 120 | c.toCodeForProperty("bogus", "bogus"); 121 | fail("Should have thrown ConstantException"); 122 | } 123 | catch (ConstantException ex) { 124 | // expected 125 | } 126 | } 127 | 128 | 129 | public static class A { 130 | 131 | public static final int DOG = 0; 132 | public static final int CAT = 66; 133 | public static final String S1 = ""; 134 | 135 | public static final int MY_PROPERTY_NO = 1; 136 | public static final int MY_PROPERTY_YES = 2; 137 | 138 | /** ignore these */ 139 | protected static final int P = -1; 140 | protected boolean f; 141 | static final Object o = new Object(); 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/DefaultControlFlowTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import org.junit.Ignore; 20 | import org.junit.Test; 21 | 22 | import static org.junit.Assert.assertEquals; 23 | 24 | /** 25 | * Tests with ControlFlowFactory return 26 | * @author Rod Johnson 27 | * @version $Id: DefaultControlFlowTests.java,v 1.2 2004/03/18 03:01:13 trisberg Exp $ 28 | */ 29 | public class DefaultControlFlowTests extends AbstractControlFlowTests { 30 | 31 | /** 32 | * Necessary only because 33 | * Eclipse won't run test suite unless it declares some methods 34 | * as well as inherited methods 35 | */ 36 | public void testThisClassPlease() { 37 | } 38 | 39 | public ControlFlow createControlFlow() { 40 | ControlFlow cf = ControlFlowFactory.createControlFlow(); 41 | return cf; 42 | } 43 | 44 | @Test 45 | @Ignore("Java version comparing is difficult") 46 | public void createControlFlowCustom() { 47 | ControlFlow cf = ControlFlowFactory.createControlFlow(); 48 | boolean is18 = System.getProperty("java.version").indexOf("1.8") != -1; 49 | assertEquals("Autodetection of JVM succeeded", is18, cf instanceof ControlFlowFactory.Jdk18ControlFlow); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/Jdk13ControlFlowTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import org.junit.Test; 20 | 21 | /** 22 | * Tests with ControlFlowFactory return. 23 | * @author Rod Johnson 24 | * @version $Id: Jdk13ControlFlowTests.java,v 1.2 2004/03/18 03:01:13 trisberg Exp $ 25 | */ 26 | public class Jdk13ControlFlowTests extends AbstractControlFlowTests { 27 | 28 | /** 29 | * Necessary only because Eclipse won't run test suite unless it declares 30 | * some methods as well as inherited methods 31 | */ 32 | @Test 33 | public void testThisClassPlease() { 34 | super.testUnderClassAndMethod(); 35 | } 36 | 37 | protected ControlFlow createControlFlow() { 38 | return new ControlFlowFactory.Jdk13ControlFlow(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/Jdk14ControlFlowTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import org.junit.Test; 20 | 21 | /** 22 | * Tests with ControlFlowFactory return. 23 | * @author Rod Johnson 24 | * @version $Id: Jdk14ControlFlowTests.java,v 1.2 2004/03/18 03:01:13 trisberg Exp $ 25 | */ 26 | public class Jdk14ControlFlowTests extends AbstractControlFlowTests { 27 | 28 | /** 29 | * Necessary only because Eclipse won't run test suite unless it declares 30 | * some methods as well as inherited methods 31 | */ 32 | @Test 33 | public void testThisClassPlease() { 34 | super.testUnderClassAndMethod(); 35 | } 36 | 37 | protected ControlFlow createControlFlow() { 38 | return new ControlFlowFactory.Jdk14ControlFlow(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/Jdk18ControlFlowTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.core; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * @author Lucas Choi 7 | */ 8 | public class Jdk18ControlFlowTests extends AbstractControlFlowTests{ 9 | 10 | 11 | @Override 12 | protected ControlFlow createControlFlow() { 13 | return new ControlFlowFactory.Jdk18ControlFlow(); 14 | } 15 | 16 | @Test 17 | public void testUnderClassAndMethod() { 18 | System.out.println("testUnderClassAndMethod"); 19 | super.testUnderClassAndMethod(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/core/NestedCheckedExceptionTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2004 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.core; 18 | 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.PrintWriter; 21 | 22 | import javax.servlet.ServletException; 23 | 24 | import junit.framework.TestCase; 25 | 26 | /** 27 | * 28 | * @author Rod Johnson 29 | * @version $Id: NestedCheckedExceptionTests.java,v 1.3 2004/03/18 03:01:13 trisberg Exp $ 30 | */ 31 | public class NestedCheckedExceptionTests extends TestCase { 32 | 33 | public void testNoRootCause() { 34 | String mesg = "mesg of mine"; 35 | // Making a class abstract doesn't _really_ prevent instantiation :-) 36 | NestedCheckedException nce = new NestedCheckedException(mesg) {}; 37 | assertNull(nce.getCause()); 38 | assertEquals(nce.getMessage(), mesg); 39 | 40 | // Check PrintStackTrace 41 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 42 | PrintWriter pw = new PrintWriter(baos); 43 | nce.printStackTrace(pw); 44 | pw.flush(); 45 | String stackTrace = new String(baos.toByteArray()); 46 | assertFalse(stackTrace.indexOf(mesg) == -1); 47 | } 48 | 49 | public void testRootCause() { 50 | String myMessage = "mesg for this exception"; 51 | String rootCauseMesg = "this is the obscure message of the root cause"; 52 | ServletException rootCause = new ServletException(rootCauseMesg); 53 | // Making a class abstract doesn't _really_ prevent instantiation :-) 54 | NestedCheckedException nce = new NestedCheckedException(myMessage, rootCause) {}; 55 | assertEquals(nce.getCause(), rootCause); 56 | assertTrue(nce.getMessage().indexOf(myMessage) != -1); 57 | assertTrue(nce.getMessage().indexOf(rootCauseMesg) != -1); 58 | 59 | // Check PrintStackTrace 60 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 61 | PrintWriter pw = new PrintWriter(baos); 62 | nce.printStackTrace(pw); 63 | pw.flush(); 64 | String stackTrace = new String(baos.toByteArray()); 65 | assertFalse(stackTrace.indexOf(rootCause.getClass().getName()) == -1); 66 | assertFalse(stackTrace.indexOf(rootCauseMesg) == -1); 67 | } 68 | 69 | } 70 | --------------------------------------------------------------------------------