1.1 --- a/samples/componentinjection/anagram-modular/src-app-property/org/apidesign/anagram/app/property/AnagramsWithProperties.java Sat Jun 14 10:07:00 2008 +0200
1.2 +++ b/samples/componentinjection/anagram-modular/src-app-property/org/apidesign/anagram/app/property/AnagramsWithProperties.java Sat Jun 14 10:07:01 2008 +0200
1.3 @@ -13,23 +13,14 @@
1.4 public AnagramsWithProperties() {
1.5 }
1.6
1.7 - private static <T> Class<? extends T> loadImpl(Class<T> clazz) throws ClassNotFoundException {
1.8 - String implName = System.getProperty(clazz.getName());
1.9 - assert implName != null;
1.10 - ClassLoader loader = Thread.currentThread().getContextClassLoader();
1.11 - if (loader == null) {
1.12 - loader = AnagramsWithProperties.class.getClassLoader();
1.13 - }
1.14 - Class<?> impl = Class.forName(implName, false, loader);
1.15 - return impl.asSubclass(clazz);
1.16 - }
1.17 -
1.18 -
1.19 @Override
1.20 protected WordLibrary getWordLibrary() {
1.21 try {
1.22 if (wordLibrary == null) {
1.23 - wordLibrary = loadImpl(WordLibrary.class).newInstance();
1.24 + String implName = System.getProperty("org.apidesign.anagram.api.WordLibrary");
1.25 + assert implName != null;
1.26 + Class<?> impl = Class.forName(implName);
1.27 + wordLibrary = (WordLibrary)impl.newInstance();
1.28 }
1.29 return wordLibrary;
1.30 } catch (Exception ex) {
1.31 @@ -41,7 +32,10 @@
1.32 protected Scrambler getScrambler() {
1.33 try {
1.34 if (scrambler == null) {
1.35 - scrambler = loadImpl(Scrambler.class).newInstance();
1.36 + String implName = System.getProperty("org.apidesign.anagram.api.Scrambler");
1.37 + assert implName != null;
1.38 + Class<?> impl = Class.forName(implName);
1.39 + scrambler = (Scrambler)impl.newInstance();
1.40 }
1.41 return scrambler;
1.42 } catch (Exception ex) {