add piflow-configure module

This commit is contained in:
judy0131 2020-04-15 12:01:42 +08:00
parent b0854bbad0
commit 3d0f5b5350
21 changed files with 108 additions and 7 deletions

View File

@ -81,6 +81,11 @@
<artifactId>piflow-core</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>piflow</groupId>
<artifactId>piflow-configure</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.clapper</groupId>

70
piflow-configure/pom.xml Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>piflow-project</artifactId>
<groupId>piflow</groupId>
<version>0.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>piflow-configure</artifactId>
<dependencies>
<dependency>
<groupId>piflow</groupId>
<artifactId>piflow-core</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.clapper</groupId>
<artifactId>classutil_2.11</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
</dependency>
<dependency>
<groupId>com.chuusai</groupId>
<artifactId>shapeless_2.11</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sksamuel.scrimage</groupId>
<artifactId>scrimage-core_2.11</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sksamuel.scrimage</groupId>
<artifactId>scrimage-io-extra_2.11</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sksamuel.scrimage</groupId>
<artifactId>scrimage-filters_2.11</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-json_2.11</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
</project>

View File

@ -1,6 +1,7 @@
package cn.piflow.conf.util
import java.io.File
import java.net.URLClassLoader
import cn.piflow.conf.ConfigurableStop
import cn.piflow.conf.bean.PropertyDescriptor
@ -9,12 +10,15 @@ import org.clapper.classutil.ClassFinder
import org.reflections.Reflections
import net.liftweb.json.JsonDSL._
import sun.misc.BASE64Encoder
import util.control.Breaks._
object ClassUtil {
val configurableStopClass:String = "cn.piflow.conf.ConfigurableStop"
val configurableStopClass:String = "ConfigurableStop"
val configurableStreamingStop:String = "ConfigurableStreamingStop"
val configurableIncrementalStop:String = "ConfigurableIncrementalStop"
//val classpath:String = "/opt/project/piflow/classpath"
/*def findAllConfigurableStopByClassFinder() : List[String] = {
@ -46,6 +50,7 @@ object ClassUtil {
val reflections = new Reflections("")
val allClasses = reflections.getSubTypesOf(classOf[ConfigurableStop])
val it = allClasses.iterator();
var count = 0
while(it.hasNext) {
breakable{
@ -69,8 +74,9 @@ object ClassUtil {
}
private def findAllConfigurableStopInClasspath() : List[ConfigurableStop] = {
def findAllConfigurableStopInClasspath() : List[ConfigurableStop] = {
//val classLoader = ClassUtil.getClass.getClassLoader
val classpath = System.getProperty("user.dir")+ "/classpath/"
var stopList:List[ConfigurableStop] = List()
@ -84,10 +90,16 @@ object ClassUtil {
while(it.hasNext) {
val externalClass = it.next()
if(externalClass.superClassName.equals(configurableStopClass)){
val stopIntance = Class.forName(externalClass.name).newInstance()
stopList = stopIntance.asInstanceOf[ConfigurableStop] +: stopList
if(externalClass.superClassName.equals(configurableStopClass) &&
!externalClass.name.equals(configurableStreamingStop) &&
!externalClass.name.equals(configurableIncrementalStop)){
val classpath = System.getProperty("user.dir")+ "/classpath/NSFC.jar"
var classLoader = new URLClassLoader(Array(new File(classpath).toURI.toURL),this.getClass.getClassLoader )
val stopInstance = classLoader.loadClass(externalClass.name).newInstance()
//val stopInstance = Class.forName(externalClass.name).newInstance()
stopList = stopInstance.asInstanceOf[ConfigurableStop] +: stopList
}
}
}
@ -221,6 +233,12 @@ object ClassUtil {
}
/*def getExterClassInJar() : List[ConfigurableStop] = {
val classpath = System.getProperty("user.dir")+ "/classpath/NSFC.jar"
var classLoader = new URLClassLoader(Array(new File(classpath).toURI.toURL),this.getClass.getClassLoader )
}*/
def main(args: Array[String]): Unit = {
//val stop = findConfigurableStop("cn.piflow.bundle.Class1")
//val allConfigurableStopList = findAllConfigurableStop()
@ -232,8 +250,9 @@ object ClassUtil {
val str = propertyJsonList.mkString(start, ",", end)
println(str)*/
val stop = findAllConfigurableStop()
stop.foreach(s => println(s.getClass.getName))
//val stop = findAllConfigurableStop()
//stop.foreach(s => println(s.getClass.getName))
val stopListInClassPath = findAllConfigurableStopInClasspath()
val temp = 1

View File

@ -25,6 +25,12 @@
<version>0.9</version>
</dependency>
<dependency>
<groupId>piflow</groupId>
<artifactId>piflow-configure</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>piflow</groupId>
<artifactId>piflow-bundle</artifactId>

View File

@ -198,5 +198,6 @@
<!--<module>piflow-conf</module>-->
<module>piflow-bundle</module>
<module>piflow-server</module>
<module>piflow-configure</module>
</modules>
</project>