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] * JSONObject - [JSON Object]
* JPanel - [J Panel] * JPanel - [J Panel]
* toJSONString - [to JSON String] * toJSONString - [to JSON String]
* Log4J - [Log 4 J] * Log4j - [Log4j]
* Log4j - [Log 4 j]
* 99Roses - [99 Roses] * 99Roses - [99 Roses]
* Varchar2 - [Varchar 2] * DO178 - [DO178]
* DO178 - [DO 178] * Do178 - [Do178]
* Do178 - [Do 178]
* </pre> * </pre>
* @param str word * @param str word
* @return split result * @return split result
@ -34,13 +32,16 @@ public class WordUtils {
public static String[] splitToWords(String str) { public static String[] splitToWords(String str) {
return StringUtils.isNotBlank(str) ? return StringUtils.isNotBlank(str) ?
// JSONObject - JSON Object // JSONObject - JSON Object
str.split(new StringBuilder("(?<=[A-Z])(?=[A-Z][a-z])|") str.split(new StringBuilder("(?<=[A-Z])(?=[A-Z][a-z])")
// MySQL - My SQL | Log4J - Log 4 J // MySQL - My SQL
.append("(?<=[^A-Z])(?=[A-Z])|") .append("|(?<=[a-z])(?=[A-Z])")
// 99Roses -> 99 Roses
.append("|(?<=[^a-zA-Z])(?=[A-Z])")
// .append("|(?<=[^A-Z])(?=[A-Z])")
// 5s - 5 s // 5s - 5 s
.append("(?<=[^a-zA-Z])(?=[a-z])|") // .append("|(?<=[^a-zA-Z])(?=[a-z])")
// A3 - A 3 | a3 - a 3 // A3 - A 3 | a3 - a 3
.append("(?<=[A-Za-z])(?=[^A-Za-z])") // .append("|(?<=[A-Za-z])(?=[^A-Za-z])")
.toString()) : .toString()) :
new String[]{}; 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; package me.chyxion.tigon.mybatis;
import java.io.File;
import java.net.URL;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -205,15 +207,8 @@ public class TigonSqlSessionFactoryBean extends SqlSessionFactoryBean {
docType.getSystemId()); docType.getSystemId());
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(doc), new StreamResult(baos)); transformer.transform(new DOMSource(doc), new StreamResult(baos));
final String mapperFilePath = "[TIGON] " + mapperLocation.toString(); mapperResourceUpdated = new TigonMapperResource(baos.toByteArray(), mapperLocation);
log.info("Use Mapper Path [{}] For Updated Byte Array.", mapperFilePath); log.info("Tigon MyBatis Mapper [{}] Updated Result [{}].", mapperResourceUpdated, baos);
mapperResourceUpdated = new ByteArrayResource(baos.toByteArray()) {
@Override
public String toString() {
return mapperFilePath;
}
};
log.debug("Mapper Processed [{}].", 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();
}
}
} }