Package rocket.generator.rebind.method

Examples of rocket.generator.rebind.method.NewMethod


   */
  protected void addImageFactoryAbstractImageGetter(final ImageValue imageValue, final NewType imageFactory) {
    Checker.notNull("parameter:imageValue", imageValue);
    Checker.notNull("parameter:imageFactory", imageFactory);

    final NewMethod newMethod = imageFactory.newMethod();
    newMethod.setAbstract(true);
    newMethod.setFinal(false);
    newMethod.setName(Constants.IMAGE_GETTER_PREFIX + imageValue.getImageIndex());
    newMethod.setNative(false);
    newMethod.setReturnType(imageValue.getPropertyType());
    newMethod.setStatic(false);
    newMethod.setVisibility(Visibility.PUBLIC);

    // add annotations
    newMethod.addMetaData(ImageFactoryConstants.IMAGE_FILE, imageValue.getFile());
    newMethod.addMetaData(ImageFactoryConstants.LOCATION, imageValue.isLocal() ? ImageFactoryConstants.LOCATION_LOCAL
        : ImageFactoryConstants.LOCATION_SERVER);
    newMethod.addMetaData(ImageFactoryConstants.SERVER_REQUEST, imageValue.isLazy() ? ImageFactoryConstants.SERVER_REQUEST_LAZY
        : ImageFactoryConstants.SERVER_REQUEST_EAGER);

    imageValue.setImageFactoryGetter(newMethod);
  }
View Full Code Here


    final GeneratorContext context = this.getGeneratorContext();
    context.debug("Overriding destroy to call " + destroyMethod + " for bean: " + bean);

    final NewType beanFactory = bean.getFactoryBean();
    final Method beanFactoryInitMethod = beanFactory.getMostDerivedMethod(Constants.DESTROY, 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(destroyMethod);

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

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

   */
  protected void createProxyMethod(final NewNestedType proxy, final Method method) {
    Checker.notNull("parameter:proxy", proxy);
    Checker.notNull("parameter:method", method);

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

    GeneratorHelper.makeAllParametersFinal(newMethod);

    final ProxyMethodTemplatedFile body = new ProxyMethodTemplatedFile();
    newMethod.setBody(body);
    body.setMethod(newMethod);
  }
View Full Code Here

  protected void createProxyMethodWithInterceptors(final NewNestedType proxy, final Method method, final List<Aspect> aspects) {
    Checker.notNull("parameter:proxy", proxy);
    Checker.notNull("parameter:method", method);
    Checker.notNull("parameter:advices", aspects);

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

    GeneratorHelper.renameParametersToParameterN(newMethod);
    GeneratorHelper.makeAllParametersFinal(newMethod);

    final ProxyInterceptedMethodTemplatedFile body = new ProxyInterceptedMethodTemplatedFile();
    body.setAspects(aspects);
    body.setBeanFactory(this.getBeanFactory());
    body.setMethod(newMethod);
    body.setTargetMethod(method);

    final Type methodInterceptor = this.getMethodInterceptor();
    final List<Type> methodInvocationParameterList = Arrays.asList(new Type[] { this.getMethodInvocation() });
    final Method invoke = methodInterceptor.getMethod(Constants.METHOD_INTERCEPTOR_INVOKE, methodInvocationParameterList);
    final MethodParameter target = (MethodParameter) invoke.getParameters().get(0);

    body.setTarget(target);
    newMethod.setBody(body);
  }
View Full Code Here

    final NewNestedType proxyFactoryBean = bean.getProxyFactoryBean();
    final List<Type> objectParameterList = this.getParameterListWithOnlyObject();
    final Method method = proxyFactoryBean.getMostDerivedMethod(Constants.CREATE_PROXY, objectParameterList);

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

    // add a new constructor...
    final MethodParameter targetBeanParameter = (MethodParameter) newMethod.getParameters().get(0);

    final Type proxy = bean.getProxy();
    final Constructor constructor = proxy.getConstructor(Collections.<Type>emptyList());

    final CreateProxyTemplatedFile body = new CreateProxyTemplatedFile();
    body.setProxyConstructor(constructor);
    body.setTargetBeanParameter(targetBeanParameter);
    body.setTargetBeanType(bean.getType());

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

    context.branch();

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

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

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

    context.branch();
    context.info("Overriding " + newMethod + " to register all beans.");

    final Iterator<Bean> beansIterator = this.getBeans().values().iterator();
View Full Code Here

    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();
    newMethod.setBody(body);

    context.branch();
    context.info("Overriding " + newMethod + " to register all aliases.");

    final Iterator<Alias> beansIterator = this.getAliases().values().iterator();
View Full Code Here

    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();
    newMethod.setBody(body);

    int eagerSingletonBeanCount = 0;
    int lazySingletonBeanCount = 0;

    final Iterator<Bean> beansIterator = beans.values().iterator();
View Full Code Here

    final GeneratorContext context = this.getGeneratorContext();

    final SetFieldTemplatedFile body = new SetFieldTemplatedFile();
    body.setField(field);

    final NewMethod method = reader.newMethod();
    method.setAbstract(false);
    method.setBody(body);
    method.setFinal(true);
    method.setName(GeneratorHelper.buildSetterName(field.getName()));
    method.setNative(true);
    method.setReturnType(context.getVoid());
    method.setStatic(false);
    method.setVisibility(Visibility.PRIVATE);

    final NewMethodParameter instance = method.newParameter();
    instance.setFinal(true);
    instance.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_FIELD_SETTER_INSTANCE_PARAMETER);
    instance.setType(field.getEnclosingType());

    final NewMethodParameter value = method.newParameter();
    value.setFinal(true);
    value.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_FIELD_SETTER_VALUE_PARAMETER);

    final Type fieldType = field.getType();
    value.setType(fieldType);

    if (fieldType.equals(context.getLong())) {
      method.addMetaData("com.google.gwt.core.client.UnsafeNativeLong", "");
    }

    context.debug(field.getName());

    return method;
View Full Code Here

    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);
    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 WriteArrayTemplatedFile body = new WriteArrayTemplatedFile();
    body.setType(type);
    newMethod.setBody(body);

    if (type.getComponentType() == context.getLong()) {
      newMethod.addMetaData("com.google.gwt.core.client.UnsafeNativeLong", "");
    }

    context.debug("Overridden " + newMethod);
  }
View Full Code Here

TOP

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

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.