Skip to content

Commit 39d3d12

Browse files
author
zhou01.zhao
committed
备份
1 parent 0a755b5 commit 39d3d12

14 files changed

Lines changed: 203 additions & 108 deletions

File tree

build.gradle

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ configure(allprojects) { project ->
44
repositories {
55
mavenCentral()
66
}
7-
<<<<<<< HEAD
7+
88

99
}
1010

@@ -45,7 +45,7 @@ project ("zz-basic") {
4545
description = "basic code"
4646

4747
dependencies {
48-
testCompile libraries.junit
48+
compile libraries.junit
4949
compile libraries.mybatis
5050
compile libraries.mysqlConnector
5151
compile libraries.slf4j_log4j12
@@ -75,71 +75,4 @@ task showProjectInfo {
7575
println project.group
7676
}
7777

78-
=======
79-
80-
}
81-
82-
configure(subprojects) { subproject ->
83-
84-
apply plugin: "idea"
85-
apply plugin: "eclipse"
86-
87-
apply plugin: 'java'
88-
89-
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
90-
91-
compileJava {
92-
sourceCompatibility = 1.7
93-
targetCompatibility = 1.7
94-
}
95-
96-
compileTestJava {
97-
sourceCompatibility = 1.8
98-
targetCompatibility = 1.8
99-
100-
}
101-
102-
task sourcesJar(type: Jar, dependsOn: classes) {
103-
classifier = 'sources'
104-
from sourceSets.main.allSource
105-
}
106-
107-
108-
artifacts {
109-
archives sourcesJar
110-
}
111-
112-
}
113-
114-
project ("zz-basic") {
115-
description = "basic code"
116-
117-
dependencies {
118-
testCompile libraries.junit
119-
compile libraries.mybatis
120-
compile libraries.mysqlConnector
121-
compile libraries.slf4j_log4j12
122-
compile libraries.spring_core
123-
compile libraries.spring_context
124-
compile libraries.quartz
125-
compile libraries.quartzJob
126-
compile libraries.bouncycastle
127-
compile libraries.commons_lang3
128-
}
129-
130-
}
131-
132-
project ( "zz-test" ) {
133-
description = "test project"
134-
135-
dependencies {
136-
compile project(":zz-basic")
137-
}
138-
}
139-
140-
project ( "zz-utils" ) {
141-
description = "common utils"
142-
}
143-
144-
>>>>>>> b81367978cb7ed8c1333ef9fab228eef14fcb7e1
14578

gradle.properties

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
group=org.simon.javaLib
2-
<<<<<<< HEAD
32
version=1.0.0-SNAPSHOT
4-
=======
5-
version=1.0-SNAPSHOT
6-
>>>>>>> b81367978cb7ed8c1333ef9fab228eef14fcb7e1

logs/log.log

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
2017-03-14 17:22:40 [ main:0 ] - [ INFO ] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@aec6354: startup date [Tue Mar 14 17:22:40 CST 2017]; root of context hierarchy
2-
2017-03-14 17:22:40 [ main:94 ] - [ INFO ] Loading XML bean definitions from class path resource [applicationContext.xml]
1+
2017-03-22 19:00:05 [ main:0 ] - [ INFO ] Using default implementation for ThreadExecutor
2+
2017-03-22 19:00:05 [ main:17 ] - [ INFO ] Job execution threads will use class loader of thread: main
3+
2017-03-22 19:00:05 [ main:40 ] - [ INFO ] Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
4+
2017-03-22 19:00:05 [ main:41 ] - [ INFO ] Quartz Scheduler v.2.2.1 created.
5+
2017-03-22 19:00:05 [ main:42 ] - [ INFO ] RAMJobStore initialized.
6+
2017-03-22 19:00:05 [ main:43 ] - [ INFO ] Scheduler meta-data: Quartz Scheduler (v2.2.1) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'
7+
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
8+
NOT STARTED.
9+
Currently in standby mode.
10+
Number of jobs executed: 0
11+
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
12+
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
13+
14+
2017-03-22 19:00:05 [ main:43 ] - [ INFO ] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
15+
2017-03-22 19:00:05 [ main:43 ] - [ INFO ] Quartz scheduler version: 2.2.1
16+
2017-03-22 19:00:05 [ main:43 ] - [ INFO ] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
17+
2017-03-22 19:00:38 [ main:1 ] - [ INFO ] Using default implementation for ThreadExecutor
18+
2017-03-22 19:00:38 [ main:3 ] - [ INFO ] Job execution threads will use class loader of thread: main
19+
2017-03-22 19:00:38 [ main:19 ] - [ INFO ] Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
20+
2017-03-22 19:00:38 [ main:21 ] - [ INFO ] Quartz Scheduler v.2.2.1 created.
21+
2017-03-22 19:00:38 [ main:21 ] - [ INFO ] RAMJobStore initialized.
22+
2017-03-22 19:00:38 [ main:22 ] - [ INFO ] Scheduler meta-data: Quartz Scheduler (v2.2.1) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'
23+
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
24+
NOT STARTED.
25+
Currently in standby mode.
26+
Number of jobs executed: 0
27+
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
28+
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
29+
30+
2017-03-22 19:00:38 [ main:22 ] - [ INFO ] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
31+
2017-03-22 19:00:38 [ main:22 ] - [ INFO ] Quartz scheduler version: 2.2.1
32+
2017-03-22 19:00:38 [ main:22 ] - [ INFO ] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.

logs/log.log.2017-03-14

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2017-03-14 17:22:40 [ main:0 ] - [ INFO ] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@aec6354: startup date [Tue Mar 14 17:22:40 CST 2017]; root of context hierarchy
2+
2017-03-14 17:22:40 [ main:94 ] - [ INFO ] Loading XML bean definitions from class path resource [applicationContext.xml]
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.simon.zhao.java.generic;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.function.Function;
6+
7+
/**
8+
* @author Zhaozhou
9+
* @date 2017/3/27
10+
*/
11+
public class App {
12+
13+
public static void main(String[] args) {
14+
/* List<String> strings = new ArrayList<>();
15+
List<Integer> ints = new ArrayList<>();
16+
List<String> list = new ArrayList();
17+
List<?> list3 = (List<?>) list;
18+
unsafeAdd(strings, new Integer(0));
19+
unsafeAdd3(list);
20+
unsafeAdd4(ints, list);*/
21+
List<Class> l = new ArrayList();
22+
23+
List<?> [] lists = new List<?>[3];
24+
// lists[0].add("1");
25+
26+
Object[] objects = new Long[1];
27+
objects[0] = 1l;
28+
System.out.println(objects[0]);
29+
30+
31+
32+
33+
}
34+
35+
public static void unsafeAdd(List list, Object o) {
36+
list.add(o);
37+
}
38+
39+
public static void unsafeAdd2(List<Object> list, Object o) {
40+
list.add(o);
41+
}
42+
43+
public static void unsafeAdd3(List<String> list) {
44+
list.add(new String("1"));
45+
}
46+
47+
public static void unsafeAdd4(List<?> list, List<?> list2) {
48+
49+
}
50+
51+
interface Function<T> {
52+
T apply(T arg1, T args);
53+
}
54+
55+
static <E> E reduce(List<E> list, Function<E> f, E initVal) {
56+
List<E> snapshot = new ArrayList<>(list);
57+
E result = initVal;
58+
for (E e:snapshot) {
59+
result = f.apply(result, e);
60+
}
61+
return result;
62+
}
63+
64+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.simon.zhao.java.java7ConcurrencyCookbook.ch4.phase2;
2+
3+
4+
import org.junit.Test;
5+
6+
/**
7+
* @author Zhaozhou
8+
* @date 2017/4/1
9+
*/
10+
public class Main {
11+
public static void main(String[] args) throws InterruptedException {
12+
new Main().test();
13+
}
14+
15+
@Test
16+
public void test() throws InterruptedException {
17+
Server server = new Server();
18+
int size = 10;
19+
for ( int i = 0; i < size; i++ ) {
20+
Task task = new Task("Task " + i);
21+
server.executeTask(task);
22+
}
23+
server.awaitServer();
24+
server.endServer();
25+
System.out.println("main end");
26+
}
27+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.simon.zhao.java.java7ConcurrencyCookbook.ch4.phase2;
2+
3+
import java.util.concurrent.Executors;
4+
import java.util.concurrent.ThreadPoolExecutor;
5+
import java.util.concurrent.TimeUnit;
6+
7+
/**
8+
* @author Zhaozhou
9+
* @date 2017/4/1
10+
*/
11+
public class Server {
12+
private ThreadPoolExecutor executor;
13+
14+
public Server() {
15+
this.executor = (ThreadPoolExecutor) Executors.newCachedThreadPool();
16+
}
17+
18+
public void executeTask( Task task ) {
19+
System.out.printf("Server: A new task has arrived \n");
20+
executor.execute(task);
21+
System.out.printf("Server: Pool Size: %d\n", executor.getPoolSize());
22+
System.out.printf("Server: Active Count: %d\n", executor.getActiveCount());
23+
System.out.printf("Server: Completed Tasks: %d\n", executor.getCompletedTaskCount());
24+
}
25+
26+
public void awaitServer() {
27+
try {
28+
executor.awaitTermination(15, TimeUnit.SECONDS);
29+
} catch (InterruptedException e) {
30+
e.printStackTrace();
31+
}
32+
}
33+
34+
public void endServer() {
35+
executor.shutdown();
36+
}
37+
38+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.simon.zhao.java.java7ConcurrencyCookbook.ch4.phase2;
2+
3+
import java.util.Date;
4+
import java.util.concurrent.TimeUnit;
5+
6+
/**
7+
* @author Zhaozhou
8+
* @date 2017/4/1
9+
*/
10+
public class Task implements Runnable {
11+
12+
private Date initDate;
13+
private String name;
14+
15+
public Task(String name) {
16+
initDate = new Date();
17+
this.name = name;
18+
}
19+
@Override
20+
public void run() {
21+
System.out.printf("%s: Task %s: Created on: %s\n", Thread.currentThread().getName(), name, initDate);
22+
System.out.printf("%s: Task %s: Started on: %s\n", Thread.currentThread().getName(), name, new Date());
23+
try {
24+
Long duration = ( long) ( Math.random()*10 );
25+
26+
TimeUnit.SECONDS.sleep(duration);
27+
System.out.printf("%s: Task %s: Doing a task during %d seconds\n", Thread.currentThread().getName(), name, duration);
28+
} catch (InterruptedException e) {
29+
e.printStackTrace();
30+
}
31+
32+
}
33+
}

zz-basic/src/main/java/org/simon/zhao/java/security/keys/KeyPairCreator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
public class KeyPairCreator {
1414

1515
private static final String ALGORITHM_RSA = "RSA";
16-
private static final String ALGORITHM_DSA = "DSA";
1716

1817
public static void generateRsaKeys(int length) throws Exception {
1918
System.out.println("--------------------------generate rsa key pair--------------------------");

zz-basic/src/main/java/org/simon/zhao/quartz/HelloJob.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class HelloJob implements Job {
1313
Logger logger = LoggerFactory.getLogger(HelloJob.class);
1414
@Override
1515
public void execute(JobExecutionContext context) throws JobExecutionException {
16-
logger.info("Hello Quartz!");
16+
// logger.info("Hello Quartz!");
17+
System.out.println("Hello Quartz");
1718
}
1819
}

0 commit comments

Comments
 (0)