Skip to content

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

@yaoguangluo

Description

@yaoguangluo

因为该作品已经申请个人软著,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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions