01
02
03
04
05
06
07
08
09
10
11
12
|
@ServiceComponent
(
)
public
class
HelloWorldAnnotationService
{
@ServiceMethod
(
serviceId
=
"sayHelloA"
)
@ServiceResult
(
name
=
"result"
)
@ServiceViewMapping
(
"/helloworld/helloresult.page"
)
public String sayHello
(
String
name
)
{
if
(
name
=
=
null
)
{
name
=
"world."
;
}
return
"hello,"
+
name
;
}
}
|
1
2
3
4
|
<
form action
=
"sayHelloA.servicepage"
>
输入名称:
<
input type
=
"text"
name
=
"name"
/
>
<
input type
=
"submit"
value
=
"提交"
/
>
<
/
form
>
|
1
2
3
4
5
6
7
8
|
public
class
HelloWorldXmlService
{
public String sayHello
(
String
name
)
{
if
(
name
=
=
null
)
{
name
=
"world."
;
}
return
"hello,"
+
name
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
|
<
service
-
components
>
<
service
-
component type
=
"org.tinygroup.helloworld.service.HelloWorldXmlService"
group
-
id
=
"org.tinygroup"
artifact
-
id
=
"helloworldservice"
>
<
service
-
method
name
=
"sayHello"
local
-
name
=
"sayHello"
service
-
id
=
"sayHello"
version
=
""
description
=
""
method
-
name
=
"sayHello"
>
<
service
-
parameters
>
<
service
-
parameter
name
=
"name"
type
=
"java.lang.String"
required
=
"true"
is
-
array
=
"false"
/
>
<
/
service
-
parameters
>
<
service
-
result
name
=
"result"
required
=
"false"
is
-
array
=
"false"
type
=
"java.lang.String"
/
>
<
/
service
-
method
>
<
/
service
-
component
>
<
/
service
-
components
>
|
1
2
3
|
<
service
-
view
-
mappings
>
<
service
-
view
-
mapping service
-
id
=
"sayHello"
path
=
"/helloworld/helloresult.page"
type
=
"forward"
>
<
/
service
-
view
-
mapping
>
<
/
service
-
view
-
mappings
>
|
1
2
3
4
|
<
form action
=
"sayHello.servicepage"
>
输入名称:
<
input type
=
"text"
name
=
"name"
/
>
<
input type
=
"submit"
value
=
"提交"
/
>
<
/
form
>
|
1
2
|
helloresult.page
$!
result
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
|
public
class
HelloWorldComponent implements ComponentInterface
{
String
name
;
String resultKey;
public String getResultKey
(
)
{
return
resultKey;
}
public void setResultKey
(
String resultKey
)
{
this.resultKey
=
resultKey;
}
public String getName
(
)
{
return
name
;
}
public void setName
(
String
name
)
{
this.
name
=
name
;
}
public void execute
(
Context
context
)
{
context
.put
(
resultKey
,
String.format
(
"Hello, %s"
,
name
)
)
;
}
}
|
01
02
03
04
05
06
07
08
09
10
|
<
components
>
<
component
name
=
"helloworld"
bean
=
"helloworld"
title
=
"HelloWorld组件"
category
=
"测试组件"
icon
=
"/icon/component.gif"
>
<
short
-
description
>
helloworld component
<
/
short
-
description
>
<
long
-
description
>
helloworld component long description
<
/
long
-
description
>
<
parameter
name
=
"name"
title
=
"名字"
type
=
"java.lang.String"
>
<
/
parameter
>
<
parameter
name
=
"resultKey"
title
=
"结果键值"
type
=
"java.lang.String"
>
<
/
parameter
>
<
/
component
>
<
/
components
>
|
1
2
3
4
5
6
|
/
helloworld.page
流程方式:
<
form action
=
"helloworld.pageflow"
>
输入名称:
<
input type
=
"text"
name
=
"name"
/
>
<
input type
=
"submit"
value
=
"提交"
/
>
<
/
form
>
|
1
2
|
helloresult.page
$!
result
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
@ServiceComponent
(
)
public
class
FourOperateAnnotationService
{
@ServiceMethod
(
serviceId
=
"additionWithAnno"
)
@ServiceResult
(
name
=
"result"
)
@ServiceViewMapping
(
"/fouroperate/result.page"
)
public double addition
(
double number
1
,
double number
2
)
{
return
number
1
+
number
2
;
}
@ServiceMethod
(
serviceId
=
"subtractWithAnno"
)
@ServiceResult
(
name
=
"result"
)
@ServiceViewMapping
(
"/fouroperate/result.page"
)
public double subtraction
(
double number
1
,
double number
2
)
{
return
number
1
-
number
2
;
}
@ServiceMethod
(
serviceId
=
"multiWithAnno"
)
@ServiceResult
(
name
=
"result"
)
@ServiceViewMapping
(
"/fouroperate/result.page"
)
public double multi
(
double number
1
,
double number
2
)
{
return
number
1
*
number
2
;
}
@ServiceMethod
(
serviceId
=
"divisionWithAnno"
)
@ServiceResult
(
name
=
"result"
)
@ServiceViewMapping
(
"/fouroperate/result.page"
)
public double division
(
double number
1
,
double number
2
)
{
return
number
1
/
number
2
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
|
public
class
FourOperateXmlService
{
public Double addition
(
Double number
1
,
Double number
2
)
{
return
number
1
+
number
2
;
}
public Double subtraction
(
Double number
1
,
Double number
2
)
{
return
number
1
-
number
2
;
}
public Double multi
(
Double number
1
,
Double number
2
)
{
return
number
1
*
number
2
;
}
public Double division
(
Double number
1
,
Double number
2
)
{
return
number
1
/
number
2
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
public abstract
class
AbstractFourOperateComponent implements ComponentInterface
{
protected double number
1
;
protected double number
2
;
protected String resultKey;
public String getResultKey
(
)
{
return
resultKey;
}
public void setResultKey
(
String resultKey
)
{
this.resultKey
=
resultKey;
}
public double getNumber
1
(
)
{
return
number
1
;
}
public void setNumber
1
(
double number
1
)
{
this.number
1
=
number
1
;
}
public double getNumber
2
(
)
{
return
number
2
;
}
public void setNumber
2
(
double number
2
)
{
this.number
2
=
number
2
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
public
class
User
{
private int
id
;
private String
name
;
private int age;
public int getId
(
)
{
return
id
;
}
public void setId
(
int
id
)
{
this.
id
=
id
;
}
public String getName
(
)
{
return
name
;
}
public void setName
(
String
name
)
{
this.
name
=
name
;
}
public int getAge
(
)
{
return
age;
}
public void setAge
(
int age
)
{
this.age
=
age;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
public
class
User
{
private int
id
;
private String
name
;
private int age;
public int getId
(
)
{
return
id
;
}
public void setId
(
int
id
)
{
this.
id
=
id
;
}
public String getName
(
)
{
return
name
;
}
public void setName
(
String
name
)
{
this.
name
=
name
;
}
public int getAge
(
)
{
return
age;
}
public void setAge
(
int age
)
{
this.age
=
age;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
|
<
?xml
version
=
"1.0"
?
>
<
!DOCTYPE hibernate
-
mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
<
hibernate
-
mapping package
=
"org.tinygroup.crud.pojo"
>
<
class
name
=
"User"
table
=
"user"
>
<
id
name
=
"id"
>
<
generator
class
=
"native"
/
>
<
/
id
>
<
property
name
=
"name"
/
>
<
property
name
=
"age"
/
>
<
/
class
>
<
/
hibernate
-
mapping
>
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
public
class
HibernateCrudDao extends HibernateDaoSupport implements CrudDbDao
<
User
>
{
public void addUser
(
User user
)
{
getHibernateTemplate
(
)
.
save
(
user
)
;
}
public void updateUser
(
User user
)
{
getHibernateTemplate
(
)
.
update
(
user
)
;
}
public void deleteUser
(
User user
)
{
getHibernateTemplate
(
)
.
delete
(
user
)
;
}
@SuppressWarnings
(
"unchecked"
)
public List
<
User
>
queryUsers
(
User user
)
{
if
(
user
=
=
null
)
{
return
getHibernateTemplate
(
)
.loadAll
(
User.
class
)
;
}
return
getHibernateTemplate
(
)
.findByExample
(
user
)
;
}
public User queryUserById
(
int
id
)
{
return
(
User
)
getHibernateTemplate
(
)
.
get
(
User.
class
,
id
)
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
@ServiceComponent
(
)
public
class
HibernateCrudService implements CrudDbService
<
User
>
{
private CrudDbDao
<
User
>
crudDbDao;
public CrudDbDao
<
User
>
getCrudDbDao
(
)
{
return
crudDbDao;
}
public void setCrudDbDao
(
CrudDbDao
<
User
>
crudDbDao
)
{
this.crudDbDao
=
crudDbDao;
}
@ServiceMethod
(
serviceId
=
"addUser"
)
@ServiceViewMapping
(
value
=
"/queryUsers.servicepage"
,
type
=
"redirect"
)
public void addUser
(
User user
)
{
crudDbDao.addUser
(
user
)
;
}
@ServiceMethod
(
serviceId
=
"updateUser"
)
@ServiceViewMapping
(
value
=
"/queryUsers.servicepage"
,
type
=
"redirect"
)
public void updateUser
(
User user
)
{
crudDbDao.updateUser
(
user
)
;
}
@ServiceMethod
(
serviceId
=
"deleteUser"
)
@ServiceViewMapping
(
value
=
"/queryUsers.servicepage"
,
type
=
"redirect"
)
public void deleteUserById
(
int
id
)
{
User user
=
getUserById
(
id
)
;
crudDbDao.deleteUser
(
user
)
;
}
@ServiceMethod
(
serviceId
=
"queryUsers"
)
@ServiceResult
(
name
=
"users"
)
@ServiceViewMapping
(
"/crud/service/hibernate/list.page"
)
public List
<
User
>
queryUsers
(
User user
)
{
return
crudDbDao.queryUsers
(
user
)
;
}
@ServiceMethod
(
serviceId
=
"queryUserById"
)
@ServiceResult
(
name
=
"user"
)
@ServiceViewMapping
(
"/crud/service/hibernate/operate.page"
)
public User getUserById
(
Integer
id
)
{
if
(
id
=
=
null
)
{
return
null;
}
return
crudDbDao.queryUserById
(
id
)
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
@ServiceComponent
(
)
public
class
TinyDbCrudService extends BeanSupport implements CrudDbService
<
Bean
>
{
private DBOperator operator;
private BeanOperatorManager manager;
private String beanType;
public void setBeanType
(
String beanType
)
{
this.beanType
=
beanType;
}
public void setManager
(
BeanOperatorManager manager
)
{
this.manager
=
manager;
}
/
*
*
初始化bean。
*
/
protected void init
(
)
throws Exception
{
Assert.assertNotNull
(
manager
,
"manager must not null"
)
;
operator
=
manager.getDbOperator
(
beanType
)
;
}
@ServiceMethod
(
serviceId
=
"addUserTiny"
)
@ServiceViewMapping
(
value
=
"/queryUsersTiny.servicepage?@beantype=user"
,
type
=
"redirect"
)
public void addUser
(
Bean user
)
{
operator.insert
(
user
)
;
}
@ServiceMethod
(
serviceId
=
"updateUserTiny"
)
@ServiceViewMapping
(
value
=
"/queryUsersTiny.servicepage?@beantype=user"
,
type
=
"redirect"
)
public void updateUser
(
Bean user
)
{
operator.
update
(
user
)
;
}
@ServiceMethod
(
serviceId
=
"deleteUserTiny"
)
@ServiceViewMapping
(
value
=
"/queryUsersTiny.servicepage?@beantype=user"
,
type
=
"redirect"
)
public void deleteUserById
(
int
id
)
{
operator.deleteById
(
id
)
;
}
@ServiceMethod
(
serviceId
=
"queryUsersTiny"
)
@ServiceResult
(
name
=
"users"
)
@ServiceViewMapping
(
"/crud/service/tinydb/list.page"
)
public List
<
Bean
>
queryUsers
(
Bean user
)
{
if
(
user
=
=
null
)
{
user
=
new
Bean
(
beanType
)
;
}
Bean[] beans
=
operator.getBeans
(
user
)
;
return
Arrays.asList
(
beans
)
;
}
@ServiceMethod
(
serviceId
=
"queryUserByIdTiny"
)
@ServiceResult
(
name
=
"user"
)
@ServiceViewMapping
(
"/crud/service/tinydb/operate.page"
)
public Bean getUserById
(
Integer
id
)
{
if
(
id
=
=
null
)
{
return
null;
}
return
operator.getBean
(
id
)
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
|
<
dependency
>
<
groupId
>
org.tinygroup
<
/
groupId
>
<
artifactId
>
org.tinygroup.helloworld
<
/
artifactId
>
<
version
>
1.2
.
0
-
SNAPSHOT
<
/
version
>
<
/
dependency
>
<
dependency
>
<
groupId
>
org.tinygroup
<
/
groupId
>
<
artifactId
>
org.tinygroup.fouroperate
<
/
artifactId
>
<
version
>
1.2
.
0
-
SNAPSHOT
<
/
version
>
<
/
dependency
>
<
dependency
>
<
groupId
>
org.tinygroup
<
/
groupId
>
<
artifactId
>
org.tinygroup.crud
<
/
artifactId
>
<
version
>
1.2
.
0
-
SNAPSHOT
<
/
version
>
<
/
dependency
>
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
|
<
table border
=
"1"
width
=
"100%"
>
<
tr
>
<
td colspan
=
"2"
>
helloworld示例
:
<
a href
=
"${TINY_CONTEXT_PATH}/helloworld/helloworld.page"
>
helloworld
<
/
a
>
<
br
/
>
四则运算示例
:
<
a href
=
"${TINY_CONTEXT_PATH}/fouroperate/fouroperate.page"
>
四则运算
<
/
a
>
<
br
/
>
增删改查示例
:
<
a href
=
"${TINY_CONTEXT_PATH}/crud/crud.page"
>
增删改查
<
/
a
>
<
br
/
>
<
/
td
>
<
/
tr
>
<
tr
>
<
td width
=
"20%"
>
内容展示
<
/
td
>
<
td
>
$pageContent
<
/
td
>
<
/
tr
>
<
/
table
>
|