Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于插件扫描OSGI注册模式 #7

Open
yaoguangluo opened this issue Apr 24, 2020 · 0 comments
Open

关于插件扫描OSGI注册模式 #7

yaoguangluo opened this issue Apr 24, 2020 · 0 comments

Comments

@yaoguangluo
Copy link
Owner

因为该作品已经申请个人软著,osgi实现不方便在作品中发布。
于是贴在这里。作者已经调通论证如下。

String jarCategoryLink= "";
FileDialog filedialog= new FileDialog(new Frame(), StableData.ATTENSION_LOAD_HISTORY
, FileDialog.LOAD);
filedialog.setFilenameFilter(new TXTFilter(StableData.FILE_FORMAT_ETL));
filedialog.setVisible(true);
jarCategoryLink= filedialog.getDirectory();
System.out.println(jarCategoryLink);
if(null== jarCategoryLink|| jarCategoryLink.isEmpty()|| jarCategoryLink.contains
(StableData.FILE_FORMAT_JAR)) {
System.out.println(StableData.ATTENSION_RECHOICE);
return first;
}
File file= new File(jarCategoryLink);
if(file.isFile()) {
System.out.println(StableData.ATTENSION_FILE_CHOICE);
return first;
}
File[] files= file.listFiles();
for(int i= 0; i< files.length; i++) {
@SuppressWarnings("deprecation")
URLClassLoader loader= new URLClassLoader(new URL[]{ files[i].toURL() });
String filename= files[i].getName().replace(".jar", "");
String[] columns= filename.split("\.");
//如下2行代码 refer https://www.cnblogs.com/chinaxin/p/3678442.html
//这小伙子以后有前途。哈哈
//Class myclass = loader.loadClass("hand.java.loadjar.TestClass"); //Gene new object //Object myobject = myclass.newInstance(); Class myclass= loader.loadClass(filename+ "."+ columns[columns.length- 1]+ "NodeInterface");
Object myobject= myclass.newInstance();
//我准备之后设计成病毒式热插拔,因为绕过虚拟机的思想涉及情报学特工和计算机病毒领域,害怕国家相关安全体系管控,暂时不研发。
ObjectInterface objectInterface= (ObjectInterface) myobject;
first = link.addNode(first, objectInterface);
}

yaoguangluo pushed a commit to yaoguangluo/HuaRuiJi2.8.0 that referenced this issue Apr 24, 2020
扫描插件文档代码 完整来源Refer: :yaoguangluo/ETL_Unicorn#7

20200425 罗瑶光
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant