Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
99611d9
Set theme jekyll-theme-merlot
mycsoft Feb 20, 2017
128fbd4
阅读代码,添加注释.
mycsoft Feb 17, 2017
df93f06
修改注释,加入myc版本号
mycsoft Feb 21, 2017
9a749d5
添加derby测试数据库脚本
mycsoft Feb 21, 2017
f91af50
添加derby测试数据库脚本:create 改为 schema.
mycsoft Feb 21, 2017
3afbf3c
阅读代码,添加注释.
mycsoft Feb 21, 2017
c4accc1
阅读代码,添加注释.
mycsoft Feb 21, 2017
29d5e8f
修改版本说明
mycsoft Feb 21, 2017
3edff77
增加derby测试数据源.首轮测试达到了90%.
mycsoft Feb 21, 2017
0c96538
修正分号错误.
mycsoft Feb 21, 2017
8f509bf
修正测试脚本,ID应该是文字类型.
mycsoft Feb 21, 2017
f00d6f3
修正测试脚本,ID应该是文字类型.
mycsoft Feb 21, 2017
50d4bfc
加入Spring ChainedTransactionManager做为分布式事务管理器.
mycsoft Feb 21, 2017
a883e86
阅读代码,添加注释.
mycsoft Feb 21, 2017
d4044be
上传e企学测试代码:实现添加平台用户
mycsoft Feb 21, 2017
087d779
上传e企学测试代码:实现添加平台企业
mycsoft Feb 21, 2017
bcb9dc3
上传e企学测试代码:实现添加平台企业
mycsoft Feb 21, 2017
71b9d5b
上传e企学测试代码:实现添加员工
mycsoft Feb 21, 2017
c25f7e4
修正log4j日志不能显示的问题.
mycsoft Feb 22, 2017
7cc4037
重构数据模型框架,提取分区对象基类.
mycsoft Feb 22, 2017
26c2b58
重构数据模型框架,提取分区对象基类.
mycsoft Feb 22, 2017
245c24c
打开调试日志
mycsoft Feb 22, 2017
21e93ad
上传e企学测试代码:实现添加员工后的检查
mycsoft Feb 22, 2017
45c1bbb
上传e企学测试代码:实现为主从分区模式的测试.
mycsoft Feb 22, 2017
fe4cb09
修复单元测试对mysql的引用问题.
mycsoft Feb 22, 2017
bc33809
将easyxue测试加入到统一测试脚本中.
mycsoft Feb 22, 2017
a6d3a9a
Merge pull request #1 from mycsoft/myc
mycsoft Feb 22, 2017
15714a1
Set theme jekyll-theme-minimal
mycsoft Feb 23, 2017
c088067
Create CNAME
mycsoft Feb 23, 2017
b580298
Update CNAME
mycsoft Feb 23, 2017
a441c70
变更项目配置信息
mycsoft Feb 23, 2017
23ed596
Update README.md
mycsoft Feb 23, 2017
b7c2911
Merge pull request #2 from mycsoft/myc
mycsoft Feb 23, 2017
b42451c
版本号升级为1.0.1
mycsoft Feb 23, 2017
573b225
解决打包时的javadoc问题,顺便把插件都升级到最新版.
mycsoft Feb 23, 2017
2a1a21f
解决打包时的javadoc问题,顺便把插件都升级到最新版.
mycsoft Feb 23, 2017
89a4683
再次升级了1.0.1.
mycsoft Feb 23, 2017
6bb88cf
上传发布操作命令.for Netbeans.
mycsoft Feb 23, 2017
11c141b
完善cobertura配置
mycsoft Feb 23, 2017
5248c49
增加findbugs
mycsoft Feb 23, 2017
268de0f
屏蔽maven-source-plugin
mycsoft Feb 23, 2017
e63f3ac
Merge remote-tracking branch 'refs/remotes/origin/master' into myc
mycsoft Feb 23, 2017
ccf890c
fixed for findbugs.
mycsoft Feb 23, 2017
760858b
fixed for findbugs.
mycsoft Feb 23, 2017
8c646fd
fixed for findbugs.
mycsoft Feb 23, 2017
15c116a
合并myc1.0.1的修改
mycsoft Feb 24, 2017
004367e
优化升级:
mycsoft Feb 24, 2017
c089025
优化升级:
mycsoft Feb 24, 2017
718b65d
删除多余文件
mycsoft Feb 24, 2017
24daad5
删除多余文件
mycsoft Feb 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/.project
/.idea
/*.iml
/.DS_Store
/.DS_Store
/derby.log
116 changes: 107 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<spring.version>3.2.4.RELEASE</spring.version>
<mybatis.version>3.2.2</mybatis.version>
<mybatis-spring.version>1.2.1</mybatis-spring.version>
<maven.compler.encoding>UTF-8</maven.compler.encoding>
</properties>

<dependencies>
Expand Down Expand Up @@ -212,7 +213,24 @@
<version>1.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.13.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.8.5.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
<scope>test</scope>
</dependency>
</dependencies>

<licenses>
Expand All @@ -233,6 +251,11 @@
<name>Feng Kuok</name>
<email>[email protected]</email>
</developer>
<developer>
<id>myc</id>
<name>Ma Yichao</name>
<email>[email protected]</email>
</developer>
</developers>

<mailingLists>
Expand Down Expand Up @@ -263,22 +286,25 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<version>3.0.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.6.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<version>2.19.1</version>
<configuration>
<skip>false</skip>
<testFailureIgnore>true</testFailureIgnore>
Expand All @@ -290,21 +316,32 @@
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12.4</version>
<version>2.19.1</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<instrumentation>
<excludes>
<exclude>**/*Test.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -314,6 +351,67 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<nohelp>true</nohelp>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>

</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<configuration>
<!-- <configLocation>${basedir}/springside-findbugs.xml</configLocation> -->

<threshold>High</threshold>
<effort>Default</effort>
<findbugsXmlOutput>true</findbugsXmlOutput>
<!-- findbugs xml���·��-->
<findbugsXmlOutputDirectory>target/site</findbugsXmlOutputDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>

</project>
32 changes: 32 additions & 0 deletions src/main/java/org/makersoft/shards/ShardedEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2017 MaYichao.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.makersoft.shards;

import org.makersoft.shards.ShardId;

/**
* 分区存储对象.
* @author MaYichao
*/
public interface ShardedEntity {

/**
* 分区与分表信息.
* @return the shardId
*/
ShardId getShardId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
*/
package org.makersoft.shards.cfg;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.ibatis.binding.BindingException;
import org.apache.ibatis.mapping.Environment;
Expand All @@ -25,6 +28,8 @@
* (只重写用的到的几个方法)
*/
public class MyBatisConfigurationsWrapper extends Configuration {

private static final Log log = LogFactory.getLog(MyBatisConfigurationsWrapper.class);

private final Configuration configuration;

Expand Down Expand Up @@ -128,12 +133,13 @@ public boolean hasStatement(String statementName, boolean validateIncompleteStat
protected void buildAllStatements() {
for (SqlSessionFactory sqlSessionFactory : getSqlSessionFactories()) {
try {
Configuration configuration = sqlSessionFactory.getConfiguration();
Configuration conf = sqlSessionFactory.getConfiguration();

Method m = Configuration.class.getDeclaredMethod("buildAllStatements");
m.setAccessible(true);
m.invoke(configuration);
} catch (Exception e) {
m.invoke(conf);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
log.error("build statements failed!", e);
// ignore exception
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public Serializable generate(SqlSession session, Object object) {

@Override
public ShardId extractShardId(Serializable identifier) {
//如果是整型直接定位分区.
if (identifier instanceof Integer) {
return new ShardId((Integer)identifier);
}
String hexId = (String) identifier;
return new ShardId(Integer.decode("0x" + hexId.substring(0, 4)));
}
Expand Down
Loading