Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java @ 8254:c87c87544cc6
Made call context injectors a list of comma separated classes.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 10 Sep 2014 12:42:39 +0200 |
parents | 9667900536b6 |
children | c57b0400ac98 |
comparison
equal
deleted
inserted
replaced
8253:b6d54b946f4c | 8254:c87c87544cc6 |
---|---|
350 int idx = 0; | 350 int idx = 0; |
351 | 351 |
352 for (int i = 0; i < num; i++) { | 352 for (int i = 0; i < num; i++) { |
353 Element item = (Element)outGenerators.item(i); | 353 Element item = (Element)outGenerators.item(i); |
354 | 354 |
355 String names = item.getAttribute("names").trim(); | 355 String names = item.getAttribute("names").trim(); |
356 String clazz = item.getAttribute("class").trim(); | 356 String clazz = item.getAttribute("class").trim(); |
357 String converter = item.getAttribute("converter").trim(); | 357 String converter = item.getAttribute("converter").trim(); |
358 String injector = item.getAttribute("injector").trim(); | 358 String injectors = item.getAttribute("injectors").trim(); |
359 | 359 |
360 if (names.isEmpty() || clazz.isEmpty()) { | 360 if (names.isEmpty() || clazz.isEmpty()) { |
361 continue; | 361 continue; |
362 } | 362 } |
363 | 363 |
389 catch (IllegalAccessException iae) { | 389 catch (IllegalAccessException iae) { |
390 log.error(iae); | 390 log.error(iae); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 ContextInjector ci = null; | 394 List<ContextInjector> cis = null; |
395 | 395 |
396 if (!injector.isEmpty()) { | 396 if (!injectors.isEmpty()) { |
397 try { | 397 cis = new ArrayList<ContextInjector>(); |
398 ci = (ContextInjector)Class.forName(injector) | 398 for (String injector: injectors.split("[\\s,]+")) { |
399 .newInstance(); | 399 try { |
400 ci.setup(item); | 400 ContextInjector ci = (ContextInjector)Class.forName(injector) |
401 } | 401 .newInstance(); |
402 catch (ClassNotFoundException cnfe) { | 402 ci.setup(item); |
403 log.error(cnfe, cnfe); | 403 cis.add(ci); |
404 } | 404 } |
405 catch (InstantiationException ie) { | 405 catch (ClassNotFoundException cnfe) { |
406 log.error(ie); | 406 log.error(cnfe, cnfe); |
407 } | 407 } |
408 catch (IllegalAccessException iae) { | 408 catch (InstantiationException ie) { |
409 log.error(iae); | 409 log.error(ie); |
410 } | 410 } |
411 } | 411 catch (IllegalAccessException iae) { |
412 | 412 log.error(iae); |
413 for (String key: names.split("[\\s,]")) { | 413 } |
414 } | |
415 } | |
416 | |
417 for (String key: names.split("[\\s,]+")) { | |
414 if (!(key = key.trim()).isEmpty()) { | 418 if (!(key = key.trim()).isEmpty()) { |
415 generators.putGenerator(key, generatorClass, cfg, ci); | 419 generators.putGenerator(key, generatorClass, cfg, cis); |
416 idx++; | 420 idx++; |
417 } | 421 } |
418 } | 422 } |
419 } | 423 } |
420 | 424 |