add jrebel mybatis support

This commit is contained in:
Shaun Chyxion 2017-05-30 12:11:43 +08:00
parent a9336d1c91
commit c2a089676e
3 changed files with 90 additions and 19 deletions

View File

@ -21,12 +21,10 @@ public class WordUtils {
* JSONObject - [JSON Object]
* JPanel - [J Panel]
* toJSONString - [to JSON String]
* Log4J - [Log 4 J]
* Log4j - [Log 4 j]
* Log4j - [Log4j]
* 99Roses - [99 Roses]
* Varchar2 - [Varchar 2]
* DO178 - [DO 178]
* Do178 - [Do 178]
* DO178 - [DO178]
* Do178 - [Do178]
* </pre>
* @param str word
* @return split result
@ -34,13 +32,16 @@ public class WordUtils {
public static String[] splitToWords(String str) {
return StringUtils.isNotBlank(str) ?
// JSONObject - JSON Object
str.split(new StringBuilder("(?<=[A-Z])(?=[A-Z][a-z])|")
// MySQL - My SQL | Log4J - Log 4 J
.append("(?<=[^A-Z])(?=[A-Z])|")
str.split(new StringBuilder("(?<=[A-Z])(?=[A-Z][a-z])")
// MySQL - My SQL
.append("|(?<=[a-z])(?=[A-Z])")
// 99Roses -> 99 Roses
.append("|(?<=[^a-zA-Z])(?=[A-Z])")
// .append("|(?<=[^A-Z])(?=[A-Z])")
// 5s - 5 s
.append("(?<=[^a-zA-Z])(?=[a-z])|")
// .append("|(?<=[^a-zA-Z])(?=[a-z])")
// A3 - A 3 | a3 - a 3
.append("(?<=[A-Za-z])(?=[^A-Za-z])")
// .append("|(?<=[A-Za-z])(?=[^A-Za-z])")
.toString()) :
new String[]{};
}

View File

@ -0,0 +1,24 @@
package me.chyxion.tigon.test;
import me.chyxion.tigon.util.WordUtils;
import org.junit.Test;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* May 30, 2017 12:05:52
*/
public class WordUtilsTest {
@Test
public void testSplit() {
System.err.println(WordUtils.convertCamelCase("MySQL", "_"));
System.err.println(WordUtils.convertCamelCase("log4", "_"));
System.err.println(WordUtils.convertCamelCase("log4j", "_"));
System.err.println(WordUtils.convertCamelCase("log4J", "_"));
System.err.println(WordUtils.convertCamelCase("JSONObject", "_"));
System.err.println(WordUtils.convertCamelCase("JSONObject", "_"));
System.err.println(WordUtils.convertCamelCase("99Rose", "_"));
System.err.println(WordUtils.convertCamelCase("99rose", "_"));
}
}

View File

@ -1,5 +1,7 @@
package me.chyxion.tigon.mybatis;
import java.io.File;
import java.net.URL;
import java.util.List;
import java.io.IOException;
import java.io.InputStream;
@ -205,15 +207,8 @@ public class TigonSqlSessionFactoryBean extends SqlSessionFactoryBean {
docType.getSystemId());
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(doc), new StreamResult(baos));
final String mapperFilePath = "[TIGON] " + mapperLocation.toString();
log.info("Use Mapper Path [{}] For Updated Byte Array.", mapperFilePath);
mapperResourceUpdated = new ByteArrayResource(baos.toByteArray()) {
@Override
public String toString() {
return mapperFilePath;
}
};
log.debug("Mapper Processed [{}].", baos);
mapperResourceUpdated = new TigonMapperResource(baos.toByteArray(), mapperLocation);
log.info("Tigon MyBatis Mapper [{}] Updated Result [{}].", mapperResourceUpdated, baos);
}
}
}
@ -239,4 +234,55 @@ public class TigonSqlSessionFactoryBean extends SqlSessionFactoryBean {
}
}
}
static class TigonMapperResource extends ByteArrayResource {
private final Resource originResource;
public TigonMapperResource(byte[] byteArray, Resource originResource) {
super(byteArray);
this.originResource = originResource;
}
/**
* {@inheritDoc}
* for JRebel monitor file
*/
@Override
public URL getURL() throws IOException {
return originResource.getURL();
}
/**
* {@inheritDoc}
* for JRebel monitor file
*/
@Override
public File getFile() throws IOException {
return originResource.getFile();
}
/**
* {@inheritDoc}
*/
@Override
public String getFilename() {
return originResource.getFilename();
}
/**
* {@inheritDoc}
*/
@Override
public String getDescription() {
return "[TIGON] " + originResource.getDescription();
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "[TIGON] " + originResource.toString();
}
}
}