Browse Source

增加授权插件的编写示例

pull/3/head
richie 6 years ago
parent
commit
d373cde1d2
  1. 6
      plugin-function/build.xml
  2. 6
      plugin-function/src/main/java/com/fr/plugin/MyAbs.java
  3. 6
      plugin-function/src/main/java/com/fr/plugin/MyFunctionConstants.java

6
plugin-function/build.xml

@ -5,7 +5,7 @@
<property name="libs" value="${basedir}/lib"/> <property name="libs" value="${basedir}/lib"/>
<property name="publicLibs" value=""/> <property name="publicLibs" value=""/>
<property name="reportLibs" value="${basedir}/../../webroot/WEB-INF/lib"/> <property name="reportLibs" value="lib/report"/>
<property name="destLoc" value="."/> <property name="destLoc" value="."/>
<property name="classes" value="classes"/> <property name="classes" value="classes"/>
<xmlproperty file="${basedir}/plugin.xml"/> <xmlproperty file="${basedir}/plugin.xml"/>
@ -68,6 +68,10 @@
<compilerarg line="-encoding UTF8 "/> <compilerarg line="-encoding UTF8 "/>
<classpath refid="compile.classpath"/> <classpath refid="compile.classpath"/>
</javac> </javac>
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask">
<classpath refid="compile.classpath"/>
</taskdef>
<pretreatment baseDir="${basedir}"/>
</target> </target>
<target name="jar_classes"> <target name="jar_classes">

6
plugin-function/src/main/java/com/fr/plugin/MyAbs.java

@ -4,16 +4,22 @@ import com.fr.general.FArray;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.intelli.record.Focus; import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original; import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction; import com.fr.script.AbstractFunction;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Primitive; import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
@EnableMetrics @EnableMetrics
@Authorize(callSignKey = MyFunctionConstants.PLUGIN_ID)
public class MyAbs extends AbstractFunction { public class MyAbs extends AbstractFunction {
@Focus(id = "com.fr.plugin.function.test", text = "Plugin-Test_Function_Abs", source = Original.PLUGIN) @Focus(id = "com.fr.plugin.function.test", text = "Plugin-Test_Function_Abs", source = Original.PLUGIN)
public Object run(Object[] args) { public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return "Error:authorization is expired.";
}
int len = ArrayUtils.getLength(args); int len = ArrayUtils.getLength(args);
if (len == 0) { if (len == 0) {
return Primitive.ERROR_VALUE; return Primitive.ERROR_VALUE;

6
plugin-function/src/main/java/com/fr/plugin/MyFunctionConstants.java

@ -0,0 +1,6 @@
package com.fr.plugin;
public class MyFunctionConstants {
public static final String PLUGIN_ID = "com.fr.plugin.function.test";
}
Loading…
Cancel
Save