Ejemplo n.º 1
0
  /** Returns the static method defined in an element, or null if failed. */
  /*package*/ static MethodInfo getMethodInfo(Element el) {
    final String clsnm = IDOMs.getRequiredAttributeValue(el, "class");
    final String sig = IDOMs.getRequiredAttributeValue(el, "signature");
    final Class cls;
    try {
      cls = Classes.forNameByThread(clsnm);
    } catch (ClassNotFoundException ex) {
      log.error("Class not found: " + clsnm + ", " + el.getLocator());
      return null; // to report as many errors as possible
    }

    try {
      final Method mtd = Classes.getMethodBySignature(cls, sig, null);
      if ((mtd.getModifiers() & Modifier.STATIC) == 0) {
        log.error("Not a static method: " + mtd);
        return null;
      }

      final Object[] args = new Object[mtd.getParameterTypes().length];
      for (int j = 0; j < args.length; ++j) args[j] = el.getAttributeValue("arg" + j);

      return new MethodInfo(mtd, args);
    } catch (ClassNotFoundException ex) {
      log.realCauseBriefly(
          "Unable to load class when resolving " + sig + " " + el.getLocator(), ex);
    } catch (NoSuchMethodException ex) {
      log.error("Method not found in " + clsnm + ": " + sig + " " + el.getLocator());
    }
    return null;
  }
Ejemplo n.º 2
0
 private void handleFailedModal(int oldmode, boolean oldvisi) {
   try {
     if (Executions.getCurrent().getAttribute("javax.servlet.error.exception") != null) {
       // handle it specially if it is used for dispalying err
       setMode(HIGHLIGHTED);
     } else {
       setMode(oldmode); // restore
       setVisible(oldvisi);
     }
   } catch (Throwable ex) {
     log.realCauseBriefly("Causing another error", ex);
   }
 }
Ejemplo n.º 3
0
 private static Extension getExtension() {
   if (_ext == null) {
     synchronized (BindUiLifeCycle.class) {
       if (_ext == null) {
         String clsnm = Library.getProperty("org.zkoss.bind.tracker.impl.extension");
         if (clsnm != null) {
           try {
             _ext = (Extension) Classes.newInstanceByThread(clsnm);
           } catch (Throwable ex) {
             log.realCauseBriefly("Unable to instantiate " + clsnm, ex);
           }
         }
         if (_ext == null) _ext = new DefaultExtension();
       }
     }
   }
   return _ext;
 }
Ejemplo n.º 4
0
  private static final String getNotFound(int code, Locale locale) {
    if (code == NULL_CODE) return ""; // special code

    try {
      log.error(
          "Message code not found: "
              + Integer.toHexString(code)
              + " not in "
              + locale
              + ":"
              + Aide.getBundleInfo(code));

      final String hexcode = Integer.toHexString(code);
      final String s = getFromBundle(MCommon.MESSAGE_CODE_NOT_FOUND, locale);
      return s != null
          ? MessageFormats.format(s, new Object[] {hexcode}, locale)
          : "Unknown message code: " + hexcode;
    } catch (Exception ex) {
      log.realCauseBriefly(ex);
      return "Unknown message code: " + Integer.toHexString(code);
    }
  }