Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄营
datax-cloud
Commits
2bf97a4b
Commit
2bf97a4b
authored
Oct 30, 2019
by
yw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
4199d49e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
146 additions
and
0 deletions
+146
-0
pom.xml
datax-common/datax-common-log/pom.xml
+16
-0
EnableDataLog.java
...in/java/cn/datax/common/log/annotation/EnableDataLog.java
+14
-0
LogAop.java
.../src/main/java/cn/datax/common/log/annotation/LogAop.java
+20
-0
LogAspect.java
...-log/src/main/java/cn/datax/common/log/aop/LogAspect.java
+75
-0
AutoConfiguration.java
...in/java/cn/datax/common/log/config/AutoConfiguration.java
+19
-0
pom.xml
datax-common/pom.xml
+2
-0
No files found.
datax-common/datax-common-log/pom.xml
0 → 100644
View file @
2bf97a4b
<?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"
>
<parent>
<artifactId>
datax-common
</artifactId>
<groupId>
cn.datax
</groupId>
<version>
1.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
datax-common-log
</artifactId>
</project>
\ No newline at end of file
datax-common/datax-common-log/src/main/java/cn/datax/common/log/annotation/EnableDataLog.java
0 → 100644
View file @
2bf97a4b
package
cn
.
datax
.
common
.
log
.
annotation
;
import
cn.datax.common.log.config.AutoConfiguration
;
import
org.springframework.context.annotation.Import
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
({
AutoConfiguration
.
class
})
public
@interface
EnableDataLog
{
}
datax-common/datax-common-log/src/main/java/cn/datax/common/log/annotation/LogAop.java
0 → 100644
View file @
2bf97a4b
package
cn
.
datax
.
common
.
log
.
annotation
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
LogAop
{
/** 模块 */
String
module
()
default
""
;
/** 描述 */
String
value
()
default
""
;
}
datax-common/datax-common-log/src/main/java/cn/datax/common/log/aop/LogAspect.java
0 → 100644
View file @
2bf97a4b
package
cn
.
datax
.
common
.
log
.
aop
;
import
java.lang.reflect.Method
;
import
cn.datax.common.log.annotation.LogAop
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Aspect
public
class
LogAspect
{
// 配置织入点
@Pointcut
(
"@annotation(cn.datax.common.log.annotation.LogAop)"
)
public
void
logPointCut
()
{}
/**
* 前置通知 用于拦截操作
*
* @param joinPoint 切点
*/
@AfterReturning
(
pointcut
=
"logPointCut()"
)
public
void
doBefore
(
JoinPoint
joinPoint
)
{
handleLog
(
joinPoint
,
null
);
}
/**
* 拦截异常操作
*
* @param joinPoint
* @param e
*/
@AfterThrowing
(
value
=
"logPointCut()"
,
throwing
=
"e"
)
public
void
doAfter
(
JoinPoint
joinPoint
,
Exception
e
)
{
handleLog
(
joinPoint
,
e
);
}
protected
void
handleLog
(
final
JoinPoint
joinPoint
,
final
Exception
e
)
{
try
{
// 获得注解
LogAop
logAop
=
getAnnotationLog
(
joinPoint
);
if
(
logAop
==
null
)
{
return
;
}
// 设置方法名称
String
className
=
joinPoint
.
getTarget
().
getClass
().
getName
();
String
methodName
=
joinPoint
.
getSignature
().
getName
();
log
.
info
(
"[类名]:{},[方法]:{},[模块]:{},[描述]:{}"
,
className
,
methodName
,
logAop
.
module
(),
logAop
.
value
());
}
catch
(
Exception
exp
)
{
log
.
error
(
"前置通知异常信息:{}"
,
exp
.
getMessage
(),
exp
);
}
}
/**
* 是否存在注解,如果存在就获取
*/
private
LogAop
getAnnotationLog
(
JoinPoint
joinPoint
)
throws
Exception
{
Signature
signature
=
joinPoint
.
getSignature
();
MethodSignature
methodSignature
=
(
MethodSignature
)
signature
;
Method
method
=
methodSignature
.
getMethod
();
if
(
method
!=
null
)
{
return
method
.
getAnnotation
(
LogAop
.
class
);
}
return
null
;
}
}
datax-common/datax-common-log/src/main/java/cn/datax/common/log/config/AutoConfiguration.java
0 → 100644
View file @
2bf97a4b
package
cn
.
datax
.
common
.
log
.
config
;
import
cn.datax.common.log.aop.LogAspect
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
/**
* 扫描注入bean
* @author yuwei
* @since 2019/10/30
*/
@ComponentScan
({
"cn.datax.common.log"
})
public
class
AutoConfiguration
{
@Bean
public
LogAspect
logAspect
()
{
return
new
LogAspect
();
}
}
datax-common/pom.xml
View file @
2bf97a4b
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
<module>
datax-common-core
</module>
<module>
datax-common-core
</module>
<module>
datax-common-mybatis
</module>
<module>
datax-common-mybatis
</module>
<module>
datax-common-security
</module>
<module>
datax-common-security
</module>
<module>
datax-common-log
</module>
</modules>
</modules>
</project>
</project>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment