Skip to content

Commit 5746a55

Browse files
committed
http moudle also can be disable
1 parent f2c9616 commit 5746a55

File tree

5 files changed

+22
-88
lines changed

5 files changed

+22
-88
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ Step-by-Step-tutorial-for-ServiceFramework
55
* [Step-by-Step-tutorial-for-ServiceFramework(1)](https://github.com/allwefantasy/service_framework_example/blob/master/README.md)
66
* [Step-by-Step-tutorial-for-ServiceFramework(2)](https://github.com/allwefantasy/service_framework_example/blob/master/doc/Step-by-Step-tutorial-for-ServiceFramework\(2\).md)
77
* [Step-by-Step-tutorial-for-ServiceFramework(3)](https://github.com/allwefantasy/service_framework_example/blob/master/doc/Step-by-Step-tutorial-for-ServiceFramework\(3\).md)
8-
* [Step-by-Step-tutorial-for-ServiceFramework(4)](https://github.com/allwefantasy/service_framework_example/blob/master/doc/Step-by-Step-tutorial-for-ServiceFramework\(4\).md)
8+
* [Step-by-Step-tutorial-for-ServiceFramework(4)](https://github.com/allwefantasy/service_framework_example/blob/master/doc/Step-by-Step-tutorial-for-ServiceFramework\(4\).md)*
9+
10+
11+
##[README-EN](https://github.com/allwefantasy/ServiceFramework/blob/master/README-EN.md)
12+
913

1014
## 创建一个新的ServiceFramework 项目
1115

@@ -20,9 +24,10 @@ ServcieFramework 定位在 **移动互联网后端** 领域。
2024
3. 简单但实用的View层,天然支持JSON,XMl格式输出
2125

2226
框架提供了对mysql([ActiveORM](https://github.com/allwefantasy/active_orm)),mongodb([MongoMongo](https://github.com/allwefantasy/mongomongo))的支持.
23-
对象缓存正在开发中。
2427

25-
如果你面对的是一个遗留项目或者遗留的数据库,那么ServiceFramework不适合你。我们倾向于在一个全新的项目中使用它。
28+
_对象缓存正在开发中,开发以[Web应用的缓存设计模式](http://robbinfan.com/blog/38/orm-cache-sumup)的描述为基础思路,并且会直接提供包括计数等的实现。_
29+
30+
*** 如果你面对的是一个遗留项目或者遗留的数据库,那么ServiceFramework不适合你。我们倾向于在一个全新的项目中使用它。***
2631
相信你会为Java也能做到如此的简洁而惊讶,如此高效的开发而窃喜。
2732

2833
现在让我们了解下 ServiceFramework 吧。

src/net/csdn/bootstrap/Bootstrap.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ public static void main(String[] args) {
3737
e.printStackTrace();
3838
System.exit(3);
3939
}
40-
httpServer = ServiceFramwork.injector.getInstance(HttpServer.class);
41-
httpServer.start();
42-
httpServer.join();
43-
44-
4540
}
4641

4742
public static void shutdown() {
@@ -60,7 +55,10 @@ private static void configureSystem() throws Exception {
6055
Settings settings = tuple.v1();
6156
boolean disableMysql = settings.getAsBoolean(ServiceFramwork.mode + ".datasources.mysql.disable", false);
6257
boolean disableMongo = settings.getAsBoolean(ServiceFramwork.mode + ".datasources.mongodb.disable", false);
63-
if (ServiceFramwork.scanService.getLoader() == null || (ServiceFramwork.scanService.getLoader()== DefaultScanService.class)) {
58+
boolean disableHttp = settings.getAsBoolean("http.disable", false);
59+
60+
61+
if (ServiceFramwork.scanService.getLoader() == null || (ServiceFramwork.scanService.getLoader() == DefaultScanService.class)) {
6462
ServiceFramwork.scanService.setLoader(ServiceFramwork.class);
6563
}
6664
if (!disableMysql) {
@@ -95,6 +93,12 @@ private static void configureSystem() throws Exception {
9593
}
9694

9795
isSystemConfigured = true;
96+
97+
if (!disableHttp) {
98+
httpServer = ServiceFramwork.injector.getInstance(HttpServer.class);
99+
httpServer.start();
100+
httpServer.join();
101+
}
98102
}
99103

100104

src/net/csdn/modules/http/ApplicationController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public String param(String key) {
260260
return request.params().get(key);
261261
}
262262

263+
263264
public String paramMultiKey(String... keys) {
264265
return request.paramMultiKey(keys);
265266
}

test/test/com/example/PersonTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public void testDocumentHasManyAssociation() {
2929

3030
person.addresses().build(map("_id", 77, "location", "天国的世界")).save();
3131
person = Person.findById(100);
32-
List<Address> addresses = person.addresses().filter().fetch();
32+
List<Address> addresses = person.addresses().findAll();
3333
Assert.assertTrue(addresses.size() == 1);
3434

3535
Address address = addresses.get(0);
36-
Person person1 = address.person().filter().singleFetch();
36+
Person person1 = address.person().findOne();
3737
Assert.assertTrue(person1.getName().equals(person.getName()));
3838

3939
person.remove();
@@ -75,7 +75,7 @@ public void testDocumentEnhancer() {
7575

7676
personList = Person.select(list("name")).where(map("name", "google")).fetch();
7777
Assert.assertTrue(personList.size() == 1);
78-
Assert.assertTrue(personList.get(0).attributes().toMap().size() == 2);
78+
Assert.assertTrue(personList.get(0).attributes().size() == 2);
7979

8080
personFound.remove();
8181
personFound = Person.findById(100);

test/test/com/example/document/BlogTest.java

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,81 +20,5 @@
2020
public class BlogTest extends IocTest {
2121

2222

23-
public void embeddedDocumentDeleteTest() {
24-
Map blogMap = map(
25-
"_id", 100,
26-
"userName", "jack",
27-
"blogTitle", "this is a test blog",
28-
"articles", list(
29-
map(
3023

31-
"title", "article",
32-
"body", "article body"
33-
),
34-
map(
35-
36-
"title", "article1",
37-
"body", "article body1"
38-
)
39-
)
40-
);
41-
42-
Blog blog = Blog.create(blogMap);
43-
blog.save();
44-
blog = Blog.findById(100);
45-
List<Article> articles = blog.articles().find();
46-
Assert.assertTrue(articles.size() == 2);
47-
Article article = articles.get(0);
48-
article.remove();
49-
50-
blog = Blog.findById(100);
51-
articles = blog.articles().find();
52-
Assert.assertTrue(articles.size() == 1);
53-
}
54-
55-
56-
@Test
57-
public void embeddedDocumentTest() {
58-
Map blogMap = map(
59-
"_id", 100,
60-
"userName", "jack",
61-
"blogTitle", "this is a test blog",
62-
"articles", list(
63-
map(
64-
"_id", 101,
65-
"title", "article",
66-
"body", "article body"
67-
),
68-
map(
69-
"_id", 102,
70-
"title", "article1",
71-
"body", "article body1"
72-
)
73-
)
74-
);
75-
76-
Blog blog = Blog.create(blogMap);
77-
blog.save();
78-
79-
List<Article> articleList = blog.articles().find();
80-
Assert.assertTrue(articleList.size() == 2);
81-
82-
articleList = blog.articles().find(101);
83-
Assert.assertTrue(articleList.size() == 1);
84-
85-
Article article = articleList.get(0);
86-
Assert.assertTrue(blog.id().equals(article.blog().findOne().id()));
87-
88-
//test delete
89-
articleList = blog.articles().find();
90-
91-
Assert.assertTrue(articleList.size() == 2);
92-
article = articleList.get(0);
93-
article.remove();
94-
95-
articleList = blog.articles().find();
96-
Assert.assertTrue(articleList.size() == 1);
97-
98-
99-
}
10024
}

0 commit comments

Comments
 (0)