Package rocket.generator.rebind.method

Examples of rocket.generator.rebind.method.Method


  protected void overrideBeanFactoryGetAliasesToBeans() {
    final GeneratorContext context = this.getGeneratorContext();
    context.branch();

    final NewType beanFactory = this.getBeanFactory();
    final Method abstractMethod = beanFactory.getSuperType().getMostDerivedMethod(Constants.GET_ALIASES_TO_BEANS_METHOD, Collections.<Type>emptyList());

    final NewMethod newMethod = abstractMethod.copy(beanFactory);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(false);

    final GetAliasesToBeans body = new GetAliasesToBeans();
View Full Code Here


    context.info("Overriding BeanFactory." + Constants.GET_EAGER_SINGELTON_BEAN_NAMES_METHOD
        + "() to initialize eager singleton beans on factory startup.");
    context.branch();

    final NewType beanFactory = this.getBeanFactory();
    final Method abstractMethod = beanFactory.getSuperType().getMostDerivedMethod(Constants.GET_EAGER_SINGELTON_BEAN_NAMES_METHOD,Collections.<Type>emptyList());

    final NewMethod newMethod = abstractMethod.copy(beanFactory);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(false);

    final GetEagerSingletonBeanNames body = new GetEagerSingletonBeanNames();
View Full Code Here

    return testBuilder;
  }

  protected Type getTestRunner(final Type type) {
    final Method method = type.getMethod(Constants.BUILD_CANDIDATES_METHOD, Collections.EMPTY_LIST);
    final List webPageTestRunners = method.getMetadataValues(Constants.TEST_ANNOTATION);
    if (webPageTestRunners.size() != 1) {
      throwTestAnnotationProblem(type);
    }
    final String webPageTestRunnerName = (String) webPageTestRunners.get(0);
    final Type webPageTestRunner = this.getGeneratorContext().findType(webPageTestRunnerName);
View Full Code Here

  protected void addBuildCandidates(final NewConcreteType testBuilder, final Type webPageTestRunner) {
    Checker.notNull("parameter:testBuilder", testBuilder);

    final GeneratorContext context = this.getGeneratorContext();

    final Method method = this.getTestBuilder().findMethod(Constants.BUILD_CANDIDATES_METHOD, Collections.EMPTY_LIST);
    final NewMethod newMethod = method.copy(testBuilder);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(false);

    final BuildCandidatesTemplatedFile body = new BuildCandidatesTemplatedFile();
    newMethod.setBody(body);

    final Type voidType = this.getGeneratorContext().getVoid();

    final List<Method> methods = new ArrayList<Method>();

    // find and add public methods that start with test
    final VirtualMethodVisitor testMethodFinder = new VirtualMethodVisitor() {

      protected boolean visit(final Method method) {

        while (true) {
          if (method.getVisibility() != Visibility.PUBLIC) {
            break;
          }
          if (false == method.getName().startsWith(Constants.TEST_METHOD_NAME_PREFIX)) {
            context.debug("Ignoring method " + method + " because it doesnt start with public.");
            break;
          }

          // test method must return void
          final Type returnType = method.getReturnType();
          if (returnType != voidType) {
            throwTestMethodDoesntReturnVoid(method);
          }

          // test method must have no parameters.
          final List<MethodParameter> parameters = method.getParameters();
          if (false == parameters.isEmpty()) {
            throwTestMethodHasParameters(method);
          }

          // public void test*() method found...
          methods.add(method);
          break;
        }

        return false;
      }

      protected boolean skipJavaLangObjectMethods() {
        return true;
      }
    };
    testMethodFinder.start(webPageTestRunner);

    Collections.sort(methods, new Comparator<Method>() {
      public int compare(final Method method, final Method otherMethod) {
        return TestBuilderGenerator.this.getOrder( method) - TestBuilderGenerator.this.getOrder(otherMethod);
      }
    });

    final Iterator<Method> iterator = methods.iterator();
    while (iterator.hasNext()) {
      final Method testMethod = iterator.next();
      body.addTestMethod(testMethod);
      context.debug("Adding test method " + testMethod);
    }
  }
View Full Code Here

   *
   * @return
   */
  protected CodeBlock getRethrowExpectedExceptions() {
    // first build up a list of the exceptions that should be handled.
    final Method method = this.getMethod();
    final GeneratorContext context = method.getGeneratorContext();
    final List<Type> alreadyCaughts = new ArrayList<Type>();
    final Type exception = context.getType(Constants.EXCEPTION);
    final Type runtimeException = context.getType(Constants.RUNTIME_EXCEPTION);

    final List<Type> catchAndRethrow = new ArrayList<Type>();
View Full Code Here

    final List<Type> parameters = new ArrayList<Type>();
    parameters.add(context.getString());
    parameters.add(this.getObjectInputStream());

    final Method method = reader.getMostDerivedMethod(SerializationConstants.CLIENT_OBJECT_READER_IMPL_NEW_INSTANCE_METHOD,
        parameters);
    final NewMethod newMethod = method.copy(reader);
    newMethod.setAbstract(false);

    final NewArrayInstanceTemplatedFile populateNewArray = new NewArrayInstanceTemplatedFile();
    populateNewArray.setType(arrayType.getComponentType());
    newMethod.setBody(populateNewArray);
View Full Code Here

    final GeneratorContext context = this.getGeneratorContext();
    final List<Type> parameters = new ArrayList<Type>();
    parameters.add(context.getString());
    parameters.add(this.getObjectInputStream());

    final Method method = reader.getMostDerivedMethod(SerializationConstants.CLIENT_OBJECT_READER_IMPL_NEW_INSTANCE_METHOD,
        parameters);
    final NewMethod newMethod = method.copy(reader);
    newMethod.setAbstract(false);

    final Constructor constructor = type.getConstructor(Collections.EMPTY_LIST);
    final NewInstanceTemplatedFile newInstanceStatement = new NewInstanceTemplatedFile();
    newInstanceStatement.setConstructor(constructor);
View Full Code Here

    final List<Type> parameterTypes = new ArrayList<Type>();
    parameterTypes.add(context.getObject());
    final Type objectInputStreamType = this.getObjectInputStream();
    parameterTypes.add(objectInputStreamType);

    final Method method = reader.getMostDerivedMethod(SerializationConstants.CLIENT_OBJECT_READER_IMPL_READ_METHOD, parameterTypes);
    final NewMethod newMethod = method.copy(reader);
    newMethod.setNative(false);

    // rename parameters to the same names used in templates...
    final List<MethodParameter> newMethodParameters = (List<MethodParameter>) newMethod.getParameters();
    final NewMethodParameter object = (NewMethodParameter) newMethodParameters.get(0);
View Full Code Here

    int fieldCount = 0;
    context.branch();

    while (fields.hasNext()) {
      final Field field = fields.next();
      final Method setter = this.createFieldSetter(reader, field);
      body.addFieldSetter(setter);

      fieldCount++;
    }
View Full Code Here

    // locate the writeFields method that will be overridden.
    final List<Type> parameterTypes = new ArrayList<Type>();
    parameterTypes.add(context.getObject());
    parameterTypes.add(this.getObjectOutputStream());

    final Method method = writer
        .getMostDerivedMethod(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE0_METHOD, parameterTypes);
    final NewMethod newMethod = method.copy(writer);
    newMethod.setAbstract(false);

    // rename parameters to the same names used in templates...
    final List newMethodParameters = newMethod.getParameters();
    final NewMethodParameter object = (NewMethodParameter) newMethodParameters.get(0);
View Full Code Here

TOP

Related Classes of rocket.generator.rebind.method.Method

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.