Package com.caucho.quercus.program

Examples of com.caucho.quercus.program.JavaClassDef$JavaEntry


    _constMap = new HashMap<String,Expr>();

    _staticFieldExprMap = new LinkedHashMap<String,ArrayList<StaticField>>();

    JavaClassDef javaClassDef = null;

    if (classDef instanceof JavaClassDef) {
      javaClassDef = (JavaClassDef) classDef;
      _isJavaWrapper = ! javaClassDef.isDelegate();
    }
   
    for (QuercusClass cls = parent; cls != null; cls = cls.getParent()) {
      AbstractFunction cons = cls.getConstructor();
     
View Full Code Here


  public static Object java(Env env,
                            String className,
                            Value []args)
  {
    try {
      JavaClassDef def = env.getJavaClassDefinition(className);

      if (def == null) {
        env.warning(L.l("could not find Java class {0}", className));
        return null;
      }
     
      Value newObj = def.callNew(env, args);

      if (newObj.isNull())
        return new JavaValue(env, null, def);
      else
        return newObj;
View Full Code Here

   */
  public static Object java_class(Env env,
                                  String className)
  {
    try {
      JavaClassDef def = env.getJavaClassDefinition(className);

      if (def == null) {
        env.warning(L.l("could not find Java class {0}", className));
        return null;
      }

      return new JavaValue(env, def.getType(), def);
    } catch (Throwable e) {
      log.log(Level.FINE, e.getMessage(), e);
      env.warning(e);

      return null;
View Full Code Here

  /**
   * Adds a java class
   */
  public JavaClassDef getJavaClassDefinition(Class<?> type, String className)
  {
    JavaClassDef def;

    if (_classNotFoundCache.get(className) != null)
      return null;

    def = _javaClassWrappers.get(className);

    if (def == null) {
      try {
        def = getModuleContext().getJavaClassDefinition(type, className);

        int id = getClassId(className);
        _classDefMap[id] = def;

        _javaClassWrappers.put(className, def);
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new QuercusRuntimeException(e);
      }
    }

    def.init();

    return def;
  }
View Full Code Here

  /**
   * Adds a java class
   */
  public JavaClassDef getJavaClassDefinition(String className)
  {
    JavaClassDef def;

    if (_classNotFoundCache.get(className) != null)
      return null;

    def = _javaClassWrappers.get(className);

    if (def == null) {
      try {
        def = getModuleContext().getJavaClassDefinition(className);

        _javaClassWrappers.put(className, def);
      } catch (RuntimeException e) {
        _classNotFoundCache.put(className, className);

        throw e;
      } catch (Exception e) {
        throw new QuercusRuntimeException(e);
      }
    }

    def.init();

    return def;
  }
View Full Code Here

  private void initClasses()
  {
    for (Map.Entry<String,JavaClassDef> entry
           : _moduleContext.getWrapperMap().entrySet()) {
      String name = entry.getKey();
      JavaClassDef def = entry.getValue();

      _javaClassWrappers.put(name, def);
      _lowerJavaClassWrappers.put(name.toLowerCase(Locale.ENGLISH), def);
    }
View Full Code Here

      marshal = new JavaArrayMarshal(argType);
    }
    else if (Map.class.isAssignableFrom(argType)) {
      String typeName = argType.getName();

      JavaClassDef javaDef = _moduleContext.getJavaClassDefinition(typeName);

      marshal = new JavaMapMarshal(javaDef, isNotNull, isNullAsFalse);
    }
    else if (List.class.isAssignableFrom(argType)) {
      String typeName = argType.getName();

      JavaClassDef javaDef = _moduleContext.getJavaClassDefinition(typeName);

      marshal = new JavaListMarshal(javaDef, isNotNull, isNullAsFalse);
    }
    else if (Collection.class.isAssignableFrom(argType)) {
      String typeName = argType.getName();

      JavaClassDef javaDef = _moduleContext.getJavaClassDefinition(typeName);

      marshal = new JavaCollectionMarshal(javaDef, isNotNull, isNullAsFalse);
    }
    else if (Enum.class.isAssignableFrom(argType)) {
      marshal = new EnumMarshal(argType);
    }
    else {
      String typeName = argType.getName();

      JavaClassDef javaDef = _moduleContext.getJavaClassDefinition(typeName);

      marshal = new JavaMarshal(javaDef, isNotNull, isNullAsFalse);
    }

    if (!isNullAsFalse)
View Full Code Here

           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(Locale.ENGLISH), def);

      _staticClasses.put(name, def);
View Full Code Here

  /**
   * 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)
View Full Code Here

    // 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 {
View Full Code Here

TOP

Related Classes of com.caucho.quercus.program.JavaClassDef$JavaEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.