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