Ejemplo n.º 1
0
  public JavaClassDef addClass(String name, Class type, String extension, Class javaClassDefClass)
      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException,
          InstantiationException {
    synchronized (_javaClassWrappers) {
      JavaClassDef def = _javaClassWrappers.get(name);

      if (def == null) {
        if (log.isLoggable(Level.FINEST)) {
          if (extension == null) {
            log.finest(L.l("PHP loading class {0} with type {1}", name, type.getName()));
          } else {
            log.finest(
                L.l(
                    "PHP loading class {0} with type {1} providing extension {2}",
                    name, type.getName(), extension));
          }
        }

        if (javaClassDefClass != null) {
          Constructor constructor =
              javaClassDefClass.getConstructor(ModuleContext.class, String.class, Class.class);

          def = (JavaClassDef) constructor.newInstance(this, name, type);
        } else {
          def = JavaClassDef.create(this, name, type);

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

        def.setPhpClass(true);

        _javaClassWrappers.put(name, def);
        // _lowerJavaClassWrappers.put(name.toLowerCase(), def);

        _staticClasses.put(name, def);
        // _lowerStaticClasses.put(name.toLowerCase(), def);

        // def.introspect();

        if (extension != null) {
          _extensionSet.add(extension);
        }
      }

      return def;
    }
  }
Ejemplo 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);
      }
    }
  }
Ejemplo n.º 3
0
  /** Gets or creates a JavaClassDef for the given class name. */
  public JavaClassDef getJavaClassDefinition(Class type, String className) {
    JavaClassDef def;

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

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

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

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

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

    return def;
  }