コード例 #1
0
 protected void loadGrailsBuildListeners() {
   for (Object listener : buildSettings.getBuildListeners()) {
     if (listener instanceof String) {
       addGrailsBuildListener((String) listener);
     } else if (listener instanceof Class<?>) {
       addGrailsBuildListener((Class<?>) listener);
     } else {
       throw new IllegalStateException(
           "buildSettings.getBuildListeners() returned a " + listener.getClass().getName());
     }
   }
 }
コード例 #2
0
 protected void addGrailsBuildListener(String listenerClassName) {
   Class<?> listenerClass;
   try {
     listenerClass = classLoader.loadClass(listenerClassName);
   } catch (ClassNotFoundException e) {
     throw new RuntimeException("Could not load grails build listener class", e);
   }
   addGrailsBuildListener(listenerClass);
 }
コード例 #3
0
  @SuppressWarnings("rawtypes")
  protected void addGrailsBuildListener(Class listenerClass) {
    if (!GrailsBuildListener.class.isAssignableFrom(listenerClass)) {
      throw new RuntimeException(
          "Intended grails build listener class of "
              + listenerClass.getName()
              + " does not implement "
              + GrailsBuildListener.class.getName());
    }

    try {
      addGrailsBuildListener((GrailsBuildListener) listenerClass.newInstance());
    } catch (Exception e) {
      throw new RuntimeException("Could not instantiate " + listenerClass.getName(), e);
    }
  }