Exemplo n.º 1
0
  /**
   * Finds a matching method in filterMethods for the given service method. A matching method has
   * the same signature as the service interface method, but with an additional parameter matching
   * the service interface itself.
   *
   * <p>The matching method signature from the list of filterMethods is removed and code generation
   * strategies for making the two methods call each other are added.
   */
  private void addBridgeMethod(MethodSignature ms, List filterMethods) {
    Iterator i = filterMethods.iterator();

    while (i.hasNext()) {
      MethodSignature fms = (MethodSignature) i.next();

      int position = _filterMethodAnalyzer.findServiceInterfacePosition(ms, fms);

      if (position >= 0) {
        addBridgeMethod(position, ms, fms);
        i.remove();
        return;
      }
    }

    String message = PipelineMessages.unmatchedServiceMethod(ms, _filterInterface);

    _errorLog.error(message, null, null);

    BodyBuilder b = new BodyBuilder();

    b.add("throw new org.ops4j.gaderian.ApplicationRuntimeException(");
    b.addQuoted(message);
    b.addln(");");

    _classFab.addMethod(Modifier.PUBLIC, ms, b.toString());
  }