Skip to content

Commit

Permalink
删除guava依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
muzhantong committed Oct 19, 2022
1 parent d63b87f commit e36b1fb
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 27 deletions.
10 changes: 5 additions & 5 deletions bizlog-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>bizlog-sdk</artifactId>
<version>3.0.2-SNAPSHOT</version>
<version>3.0.2</version>
<parent>
<groupId>io.github.mouzt</groupId>
<artifactId>mzt-biz-log</artifactId>
Expand All @@ -31,13 +31,13 @@
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
</dependency>


<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.mzt.logapi.context;

import com.google.common.collect.Maps;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
Expand All @@ -28,7 +26,7 @@ public static void putVariable(String name, Object value) {
}
Deque<Map<String, Object>> mapStack = VARIABLE_MAP_STACK.get();
if (mapStack.isEmpty()) {
VARIABLE_MAP_STACK.get().push(Maps.newHashMap());
VARIABLE_MAP_STACK.get().push(new HashMap<>());
}
VARIABLE_MAP_STACK.get().element().put(name, value);
}
Expand Down Expand Up @@ -73,7 +71,7 @@ public static void putEmptySpan() {
Deque<Map<String, Object>> stack = new ArrayDeque<>();
VARIABLE_MAP_STACK.set(stack);
}
VARIABLE_MAP_STACK.get().push(Maps.newHashMap());
VARIABLE_MAP_STACK.get().push(new HashMap<>());

if (GLOBAL_VARIABLE_MAP.get() == null) {
GLOBAL_VARIABLE_MAP.set(new HashMap<>());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mzt.logapi.service.impl;

import com.google.common.collect.Lists;
import com.mzt.logapi.beans.LogRecord;
import com.mzt.logapi.service.ILogRecordService;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -27,12 +27,12 @@ public void record(LogRecord logRecord) {

@Override
public List<LogRecord> queryLog(String bizNo, String type) {
return Lists.newArrayList();
return new ArrayList<>();
}

@Override
public List<LogRecord> queryLogByBizNo(String bizNo, String type, String subType) {
return Lists.newArrayList();
return new ArrayList<>();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
* Indicate the ordering of the execution of the transaction advisor
* when multiple advices are applied at a specific joinpoint.
* <p>The default is {@link Ordered#LOWEST_PRECEDENCE}.
*
* @return 事务 advisor 的优先级
*/
int order() default Ordered.LOWEST_PRECEDENCE;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.mzt.logapi.starter.diff;

import com.google.common.collect.Lists;
import com.mzt.logapi.service.IFunctionService;
import com.mzt.logapi.starter.annotation.DiffLogField;
import com.mzt.logapi.starter.annotation.DiffLogAllFields;
import com.mzt.logapi.starter.annotation.DIffLogIgnore;
import com.mzt.logapi.starter.annotation.DiffLogAllFields;
import com.mzt.logapi.starter.annotation.DiffLogField;
import com.mzt.logapi.starter.configuration.LogRecordProperties;
import de.danielbechler.diff.node.DiffNode;
import de.danielbechler.diff.selector.ElementSelector;
Expand Down Expand Up @@ -167,7 +166,7 @@ private Collection<Object> getListValue(DiffNode node, Object object) {
if (fieldSourceValue != null && fieldSourceValue.getClass().isArray()) {
return new ArrayList<>(Arrays.asList((Object[]) fieldSourceValue));
}
return fieldSourceValue == null ? Lists.newArrayList() : (Collection<Object>) fieldSourceValue;
return fieldSourceValue == null ? new ArrayList<>() : (Collection<Object>) fieldSourceValue;
}

private Collection<Object> listSubtract(Collection<Object> minuend, Collection<Object> subTractor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.mzt.logapi.starter.support.aop;

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mzt.logapi.beans.CodeVariableType;
import com.mzt.logapi.beans.LogRecord;
import com.mzt.logapi.beans.LogRecordOps;
Expand All @@ -15,9 +12,6 @@
import com.mzt.logapi.service.impl.DiffParseFunction;
import com.mzt.logapi.starter.support.parse.LogFunctionParser;
import com.mzt.logapi.starter.support.parse.LogRecordValueParser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
Expand Down Expand Up @@ -210,19 +204,22 @@ private void saveLog(Method method, boolean flag, LogRecordOps operation, String
.createTime(new Date())
.build();

Preconditions.checkNotNull(bizLogService, "bizLogService not init!!");
bizLogService.record(logRecord);
}

private Map<CodeVariableType, Object> getCodeVariable(Method method) {
Map<CodeVariableType, Object> map = Maps.newHashMap();
Map<CodeVariableType, Object> map = new HashMap<>();
map.put(CodeVariableType.ClassName, method.getDeclaringClass());
map.put(CodeVariableType.MethodName, method.getName());
return map;
}

private List<String> getSpElTemplates(LogRecordOps operation, String... actions) {
List<String> spElTemplates = Lists.newArrayList(operation.getType(), operation.getBizNo(), operation.getSubType(), operation.getExtra());
List<String> spElTemplates = new ArrayList<>();
spElTemplates.add(operation.getType());
spElTemplates.add(operation.getBizNo());
spElTemplates.add(operation.getSubType());
spElTemplates.add(operation.getExtra());
spElTemplates.addAll(Arrays.asList(actions));
return spElTemplates;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mzt.logapi.starter.support.parse;

import com.google.common.base.Strings;
import com.mzt.logapi.beans.MethodExecuteResult;
import com.mzt.logapi.service.impl.DiffParseFunction;
import org.springframework.beans.BeansException;
Expand Down Expand Up @@ -74,7 +73,7 @@ public Map<String, String> processTemplate(Collection<String> templates, MethodE
Object value = expressionEvaluator.parseExpression(expression, annotatedElementKey, evaluationContext);
expression = logFunctionParser.getFunctionReturnValue(beforeFunctionNameAndReturnMap, value, expression, functionName);
}
matcher.appendReplacement(parsedStr, Matcher.quoteReplacement(Strings.nullToEmpty(expression)));
matcher.appendReplacement(parsedStr, Matcher.quoteReplacement(expression == null ? "" : expression));
}
matcher.appendTail(parsedStr);
expressionValues.put(expressionTemplate, parsedStr.toString());
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* 修复 DIffLogIgnore注解在集合类型上失效问题
* 支持跨方法的全局变量
* 支持日志记录异常与业务逻辑一起回滚的逻辑,默认日志记录不影响业务逻辑
* 移除了 guava 依赖

| 版本 | 状态 |
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------|
Expand Down

0 comments on commit e36b1fb

Please sign in to comment.