Examples of NewMethod


Examples of rocket.generator.rebind.method.NewMethod

    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<MethodParameter> newMethodParameters = newMethod.getParameters();
    final NewMethodParameter object = (NewMethodParameter) newMethodParameters.get(0);
    object.setFinal(true);
    object.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE0_INSTANCE_PARAMETER);

    final NewMethodParameter objectOutputStream = (NewMethodParameter) newMethodParameters.get(1);
    objectOutputStream.setFinal(true);
    objectOutputStream.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE0_OBJECT_OUTPUT_STREAM_PARAMETER);

    final WriteTemplatedFile body = new WriteTemplatedFile();
    body.setType(type);
    newMethod.setBody(body);

    newMethod.addMetaData(com.google.gwt.core.client.UnsafeNativeLong.class.getName(), "");
    context.debug("Overridden " + newMethod);
  }
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

    Checker.notNull("parameter:writer", writer);
    Checker.notNull("parameter:type", type);

    final GeneratorContext context = this.getGeneratorContext();

    final NewMethod newMethod = writer.newMethod();
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE_FIELDS_METHOD);
    newMethod.setNative(false);
    newMethod.setReturnType(context.getVoid());
    newMethod.setStatic(false);
    newMethod.setVisibility(Visibility.PUBLIC);

    final NewMethodParameter instance = newMethod.newParameter();
    instance.setFinal(true);
    instance.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE_FIELDS_INSTANCE_PARAMETER);
    instance.setType(type);

    final NewMethodParameter objectOutputStream = newMethod.newParameter();
    objectOutputStream.setFinal(true);
    objectOutputStream.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE_FIELDS_OBJECT_OUTPUT_STREAM_PARAMETER);
    objectOutputStream.setType(this.getObjectOutputStream());

    final WriteFieldsTemplatedFile body = new WriteFieldsTemplatedFile();
    body.setType(type);
    newMethod.setBody(body);

    // add all fields to the template
    final Iterator fields = this.filterSerializableFields(type.getFields()).iterator();
    int fieldCount = 0;
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

    final GeneratorContext context = this.getGeneratorContext();
    final GetFieldTemplatedFile body = new GetFieldTemplatedFile();
    body.setField(field);

    final NewMethod method = writer.newMethod();
    method.setAbstract(false);
    method.setBody(body);
    method.setFinal(true);
    method.setName(GeneratorHelper.buildGetterName(field.getName()));
    method.setNative(true);

    final Type fieldType = field.getType();
    method.setReturnType(fieldType);
    method.setStatic(false);
    method.setVisibility(Visibility.PRIVATE);

    if (fieldType.equals(context.getLong())) {
      method.addMetaData("com.google.gwt.core.client.UnsafeNativeLong", "");
    }
    // add a parameter
    final NewMethodParameter instance = method.newParameter();
    instance.setFinal(true);
    instance.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_FIELD_GETTER_INSTANCE_PARAMETER);
    instance.setType(field.getEnclosingType());

    context.debug(field.getName());
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

    context.debug("Overriding \"" + SerializationConstants.SERIALIZATION_FACTORY_GET_OBJECT_READER
        + "\" to register needed ObjectReaders.");

    final Method method = serializationFactory.getMostDerivedMethod(SerializationConstants.SERIALIZATION_FACTORY_GET_OBJECT_READER,
        Collections.nCopies(1, context.getString()));
    final NewMethod newMethod = method.copy(serializationFactory);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(true);

    final SwitchTemplatedFile body = new SwitchTemplatedFile();

    final Iterator<Map.Entry<Type, Type>> iterator = objectReaders.entrySet().iterator();
    while (iterator.hasNext()) {
      final Map.Entry<Type, Type> entry = iterator.next();

      final Type type = entry.getKey();
      if (false == this.isSerializable(type)) {
        continue;
      }

      final Type objectReader = entry.getValue();
      final Field objectReaderSingleton = objectReader.getField(SerializationConstants.SINGLETON);

      body.register(type, objectReaderSingleton);

      context.debug(type.getName() + " = " + objectReader.getName());
    }

    newMethod.setBody(body);

    context.unbranch();
  }
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

    context.debug("Overriding \"" + SerializationConstants.SERIALIZATION_FACTORY_GET_OBJECT_WRITER
        + "\" to register needed ObjectWriters.");

    final Method method = serializationFactory.getMostDerivedMethod(SerializationConstants.SERIALIZATION_FACTORY_GET_OBJECT_WRITER,
        Collections.nCopies(1, context.getString()));
    final NewMethod newMethod = method.copy(serializationFactory);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(true);

    final SwitchTemplatedFile body = new SwitchTemplatedFile();

    final Iterator<Map.Entry<Type, Type>> iterator = objectWriters.entrySet().iterator();
    while (iterator.hasNext()) {
      final Map.Entry<Type, Type> entry = iterator.next();

      final Type type = entry.getKey();
      if (false == this.isSerializable(type)) {
        continue;
      }

      final Type objectWriter = entry.getValue();
      final Field objectWriterSingleton = objectWriter.getField(SerializationConstants.SINGLETON);

      body.register(type, objectWriterSingleton);

      context.debug(type.getName() + " = " + objectWriter.getName());
    }

    newMethod.setBody(body);

    context.unbranch();
  }
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

    final String asyncInterfaceName = asyncInterfaceType.getName();

    final String interfaceTypeName = asyncInterfaceName.substring(0, asyncInterfaceName.length() - Constants.ASYNC_SUFFIX.length());
    final Type interfaceType = this.getInterfaceType(rpc.getId(), interfaceTypeName);

    final NewMethod createInstance = this.createCreateInstanceMethod(factoryBean);
    final DeferredBinding body = new DeferredBinding();
    body.setType(interfaceType);
    createInstance.setBody(body);
  }
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

   *            The bean
   */
  protected void overrideFactoryBeanCreateInstanceNewConstructor(final Bean bean) {
    Checker.notNull("parameter:bean", bean);

    final NewMethod newFactoryMethod = this.createCreateInstanceMethod(bean.getFactoryBean());
    newFactoryMethod.setAbstract(false);
    newFactoryMethod.setFinal(true);
    newFactoryMethod.setNative(false);

    final ConstructorTemplatedFile body = new ConstructorTemplatedFile();
    newFactoryMethod.setBody(body);

    final GeneratorContext context = this.getGeneratorContext();
    context.delayedBranch();
    context.debug("Constructor parameter values.");

View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

      this.throwFactoryMethodNotFound(bean, factoryMethodName);
    }

    this.getGeneratorContext().debug("FactoryBean will create new instance by calling " + factoryMethod);

    final NewMethod newFactoryMethod = this.createCreateInstanceMethod(bean.getFactoryBean());

    final FactoryMethodTemplatedFile body = new FactoryMethodTemplatedFile();
    body.setFactoryType(beanType);
    body.setFactoryMethod(factoryMethod);

    newFactoryMethod.setBody(body);
  }
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

  protected NewMethod createCreateInstanceMethod(final NewType factoryBean) {
    Checker.notNull("parameter:factoryBean", factoryBean);

    final Method method = factoryBean.getMostDerivedMethod(Constants.CREATE_INSTANCE, Collections.<Type>emptyList());

    final NewMethod newMethod = method.copy(factoryBean);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(false);

    return newMethod;
  }
View Full Code Here

Examples of rocket.generator.rebind.method.NewMethod

    context.debug("Overriding satisfyInit to call " + initMethod);

    final NewType beanFactory = bean.getFactoryBean();
    final Method beanFactoryInitMethod = beanFactory.getMostDerivedMethod(Constants.SATISFY_INIT, this
        .getParameterListWithOnlyObject());
    final NewMethod newMethod = beanFactoryInitMethod.copy(beanFactory);
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setNative(false);

    final InvokeMethodTemplatedFile body = new InvokeMethodTemplatedFile();
    body.setType(beanType);
    body.setMethod(initMethod);

    final NewMethodParameter instanceParameter = (NewMethodParameter) newMethod.getParameters().get(0);
    instanceParameter.setFinal(true);
    instanceParameter.setName(Constants.SATISFY_INIT_INSTANCE_PARAMETER);

    newMethod.setBody(body);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.