Package org.jboss.errai.codegen.framework.meta

Examples of org.jboss.errai.codegen.framework.meta.MetaMethod


    return _getMethod(getDeclaredMethods(), name, parmTypes);
  }

  @Override
  public MetaMethod getBestMatchingMethod(String name, Class... parameters) {
    MetaMethod meth = getMethod(name, parameters);
    if (meth == null || meth.isStatic()) {
      meth = null;
    }

    if (meth == null) {
      meth = getBestMatchingMethod(null, name, parameters);
View Full Code Here


    return getBestMatchingMethod(name, asClassArray(parameters));
  }

  @Override
  public MetaMethod getBestMatchingStaticMethod(String name, Class... parameters) {
    MetaMethod meth = getMethod(name, parameters);
    if (meth == null || !meth.isStatic()) {
      meth = null;
    }

    if (meth == null) {
      meth = getBestMatchingMethod(new GetMethodsCallback() {
View Full Code Here

    Method[] getMethods();
  }

  private MetaMethod getBestMatchingMethod(GetMethodsCallback methodsCallback, String name, Class... parameters) {
    Map<String, MetaMethod> subMap;
    MetaMethod meth;
    if ((subMap = METHOD_MATCH_CACHE.get(name)) == null) {
      METHOD_MATCH_CACHE.put(name, subMap = new HashMap<String, MetaMethod>());
    }

    String parmKey = Arrays.toString(parameters);
View Full Code Here

      statement.generate(context);
     
      MetaClass callType = statement.getType();

      MetaClass[] parameterTypes = callParams.getParameterTypes();
      final MetaMethod method = (staticMethod) ? callType.getBestMatchingStaticMethod(methodName, parameterTypes)
              : callType.getBestMatchingMethod(methodName, parameterTypes);

      if (method == null) {
        callType.getBestMatchingMethod(methodName, parameterTypes);
        throw new UndefinedMethodException(statement.getType(), methodName, parameterTypes);
View Full Code Here

  public BlockBuilder<AnonymousClassStructureBuilder> publicOverridesMethod(String name, Parameter... args) {
    List<MetaClass> types = new ArrayList<MetaClass>();
    for (Parameter arg : args) {
      types.add(arg.getType());
    }
    MetaMethod method = classDefinition.getSuperClass()
            .getBestMatchingMethod(name, types.toArray(new MetaClass[args.length]));
    if (method == null)
      throw new UndefinedMethodException("Method not found:" + name + "(" + types + ")");

    return publicOverridesMethod(method, DefParameters.from(method, args));
View Full Code Here

  public JaxrsProxyMethodGenerator(JaxrsResourceMethod resourceMethod) {
    this.resourceMethod = resourceMethod;
  }

  public void generate(ClassStructureBuilder<?> classBuilder) {
    MetaMethod method = resourceMethod.getMethod();
   
    this.errorHandling = Stmt.loadStatic(classBuilder.getClassDefinition(), "this")
        .invoke("handleError", Variable.get("throwable"));
    this.responseHandling = Stmt.loadStatic(classBuilder.getClassDefinition(), "this")
      .loadField("remoteCallback").invoke("callback",
        demarshal(method.getReturnType(), Stmt.loadVariable("response").invoke("getText")));

    BlockBuilder<?> methodBlock =
        classBuilder.publicMethod(method.getReturnType(), method.getName(),
            DefParameters.from(method).getParameters().toArray(new Parameter[0]));

    if (resourceMethod.getHttpMethod() != null) {
      generateUrl(methodBlock);
      generateRequestBuilder(methodBlock);
      generateHeaders(methodBlock);
      generateRequest(methodBlock);
    }

    Statement returnStatement;
    if (!method.getReturnType().equals(MetaClassFactory.get(void.class))) {
      if (MetaClassFactory.get(Number.class).isAssignableFrom(method.getReturnType().asBoxed())) {
        returnStatement = Stmt.load(0).returnValue();
      }
      else if (MetaClassFactory.get(Boolean.class).isAssignableFrom(method.getReturnType().asBoxed())) {
        returnStatement = Stmt.load(true).returnValue();
      }
      else {
        returnStatement = Stmt.load(null).returnValue();
      }
View Full Code Here

            for (Method method : methods) {
              final Annotation aInstance = method.getAnnotation(aClass);

              final MetaClass type = MetaClassFactory.get(method.getDeclaringClass());
              final MetaMethod metaMethod = MetaClassFactory.get(method);

              entry.addProcessingDelegate(new ProcessingDelegate<MetaField>() {
                @Override
                public boolean process() {
                  injectorFactory.addType(type);
View Full Code Here

  }

  @Override
  public Statement generateDecorator(InjectableInstance<Observes> instance) {
    final Context ctx = instance.getInjectionContext().getProcessingContext().getContext();
    final MetaMethod method = instance.getMethod();
    final MetaParameter parm = instance.getParm();

    if (!method.isPublic()) {
      instance.ensureMemberExposed();
    }

    final String parmClassName = parm.getType().getFullyQualifiedName();
    final Statement bus = instance.getInjectionContext().getInjector(MessageBus.class).getType(instance);
    final String subscribeMethodName = method.isAnnotationPresent(Local.class) ? "subscribeLocal" : "subscribe";

    final String subject = CDI.getSubjectNameByType(parmClassName);
    final Annotation[] qualifiers = InjectUtil.extractQualifiers(instance).toArray(new Annotation[0]);
    final List<String> qualifierNames = CDI.getQualifiersPart(qualifiers);
View Full Code Here

    if (methods.length == 0) {
      return null;
    }

    MetaParameter[] parmTypes;
    MetaMethod bestCandidate = null;
    int bestScore = 0;
    int score = 0;
    boolean retry = false;

    do {
View Full Code Here

    }
    return buf.toString();
  }

  protected static MetaMethod _getMethod(MetaMethod[] methods, String name, MetaClass... parmTypes) {
    MetaMethod candidate = null;
    int bestScore = 0;
    int score;

    for (MetaMethod method : methods) {
      score = 0;
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.framework.meta.MetaMethod

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.