11 changed files with 523 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# demo-resource-repository-factory-provider |
||||
|
||||
文件服务器扩展demo |
||||
文件服务器扩展demo\ |
||||
demo 生效后,决策平台的文件服务器类型多了一个DEMO REPOSITORY的选项\ |
||||
选择后,可配置root值保存(root本身没啥用,只是用来做演示)。\ |
||||
新文件服务器本质 还是直接用的本地磁盘做的文件服务器 |
@ -0,0 +1,124 @@
|
||||
|
||||
apply plugin: 'java' |
||||
|
||||
[compileJava,compileTestJava]*.options*.encoding = 'UTF-8' |
||||
|
||||
ext { |
||||
/** |
||||
* 项目中依赖的jar的路径 |
||||
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||
*/ |
||||
libPath = "$projectDir/../../webroot/WEB-INF/lib" |
||||
|
||||
/** |
||||
* 是否对插件的class进行加密保护,防止反编译 |
||||
*/ |
||||
guard = false |
||||
|
||||
def pluginInfo = getPluginInfo() |
||||
pluginPre = "fine-plugin" |
||||
pluginName = pluginInfo.id |
||||
pluginVersion = pluginInfo.version |
||||
|
||||
outputPath = "$projectDir/../../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" |
||||
} |
||||
|
||||
group = 'com.fr.plugin' |
||||
version = '10.0' |
||||
sourceCompatibility = '8' |
||||
|
||||
sourceSets { |
||||
main { |
||||
java.outputDir = file(outputPath) |
||||
output.resourcesDir = file(outputPath) |
||||
} |
||||
} |
||||
|
||||
ant.importBuild("encrypt.xml") |
||||
//定义ant变量 |
||||
ant.projectDir = projectDir |
||||
ant.references["compile.classpath"] = ant.path { |
||||
fileset(dir: libPath, includes: '**/*.jar') |
||||
fileset(dir: ".",includes:"**/*.jar" ) |
||||
} |
||||
|
||||
classes.dependsOn('clean') |
||||
|
||||
task copyFiles(type: Copy,dependsOn: 'classes'){ |
||||
from outputPath |
||||
into "$projectDir/classes" |
||||
} |
||||
|
||||
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){ |
||||
from "$projectDir/classes" |
||||
into "$projectDir/transform-classes" |
||||
include "**/*.*" |
||||
} |
||||
jar.dependsOn("preJar") |
||||
|
||||
task makeJar(type: Jar,dependsOn: preJar){ |
||||
from fileTree(dir: "$projectDir/transform-classes") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
destinationDir = file("$buildDir/libs") |
||||
|
||||
doLast(){ |
||||
delete file("$projectDir/classes") |
||||
delete file("$projectDir/transform-classes") |
||||
} |
||||
} |
||||
|
||||
task copyFile(type: Copy,dependsOn: ["makeJar"]){ |
||||
from "$buildDir/libs" |
||||
from("$projectDir/lib") { |
||||
include "*.jar" |
||||
} |
||||
from "$projectDir/plugin.xml" |
||||
into file("$buildDir/temp/plugin") |
||||
} |
||||
|
||||
task zip(type:Zip,dependsOn:["copyFile"]){ |
||||
from "$buildDir/temp/plugin" |
||||
destinationDir file("$buildDir/install") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
} |
||||
|
||||
//控制build时包含哪些文件,排除哪些文件 |
||||
processResources { |
||||
// exclude everything |
||||
// 用*.css没效果 |
||||
// exclude '**/*.css' |
||||
// except this file |
||||
// include 'xx.xml' |
||||
} |
||||
|
||||
/*读取plugin.xml中的version*/ |
||||
def getPluginInfo(){ |
||||
def xmlFile = file("plugin.xml") |
||||
if (!xmlFile.exists()) { |
||||
return ["id":"none", "version":"1.0.0"] |
||||
} |
||||
def plugin = new XmlParser().parse(xmlFile) |
||||
def version = plugin.version[0].text() |
||||
def id = plugin.id[0].text() |
||||
return ["id":id,"version":version] |
||||
} |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
maven { |
||||
url = uri('http://mvn.finedevelop.com/repository/maven-public/') |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
//使用本地jar |
||||
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||
implementation fileTree(dir: libPath, include: ['**/*.jar']) |
||||
} |
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project> |
||||
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||
<echo message="加密文件"/> |
||||
<echo message="${projectDir}"/> |
||||
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||
<classpath refid="compile.classpath"/> |
||||
</taskdef> |
||||
<pretreatment baseDir="${projectDir}"/> |
||||
</target> |
||||
<target name="compile_plain_javas" depends="copyFiles"> |
||||
</target> |
||||
</project> |
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.tptj.demo.hg.resource.repository.factory.provider.v10</id> |
||||
<name><![CDATA[ ResourceRepositoryFactoryProvider ]]></name> |
||||
<active>yes</active> |
||||
<version>1.0</version> |
||||
<env-version>10.0</env-version> |
||||
<vendor>tptj</vendor> |
||||
<jartime>2019-07-18</jartime> |
||||
<description><![CDATA[ ]]></description> |
||||
<change-notes><![CDATA[]]></change-notes> |
||||
<main-package>com.tptj.demo.hg.resource.repository.factory.provider</main-package> |
||||
<function-recorder class="com.tptj.demo.hg.resource.repository.factory.provider.Demo"/> |
||||
<extra-core> |
||||
<ResourceRepositoryFactoryProvider class="com.tptj.demo.hg.resource.repository.factory.provider.Demo"/> |
||||
</extra-core> |
||||
<extra-decision> |
||||
<WebResourceProvider class="com.tptj.demo.hg.resource.repository.factory.provider.DemoWebResource"/> |
||||
</extra-decision> |
||||
</plugin> |
@ -0,0 +1,20 @@
|
||||
package com.tptj.demo.hg.resource.repository.factory.provider; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.io.base.provider.RepositoryFactoryProvider; |
||||
import com.fr.io.fun.AbstractRepositoryFactoryProvider; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
@EnableMetrics |
||||
public class Demo extends AbstractRepositoryFactoryProvider { |
||||
@Override |
||||
@Focus(id="com.tptj.demo.hg.resource.repository.factory.provider.v10",text = "ResourceRepositoryFactoryProvider") |
||||
public RepositoryFactoryProvider getFactory() { |
||||
return new DemoFactory(); |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.tptj.demo.hg.resource.repository.factory.provider; |
||||
|
||||
import com.fr.config.Identifier; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
import com.fr.io.config.CommonRepoConfig; |
||||
import com.fr.io.context.info.GetConfig; |
||||
import com.fr.io.context.info.SetConfig; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
public class DemoConfig extends CommonRepoConfig { |
||||
|
||||
private static final String ROOT = "root"; |
||||
|
||||
public DemoConfig() { |
||||
super(DemoFactory.IDENTITY); |
||||
} |
||||
|
||||
@Identifier(ROOT) |
||||
private Conf<String> root = Holders.simple(StringUtils.EMPTY); |
||||
|
||||
@GetConfig(ROOT) |
||||
public String getRoot() { |
||||
return root.get(); |
||||
} |
||||
|
||||
@SetConfig(ROOT) |
||||
public void setRoot( String root) { |
||||
this.root.set( root ); |
||||
} |
||||
|
||||
@Override |
||||
public DemoConfig clone() throws CloneNotSupportedException { |
||||
DemoConfig obj = (DemoConfig) super.clone(); |
||||
obj.root = (Conf<String>) root.clone(); |
||||
return obj; |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.tptj.demo.hg.resource.repository.factory.provider; |
||||
|
||||
import com.fr.io.base.provider.impl.ConfigRepositoryFactory; |
||||
import com.fr.io.context.info.RepositoryProfile; |
||||
import com.fr.io.repository.ResourceRepository; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
public class DemoFactory extends ConfigRepositoryFactory<DemoConfig> { |
||||
public static final String IDENTITY = "DEMO"; |
||||
public DemoFactory() { |
||||
super(IDENTITY); |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends RepositoryProfile<DemoConfig>> getProfileClass() { |
||||
return DemoProfile.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<DemoConfig> getConfigClass() { |
||||
return DemoConfig.class; |
||||
} |
||||
|
||||
@Override |
||||
public boolean verifyConfig(DemoConfig config) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public ResourceRepository produce(String name, String root, DemoConfig config) { |
||||
return new DemoRepository(name, root, config.getRoot() ); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.tptj.demo.hg.resource.repository.factory.provider; |
||||
|
||||
import com.fr.config.Identifier; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
import com.fr.io.context.info.RepositoryProfile; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
public class DemoProfile extends RepositoryProfile<DemoConfig> { |
||||
|
||||
@Identifier("DemoConfig") |
||||
private Conf<DemoConfig> config = Holders.obj(null, DemoConfig.class); |
||||
|
||||
@Override |
||||
public DemoConfig getConfig() { |
||||
return config.get(); |
||||
} |
||||
|
||||
@Override |
||||
public void setConfig(DemoConfig config) { |
||||
this.config.set(config); |
||||
} |
||||
|
||||
@Override |
||||
public RepositoryProfile<DemoConfig> clone() throws CloneNotSupportedException { |
||||
DemoProfile cloned = (DemoProfile) super.clone(); |
||||
cloned.config = (Conf<DemoConfig>) this.config.clone(); |
||||
return cloned; |
||||
} |
||||
} |
@ -0,0 +1,108 @@
|
||||
package com.tptj.demo.hg.resource.repository.factory.provider; |
||||
|
||||
import com.fr.io.repository.FineFileEntry; |
||||
import com.fr.io.repository.base.BaseResourceRepository; |
||||
import com.fr.io.repository.base.fs.FileSystemRepository; |
||||
import com.fr.stable.Filter; |
||||
import com.fr.workspace.resource.ResourceIOException; |
||||
|
||||
import java.io.InputStream; |
||||
import java.net.URL; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
public class DemoRepository extends BaseResourceRepository { |
||||
private String root; |
||||
public DemoRepository(String name, String work_root, String root) { |
||||
super(name, work_root); |
||||
this.root = root; |
||||
} |
||||
|
||||
@Override |
||||
public boolean copyFile( String from, String to ) throws ResourceIOException { |
||||
return FileSystemRepository.getSingleton().copyFile(from, to); |
||||
} |
||||
|
||||
@Override |
||||
public String getSeparator() { |
||||
return FileSystemRepository.getSingleton().getSeparator(); |
||||
} |
||||
|
||||
@Override |
||||
public FineFileEntry getEntry(String path) { |
||||
return FileSystemRepository.getSingleton().getEntry(path); |
||||
} |
||||
|
||||
@Override |
||||
public FineFileEntry[] listEntry(String path) { |
||||
return FileSystemRepository.getSingleton().listEntry(path); |
||||
} |
||||
|
||||
@Override |
||||
public URL getResource(String path) { |
||||
return FileSystemRepository.getSingleton().getResource(path); |
||||
} |
||||
|
||||
@Override |
||||
public InputStream read(String path) throws ResourceIOException { |
||||
return FileSystemRepository.getSingleton().read(path); |
||||
} |
||||
|
||||
@Override |
||||
public void write(String path, byte[] bytes) { |
||||
FileSystemRepository.getSingleton().write(path,bytes); |
||||
} |
||||
|
||||
@Override |
||||
public boolean createFile(String path) { |
||||
return FileSystemRepository.getSingleton().createFile(path); |
||||
} |
||||
|
||||
@Override |
||||
public boolean createDirectory(String path) { |
||||
return FileSystemRepository.getSingleton().createDirectory(path); |
||||
} |
||||
|
||||
@Override |
||||
public boolean delete(String path) { |
||||
return FileSystemRepository.getSingleton().delete(path); |
||||
} |
||||
|
||||
@Override |
||||
public boolean exist(String path) { |
||||
return FileSystemRepository.getSingleton().exist(path); |
||||
} |
||||
|
||||
@Override |
||||
public String[] list(String path, Filter<String> filter) { |
||||
return FileSystemRepository.getSingleton().list(path,filter); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isDirectory(String path) { |
||||
return FileSystemRepository.getSingleton().isDirectory(path); |
||||
} |
||||
|
||||
@Override |
||||
public long lastModified(String path) { |
||||
return FileSystemRepository.getSingleton().lastModified(path); |
||||
} |
||||
|
||||
@Override |
||||
public long length(String path) { |
||||
return FileSystemRepository.getSingleton().length(path); |
||||
} |
||||
|
||||
@Override |
||||
public void shutDown() { |
||||
FileSystemRepository.getSingleton().shutDown(); |
||||
} |
||||
|
||||
@Override |
||||
public String getIdentity() { |
||||
return DemoFactory.IDENTITY; |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.tptj.demo.hg.resource.repository.factory.provider; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
public class DemoWebResource extends AbstractWebResourceProvider { |
||||
@Override |
||||
public Atom attach() { |
||||
return MainComponent.KEY; |
||||
} |
||||
@Override |
||||
public Atom client() { |
||||
return new Component(){ |
||||
public ScriptPath script( RequestClient client ) { |
||||
return ScriptPath.build("com/tptj/demo/hg/resource/repository/factory/provider/demo.js"); |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/7/20 |
||||
**/ |
||||
!(function () { |
||||
BI.config("dec.constant.intelligence.cluster.file.server", function (items) { |
||||
items.push({ |
||||
value: "DEMO", |
||||
id: "decision-intelligence-cluster-file-demo", |
||||
text: "DEMO REPOSITORY", |
||||
cardType: "dec.intelligence.cluster.file.demo" |
||||
}); |
||||
return items; |
||||
}); |
||||
var LABEL_WIDTH = 116, EDITOR_WIDTH = 300; |
||||
var DEMO = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "dec-cluster-demo", |
||||
value: {} |
||||
}, |
||||
_store: function () { |
||||
return BI.Models.getModel("dec.model.intelligence.cluster.file.demo", { |
||||
value: this.options.value |
||||
}); |
||||
}, |
||||
|
||||
watch: {}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
return { |
||||
type: "bi.vertical", |
||||
tgap: 15, |
||||
items: [ |
||||
{ |
||||
type: "dec.label.editor.item", |
||||
textWidth: LABEL_WIDTH, |
||||
editorWidth: EDITOR_WIDTH, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: "ROOT", |
||||
value: this.model.root, |
||||
ref: function (_ref) { |
||||
self.rootRow = _ref; |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setRoot(this.getValue()); |
||||
} |
||||
}] |
||||
}] |
||||
}; |
||||
}, |
||||
getValue: function () { |
||||
return { |
||||
root: this.model.root |
||||
}; |
||||
}, |
||||
validation: function () { |
||||
var valid = true, root = this.model.root; |
||||
if (BI.isEmpty(root)) { |
||||
this.rootRow.showError(BI.i18nText("Dec-Error_Null")); |
||||
valid = false; |
||||
} |
||||
return valid; |
||||
} |
||||
}); |
||||
BI.shortcut("dec.intelligence.cluster.file.demo", DEMO); |
||||
var Model = BI.inherit(Fix.Model, { |
||||
state: function () { |
||||
var val = this.options.value; |
||||
return { |
||||
root: val.root |
||||
}; |
||||
}, |
||||
computed: { |
||||
encodingArray: function () { |
||||
return BI.map(DecCst.EncodeConstants.ENCODING_ARRAY, function (i, v) { |
||||
return { |
||||
value: v |
||||
}; |
||||
}); |
||||
} |
||||
}, |
||||
actions: { |
||||
setRoot: function (v) { |
||||
this.model.root = v; |
||||
} |
||||
} |
||||
}); |
||||
BI.model("dec.model.intelligence.cluster.file.demo", Model); |
||||
})(); |
Loading…
Reference in new issue