Beispiel #1
0
  public static Object loadFrame(
      JopSession session, String className, String instance, boolean scrollbar)
      throws ClassNotFoundException {

    if (className.indexOf(".pwg") != -1) {
      GrowFrame frame =
          new GrowFrame(
              className, session.getGdh(), instance, new GrowFrameCb(session), session.getRoot());
      frame.validate();
      frame.setVisible(true);
    } else {
      Object frame;
      if (instance == null) instance = "";

      JopLog.log(
          "JopSpider.loadFrame: Loading frame \"" + className + "\" instance \"" + instance + "\"");
      try {
        Class clazz = Class.forName(className);
        try {
          Class argTypeList[] =
              new Class[] {session.getClass(), instance.getClass(), boolean.class};
          Object argList[] = new Object[] {session, instance, new Boolean(scrollbar)};
          System.out.println("JopSpider.loadFrame getConstructor");
          Constructor constructor = clazz.getConstructor(argTypeList);

          try {
            frame = constructor.newInstance(argList);
          } catch (Exception e) {
            System.out.println(
                "Class instanciation error: "
                    + className
                    + " "
                    + e.getMessage()
                    + " "
                    + constructor);
            return null;
          }
          // frame = clazz.newInstance();
          JopLog.log("JopSpider.loadFrame openFrame");
          openFrame(frame);
          return frame;
        } catch (NoSuchMethodException e) {
          System.out.println("NoSuchMethodException: Unable to get frame constructor " + className);
        } catch (Exception e) {
          System.out.println(
              "Exception: Unable to get frame class " + className + " " + e.getMessage());
        }
      } catch (ClassNotFoundException e) {
        System.out.println("Class not found: " + className);
        throw new ClassNotFoundException();
      }
      return null;
    }
    return null;
  }
Beispiel #2
0
  // New implementation
  public JopSession(JopEngine engine, Object rootObject) {
    // Create a JopSessionRep object which class is not known by the compiler
    try {
      Class clazz = Class.forName("jpwr.jop.JopSessionRep");
      try {
        sessionRep = clazz.newInstance();
      } catch (InstantiationException e) {
        System.out.println("InstatiationException");
      } catch (IllegalAccessException e) {
        System.out.println("IllegalAccessException");
      }
    } catch (ClassNotFoundException e) {
      System.out.println("Class not found");
    }

    ((JopSessionIfc) sessionRep).setSession(this);
    ((JopSessionIfc) sessionRep).setRoot(rootObject);
    ((JopSessionIfc) sessionRep).setEngine(engine);
  }