< prev index next >

src/java.desktop/share/classes/com/sun/beans/finder/InstanceFinder.java

Print this page




  76         int index = name.lastIndexOf('.') + 1;
  77         if (index > 0) {
  78             name = name.substring(index);
  79         }
  80         for (String prefix : this.packages) {
  81             object = instantiate(type, prefix, name);
  82             if (object != null) {
  83                 return object;
  84             }
  85         }
  86         return null;
  87     }
  88 
  89     protected T instantiate(Class<?> type, String name) {
  90         if (type != null) {
  91             try {
  92                 if (name != null) {
  93                     type = ClassFinder.findClass(name, type.getClassLoader());
  94                 }
  95                 if (this.type.isAssignableFrom(type)) {
  96                     @SuppressWarnings("unchecked")
  97                     T tmp = (T) type.newInstance();
  98                     return tmp;
  99                 }
 100             }
 101             catch (Exception exception) {
 102                 // ignore any exceptions
 103             }
 104         }
 105         return null;
 106     }
 107 
 108     protected T instantiate(Class<?> type, String prefix, String name) {
 109         return instantiate(type, prefix + '.' + name);
 110     }
 111 }


  76         int index = name.lastIndexOf('.') + 1;
  77         if (index > 0) {
  78             name = name.substring(index);
  79         }
  80         for (String prefix : this.packages) {
  81             object = instantiate(type, prefix, name);
  82             if (object != null) {
  83                 return object;
  84             }
  85         }
  86         return null;
  87     }
  88 
  89     protected T instantiate(Class<?> type, String name) {
  90         if (type != null) {
  91             try {
  92                 if (name != null) {
  93                     type = ClassFinder.findClass(name, type.getClassLoader());
  94                 }
  95                 if (this.type.isAssignableFrom(type)) {
  96                     @SuppressWarnings({"unchecked", "deprecation"})
  97                     T tmp = (T) type.newInstance();
  98                     return tmp;
  99                 }
 100             }
 101             catch (Exception exception) {
 102                 // ignore any exceptions
 103             }
 104         }
 105         return null;
 106     }
 107 
 108     protected T instantiate(Class<?> type, String prefix, String name) {
 109         return instantiate(type, prefix + '.' + name);
 110     }
 111 }
< prev index next >