Skip to content

Instantly share code, notes, and snippets.

@FrankieFeng
Created May 6, 2019 12:16
Show Gist options
  • Save FrankieFeng/27d2b106af25782388ae33118046c5f6 to your computer and use it in GitHub Desktop.
Save FrankieFeng/27d2b106af25782388ae33118046c5f6 to your computer and use it in GitHub Desktop.
Exercises at ordinary time,including distributed lock,sword to offer etc.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="FycSpringTest" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="FycSpringTest" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.7.0">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.core:jackson-core:2.7.9">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-core/2.7.9/jackson-core-2.7.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-core/2.7.9/jackson-core-2.7.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-core/2.7.9/jackson-core-2.7.9-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.core:jackson-databind:2.7.9">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-databind/2.7.9/jackson-databind-2.7.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-databind/2.7.9/jackson-databind-2.7.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/core/jackson-databind/2.7.9/jackson-databind-2.7.9-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.7.9">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.7.9/jackson-dataformat-yaml-2.7.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.7.9/jackson-dataformat-yaml-2.7.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.7.9/jackson-dataformat-yaml-2.7.9-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: com.google.guava:guava:20.0">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/com/google/guava/guava/20.0/guava-20.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/com/google/guava/guava/20.0/guava-20.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/com/google/guava/guava/20.0/guava-20.0-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.netty:netty-buffer:4.1.13.Final">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-buffer/4.1.13.Final/netty-buffer-4.1.13.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-buffer/4.1.13.Final/netty-buffer-4.1.13.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-buffer/4.1.13.Final/netty-buffer-4.1.13.Final-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.netty:netty-codec:4.1.13.Final">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-codec/4.1.13.Final/netty-codec-4.1.13.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-codec/4.1.13.Final/netty-codec-4.1.13.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-codec/4.1.13.Final/netty-codec-4.1.13.Final-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.netty:netty-common:4.1.13.Final">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-common/4.1.13.Final/netty-common-4.1.13.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-common/4.1.13.Final/netty-common-4.1.13.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-common/4.1.13.Final/netty-common-4.1.13.Final-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.netty:netty-handler:4.1.13.Final">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-handler/4.1.13.Final/netty-handler-4.1.13.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-handler/4.1.13.Final/netty-handler-4.1.13.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-handler/4.1.13.Final/netty-handler-4.1.13.Final-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.netty:netty-resolver:4.1.13.Final">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-resolver/4.1.13.Final/netty-resolver-4.1.13.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-resolver/4.1.13.Final/netty-resolver-4.1.13.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-resolver/4.1.13.Final/netty-resolver-4.1.13.Final-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.netty:netty-transport:4.1.13.Final">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-transport/4.1.13.Final/netty-transport-4.1.13.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-transport/4.1.13.Final/netty-transport-4.1.13.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/netty/netty-transport/4.1.13.Final/netty-transport-4.1.13.Final-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.projectreactor:reactor-core:2.0.8.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/projectreactor/reactor-core/2.0.8.RELEASE/reactor-core-2.0.8.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/projectreactor/reactor-core/2.0.8.RELEASE/reactor-core-2.0.8.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/projectreactor/reactor-core/2.0.8.RELEASE/reactor-core-2.0.8.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: io.projectreactor:reactor-stream:2.0.8.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/io/projectreactor/reactor-stream/2.0.8.RELEASE/reactor-stream-2.0.8.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/io/projectreactor/reactor-stream/2.0.8.RELEASE/reactor-stream-2.0.8.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/io/projectreactor/reactor-stream/2.0.8.RELEASE/reactor-stream-2.0.8.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: javax.cache:cache-api:1.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/javax/cache/cache-api/1.0.0/cache-api-1.0.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/javax/cache/cache-api/1.0.0/cache-api-1.0.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/javax/cache/cache-api/1.0.0/cache-api-1.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: joda-time:joda-time:2.9">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/joda-time/joda-time/2.9/joda-time-2.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/joda-time/joda-time/2.9/joda-time-2.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/joda-time/joda-time/2.9/joda-time-2.9-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: junit:junit:4.7">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/junit/junit/4.7/junit-4.7.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/junit/junit/4.7/junit-4.7-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/junit/junit/4.7/junit-4.7-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: net.bytebuddy:byte-buddy:1.6.14">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/net/bytebuddy/byte-buddy/1.6.14/byte-buddy-1.6.14.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/net/bytebuddy/byte-buddy/1.6.14/byte-buddy-1.6.14-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/net/bytebuddy/byte-buddy/1.6.14/byte-buddy-1.6.14-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: net.openhft:zero-allocation-hashing:0.8">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/net/openhft/zero-allocation-hashing/0.8/zero-allocation-hashing-0.8.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/net/openhft/zero-allocation-hashing/0.8/zero-allocation-hashing-0.8-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/net/openhft/zero-allocation-hashing/0.8/zero-allocation-hashing-0.8-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.aspectj:aspectjweaver:1.8.9">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.jodd:jodd-bean:3.7.1">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/jodd/jodd-bean/3.7.1/jodd-bean-3.7.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/jodd/jodd-bean/3.7.1/jodd-bean-3.7.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/jodd/jodd-bean/3.7.1/jodd-bean-3.7.1-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.jodd:jodd-core:3.7.1">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/jodd/jodd-core/3.7.1/jodd-core-3.7.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/jodd/jodd-core/3.7.1/jodd-core-3.7.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/jodd/jodd-core/3.7.1/jodd-core-3.7.1-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.projectlombok:lombok:1.16.4">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/projectlombok/lombok/1.16.4/lombok-1.16.4.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/projectlombok/lombok/1.16.4/lombok-1.16.4-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/projectlombok/lombok/1.16.4/lombok-1.16.4-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.reactivestreams:reactive-streams:1.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/reactivestreams/reactive-streams/1.0.0/reactive-streams-1.0.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/reactivestreams/reactive-streams/1.0.0/reactive-streams-1.0.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/reactivestreams/reactive-streams/1.0.0/reactive-streams-1.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.redisson:redisson:2.10.0">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/redisson/redisson/2.10.0/redisson-2.10.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/redisson/redisson/2.10.0/redisson-2.10.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/redisson/redisson/2.10.0/redisson-2.10.0-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.slf4j:slf4j-api:1.7.21">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.springframework:spring-aop:4.3.7.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.springframework:spring-beans:4.3.7.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.springframework:spring-context:4.3.7.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.springframework:spring-core:4.3.7.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.springframework:spring-expression:4.3.7.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.springframework:spring-test:4.3.7.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-test/4.3.7.RELEASE/spring-test-4.3.7.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-test/4.3.7.RELEASE/spring-test-4.3.7.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/springframework/spring-test/4.3.7.RELEASE/spring-test-4.3.7.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Maven: org.yaml:snakeyaml:1.15">
<CLASSES>
<root url="jar://$USER_HOME$/maven/repository/org/yaml/snakeyaml/1.15/snakeyaml-1.15.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/maven/repository/org/yaml/snakeyaml/1.15/snakeyaml-1.15-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/maven/repository/org/yaml/snakeyaml/1.15/snakeyaml-1.15-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="libraryTable">
<library name="Spring-4.3.13.RELEASE" type="spring">
<properties version="4.3.13.RELEASE" />
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/spring-aspects-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-context-support-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-aop-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-expression-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-instrument-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-beans-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-instrument-tomcat-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-jms-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-context-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-jdbc-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-oxm-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-core-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-messaging-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/commons-logging-1.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/aopalliance-1.0.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-orm-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-tx-4.3.13.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/spring-test-4.3.13.RELEASE.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.ideaLibSources/spring-context-4.3.13.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/FycSpringTest.iml" filepath="$PROJECT_DIR$/FycSpringTest.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration>
<fileset id="fileset" name="Spring Application Context" removed="false">
<file>file://$MODULE_DIR$/src/spring-config.xml</file>
</fileset>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Spring-4.3.13.RELEASE" level="project" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.4" level="project" />
<orderEntry type="library" name="Maven: org.redisson:redisson:2.10.0" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.13.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.13.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.13.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.13.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.13.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.13.Final" level="project" />
<orderEntry type="library" name="Maven: javax.cache:cache-api:1.0.0" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-stream:2.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:2.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.21" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.7.9" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.7.9" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.7.9" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.7.0" level="project" />
<orderEntry type="library" name="Maven: net.openhft:zero-allocation-hashing:0.8" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.6.14" level="project" />
<orderEntry type="library" name="Maven: org.jodd:jodd-bean:3.7.1" level="project" />
<orderEntry type="library" name="Maven: org.jodd:jodd-core:3.7.1" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.9" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.7" level="project" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fengyuchen.project</groupId>
<artifactId>FycSpringTest</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3_mod</version>
<configuration>
<packagingExcludes>
WEB-INF/lib/servlet-api-2.4.jar
WEB-INF/lib/xalan-2.6.0.jar
</packagingExcludes>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<spring.version>4.3.7.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.4</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
package com.abstractclass.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-21 14:28
* @modified :
**/
public interface iquery {
void doSomeThing();
}
package com.abstractclass.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-21 14:31
* @modified :
**/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/spring-config.xml")
public class TemlateTest {
@Autowired
iquery templateson;
@Test
public void testWork(){
templateson.doSomeThing();
}
}
package com.abstractclass.test;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-21 14:26
* @modified :
**/
public abstract class template implements iquery{
@Override
public void doSomeThing() {
work();
}
protected abstract void work();
}
package com.abstractclass.test;
import org.springframework.stereotype.Service;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-21 14:27
* @modified :
**/
@Service
public class templategrandson extends templateson {
@Override
public void work() {
System.out.println("i am template grandson");
}
}
package com.abstractclass.test;
import org.springframework.stereotype.Service;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-21 14:27
* @modified :
**/
@Service
public class templateson extends template {
@Override
protected void work() {
System.out.println("i am template son ");
}
}
package com.annotation.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午5:23
* @modified :
**/
/**
* 注解使用
*/
public class Apple {
@FruitName()
private String appleName;
@FruitColor(fruitColor = FruitColor.Color.RED)
private String appleColor;
private String appleProvider;
public void setAppleColor(String appleColor) {
this.appleColor = appleColor;
}
public String getAppleColor() {
return appleColor;
}
@FruitProvider(id=1,name="陕西红富士集团",address="陕西省西安市延安路89号红富士大厦")
public void setAppleName(String appleName) {
this.appleName = appleName;
}
public String getAppleName() {
return appleName;
}
public void setAppleProvider(String appleProvider) {
this.appleProvider = appleProvider;
}
public String getAppleProvider() {
return appleProvider;
}
public void displayName(){
System.out.println("水果的名字是:苹果");
}
}
package com.annotation.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午5:24
* @modified :
**/
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 水果颜色注解
*/
@Target(FIELD)
@Retention(RUNTIME)
@Documented
public @interface FruitColor {
/**
* 颜色枚举
*/
public enum Color{ BLUE,RED,GREEN};
/**
* 颜色属性
*/
Color fruitColor() default Color.GREEN;
}
package com.annotation.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午5:24
* @modified :
**/
import com.cache.test.RedisLockAspect;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* 注解处理器
*/
public class FruitInfoUtil {
public static void getFruitInfo(Class clazz){
String strFruitName=" 水果名称:";
String strFruitColor=" 水果颜色:";
String strFruitProvicer="供应商信息:";
Field[] fields = clazz.getDeclaredFields();
for(Field field :fields){
if(field.isAnnotationPresent(FruitName.class)){
FruitName fruitName = (FruitName) field.getAnnotation(FruitName.class);
strFruitName=strFruitName+fruitName.value();
System.out.println(strFruitName);
}
else if(field.isAnnotationPresent(FruitColor.class)){
FruitColor fruitColor= (FruitColor) field.getAnnotation(FruitColor.class);
strFruitColor=strFruitColor+fruitColor.fruitColor().toString();
System.out.println(strFruitColor);
}
else if(field.isAnnotationPresent(FruitProvider.class)){
FruitProvider fruitProvider= (FruitProvider) field.getAnnotation(FruitProvider.class);
strFruitProvicer=" 供应商编号:"+fruitProvider.id()+" 供应商名称:"+fruitProvider.name()+" 供应商地址:"+fruitProvider.address();
System.out.println(strFruitProvicer);
}
}
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(FruitColor.class)){
// FruitProvider fruitProvider= (FruitProvider) methods.equals(FruitProvider.class);
System.out.println();
}
}
}
public static void main(String[] args) {
Apple a = new Apple();
getFruitInfo(Apple.class);
RedisLockAspect redisLockAspect = new RedisLockAspect();
System.out.println(redisLockAspect);
}
}
package com.annotation.test;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午5:20
* @modified :
**/
@Target(FIELD)
@Retention(RUNTIME)
@Documented
public @interface FruitName {
String value() default "apple 苹果";
}
package com.annotation.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午5:22
* @modified :
**/
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 水果供应者注解
*/
@Target(METHOD)
@Retention(RUNTIME)
@Documented
public @interface FruitProvider {
/**
* 供应商编号
*/
public int id() default -1;
/**
* 供应商名称
*/
public String name() default "";
/**
* 供应商地址
*/
public String address() default "";
}
package com.bytesopration.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-25 20:22
* @modified :
**/
public class bytestest {
public static void main(String[] args) {
System.out.println(12 & 129);
System.out.println(128 ^ 129);
System.out.println(128 | 130);
}
}
package com.cache.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.concurrent.TimeUnit;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-31 11:23
* @modified :
**/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring-config.xml")
public class AOPTest {
@Autowired
LockTest lockTest;
@Test
public void testDistLockAop() throws InterruptedException {
for (int i = 0; i < 100; i++) {
new Thread(() -> {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
lockTest.add("***********testDistLockAop", 99);
}).start();
}
TimeUnit.SECONDS.sleep(20);
}
@Test
public void testDistLock() throws InterruptedException {
lockTest.add("============testDistLock", 111111);
TimeUnit.SECONDS.sleep(10);
}
}
package com.cache.test;
import org.springframework.stereotype.Component;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-31 11:23
* @modified :
**/
@Component
public class LockTest {
private static int i = 0;
@RedisLock(lockKey = "lockKey" ,keepMills = 5*10000 )
public void add(@RedisLockKey(order = 1) String key,
@RedisLockKey(order = 0) int key1) {
i++;
System.out.println("i=***************************************" + i);
}
}
package com.cache.test;
import java.lang.annotation.*;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-31 11:02
* @modified :
**/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface RedisLock {
/**
*   * 锁的key
*   * 如果想添加非固定锁,可以在参数上添加@P4jSynKey注解,但是本参数是必写选项<br/>
*   * redis key的拼写规则为 "DistRedisLock+" + lockKey + @RedisLOckKey<br/>
*  
*/
String lockKey();
/**
*   * 持锁时间
*   * 单位毫秒,默认5秒<br/>
*  
*/
long keepMills() default 5 * 1000;
/**
*   * 没有获取到锁时,等待时间
*   * @return
*  
*/
long maxSleepMills() default 120 * 1000;
}
package com.cache.test;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-31 11:03
* @modified :
**/
@Component
@Aspect
public class RedisLockAspect {
private static Logger logger = LoggerFactory.getLogger(RedisLockAspect.class);
@Value("redis://10.237.78.33:6379")
String address;
@Around("execution(* com.cache.test..*(..))&& @annotation(RedisLock)")
public Object lock(ProceedingJoinPoint point) throws Throwable {
RLock lock = null;
Object object = null;
logger.info("into Aspect!");
try {
RedisLock redisLock = getDistRedisLockInfo(point);
RedisUtils redisUtils = RedisUtils.getInstance();
RedissonClient redissonClient = redisUtils.createClient(address, null);
String lockKey = redisUtils.getLockKey(point, redisLock.lockKey());
lock = redisUtils.getRLock(redissonClient, lockKey);
if (lock != null) {
Boolean status = lock.tryLock(redisLock.maxSleepMills(), redisLock.keepMills(), TimeUnit.MILLISECONDS);
if (status) {
object = point.proceed();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (lock != null) {
lock.unlock();
}
}
return object;
}
private RedisLock getDistRedisLockInfo(ProceedingJoinPoint point) {
try {
MethodSignature methodSignature = (MethodSignature) point.getSignature();
Method method = methodSignature.getMethod();
return method.getAnnotation(RedisLock.class);
} catch (Exception e) {
logger.info(e.getMessage());
}
return null;
}
}
package com.cache.test;
import java.lang.annotation.*;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-31 11:02
* @modified :
**/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface RedisLockKey {
/**
*   * key的拼接顺序规则
*  
*/
int order() default 0;
}
package com.cache.test;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.redisson.Redisson;
import org.redisson.api.*;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.annotation.Annotation;
import java.util.SortedMap;
import java.util.TreeMap;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-31 09:42
* @modified :
**/
public class RedisUtils {
private static Logger logger = LoggerFactory.getLogger(RedisUtils.class);
private static RedisUtils redisUtils;
private static RedissonClient redissonClient;
private RedisUtils() {
}
/**
* 提供单例模式
*
* @return
*/
public static RedisUtils getInstance() {
if (redisUtils == null)
synchronized (RedisUtils.class) {
if (redisUtils == null) redisUtils = new RedisUtils();
}
return redisUtils;
}
/**
* 使用config创建Redisson
* Redisson是用于连接Redis Server的基础类
*
* @param config
* @return
*/
public static RedissonClient getRedisson(Config config) {
RedissonClient redisson = Redisson.create(config);
logger.info("成功连接Redis Server");
return redisson;
}
/**
* 使用ip地址和端口创建Redisson
*
* @param ip
* @param port
* @return
*/
public static RedissonClient getRedisson(String ip, String port) {
Config config = new Config();
config.useSingleServer().setAddress(ip + ":" + port);
RedissonClient redisson = Redisson.create(config);
logger.info("成功连接Redis Server" + "\t" + "连接" + ip + ":" + port + "服务器");
return redisson;
}
/**
* 关闭Redisson客户端连接
*
* @param redisson
*/
public static void closeRedisson(RedissonClient redisson) {
redisson.shutdown();
logger.info("成功关闭Redis Client连接");
}
/**
* 获取字符串对象
*
* @param redisson
* @param objectName
* @return
*/
public static <T> RBucket<T> getRBucket(RedissonClient redisson, String objectName) {
RBucket<T> bucket = redisson.getBucket(objectName);
return bucket;
}
/**
* 获取Map对象
*
* @param redisson
* @param objectName
* @return
*/
public static <K, V> RMap<K, V> getRMap(RedissonClient redisson, String objectName) {
RMap<K, V> map = redisson.getMap(objectName);
return map;
}
/**
* 获取有序集合
*
* @param redisson
* @param objectName
* @return
*/
public static <V> RSortedSet<V> getRSortedSet(RedissonClient redisson, String objectName) {
RSortedSet<V> sortedSet = redisson.getSortedSet(objectName);
return sortedSet;
}
/**
* 获取集合
*
* @param redisson
* @param objectName
* @return
*/
public static <V> RSet<V> getRSet(RedissonClient redisson, String objectName) {
RSet<V> rSet = redisson.getSet(objectName);
return rSet;
}
/**
* 获取列表
*
* @param redisson
* @param objectName
* @return
*/
public static <V> RList<V> getRList(RedissonClient redisson, String objectName) {
RList<V> rList = redisson.getList(objectName);
return rList;
}
/**
* 获取队列
*
* @param redisson
* @param objectName
* @return
*/
public <V> RQueue<V> getRQueue(RedissonClient redisson, String objectName) {
RQueue<V> rQueue = redisson.getQueue(objectName);
return rQueue;
}
/**
* 获取双端队列
*
* @param redisson
* @param objectName
* @return
*/
public static <V> RDeque<V> getRDeque(RedissonClient redisson, String objectName) {
RDeque<V> rDeque = redisson.getDeque(objectName);
return rDeque;
}
/**
* 此方法不可用在Redisson 1.2 中
* 在1.2.2版本中可用
*
* @param redisson
* @param objectName
* @return
*/
public static <V> RBlockingQueue<V> getRBlockingQueue(RedissonClient redisson, String objectName) {
RBlockingQueue rb = redisson.getBlockingQueue(objectName);
return rb;
}
/**
* 获取锁
*
* @param redisson
* @param objectName
* @return
*/
public static RLock getRLock(RedissonClient redisson, String objectName) {
RLock rLock = redisson.getLock(objectName);
return rLock;
}
/**
* 获取原子数
*
* @param redisson
* @param objectName
* @return
*/
public static RAtomicLong getRAtomicLong(RedissonClient redisson, String objectName) {
RAtomicLong rAtomicLong = redisson.getAtomicLong(objectName);
return rAtomicLong;
}
/**
* 获取记数锁
*
* @param redisson
* @param objectName
* @return
*/
public static RCountDownLatch getRCountDownLatch(RedissonClient redisson, String objectName) {
RCountDownLatch rCountDownLatch = redisson.getCountDownLatch(objectName);
return rCountDownLatch;
}
/**
* 获取消息的Topic
*
* @param redisson
* @param objectName
* @return
*/
public static <M> RTopic<M> getRTopic(RedissonClient redisson, String objectName) {
RTopic<M> rTopic = redisson.getTopic(objectName);
return rTopic;
}
/**
* 获取包括方法参数上的key
* redis key的拼写规则为 "DistRedisLock+" + lockKey + @DistRedisLockKey<br/>
*
* @param point
* @param lockKey
* @return
*/
public static String getLockKey(ProceedingJoinPoint point, String lockKey) {
try {
String res = "DistRedisLock:" + lockKey;
Object[] args = point.getArgs();
if (args != null && args.length > 0) {
MethodSignature methodSignature = (MethodSignature) point.getSignature();
Annotation[][] parameterAnnotations = methodSignature.getMethod().getParameterAnnotations();
SortedMap<Integer, String> keys = new TreeMap<>();
for (int i = 0; i < parameterAnnotations.length; i++) {
RedisLockKey redisLockKey = getAnnotation(RedisLockKey.class, parameterAnnotations[i]);
if (redisLockKey != null) {
Object arg = args[i];
if (arg != null) {
keys.put(redisLockKey.order(), arg.toString());
}
}
}
if (keys != null && keys.size() > 0) {
for (String key : keys.values()) {
res += key;
}
}
}
return res;
} catch (Exception e) {
logger.error("getLockKey error.", e);
}
return null;
}
/**
* 获取注解类型
*
* @param annotationClass
* @param annotations
* @param <T>
* @return
*/
private static <T extends Annotation> T getAnnotation(final Class<T> annotationClass, final Annotation[] annotations) {
if (annotations != null && annotations.length > 0) {
for (final Annotation annotation : annotations) {
if (annotationClass.equals(annotation.annotationType())) {
return (T) annotation;
}
}
}
return null;
}
public static RedissonClient createClient(String address, String pass) {
if (redissonClient == null) {
synchronized (RedisUtils.class) {
if (redissonClient == null) {
Config config = new Config();
SingleServerConfig singleSerververConfig = config.useSingleServer();
singleSerververConfig.setAddress(address);
singleSerververConfig.setPassword(pass);
redissonClient = RedisUtils.getInstance().getRedisson(config);
}
}
}
return redissonClient;
}
}
package com.guava.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/7/2 下午8:04
* @modified :
**/
public class ArithHelper {
// 默认除法运算精度
private static final int DEF_DIV_SCALE = 16;
// 这个类不能实例化
private ArithHelper() {
}
/**
* 提供精确的加法运算。
*
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
public static double add(String v1, String v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
return b1.add(b2).doubleValue();
}
/**
* 提供精确的减法运算。
*
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public static double sub(double v1, double v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
public static double sub(String v1, String v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
return b1.subtract(b2).doubleValue();
}
/**
* 提供精确的乘法运算。
*
* @param v1
* 被乘数
* @param v2
* 乘数
* @return 两个参数的积
*/
public static double mul(double v1, double v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
}
public static double mul(String v1, String v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
return b1.multiply(b2).doubleValue();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
*
* @param v1
* 被除数
* @param v2
* 除数
* @return 两个参数的商
*/
public static double div(double v1, double v2) {
return div(v1, v2, DEF_DIV_SCALE);
}
public static double div(String v1, String v2) {
java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
return b1.divide(b2, DEF_DIV_SCALE, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
*
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public static double div(double v1, double v2, int scale) {
if (scale < 0) {
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
return b1.divide(b2, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 提供精确的小数位四舍五入处理。
*
* @param v 需要四舍五入的数字
* @param scale 小数点后保留几位
* @return 四舍五入后的结果
*/
public static double round(double v, int scale) {
if (scale < 0) {
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
java.math.BigDecimal b = new java.math.BigDecimal(Double.toString(v));
java.math.BigDecimal one = new java.math.BigDecimal("1");
return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static double round(String v, int scale) {
if (scale < 0) {
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
java.math.BigDecimal b = new java.math.BigDecimal(v);
java.math.BigDecimal one = new java.math.BigDecimal("1");
return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
}
}
package com.guava.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/7/2 下午8:08
* @modified :
**/
import java.util.Collections;
import java.util.Stack;
/**
* 算数表达式求值
* 直接调用Calculator的类方法conversion()
* 传入算数表达式,将返回一个浮点值结果
* 如果计算过程错误,将返回一个NaN
*/
public class Calculator {
private Stack<String> postfixStack = new Stack<String>();// 后缀式栈
private Stack<Character> opStack = new Stack<Character>();// 运算符栈
private int[] operatPriority = new int[] { 0, 3, 2, 1, -1, 1, 0, 2 };// 运用运算符ASCII码-40做索引的运算符优先级
public static double conversion(String expression) {
double result = 0;
Calculator cal = new Calculator();
try {
expression = transform(expression);
result = cal.calculate(expression);
} catch (Exception e) {
e.printStackTrace();
// 运算错误返回NaN
return 0.0 / 0.0;
}
// return new String().valueOf(result);
return result;
}
/**
* 将表达式中负数的符号更改
*
* @param expression
* 例如-2+-1*(-3E-2)-(-1) 被转为 ~2+~1*(~3E~2)-(~1)
* @return
*/
private static String transform(String expression) {
char[] arr = expression.toCharArray();
for (int i = 0; i < arr.length; i++) {
if (arr[i] == '-') {
if (i == 0) {
arr[i] = '~';
} else {
char c = arr[i - 1];
if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == 'E' || c == 'e') {
arr[i] = '~';
}
}
}
}
if(arr[0]=='~'||arr[1]=='('){
arr[0]='-';
return "0"+new String(arr);
}else{
return new String(arr);
}
}
/**
* 按照给定的表达式计算
*
* @param expression
* 要计算的表达式例如:5+12*(3+5)/7
* @return
*/
public double calculate(String expression) {
Stack<String> resultStack = new Stack<String>();
prepare(expression);
Collections.reverse(postfixStack);// 将后缀式栈反转
String firstValue, secondValue, currentValue;// 参与计算的第一个值,第二个值和算术运算符
while (!postfixStack.isEmpty()) {
currentValue = postfixStack.pop();
if (!isOperator(currentValue.charAt(0))) {// 如果不是运算符则存入操作数栈中
currentValue = currentValue.replace("~", "-");
resultStack.push(currentValue);
} else {// 如果是运算符则从操作数栈中取两个值和该数值一起参与运算
secondValue = resultStack.pop();
firstValue = resultStack.pop();
// 将负数标记符改为负号
firstValue = firstValue.replace("~", "-");
secondValue = secondValue.replace("~", "-");
String tempResult = calculate(firstValue, secondValue, currentValue.charAt(0));
resultStack.push(tempResult);
}
}
return Double.valueOf(resultStack.pop());
}
/**
* 数据准备阶段将表达式转换成为后缀式栈
*
* @param expression
*/
private void prepare(String expression) {
opStack.push(',');// 运算符放入栈底元素逗号,此符号优先级最低
char[] arr = expression.toCharArray();
int currentIndex = 0;// 当前字符的位置
int count = 0;// 上次算术运算符到本次算术运算符的字符的长度便于或者之间的数值
char currentOp, peekOp;// 当前操作符和栈顶操作符
for (int i = 0; i < arr.length; i++) {
currentOp = arr[i];
if (isOperator(currentOp)) {// 如果当前字符是运算符
if (count > 0) {
postfixStack.push(new String(arr, currentIndex, count));// 取两个运算符之间的数字
}
peekOp = opStack.peek();
if (currentOp == ')') {// 遇到反括号则将运算符栈中的元素移除到后缀式栈中直到遇到左括号
while (opStack.peek() != '(') {
postfixStack.push(String.valueOf(opStack.pop()));
}
opStack.pop();
} else {
while (currentOp != '(' && peekOp != ',' && compare(currentOp, peekOp)) {
postfixStack.push(String.valueOf(opStack.pop()));
peekOp = opStack.peek();
}
opStack.push(currentOp);
}
count = 0;
currentIndex = i + 1;
} else {
count++;
}
}
if (count > 1 || (count == 1 && !isOperator(arr[currentIndex]))) {// 最后一个字符不是括号或者其他运算符的则加入后缀式栈中
postfixStack.push(new String(arr, currentIndex, count));
}
while (opStack.peek() != ',') {
postfixStack.push(String.valueOf(opStack.pop()));// 将操作符栈中的剩余的元素添加到后缀式栈中
}
}
/**
* 判断是否为算术符号
*
* @param c
* @return
*/
private boolean isOperator(char c) {
return c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')';
}
/**
* 利用ASCII码-40做下标去算术符号优先级
*
* @param cur
* @param peek
* @return
*/
public boolean compare(char cur, char peek) {// 如果是peek优先级高于cur,返回true,默认都是peek优先级要低
boolean result = false;
if (operatPriority[(peek) - 40] >= operatPriority[(cur) - 40]) {
result = true;
}
return result;
}
/**
* 按照给定的算术运算符做计算
*
* @param firstValue
* @param secondValue
* @param currentOp
* @return
*/
private String calculate(String firstValue, String secondValue, char currentOp) {
String result = "";
switch (currentOp) {
case '+':
result = String.valueOf(ArithHelper.add(firstValue, secondValue));
break;
case '-':
result = String.valueOf(ArithHelper.sub(firstValue, secondValue));
break;
case '*':
result = String.valueOf(ArithHelper.mul(firstValue, secondValue));
break;
case '/':
result = String.valueOf(ArithHelper.div(firstValue, secondValue));
break;
}
return result;
}
}
package com.guava.test;
import com.google.common.collect.Lists;
import com.google.common.graph.Graph;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.Graphs;
import com.google.common.graph.MutableGraph;
import lombok.ToString;
import java.util.*;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-26 15:02
* @modified :
**/
public class GraphTest {
public static void main(String[] args) {
Graph <Node> graph = GraphBuilder.directed().build();
List<Node> list = new ArrayList<>();
for (int i = 0; i < 6; i++) {
Node n = new Node(String.valueOf(i),i);
((MutableGraph<Node>) graph).addNode(n);
list.add(n);
}
((MutableGraph<Node>) graph).putEdge(list.get(0),list.get(1));
((MutableGraph<Node>) graph).putEdge(list.get(0),list.get(2));
((MutableGraph<Node>) graph).putEdge(list.get(1),list.get(3));
((MutableGraph<Node>) graph).putEdge(list.get(1),list.get(4));
((MutableGraph<Node>) graph).putEdge(list.get(2),list.get(4));
((MutableGraph<Node>) graph).putEdge(list.get(4),list.get(5));
((MutableGraph<Node>) graph).putEdge(list.get(3),list.get(5));
Map<Node, Boolean> visited = new HashMap<>();
List<List<Node>> allPaths = new ArrayList<>();
List<Node> temp = new ArrayList<>();
dfs(graph,list.get(0),list.get(5),visited,allPaths,temp);
for (List<Node> allPath : allPaths) {
System.out.println(allPath);
}
}
/**
* 回溯法dfs
*/
private static void dfsFindPaths(Graph<Node> graph, Node cur, Node dest, Map<Node, Boolean> visited,
List<List<Node>> allPaths, List<Node> temp){
visited.put(cur, true);
temp.add(cur);
if (cur.getNum() == dest.getNum()){
allPaths.add(Lists.newArrayList(temp.iterator()));
}else {
for (Node next : graph.successors(cur)){
if (visited.get(next) == null || !visited.get(next))
dfsFindPaths(graph, next, dest, visited, allPaths, temp);
}
}
visited.put(cur, false);
temp.remove(temp.size() - 1);
}
private static void dfs(Graph<Node> graph, Node cur, Node dest, Map<Node, Boolean> visited,
List<List<Node>> allPaths, List<Node> temp){
visited.put(cur,true);
temp.add(cur);
System.out.println("访问 " + cur);
for (Node successor : graph.successors(cur)) {
if (visited.get(successor) == null || !visited.get(successor))
dfs(graph, successor, dest, visited, allPaths, temp);
}
temp.remove(temp.size() - 1);
}
private static void dfsNoRecur(Graph<Node> graph, Node cur, Node dest, Map<Node, Boolean> visited,
List<List<Node>> allPaths, List<Node> temp){
Stack<Node> stack = new Stack<>();
Node x = cur;
stack.push(x);
while (!stack.isEmpty()){
Node next = graph.successors(stack.peek()).iterator().next();
if (visited.get(next) == null || !visited.get(next)){
visited.put(next,true);
stack.push(next);
} else {
x = stack.peek();
}
}
}
@ToString
static class Node{
public Node(String s, int i) {
this.value = s;
this.num = i;
}
String value;
int num;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
}
package com.guava.test;
import com.google.common.base.*;
import com.google.common.collect.*;
import com.google.common.primitives.Ints;
import javax.sql.rowset.Predicate;
import java.util.*;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/6/5 下午4:59
* @modified :
**/
public class GuavaTest {
public static void main(String[] args) {
// String a = MoreObjects.toStringHelper("MyObject")
// .add("x", 1).add("c", 2)
// .toString();
// System.out.println(a);
//mutimap
Multimap<String, String> map = HashMultimap.create();
map.put("PEK", "CA1501");
map.put("SHA", "CA1502");
map.put("PEK", "CA1506");
map.put("PEK", "CA1508");
map.put("PEK", "CA1501");
map.put("SHA", "CA1502");
map.put("PEK", "CA1506");
map.put("PEK", "CA1508");
System.out.println(map);
//HashMap
Map<String, String> Hashmap = new HashMap<String, String>();
Hashmap.put("PEK", "CA1501");
Hashmap.put("SHA", "CA1502");
Hashmap.put("PEK", "CA1506");
Hashmap.put("PEK", "CA1508");
System.out.println(Hashmap);
//BiMap
BiMap<String, String> biMap = HashBiMap.create();
biMap.put("PEK", "CA1501");
biMap.put("SHA", "CA1502");
//value can not repeat must ues forceput
biMap.forcePut("PVG", "CA1501");
System.out.println(biMap);
//get key by value
System.out.println(biMap.inverse().get("CA1501"));
//inverse twice times
System.out.println(biMap.inverse().inverse().get("SHA"));
//Table
Table<String, String, String> table = HashBasedTable.create();
table.put("CA1501", "CA1502", "1");
table.put("CA1502", "CA1503", "1");
table.put("CA1503", "CA1501", "1");
for (Table.Cell cell : table.cellSet()) {
System.out.println(cell.getRowKey() + "," + cell.getColumnKey() + "," + cell.getValue());
}
table.columnKeySet().forEach(c -> System.out.println(c));
table.rowKeySet().forEach(r -> System.out.println(r));
table.values().forEach(v -> System.out.println(v));
System.out.println(table);
//
String preOnn = Joiner.on("").useForNull(" ").join(null, " ", "");
System.out.println(String.valueOf(Strings.isNullOrEmpty(" ")));
System.out.println(numJewelsInStones("z", "ZZ"));
System.out.println(replaceSpace(new StringBuffer("We Are Happy") ));
ListNode listNode1 = new ListNode(10);
ListNode listNode2 = new ListNode(5);
listNode1.next = listNode2;
System.out.println( printListFromTailToHead(listNode1));
printListFromTailToHead(listNode1).forEach(p-> System.out.println(p.toString()));
for (int i = 0; i < 10 ; i++) {
push(i);
}
for (int i = 0; i < 10; i++) {
System.out.println(pop());
}
System.out.println( minNumberInRotateArray(new int[]{3,4,5,6,1,2}));
System.out.println(Fibonacci(-20));
System.out.println(JumpFloor(3));
System.out.println(JumpFloorII(30));
System.out.println(RectCover(10));
System.out.println(NumberOf1(3));
System.out.println(Power(2,-3));
a = new int[]{6, 1, 2, 7, 9, 3, 4, 5, 10, 8,9};
quickSort(0,9);
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
HashMap hashMapmap = new HashMap();
hashMapmap.put("a","a");
Hashtable hashtable = new Hashtable();
hashtable.put(null,null);
}
public static int numJewelsInStones(String J, String S) {
char[] sChar = S.toCharArray();
char[] jChar = J.toCharArray();
int num = 0;
for (int i = 0; i < sChar.length; i++) {
for (int j = 0; j < jChar.length; j++) {
if (jChar[j] == sChar[i])
num++;
}
}
return num;
}
//剑指 offer
public boolean Find(int target, int[][] array) {
for (int i = 0; i < array.length; i++){
for (int j = 0 ;j< array[0].length;j++){
if (array[i][j] == target)
return true;
}
}
return false;
}
public static String replaceSpace(StringBuffer str) {
String res = "";
for (int i = 0; i < str.length() ; i++) {
if (str.charAt(i) == ' '){
res+="%20";
}else {
res+=str.charAt(i);
}
}
return res;
}
public static ArrayList<Integer> printListFromTailToHead(ListNode listNode){
Stack<ListNode> nodeStack = new Stack<>();
nodeStack.push(listNode);
while (listNode.next!=null){
nodeStack.push(listNode.next);
listNode = listNode.next;
}
ArrayList<Integer> res = Lists.newArrayList();
while(!nodeStack.isEmpty()){
res.add(nodeStack.pop().val);
}
return res;
}
public static class ListNode {
int val;
ListNode next = null;
ListNode(int val) {
this.val = val;
}
}
//两个栈实现一个队列
static Stack<Integer> stack1 = new Stack<Integer>();
static Stack<Integer> stack2 = new Stack<Integer>();
public static void push(int node) {
while (!stack2.isEmpty()) {
stack1.push(stack2.pop());
}
stack1.push(node);
}
public static int pop() {
while (!stack1.isEmpty()) {
stack2.push(stack1.pop());
}
return stack2.pop();
}
public static int minNumberInRotateArray(int[] array) {
if (array.length == 0)
return 0;
int min = array[0];
for (int anArray : array) {
if (anArray < min)
return anArray;
}
return min;
}
//斐波那契数列
public static int Fibonacci(int n) {
if (n < 0)
return 0;
if (n == 1 || n == 2)
return 1;
else
return Fibonacci(n-1)+Fibonacci(n-2);
}
//青蛙跳台阶 暴力膜 不好使
public static int JumpFloor2(int target) {
int count = 0;
for (int i = 0; i < target + 1 ; i++) {
for (int j = 0; j < target + 1 ; j++) {
if (i+2*j == target)
count++;
}
}
return count;
}
public static int JumpFloor(int target) {
if (target <= 0)
return 0;
else if (target == 1)
return 1;
else if (target == 2)
return 2;
else
return JumpFloor(target - 1) + JumpFloor(target - 2);
}
//变态跳台阶
public static int JumpFloorII(int target) {
if (target <= 0 )
return 0;
else if (target == 1)
return 1;
else
return 2*JumpFloorII(target -1);
}
//矩形覆盖
public static int RectCover(int target) {
if (target <= 0)
return 0;
else if (target == 1)
return 1;
if (target == 2)
return 2;
else
return RectCover(target - 1) + RectCover(target - 2);
}
//输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。
public static int NumberOf1(int n) {
String nStr = Integer.toBinaryString(n);
int count = 0;
for (int i = 0; i < nStr.length(); i++) {
if ('1' == nStr.charAt(i))
count++;
}
return count;
}
//给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
public static double Power(double base, int exponent) {
return 0;
}
//快速排序
static int[] a;
public static void quickSort(int left,int right){
if (left > right)
return;
int temp = a[left];
int i = left;
int j = right;
while (i != j) {
while (a[j] >= temp && i < j) {
j--;
}
while (a[i] <= temp ) {
i++;
}
int t = a[j];
a[j] = a[i];
a[i] = t;
}
a[left] = a[i];
a[i] = temp;
quickSort(left, i - 1);
quickSort(i + 1, right);
}
}
package com.guava.test;
import java.util.Scanner;
/**
* @author : fengyuchen
* @discription :两个大数字相加
* @date : created on 2018/7/2 下午8:07
* @modified :
**/
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入第一个数字:");
String numA = sc.nextLine();
System.out.println("请输入第二个数字:");
String numB = sc.nextLine();
System.out.println(twoBigSum(numA, numB));
}
private static String twoBigSum(final String numA, final String numB) {
try {
String shortOne = numA;
String longOne = numB;
//找到短的数字和长的数字
if (numA.length() > numB.length()) {
shortOne = numB;
longOne = numA;
} else if (numA.length() < numB.length()) {
shortOne = numA;
longOne = numB;
}
//在短的数字前面补充0 使它和长的数字一样长
shortOne = suplyZero4Short(shortOne, longOne.length() - shortOne.length());
return twoSameLongSum(shortOne, longOne);
} catch (Exception e) {
return numA;
}
}
private static String twoSameLongSum(String big, String small) {
int length = big.length();
//用于存储某一位要不要进位 如果进位就在它的前一位存储1 否则存0
int[] indexDivide10 = getInitArray(length + 1);
//用于存储某一位两个数求和后%10的结果
int[] indexCellng10 = getInitArray(length + 1);
for (int i = length; i > 0; i--) {
//char - '0' 可以转化为 int
int indexA = big.charAt(i - 1) - '0';
int indexB = small.charAt(i - 1) - '0';
indexDivide10[i - 1] = (indexA + indexB + indexDivide10[i]) / 10;
indexCellng10[i] = (indexA + indexB + indexDivide10[i]) % 10;
}
//循环中没有将第一位的1存到结果中,在这里补上
indexCellng10[0] = indexDivide10[0];
StringBuilder finalRes = new StringBuilder();
for (int i = firstNoZeroPos(indexCellng10); i < indexCellng10.length; i++) {
finalRes.append(indexCellng10[i]);
}
return finalRes.toString();
}
/**
* 找到结果数组中第一个不为0的位置
* 防止输入的数字前面本身就有很多个0
*
* @param intArray
* @return
*/
private static int firstNoZeroPos(int[] intArray) {
for (int i = 0; i < intArray.length; i++) {
if (intArray[i] != 0) {
return i;
}
}
return intArray.length - 1;
}
/**
* 初始化长度为length的值全是0的int数组
*
* @param length
* @return
*/
private static int[] getInitArray(int length) {
int[] res = new int[length];
for (int i = 0; i < res.length; i++) {
res[i] = 0;
}
return res;
}
/**
* 在num的前面补充suplyCount个0
*
* @param num
* @param suplyCount
* @return
*/
private static String suplyZero4Short(String num, int suplyCount) {
String temp = "";
for (int i = 0; i < suplyCount; i++) {
temp = temp.concat("0");
}
return temp + num;
}
}
package com.hello.actions;
import com.hello.interfaces.Hello;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/1/21 下午5:28
* @modified :
**/
public class ChHello implements Hello {
private String msg = null;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public ChHello(String Msg){
this.msg = Msg;
}
@Override
public String doSlution() {
return "你好啊" + this.msg;
}
}
package com.hello.actions;
import com.hello.interfaces.Hello;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/1/21 下午5:28
* @modified :
**/
public class EnHello implements Hello {
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
private String msg = null;
@Override
public String doSlution() {
return "hello " + this.msg;
}
}
package com.hello.interfaces;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/1/21 下午5:27
* @modified :
**/
public interface Hello {
String doSlution();
}
package com.interview.test;
import java.awt.*;
import java.util.*;
import java.util.List;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-03-04 19:50
* @modified :
**/
public class LeetCodeSolution {
/**
* 从排序数组中删除重复项
*
* @param nums
* @return
*/
public static int removeDuplicates(int[] nums) {
int res = 0;
if (nums == null) {
return res;
}
for (int i = 0; i < nums.length; i++) {
if (nums[i] != nums[res]) {
res++;
int tmep = nums[res];
nums[res] = nums[i];
nums[i] = tmep;
}
}
return ++res;
}
/**
* 买卖股票的最佳时机 II 贪心法
*
* @param prices
* @return
*/
public int maxProfit(int[] prices) {
//关键点在于 d3 - d1 = d3 - d2 + d2 + d1
int profit = 0;
for (int i = 0; i < prices.length - 1; i++) {
if (prices[i + 1] - prices[i] > 0) {
profit += prices[i + 1] - prices[i];
}
}
return profit;
}
/**
* 旋转数组
*
* @param nums
* @param k
*/
public void rotateVersion1(int[] nums, int k) {
int lenth = nums.length;
for (int j = 0; j < k; j++) {
int temp = nums[lenth - 1];
for (int i = lenth - 1; i > 0; i--) {
nums[i] = nums[i - 1];
}
nums[0] = temp;
}
}
public void rotateCersion2(int[] nums, int k) {
if (nums.length == 0)
return;
reverse(nums, 0, nums.length - 1 - k);
reverse(nums, nums.length - k, nums.length - 1);
reverse(nums, 0, nums.length - 1);
}
public void reverse(int[] nums, int begin, int end) {
while (begin < end) {
int temp = nums[begin];
nums[begin++] = nums[end];
nums[end--] = temp;
}
}
public boolean containsDuplicate(int[] nums) {
if (nums.length == 1)
return false;
for (int i = 0; i < nums.length; i++) {
for (int j = i + 1; j < nums.length; j++) {
if (nums[i] == nums[j]) {
return true;
}
}
}
return false;
}
public int singleNumber(int[] nums) {
int num = 0;
for (int i = 0; i < nums.length; i++) {
num = num ^ nums[i];
}
return num;
}
public int[] intersect(int[] nums1, int[] nums2) {
if (nums1.length == 0 || nums2.length == 0) {
return new int[]{};
}
Map<Integer, Integer> num1Map = new HashMap<>();
for (int i : nums1) {
num1Map.merge(i, 1, (a, b) -> a + b);
}
List<Integer> list = new ArrayList<>();
for (int i : nums2) {
if (num1Map.get(i) != null && num1Map.get(i) > 0) {
list.add(i);
num1Map.put(i, num1Map.get(i) - 1);
}
}
int[] res = new int[list.size()];
int i = 0;
for (Integer integer : list) {
res[i++] = integer;
}
return res;
}
public int[] intersectV2(int[] nums1, int[] nums2) {
int i = 0;
int j = 0;
Set<Integer> list = new HashSet<>();
while (i != nums1.length && j != nums2.length) {
if (nums1[i] == nums2[j]) {
list.add(nums1[i]);
i++;
j++;
} else if (nums1[i] < nums2[j]) {
i++;
} else {
j++;
}
}
int[] res = new int[list.size()];
int k = 0;
for (Integer integer : list) {
res[k++] = integer;
}
return res;
}
public int[] plusOne(int[] digits) {
if (digits.length == 0){
return new int[]{};
}
int i = digits.length - 1;
while((digits[i] + 1 )%10 == 0){
digits[i] = 0;
i--;
}
return digits;
}
public static void main(String[] args) {
LeetCodeSolution leetCodeSolution = new LeetCodeSolution();
int[] ints = new int[]{1, 2, 2, 1};
System.out.println(leetCodeSolution.containsDuplicate(ints));
int[] ints2 = new int[]{2, 2};
int[] res = leetCodeSolution.plusOne(ints);
for (int i = 0; i < res.length; i++) {
System.out.println(res[i]);
}
}
}
package com.interview.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-01-28 20:11
* @modified :
**/
public class Sword2Offer {
public static void main(String[] args) {
LinkList a = new LinkList(1);
LinkList b = new LinkList(2);
a.next = b;
LinkList c = new LinkList(3);
b.next = c;
LinkList d = new LinkList(4);
c.next = d;
LinkList e = new LinkList(5);
d.next = e;
System.out.println(reverseListLoop(reverseListRecusive(a)).val);
}
static class LinkList {
int val;
LinkList next = null;
LinkList(int val) {
this.val = val;
}
}
public static LinkList reverseListRecusive(LinkList head) {
if (head == null || head.next == null) {
return head;
}
LinkList newHead = reverseListRecusive(head.next);
head.next.next = head;
head.next = null;
return newHead;
}
public static LinkList reverseListLoop(LinkList head) {
if (head == null) {
return null;
}
LinkList next;
LinkList pre = null;
while (head != null) {
next = head.next;
head.next = pre;
pre = head;
head = next;
}
return pre;
}
}
package com.interview.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午2:04
* @modified :
**/
public class testExtends {
public static void main(String[] args) {
Wine a = new JNC();
a.fun2();
Wine b = new Wine();
b.fun1();
JNC c = new JNC();
c.fun1("a");
}
public static class Wine {
public void fun1(){
System.out.println("Wine 的Fun.....");
fun2();
}
public void fun2(){
System.out.println("Wine 的Fun2...");
}
}
public static class JNC extends Wine{
/**
* @desc 子类重载父类方法
* 父类中不存在该方法,向上转型后,父类是不能引用该方法的
* @param a
* @return void
*/
public void fun1(String a){
System.out.println("JNC 的 Fun1...");
fun2();
}
/**
* 子类重写父类方法
* 指向子类的父类引用调用fun2时,必定是调用该方法
*/
public void fun2(){
System.out.println("JNC 的Fun2...");
}
}
}
package com.interview.test;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019/1/15 下午2:16
* @modified :
**/
public class TestWine2 {
public static void main(String[] args) {
//定义父类数组
Wine[] wines = new Wine[2];
//定义两个子类
JNC jnc = new JNC();
JGJ jgj = new JGJ();
Wine wine=new Wine();
//父类引用子类对象
wines[0] = jnc;
wines[1] = jgj;
for(int i = 0 ; i < 2 ; i++){
System.out.println(wines[i].toString() + "--" + wines[i].drink());
}
System.out.println("-------------------------------");
System.out.println(jnc.toString() + "--" + jnc.drink());
System.out.println(jgj.toString() + "--" + jgj.drink());
}
public static class Wine {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Wine(){
}
public String drink(){
return "喝的是 " + getName();
}
/**
* 重写toString()
*/
public String toString(){
return null;
}
}
public static class JNC extends Wine{
public JNC(){
setName("JNC");
}
/**
* 重写父类方法,实现多态
*/
public String drink(){
return "喝的是 " + getName();
}
/**
* 重写toString()
*/
public String toString(){
return "Wine : " + getName();
}
}
public static class JGJ extends Wine{
public JGJ(){
setName("JGJ");
}
/**
* 重写父类方法,实现多态
*/
public String drink(){
return "喝的是 " + getName();
}
/**
* 重写toString()
*/
public String toString(){
return "Wine : " + getName();
}
}
}
package com.mutithread.chapter0_1;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/6/28 上午9:46
* @modified :
**/
public class PrintMessageMain {
public static void main(String[] args) {
new PrintThread("线程1").start();
new PrintThread_2("线程2").run();
}
}
package com.mutithread.chapter0_1;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/6/28 上午9:41
* @modified :
**/
public class PrintThread extends Thread {
private String message ;
public PrintThread(String message){
this.message = message;
}
public void run(){
for (int i = 0; i < 10000; i++) {
System.out.println(message);
}
}
}
package com.mutithread.chapter0_1;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/6/28 上午9:44
* @modified :
**/
public class PrintThread_2 implements Runnable{
private String message ;
public PrintThread_2(String message){
this.message = message;
}
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
System.out.println(message);
}
}
}
package com.mutithread.chapter1;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-03-18 21:25
* @modified :
**/
public class cacheVisibilityTest {
private long count = 0;
private void add10K() {
int idx = 0;
while(idx++ < 10000) {
count += 1;
}
}
public long calc() throws InterruptedException {
final cacheVisibilityTest test = new cacheVisibilityTest();
// 创建两个线程,执行 add() 操作
Thread th1 = new Thread(()->{
test.add10K();
});
Thread th2 = new Thread(()->{
test.add10K();
});
// 启动两个线程
th1.start();
th2.start();
// 等待两个线程执行结束
th1.join();
th2.join();
return count;
}
public static void main(String[] args) throws InterruptedException {
cacheVisibilityTest cacheVisibilityTest = new cacheVisibilityTest();
System.out.println(cacheVisibilityTest.calc());
}
}
package com.mutithread.chapter1;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-03-18 22:03
* @modified :
**/
public class VolatileExample {
int x = 0;
volatile boolean v = false;
public void writer() {
x = 42;
v = true;
}
public void reader() {
if (v == true) {
// 这里 x 会是多少呢?
}
}
}
package com.proxy.program;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午9:46
* @modified :
**/
public class AgeMapperProxy implements MethodInterceptor{
private Object target;
/**
* 创建代理类对象
*/
public IAgeMapper createProxy(IAgeMapper object) {
target = object; //创建Enhancer对象
Enhancer enhancer = new Enhancer(); //设置要代理的目标类,以扩展功能
enhancer.setSuperclass(this.target.getClass()); //设置单一回调对象,在回调中拦截对目标方法的调用
enhancer.setCallback(this);// 设置类加载
enhancer.setClassLoader(object.getClass().getClassLoader()); //创建代理对象
return (IAgeMapper) enhancer.create();
}
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
doBefore();
method.invoke(target,objects);
doAfter();
return null;
}
private void doAfter() {
System.out.println("do after.");
}
private void doBefore() {
System.out.println("do before.");
}
}
package com.proxy.program;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午9:45
* @modified :
**/
public interface IAgeMapper {
String getAge(String name);
}
package com.proxy.program;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午9:17
* @modified :
**/
public class Programmer {
private String name;
public void setName(String name) {
System.out.println("Setting Name.");
this.name = name;
}
public void code() {
System.out.println(name + " is writing bugs.");
}
}
package com.proxy.program;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午9:19
* @modified :
**/
public class ProgrammerProxy implements MethodInterceptor {
/**
* 内部持有委托类对象的引用
*/
private Object target;
/**
* 创建代理类对象
*/
public Programmer createProxy(Programmer object) {
target = object; //创建Enhancer对象
Enhancer enhancer = new Enhancer(); //设置要代理的目标类,以扩展功能
enhancer.setSuperclass(this.target.getClass()); //设置单一回调对象,在回调中拦截对目标方法的调用
enhancer.setCallback(this);// 设置类加载
enhancer.setClassLoader(object.getClass().getClassLoader()); //创建代理对象
return (Programmer) enhancer.create();
}
@Override
public Object intercept(Object proxy, Method method, Object[] params, MethodProxy methodProxy) throws Throwable {
doBefore();
method.invoke(target, params); //调用之后处理
doAfter();
return null;
}
private void doAfter() {
System.out.println("do after.");
}
private void doBefore() {
System.out.println("do before.");
}
}
package com.proxy.program;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午9:28
* @modified :
**/
public class ProxyTest {
@Test
public void testCglibProxy() {
//创建一个Programmer
Programmer programmerA = new Programmer();
programmerA.setName("Frank");
//创建代理对象
Programmer programmerProxyA = new ProgrammerProxy().createProxy(programmerA);
programmerProxyA.code();
//修改代理对象
programmerProxyA.setName("Wang");
programmerProxyA.code();
//修改委托类对象
programmerA.setName("Song");
programmerProxyA.code();
}
@Test
public void testCglibInterface(){
IAgeMapper ageMapper = new IAgeMapper() {
@Override
public String getAge(String name) {
return null;
}
};
IAgeMapper proxyAgeMapper = new AgeMapperProxy().createProxy(ageMapper);
}
@Test
public void testCompare(){
/* List<String> list = new ArrayList<String>();
Collections.sort(list);
System.out.println(list);
String a = "2018-04-23 15:33:47";
System.out.println(a.substring(0,a.length()-3));*/
System.out.println(new DateTime().toString("HH:mm"));
System.out.println(DateTime.parse("2019-02-27 19:37", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")).toString("HH:mm"));
}
}
package com.proxy.stars;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午10:06
* @modified :
**/
public interface IStars {
}
package com.proxy.stars;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/4/22 下午10:06
* @modified :
**/
public class Stars {
}
package com.springscheduler.test;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-27 14:45
* @modified :
**/
@Component
public class SpringScheduler {
@Scheduled(cron="0/10 * * * * ?")
private void runtaskA(){
TaskA.runA();
}
@Scheduled(cron="0/5 * * * * ?")
private void runtaskB(){
TaskB.runB();
}
}
package com.springscheduler.test;
import org.joda.time.DateTime;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-27 14:45
* @modified :
**/
public class TaskA {
public static void runA(){
System.out.println(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
System.out.println("i am task b , run once time per 10 seconds");
}
}
package com.springscheduler.test;
import org.joda.time.DateTime;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2019-02-27 14:45
* @modified :
**/
public class TaskB {
public static void runB(){
System.out.println(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
System.out.println("i am task b , run once time per 5 seconds");
}
}
import java.util.ArrayList;
import java.util.List;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/1/18 下午6:38
* @modified :
**/
public class HelloWorld {
private String name;
public void setWords(String words) {
this.words = words;
}
private String words;
public void setName(String name){
this.name = name;
}
public void doSalution(){
System.out.println("Hello "+name +words);
}
public static void main(String[] args) {
List<String> a = new ArrayList<>();
a.add("a");
a.add("b");
a.add("c");
a.add("d");
a.add("e");
a.add("f");
a.add("a");
a.add("f");
System.out.println(a.subList(a.indexOf("a"),a.lastIndexOf("a") + 1));
System.out.println(a.indexOf("a"));
System.out.println(a.lastIndexOf("a"));
}
}
import com.hello.actions.ChHello;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/1/18 下午6:38
* @modified :
**/
public class Main {
public static void main(String[] args){
ApplicationContext actx = new ClassPathXmlApplicationContext("spring-config.xml");
// HelloWorld helloWorld = new HelloWorld();
ChHello helloWorld = (ChHello)actx.getBean("HelloWorld");
// helloWorld.setName("chou sha bi");
System.out.println(helloWorld.doSlution());
String s = "asdfasdflocalptddate=2017-01-01,adfasdf";
Matcher matcher = Pattern.compile("localptddate=(.*),").matcher(s);
if (matcher.find()) {
System.out.println(matcher.group(1));
}
System.out.println("2018-03-07".compareTo("2018-03-07"));
System.out.println("2018-03-07".compareTo("2018-03-06"));
System.out.println("2018-03-06".compareTo("2018-03-07"));
System.out.println("2017-03-07".compareTo("2018-03-07"));
for (int i = 0 ;i <= 2 ;i++)
System.out.println(i);
HashMap map = new HashMap();
map.put("a","a");
Hashtable hashtable = new Hashtable();
hashtable.put(null,null);
List<String> list = new ArrayList<>();
list.add("A");
list.add(1,"A");
}
}
/**
* @author : fengyuchen
* @discription :
* @date : created on 2018/1/18 下午7:16
* @modified :
**/
public class test {
public static void main(String[] args) {
new Child();//语句(*)
}
}
class Parent{
static String name = "hello";
{
System.out.println("parent block");
}
static {
System.out.println("parent static block");
}
public Parent(){
System.out.println("parent constructor");
}
}
class Child extends Parent{
static String childName = "hello";
{
System.out.println("child block");
}
static {
System.out.println("child static block");
}
public Child(){
System.out.println("child constructor");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/>
<bean id="helloworld" class="HelloWorld">
<property name="name" value="shabi"></property>
<property name="words" value="dajiba"></property>
</bean>
<bean id="Helloworld" class="HelloWorld">
<property name="name" value="棒棒哒"></property>
<property name="words" value="你真聪明"></property>
</bean>
<bean id="HelloWorld" class="com.hello.actions.ChHello">
<constructor-arg index="0"><value>你好</value></constructor-arg>
</bean>
<context:component-scan base-package="com.cache.test"/>
<context:component-scan base-package="com.abstractclass.test"/>
<!--工具类中相关静态数据的定时加载-->
<task:annotation-driven scheduler="springtest" />
<task:scheduler id="springtest" pool-size="5" />
</beans>
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE jboss-web PUBLIC
"-//JBoss//DTD Web Application 2.3V2//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
<class-loading java2ClassLoadingCompliance='true'>
<loader-repository>
com.example:archive=UmeServerCore
<loader-repository-config>
java2ParentDelegaton=true
</loader-repository-config>
</loader-repository>
</class-loading>
<context-root>UmeServerCore</context-root>
<!-- -->
<resource-ref>
<res-ref-name>jdbc/mskyhlzh</res-ref-name>
<jndi-name>java:/jdbc/mskyhlzh</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/servercore</res-ref-name>
<jndi-name>java:/jdbc/servercore</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/oracleRAC</res-ref-name>
<jndi-name>java:/jdbc/oracleRAC</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/umeedb</res-ref-name>
<jndi-name>java:/jdbc/umeedb</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/umeedb29</res-ref-name>
<jndi-name>java:/jdbc/umeedb29</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/edb</res-ref-name>
<jndi-name>java:/jdbc/edb</jndi-name>
</resource-ref>
</jboss-web>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd"
default-autowire="default">
<import resource="classpath:spring-config.xml" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>UmeServerCore</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/remote-servlet.xml
</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment