示例#1
0
  public static void register(String crClassName, String dmClassName) {
    Class dmClass;
    try { dmClass = Class.forName(dmClassName); }
    catch (java.lang.ClassNotFoundException e) {
	System.out.println("Error loading dm " + dmClassName);
	return;
    }
    Critic cr = (Critic) _singletonCritics.get(crClassName);
    if (cr == null) {
      Class crClass;
      try { crClass = Class.forName(crClassName); }
      catch (java.lang.ClassNotFoundException e) {
	System.out.println("Error loading cr " + crClassName);
	return;
      }
      try { cr = (Critic) crClass.newInstance(); }
      catch (java.lang.IllegalAccessException e) {
	System.out.println("Error instancating cr " + crClassName);
	return;
      }
      catch (java.lang.InstantiationException e) {
	System.out.println("Error instancating cr " + crClassName);
	return;
      }
      _singletonCritics.put(crClassName, cr);
      addCritic(cr);
    }
    register(cr, dmClass);
  }
示例#2
0
  /** Return a Vector of all critics that can be applied to the
   * design material subclass, including inherited critics. */
  public static Vector criticsForClass(Class clazz) {
    Vector critics = (Vector) _cachedCritics.get(clazz);
    if (critics != null) return critics;
    Class origClazz = clazz;
    critics = new Vector();
    while (clazz != null) {
      Vector specificCritics = criticsForSpecificClass(clazz);
      Enumeration cur = specificCritics.elements();
      while (cur.hasMoreElements())
	critics.addElement(cur.nextElement());
      clazz = clazz.getSuperclass();
    }
    _cachedCritics.put(origClazz, critics);
    return critics;
  }
示例#3
0
 /** Return a Vector of all critics that are directly associated with
  * the given design material subclass. */
 protected static Vector criticsForSpecificClass(Class clazz) {
   Vector critics = (Vector) getCriticRegistry().get(clazz);
   if (critics == null) {
      critics = new Vector();
      _criticRegistry.put(clazz, critics);
   }
   return critics;
 }
示例#4
0
 /** Register a critic in the global table of critics that have been
  * loaded. Critics are associated with one or more design material
  * classes. One way to do registration is in a static initializer of
  * the design material class. But additional (after-market) critics
  * could added thorugh a menu command in some control panel...*/
 public static void register(Critic cr, Class clazz) {
   //System.out.println("registering critic " + c.toString());
   Vector critics = (Vector) getCriticRegistry().get(clazz);
   if (critics == null) {
      critics = new Vector();
      _criticRegistry.put(clazz, critics);
   }
   critics.addElement(cr);
   notifyStaticObservers(cr);
   Dbg.log("debugRegistration","Registered: " + critics.toString());
   _cachedCritics.remove(clazz);
   addCritic(cr);
 }