Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
superrain51
apollo
提交
1def2409
apollo
项目概览
superrain51
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1def2409
编写于
4月 16, 2016
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #99 from yiming187/update
Transactional Support
上级
bd502e16
1d123a22
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
215 addition
and
48 deletion
+215
-48
apollo-adminservice/src/main/java/com/ctrip/apollo/AdminServiceApplication.java
...c/main/java/com/ctrip/apollo/AdminServiceApplication.java
+6
-1
apollo-biz/pom.xml
apollo-biz/pom.xml
+0
-4
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
...lo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
+6
-4
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java
...c/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java
+6
-4
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
...src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
+2
-1
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java
...iz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java
+4
-2
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
...o-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
+7
-5
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Namespace.java
.../src/main/java/com/ctrip/apollo/biz/entity/Namespace.java
+5
-3
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Privilege.java
.../src/main/java/com/ctrip/apollo/biz/entity/Privilege.java
+5
-3
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
...iz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
+8
-6
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java
.../main/java/com/ctrip/apollo/biz/service/AdminService.java
+3
-6
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppService.java
...rc/main/java/com/ctrip/apollo/biz/service/AppService.java
+4
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ClusterService.java
...ain/java/com/ctrip/apollo/biz/service/ClusterService.java
+4
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemService.java
...c/main/java/com/ctrip/apollo/biz/service/ItemService.java
+4
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemSetService.java
...ain/java/com/ctrip/apollo/biz/service/ItemSetService.java
+2
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/NamespaceService.java
...n/java/com/ctrip/apollo/biz/service/NamespaceService.java
+4
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/PrivilegeService.java
...n/java/com/ctrip/apollo/biz/service/PrivilegeService.java
+3
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ReleaseService.java
...ain/java/com/ctrip/apollo/biz/service/ReleaseService.java
+2
-0
apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java
apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java
+3
-1
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
...va/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
+5
-6
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
...t/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
+5
-0
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTransactionTest.java
...ctrip/apollo/biz/service/AdminServiceTransactionTest.java
+97
-0
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
...va/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
+5
-0
apollo-common/pom.xml
apollo-common/pom.xml
+12
-0
apollo-configservice/src/main/java/com/ctrip/apollo/ConfigServiceApplication.java
.../main/java/com/ctrip/apollo/ConfigServiceApplication.java
+7
-1
apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java
.../main/java/com/ctrip/apollo/portal/PortalApplication.java
+6
-1
未找到文件。
apollo-adminservice/src/main/java/com/ctrip/apollo/AdminServiceApplication.java
浏览文件 @
1def2409
package
com.ctrip.apollo
;
import
org.springframework.boot.actuate.system.ApplicationPidFileWriter
;
import
org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.context.ConfigurableApplicationContext
;
@SpringBootApplication
@EnableEurekaClient
public
class
AdminServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
AdminServiceApplication
.
class
).
run
(
args
);
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
AdminServiceApplication
.
class
).
run
(
args
);
context
.
addApplicationListener
(
new
ApplicationPidFileWriter
());
context
.
addApplicationListener
(
new
EmbeddedServerPortFileWriter
());
}
}
apollo-biz/pom.xml
浏览文件 @
1def2409
...
...
@@ -16,10 +16,6 @@
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo-common
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
浏览文件 @
1def2409
...
...
@@ -2,25 +2,27 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"App"
)
@SQLDelete
(
sql
=
"Update App set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
App
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"Name"
,
n
ullable
=
false
)
private
String
name
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"AppId"
,
n
ullable
=
false
)
private
String
appId
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"OwnerName"
,
n
ullable
=
false
)
private
String
ownerName
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"OwnerEmail"
,
n
ullable
=
false
)
private
String
ownerEmail
;
public
String
getAppId
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java
浏览文件 @
1def2409
...
...
@@ -2,22 +2,24 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"AppNamespace"
)
@SQLDelete
(
sql
=
"Update AppNamespace set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
AppNamespace
extends
BaseEntity
{
public
class
AppNamespace
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"Name"
,
n
ullable
=
false
)
private
String
name
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"AppId"
,
n
ullable
=
false
)
private
String
appId
;
@Column
@Column
(
name
=
"Comment"
)
private
String
comment
;
public
String
getAppId
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
浏览文件 @
1def2409
...
...
@@ -18,9 +18,10 @@ public abstract class BaseEntity {
@Id
@GeneratedValue
@Column
(
name
=
"Id"
)
private
long
id
;
@Column
(
name
=
"IsDeleted"
,
columnDefinition
=
"Bit default '0'"
)
@Column
(
name
=
"IsDeleted"
,
columnDefinition
=
"Bit default '0'"
)
protected
boolean
isDeleted
=
false
;
@Column
(
name
=
"DataChange_CreatedBy"
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java
浏览文件 @
1def2409
...
...
@@ -2,6 +2,7 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
...
...
@@ -10,14 +11,15 @@ import org.hibernate.annotations.Where;
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@Table
(
name
=
"Cluster"
)
@SQLDelete
(
sql
=
"Update Cluster set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Cluster
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"Name"
,
n
ullable
=
false
)
private
String
name
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"AppId"
,
n
ullable
=
false
)
private
String
appId
;
public
String
getAppId
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
浏览文件 @
1def2409
...
...
@@ -2,28 +2,30 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Item"
)
@SQLDelete
(
sql
=
"Update Item set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Item
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"NamespaceId"
,
n
ullable
=
false
)
private
long
namespaceId
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"key"
,
n
ullable
=
false
)
private
String
key
;
@Column
@Column
(
name
=
"value"
)
private
String
value
;
@Column
@Column
(
name
=
"comment"
)
private
String
comment
;
@Column
@Column
(
name
=
"LineNum"
)
private
Integer
lineNum
;
public
String
getComment
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Namespace.java
浏览文件 @
1def2409
...
...
@@ -2,22 +2,24 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Namespace"
)
@SQLDelete
(
sql
=
"Update Namespace set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Namespace
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"appId"
,
n
ullable
=
false
)
private
String
appId
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"ClusterName"
,
n
ullable
=
false
)
private
String
clusterName
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"NamespaceName"
,
n
ullable
=
false
)
private
String
namespaceName
;
public
String
getAppId
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Privilege.java
浏览文件 @
1def2409
...
...
@@ -2,22 +2,24 @@ package com.ctrip.apollo.biz.entity;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Privilege"
)
@SQLDelete
(
sql
=
"Update Privilege set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Privilege
extends
BaseEntity
{
@Column
@Column
(
name
=
"Name"
,
nullable
=
false
)
private
String
name
;
@Column
@Column
(
name
=
"PrivilType"
,
nullable
=
false
)
private
String
privilType
;
@Column
@Column
(
name
=
"NamespaceId"
)
private
long
namespaceId
;
public
String
getName
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
浏览文件 @
1def2409
...
...
@@ -6,32 +6,34 @@ import org.hibernate.annotations.Where;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Lob
;
import
javax.persistence.Table
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@Table
(
name
=
"Release"
)
@SQLDelete
(
sql
=
"Update Release set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Release
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"Name"
,
n
ullable
=
false
)
private
String
name
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"AppId"
,
n
ullable
=
false
)
private
String
appId
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"ClusterName"
,
n
ullable
=
false
)
private
String
clusterName
;
@Column
@Column
(
name
=
"NamespaceName"
,
nullable
=
false
)
private
String
namespaceName
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"Configurations"
,
n
ullable
=
false
)
@Lob
private
String
configurations
;
@Column
(
nullable
=
false
)
@Column
(
n
ame
=
"Comment"
,
n
ullable
=
false
)
private
String
comment
;
public
String
getAppId
()
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java
浏览文件 @
1def2409
...
...
@@ -2,8 +2,8 @@ package com.ctrip.apollo.biz.service;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.boot.actuate.metrics.CounterService
;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.entity.AppNamespace
;
import
com.ctrip.apollo.biz.entity.Cluster
;
...
...
@@ -16,6 +16,7 @@ import com.ctrip.apollo.core.ConfigConsts;
import
java.util.Date
;
@Service
public
class
AdminService
{
...
...
@@ -30,12 +31,9 @@ public class AdminService {
@Autowired
private
ClusterRepository
clusterRepository
;
@Autowired
private
CounterService
counter
;
@Transactional
public
App
createNewApp
(
App
app
)
{
counter
.
increment
(
"admin.createNewApp.start"
);
String
createBy
=
app
.
getDataChangeCreatedBy
();
App
createdApp
=
appRepository
.
save
(
app
);
String
appId
=
createdApp
.
getAppId
();
...
...
@@ -46,7 +44,6 @@ public class AdminService {
createDefaultNamespace
(
appId
,
createBy
);
counter
.
increment
(
"admin.createNewApp.success"
);
return
app
;
}
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppService.java
浏览文件 @
1def2409
...
...
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.repository.AppRepository
;
...
...
@@ -17,6 +18,7 @@ public class AppService {
@Autowired
private
AppRepository
appRepository
;
@Transactional
public
void
delete
(
long
id
)
{
appRepository
.
delete
(
id
);
}
...
...
@@ -34,10 +36,12 @@ public class AppService {
return
appRepository
.
findByAppId
(
appId
);
}
@Transactional
public
App
save
(
App
entity
)
{
return
appRepository
.
save
(
entity
);
}
@Transactional
public
App
update
(
App
app
)
{
App
managedApp
=
appRepository
.
findByAppId
(
app
.
getAppId
());
BeanUtils
.
copyEntityProperties
(
app
,
managedApp
);
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ClusterService.java
浏览文件 @
1def2409
...
...
@@ -2,6 +2,7 @@ package com.ctrip.apollo.biz.service;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.repository.ClusterRepository
;
...
...
@@ -17,14 +18,17 @@ public class ClusterService {
return
clusterRepository
.
findByAppIdAndName
(
appId
,
name
);
}
@Transactional
public
Cluster
save
(
Cluster
entity
)
{
return
clusterRepository
.
save
(
entity
);
}
@Transactional
public
void
delete
(
long
id
)
{
clusterRepository
.
delete
(
id
);
}
@Transactional
public
Cluster
update
(
Cluster
cluster
)
{
Cluster
managedCluster
=
clusterRepository
.
findByAppIdAndName
(
cluster
.
getAppId
(),
cluster
.
getName
());
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemService.java
浏览文件 @
1def2409
...
...
@@ -2,6 +2,7 @@ package com.ctrip.apollo.biz.service;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.entity.Item
;
import
com.ctrip.apollo.biz.repository.ItemRepository
;
...
...
@@ -13,6 +14,7 @@ public class ItemService {
@Autowired
private
ItemRepository
itemRepository
;
@Transactional
public
void
delete
(
long
id
)
{
itemRepository
.
delete
(
id
);
}
...
...
@@ -22,10 +24,12 @@ public class ItemService {
return
item
;
}
@Transactional
public
Item
save
(
Item
item
)
{
return
itemRepository
.
save
(
item
);
}
@Transactional
public
Item
update
(
Item
item
)
{
Item
managedItem
=
itemRepository
.
findOne
(
item
.
getId
());
BeanUtils
.
copyEntityProperties
(
item
,
managedItem
);
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemSetService.java
浏览文件 @
1def2409
...
...
@@ -2,6 +2,7 @@ package com.ctrip.apollo.biz.service;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.entity.Item
;
import
com.ctrip.apollo.biz.repository.ItemRepository
;
...
...
@@ -15,6 +16,7 @@ public class ItemSetService {
@Autowired
private
ItemRepository
itemRepository
;
@Transactional
public
void
updateSet
(
ItemChangeSets
changeSet
)
{
if
(
changeSet
.
getCreateItems
()
!=
null
)
{
for
(
ItemDTO
item
:
changeSet
.
getCreateItems
())
{
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/NamespaceService.java
浏览文件 @
1def2409
...
...
@@ -2,6 +2,7 @@ package com.ctrip.apollo.biz.service;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.entity.Namespace
;
import
com.ctrip.apollo.biz.repository.NamespaceRepository
;
...
...
@@ -13,6 +14,7 @@ public class NamespaceService {
@Autowired
private
NamespaceRepository
namespaceRepository
;
@Transactional
public
void
delete
(
long
id
)
{
namespaceRepository
.
delete
(
id
);
}
...
...
@@ -26,10 +28,12 @@ public class NamespaceService {
namespaceName
);
}
@Transactional
public
Namespace
save
(
Namespace
entity
)
{
return
namespaceRepository
.
save
(
entity
);
}
@Transactional
public
Namespace
update
(
Namespace
namespace
)
{
Namespace
managedNamespace
=
namespaceRepository
.
findByAppIdAndClusterNameAndNamespaceName
(
namespace
.
getAppId
(),
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
());
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/PrivilegeService.java
浏览文件 @
1def2409
...
...
@@ -5,6 +5,7 @@ import com.ctrip.apollo.biz.repository.PrivilegeRepository;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
@@ -18,6 +19,7 @@ public class PrivilegeService {
@Autowired
private
PrivilegeRepository
privilRepo
;
@Transactional
public
Privilege
addPrivilege
(
long
namespaceId
,
String
name
,
PrivilType
privilType
)
{
Privilege
privil
=
privilRepo
.
findByNamespaceIdAndNameAndPrivilType
(
namespaceId
,
name
,
privilType
.
name
());
...
...
@@ -41,6 +43,7 @@ public class PrivilegeService {
return
privilRepo
.
findByNamespaceId
(
namespaceId
);
}
@Transactional
public
void
removePrivilege
(
long
namespaceId
,
String
name
,
PrivilType
privilType
)
{
Privilege
privil
=
privilRepo
.
findByNamespaceIdAndNameAndPrivilType
(
namespaceId
,
name
,
privilType
.
name
());
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ReleaseService.java
浏览文件 @
1def2409
...
...
@@ -7,6 +7,7 @@ import java.util.Map;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.entity.Item
;
import
com.ctrip.apollo.biz.entity.Namespace
;
...
...
@@ -40,6 +41,7 @@ public class ReleaseService {
return
release
;
}
@Transactional
public
Release
buildRelease
(
String
name
,
String
comment
,
String
appId
,
String
clusterName
,
String
namespaceName
)
{
Namespace
namespace
=
namespaceRepository
.
findByAppIdAndClusterNameAndNamespaceName
(
appId
,
...
...
apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java
浏览文件 @
1def2409
...
...
@@ -2,6 +2,7 @@ package com.ctrip.apollo.biz;
import
com.ctrip.apollo.biz.repository.AppRepositoryTest
;
import
com.ctrip.apollo.biz.service.AdminServiceTest
;
import
com.ctrip.apollo.biz.service.AdminServiceTransactionTest
;
import
com.ctrip.apollo.biz.service.ConfigServiceTest
;
import
com.ctrip.apollo.biz.service.PrivilegeServiceTest
;
...
...
@@ -14,7 +15,8 @@ import org.junit.runners.Suite.SuiteClasses;
AppRepositoryTest
.
class
,
AdminServiceTest
.
class
,
ConfigServiceTest
.
class
,
PrivilegeServiceTest
.
class
})
PrivilegeServiceTest
.
class
,
AdminServiceTransactionTest
.
class
})
public
class
AllTests
{
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
浏览文件 @
1def2409
package
com.ctrip.apollo.biz.repository
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.BizTestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
@Transactional
@Rollback
public
class
AppRepositoryTest
{
@Autowired
private
AppRepository
appRepository
;
@Before
public
void
before
()
{
appRepository
.
deleteAll
();
}
@Test
public
void
testCreate
()
{
String
appId
=
"someAppId"
;
...
...
@@ -66,4 +64,5 @@ public class AppRepositoryTest {
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
}
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
浏览文件 @
1def2409
...
...
@@ -8,7 +8,9 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.BizTestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
...
...
@@ -17,6 +19,8 @@ import com.ctrip.apollo.biz.entity.Namespace;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
@Transactional
@Rollback
public
class
AdminServiceTest
{
@Autowired
...
...
@@ -49,4 +53,5 @@ public class AdminServiceTest {
Assert
.
assertEquals
(
1
,
namespaces
.
size
());
Assert
.
assertEquals
(
"application"
,
namespaces
.
get
(
0
).
getNamespaceName
());
}
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTransactionTest.java
0 → 100644
浏览文件 @
1def2409
package
com.ctrip.apollo.biz.service
;
import
java.util.Date
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.annotation.Commit
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.transaction.AfterTransaction
;
import
org.springframework.test.context.transaction.BeforeTransaction
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.BizTestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.repository.AppNamespaceRepository
;
import
com.ctrip.apollo.biz.repository.AppRepository
;
import
com.ctrip.apollo.biz.repository.ClusterRepository
;
import
com.ctrip.apollo.biz.repository.NamespaceRepository
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
@Transactional
@Commit
public
class
AdminServiceTransactionTest
{
@Autowired
AdminService
adminService
;
@Autowired
private
AppRepository
appRepository
;
@Autowired
private
AppNamespaceRepository
appNamespaceRepository
;
@Autowired
private
NamespaceRepository
namespaceRepository
;
@Autowired
private
ClusterRepository
clusterRepository
;
@BeforeTransaction
public
void
verifyInitialDatabaseState
()
{
for
(
App
app
:
appRepository
.
findAll
())
{
System
.
out
.
println
(
app
.
getAppId
());
}
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
Assert
.
assertEquals
(
0
,
appNamespaceRepository
.
count
());
Assert
.
assertEquals
(
0
,
namespaceRepository
.
count
());
Assert
.
assertEquals
(
0
,
clusterRepository
.
count
());
}
@Before
public
void
setUpTestDataWithinTransaction
()
{
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
Assert
.
assertEquals
(
0
,
appNamespaceRepository
.
count
());
Assert
.
assertEquals
(
0
,
namespaceRepository
.
count
());
Assert
.
assertEquals
(
0
,
clusterRepository
.
count
());
}
@Test
@Rollback
public
void
modifyDatabaseWithinTransaction
()
{
String
appId
=
"someAppId"
;
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setName
(
"someAppName"
);
String
owner
=
"someOwnerName"
;
app
.
setOwnerName
(
owner
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeCreatedTime
(
new
Date
());
adminService
.
createNewApp
(
app
);
}
@After
public
void
tearDownWithinTransaction
()
{
Assert
.
assertEquals
(
1
,
appRepository
.
count
());
Assert
.
assertEquals
(
1
,
appNamespaceRepository
.
count
());
Assert
.
assertEquals
(
1
,
namespaceRepository
.
count
());
Assert
.
assertEquals
(
1
,
clusterRepository
.
count
());
}
@AfterTransaction
public
void
verifyFinalDatabaseState
()
{
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
Assert
.
assertEquals
(
0
,
appNamespaceRepository
.
count
());
Assert
.
assertEquals
(
0
,
namespaceRepository
.
count
());
Assert
.
assertEquals
(
0
,
clusterRepository
.
count
());
}
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
浏览文件 @
1def2409
...
...
@@ -8,7 +8,9 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.apollo.biz.BizTestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
...
...
@@ -18,6 +20,8 @@ import com.ctrip.apollo.biz.entity.Privilege;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
@Transactional
@Rollback
public
class
PrivilegeServiceTest
{
@Autowired
...
...
@@ -96,4 +100,5 @@ public class PrivilegeServiceTest {
Assert
.
assertTrue
(
privilService
.
hasPrivilege
(
namespace
.
getId
(),
"nobody"
,
PrivilegeService
.
PrivilType
.
RELEASE
));
}
}
apollo-common/pom.xml
浏览文件 @
1def2409
...
...
@@ -19,9 +19,21 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-spectator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-commons
</artifactId>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
</dependency>
</dependencies>
</project>
apollo-configservice/src/main/java/com/ctrip/apollo/ConfigServiceApplication.java
浏览文件 @
1def2409
package
com.ctrip.apollo
;
import
org.springframework.boot.actuate.system.ApplicationPidFileWriter
;
import
org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
* Spring boot application entry point
...
...
@@ -14,7 +17,10 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
public
class
ConfigServiceApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
SpringApplicationBuilder
(
ConfigServiceApplication
.
class
).
run
(
args
);
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
ConfigServiceApplication
.
class
).
run
(
args
);
context
.
addApplicationListener
(
new
ApplicationPidFileWriter
());
context
.
addApplicationListener
(
new
EmbeddedServerPortFileWriter
());
}
}
apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalApplication.java
浏览文件 @
1def2409
package
com.ctrip.apollo.portal
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.actuate.system.ApplicationPidFileWriter
;
import
org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ConfigurableApplicationContext
;
@SpringBootApplication
public
class
PortalApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
.
run
(
PortalApplication
.
class
,
args
);
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
PortalApplication
.
class
,
args
);
context
.
addApplicationListener
(
new
ApplicationPidFileWriter
());
context
.
addApplicationListener
(
new
EmbeddedServerPortFileWriter
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录