feat: add components
This commit is contained in:
26
components/component-dataaccessentity.js
Normal file
26
components/component-dataaccessentity.js
Normal file
@@ -0,0 +1,26 @@
|
||||
requireJAR('dataaccess-1.0.jar');
|
||||
|
||||
var InMemoryCompiler = Packages.me.hatter.tools.commons.classloader.compile.InMemoryCompiler;
|
||||
var EntityJavaSourceCodeGenerateTool = Packages.me.hatter.tools.dataaccess.entity.EntityJavaSourceCodeGenerateTool;
|
||||
|
||||
var systemInMemoryCompiler = InMemoryCompiler.systemInstance().updateClassPath();
|
||||
var allCompiledEntityClassMap = {};
|
||||
|
||||
var generateClass = (json) => {
|
||||
var sourceCode = EntityJavaSourceCodeGenerateTool.instance().config(json).generate();
|
||||
var clazz = systemInMemoryCompiler.compile(sourceCode);
|
||||
return clazz;
|
||||
};
|
||||
|
||||
var getClass = (json) => {
|
||||
var jsonSha256Hex = $$.digests().sha256().digest(json.getBytes('UTF-8')).asHex();
|
||||
if (allCompiledEntityClassMap[jsonSha256Hex]) {
|
||||
return allCompiledEntityClassMap[jsonSha256Hex];
|
||||
}
|
||||
var clazz = generateClass(json);
|
||||
allCompiledEntityClassMap[jsonSha256Hex] = clazz;
|
||||
return clazz;
|
||||
};
|
||||
|
||||
exports.getClass = getClass;
|
||||
exports.generateClass = generateClass;
|
||||
Reference in New Issue
Block a user