1212 * limitations under the License.
1313 */
1414
15- package org .httprpc .sierra .tools ;
15+ package org .httprpc .sierra .tools . dtd ;
1616
1717import org .httprpc .kilo .beans .BeanAdapter ;
1818import org .httprpc .kilo .io .Encoder ;
3737import java .awt .Image ;
3838import java .io .IOException ;
3939import java .io .Writer ;
40+ import java .net .URL ;
41+ import java .net .URLClassLoader ;
4042import java .nio .file .Files ;
4143import java .nio .file .Path ;
4244import java .util .ArrayList ;
@@ -256,7 +258,22 @@ public static void main(String[] args) throws Exception {
256258 var workingPath = Path .of (System .getProperty ("user.dir" ));
257259
258260 if (args .length > 0 ) {
259- applyBindings (workingPath .resolve (args [0 ]));
261+ ClassLoader classLoader ;
262+ if (args .length > 1 ) {
263+ try (var paths = Files .walk (workingPath .resolve (args [1 ]))) {
264+ classLoader = new URLClassLoader (paths .map (path -> {
265+ try {
266+ return path .toUri ().toURL ();
267+ } catch (IOException exception ) {
268+ throw new RuntimeException (exception );
269+ }
270+ }).toArray (URL []::new ));
271+ }
272+ } else {
273+ classLoader = ClassLoader .getSystemClassLoader ();
274+ }
275+
276+ applyBindings (workingPath .resolve (args [0 ]), classLoader );
260277 }
261278
262279 var typeSet = new HashSet <Class <?>>();
@@ -287,7 +304,7 @@ public static void main(String[] args) throws Exception {
287304 }
288305
289306 @ SuppressWarnings ("unchecked" )
290- private static void applyBindings (Path path ) throws IOException , ClassNotFoundException {
307+ private static void applyBindings (Path path , ClassLoader classLoader ) throws IOException , ClassNotFoundException {
291308 var bindings = new Properties ();
292309
293310 try (var inputStream = Files .newInputStream (path )) {
@@ -296,9 +313,9 @@ private static void applyBindings(Path path) throws IOException, ClassNotFoundEx
296313
297314 for (var entry : bindings .entrySet ()) {
298315 var tag = (String )entry .getKey ();
299- var type = (Class <? extends JComponent >) Class . forName (( String )entry .getValue () );
316+ var typeName = (String )entry .getValue ();
300317
301- UILoader .bind (tag , type , () -> null );
318+ UILoader .bind (tag , ( Class <? extends JComponent >) classLoader . loadClass ( typeName ) , () -> null );
302319 }
303320 }
304321
0 commit comments