Package railo.runtime.reflection.pairs

Examples of railo.runtime.reflection.pairs.ConstructorInstance


   * @throws NoSuchMethodException
   * @throws PageException
   */

  public static ConstructorInstance getConstructorInstance(Class clazz, Object[] args) throws NoSuchMethodException {
    ConstructorInstance ci=getConstructorInstance(clazz, args,null);
      if(ci!=null) return ci;
      throw new NoSuchMethodException("No matching Constructor for "+clazz.getName()+"("+getDspMethods(getClasses(args))+") found");
  }
View Full Code Here


         
          Class[] parameterTypes = constructors[i].getParameterTypes();
          for(int y=0;y<parameterTypes.length;y++) {
            if(toReferenceClass(parameterTypes[y])!=clazzArgs[y]) continue outer;
          }
          return new ConstructorInstance(constructors[i],args);
        }
      }
      // like comparsion
      outer:for(int i=0;i<constructors.length;i++) {
        if(constructors[i]!=null) {
          Class[] parameterTypes = constructors[i].getParameterTypes();
          for(int y=0;y<parameterTypes.length;y++) {
            if(!like(clazzArgs[y],toReferenceClass(parameterTypes[y]))) continue outer;
          }
          return new ConstructorInstance(constructors[i],args);
        }
      } 
      // convert comparsion
      ConstructorInstance ci=null;
        int _rating=0;
      outer:for(int i=0;i<constructors.length;i++) {
        if(constructors[i]!=null) {
          RefInteger rating=(constructors.length>1)?new RefIntegerImpl(0):null;
          Class[] parameterTypes = constructors[i].getParameterTypes();
          Object[] newArgs = new Object[args.length];
          for(int y=0;y<parameterTypes.length;y++) {
            try {
              newArgs[y]=convert(args[y],toReferenceClass(parameterTypes[y]),rating);
            } catch (PageException e) {
              continue outer;
            }
          }
          if(ci==null || rating.toInt()>_rating) {
            if(rating!=null)_rating=rating.toInt();
            ci=new ConstructorInstance(constructors[i],newArgs);
          }
          //return new ConstructorInstance(constructors[i],newArgs);
        }
      }
        return ci;
View Full Code Here

       
        Class[] classes = getClasses(args);
        //StringBuilder sb=null;
        JavaObject jo;
        Class c;
        ConstructorInstance ci;
        for(int i=0;i<classes.length;i++){
          if(args[i] instanceof JavaObject) {
            jo=(JavaObject) args[i];
            c=jo.getClazz();
            ci = Reflector.getConstructorInstance(c, new Object[0], null);
View Full Code Here

  }
 
  public static Object callConstructor(Class clazz, Object[] args, Object defaultValue) {
      args=cleanArgs(args);
      try {
            ConstructorInstance ci = getConstructorInstance(clazz,args,null);
            if(ci==null) return defaultValue;
            return ci.invoke();
        }
    catch (Throwable t) {
        return defaultValue;
    }
  }
View Full Code Here

      if (!StringUtil.isEmpty(className) && !StringUtil.isEmpty(name)) {
        name = name.trim();
        try {
          Class clazz = ClassUtil.loadClass(config.getClassLoader(), className);
          Object obj;
          ConstructorInstance constr = Reflector.getConstructorInstance(clazz, new Object[] { configServer }, null);
          if (constr != null)
            obj = constr.invoke();
          else
            obj = clazz.newInstance();
          SystemOut.printDate(config.getOutWriter(), "loaded "+(strType)+" monitor ["+clazz.getName()+"]");
          if (type == IntervallMonitor.TYPE_INTERVALL) {
            IntervallMonitor m = obj instanceof IntervallMonitor ? (IntervallMonitor) obj : new IntervallMonitorWrap(obj);
View Full Code Here

TOP

Related Classes of railo.runtime.reflection.pairs.ConstructorInstance

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.