Commit 82a2c2c7 by 李秋伟

Merge branch 'feature_protocol' into 'master'

Feature protocol

See merge request mall/arch/matrix!51
parents bc8d1e7d 48570d40
......@@ -50,18 +50,15 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
......
......@@ -42,8 +42,9 @@ public class StringUtil extends StringUtils {
/**
* camel转换为snake
*
* 转换为下划线
* @param str
* @param ch 原字符串中的连接符号
* @return
*/
public static String toSnakeCase(String str, char ch) {
......@@ -58,14 +59,35 @@ public class StringUtil extends StringUtils {
}
}
/**
* 连接字符串连接,如order-pay
* @return
*/
public static String toHyphen(String str){
return toSnakeCase(str, CharConstant.UNDERLINE);
}
public static String toHyphen(String str,char ch) {
switch (ch) {
case CharConstant.UNDERLINE:
return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, str);
default:
return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, str);
}
}
public static void main(String[] args) {
String str = "test_jata";
String str = "testJdate_order";
System.out.println(toCamelCase(str));
System.out.println(toCamelCase("test-jdate", '-'));
String str2 = "testJdate";
System.out.println(toSnakeCase(str));
String str2 = "testJdate_order";
System.out.println(toSnakeCase(str2,'-'));
String str3 = "testJdateOrderj";
System.out.println("toHyphen=="+toHyphen(str3,'-'));
System.out.println(toSnakeCase("test-jdate", '-'));
}
......
......@@ -20,16 +20,16 @@ public interface DataSourceConfig {
*
* @return the connection timeout in milliseconds
*/
long getConnectionTimeout();
Long getConnectionTimeout();
/**
* Set the maximum number of milliseconds that a client will wait for a connection from the pool. If this
* time is exceeded without a connection becoming available, a SQLException will be thrown from
* {@link javax.sql.DataSource#getConnection()}.
*
* @param connectionTimeoutMs the connection timeout in milliseconds
* @param connectionTimeout the connection timeout in milliseconds
*/
void setConnectionTimeout(long connectionTimeoutMs);
void setConnectionTimeout(Long connectionTimeout);
/**
* This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
......@@ -39,7 +39,7 @@ public interface DataSourceConfig {
*
* @return the idle timeout in milliseconds
*/
long getIdleTimeout();
Long getIdleTimeout();
/**
* This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
......@@ -49,7 +49,7 @@ public interface DataSourceConfig {
*
* @param idleTimeoutMs the idle timeout in milliseconds
*/
void setIdleTimeout(long idleTimeoutMs);
void setIdleTimeout(Long idleTimeoutMs);
/**
* This property controls the maximum lifetime of a connection in the pool. When a connection reaches this
......@@ -58,7 +58,7 @@ public interface DataSourceConfig {
*
* @return the maximum connection lifetime in milliseconds
*/
long getMaxLifetime();
Long getMaxLifetime();
/**
* This property controls the maximum lifetime of a connection in the pool. When a connection reaches this
......@@ -67,7 +67,7 @@ public interface DataSourceConfig {
*
* @param maxLifetimeMs the maximum connection lifetime in milliseconds
*/
void setMaxLifetime(long maxLifetimeMs);
void setMaxLifetime(Long maxLifetimeMs);
/**
* The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
......@@ -76,7 +76,7 @@ public interface DataSourceConfig {
*
* @return the minimum number of connections in the pool
*/
int getMinimumIdle();
Integer getMinimumIdle();
/**
* The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
......@@ -85,7 +85,7 @@ public interface DataSourceConfig {
*
* @param minIdle the minimum number of idle connections in the pool to maintain
*/
void setMinimumIdle(int minIdle);
void setMinimumIdle(Integer minIdle);
/**
* The property controls the maximum number of connections that HikariCP will keep in the pool,
......@@ -93,7 +93,7 @@ public interface DataSourceConfig {
*
* @return the maximum number of connections in the pool
*/
int getMaximumPoolSize();
Integer getMaximumPoolSize();
/**
* The property controls the maximum size that the pool is allowed to reach, including both idle and in-use
......@@ -105,7 +105,7 @@ public interface DataSourceConfig {
*
* @param maxPoolSize the maximum number of connections in the pool
*/
void setMaximumPoolSize(int maxPoolSize);
void setMaximumPoolSize(Integer maxPoolSize);
/**
* Set the password used for authentication. Changing this at runtime will apply to new connections only.
......
......@@ -13,14 +13,15 @@ public class MatrixDataSourceConfig implements DataSourceConfig {
*/
private String url;
private int minimumIdle = DEFAULT_MIN_IDLE;
private int maxPoolSize = DEFAULT_POOL_SIZE;
private Integer minimumIdle = DEFAULT_MIN_IDLE;
private Integer maxPoolSize = DEFAULT_POOL_SIZE;
/**
* Unit:Millis
*/
private long connectionTimeout = CONNECTION_TIMEOUT;
private long idleTimeout = IDLE_TIMEOUT;
private long maxLifetime = MAX_LIFETIME;
private Long connectionTimeout = CONNECTION_TIMEOUT;
private Long idleTimeout = IDLE_TIMEOUT;
private Long maxLifetime = MAX_LIFETIME;
public void setName(String name) {
......@@ -28,52 +29,22 @@ public class MatrixDataSourceConfig implements DataSourceConfig {
}
@Override
public long getConnectionTimeout() {
return connectionTimeout;
}
@Override
public void setConnectionTimeout(long connectionTimeoutMs) {
this.connectionTimeout = connectionTimeoutMs;
}
@Override
public long getIdleTimeout() {
return idleTimeout;
}
@Override
public void setIdleTimeout(long idleTimeoutMs) {
this.idleTimeout = idleTimeoutMs;
}
@Override
public long getMaxLifetime() {
return maxLifetime;
}
@Override
public void setMaxLifetime(long maxLifetimeMs) {
this.maxLifetime = maxLifetimeMs;
}
@Override
public int getMinimumIdle() {
public Integer getMinimumIdle() {
return this.minimumIdle;
}
@Override
public void setMinimumIdle(int minIdle) {
public void setMinimumIdle(Integer minIdle) {
this.minimumIdle = minIdle;
}
@Override
public int getMaximumPoolSize() {
public Integer getMaximumPoolSize() {
return maxPoolSize;
}
@Override
public void setMaximumPoolSize(int maxPoolSize) {
public void setMaximumPoolSize(Integer maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
......
......@@ -21,9 +21,10 @@ public class DruidDataSourceFactory extends AbsDataSourceFactory<DruidDataSource
dataSource.setPassword(config.getPassword());
dataSource.setMinIdle(config.getMinimumIdle());
dataSource.setMaxActive(config.getMaximumPoolSize());
/*屏蔽时间属性,使用druid个性化属性
dataSource.setPhyTimeoutMillis(config.getConnectionTimeout());
dataSource.setTimeBetweenEvictionRunsMillis(config.getIdleTimeout());
dataSource.setMaxEvictableIdleTimeMillis(config.getMaxLifetime());
dataSource.setMaxEvictableIdleTimeMillis(config.getMaxLifetime());*/
try {
dataSource.init();
} catch (SQLException e) {
......
......@@ -12,6 +12,9 @@ public class MatrixDruidDataSourceProperties extends MatrixDataSourceProperties
private Integer initialSize;
private Long timeBetweenEvictionRunsMillis= DruidAbstractDataSource.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
private Long timeBetweenLogStatsMillis;
private Integer minIdle;
private Integer maxIdle;
private Long maxWait;
private Integer statSqlMaxSize;
private Long minEvictableIdleTimeMillis;
private Long maxEvictableIdleTimeMillis;
......
......@@ -17,10 +17,10 @@ package com.secoo.mall.mybatis.interceptor;
import com.baomidou.mybatisplus.core.toolkit.*;
import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
import com.mysql.cj.jdbc.ClientPreparedStatement;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
......@@ -101,14 +101,9 @@ public class MatrixPerformanceInterceptor implements Interceptor {
String originalSql = null;
String stmtClassName = statement.getClass().getName();
if (DruidPooledPreparedStatement.equals(stmtClassName)) {
try {
if (statement instanceof ClientPreparedStatement) {
originalSql = ClientPreparedStatement.class.cast(Statement.class).asSql();
}
Object rawPreparedStatement = MethodUtils.invokeExactMethod(statement, "getRawPreparedStatement");
originalSql = MethodUtils.invokeExactMethod(rawPreparedStatement, "asSql").toString();
} catch (Exception e) {
e.printStackTrace();
}
} else if (T4CPreparedStatement.equals(stmtClassName)
|| OraclePreparedStatementWrapper.equals(stmtClassName)) {
try {
......
......@@ -28,7 +28,6 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
......
......@@ -6,6 +6,7 @@ import com.secoo.mall.common.util.sys.SystemUtil;
import com.secoo.mall.web.annotation.ApiController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
......@@ -29,6 +30,7 @@ public class MatrixWebAutoConfiguration {
private String appVersion;
@Bean
@ConditionalOnMissingBean(Docket.class)
public Docket createWebApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()).enable(SystemUtil.isBetaEnv())
......
......@@ -66,11 +66,7 @@
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo-starter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
......@@ -90,6 +86,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo-starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--zookeeper-->
<dependency>
<groupId>org.apache.dubbo</groupId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment