@@ -52,56 +52,4 @@ private String getClassName(JarEntry entry) {
5252 System .out .println ("entryName: " +entryName );
5353 return entryName .substring (0 , entryName .length () - 6 );
5454 }
55-
56- public void init (){
57-
58- System .out .println ("---- load all ----" );
59- List <Future <String >> futureList = new ArrayList <>();
60- for (String moudle :moudleList ){
61- Future <String > future = executor .submit (() -> {
62- try {
63- URL [] moduleUrl = new URL []{new URL ("file://" + moudle )};
64- @ SuppressWarnings ("resource" )
65- URLClassLoader classLoader = new URLClassLoader (moduleUrl );
66- @ SuppressWarnings ("resource" )
67- JarFile jar = new JarFile (new File (moudle ));
68- Enumeration <JarEntry > entries = jar .entries ();
69- while (entries .hasMoreElements ()) {
70- JarEntry entry = entries .nextElement ();
71- String className = getClassName (entry );
72- if (className == null ) {
73- continue ;
74- }
75-
76- try {
77- Class <?> clazz = classLoader .loadClass (className );
78- //放到内存里
79- cache .put (className , clazz );
80- } catch (Throwable t ) {
81- //System.out.println(t.getLocalizedMessage());
82- }
83- }
84- }catch (Exception e ){
85- System .out .println (e .getLocalizedMessage ());
86- }
87-
88- return moudle ;
89- });
90- futureList .add (future );
91- }
92-
93- for (Future <String > future :futureList ){
94- try {
95- String moduleName = future .get ();
96- System .out .println ("---load moudle " + moduleName + " ok" );
97- } catch (InterruptedException e ) {
98- e .printStackTrace ();
99- } catch (ExecutionException e ) {
100- e .printStackTrace ();
101- }
102- }
103- executor .shutdown ();
104- System .out .println ("----end load All module----" );
105-
106- }
10755}
0 commit comments