Esempio n. 1
0
  /** Parses the services file, looking for PHP services. */
  private void parseServicesModule(ReadStream in)
      throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    String line;

    while ((line = in.readLine()) != null) {
      int p = line.indexOf('#');

      if (p >= 0) {
        line = line.substring(0, p);
      }

      line = line.trim();

      if (line.length() > 0) {
        String className = line;

        try {
          Class cl;
          try {
            cl = Class.forName(className, false, loader);
          } catch (ClassNotFoundException e) {
            throw new ClassNotFoundException(L.l("'{0}' not valid {1}", className, e.toString()));
          }

          introspectPhpModuleClass(cl);
        } catch (Throwable e) {
          log.log(Level.FINE, "Failed loading {0}\n{1}", new Object[] {className, e.toString()});
          log.log(Level.FINE, e.toString(), e);
        }
      }
    }
  }
Esempio n. 2
0
  /** Adds a java class */
  public JavaClassDef getJavaClassDefinition(String className) {
    // Note, this method must not trigger an introspection to avoid
    // any race conditions.  It is only responsible for creating the
    // wrapper around the class, i.e. it's a leaf node, not a recursive not

    synchronized (_javaClassWrappers) {
      JavaClassDef def = _javaClassWrappers.get(className);

      if (def != null) {
        return def;
      }

      try {
        Class type;

        try {
          type = Class.forName(className, false, _loader);
        } catch (ClassNotFoundException e) {
          throw new ClassNotFoundException(
              L.l("'{0}' is not a known Java class: {1}", className, e.toString()), e);
        }

        def = JavaClassDef.create(this, className, type);

        if (def == null) {
          def = createDefaultJavaClassDef(className, type);
        }

        _javaClassWrappers.put(className, def);
        _javaClassWrappers.put(type.getName(), def);

        // def.introspect();

        return def;
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new BiancaRuntimeException(e);
      }
    }
  }