Package rocket.generator.rebind.type

Examples of rocket.generator.rebind.type.Type


        }
        return false;
      }
    };

    final Type beanType = bean.getType();
    visitor.start(beanType);

    if (matchingConstructors.size() == 0) {
      this.throwUnableToFindConstructor(bean);
    }
View Full Code Here


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

    final Type beanType = bean.getType();
    final String factoryMethodName = bean.getFactoryMethod();
    final Method factoryMethod = beanType.findMethod(factoryMethodName, Collections.<Type>emptyList() );
    if (null == factoryMethod || false == factoryMethod.isStatic() || factoryMethod.getVisibility() != Visibility.PUBLIC) {
      this.throwFactoryMethodNotFound(bean, factoryMethodName);
    }

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

   *            The bean about to be processed.
   */
  protected void overrideFactoryBeanSatisfyInit(final Bean bean) {
    Checker.notNull("parameter:bean", bean);

    final Type beanType = bean.getType();
    final String initMethodName = bean.getInitMethod();
    final Method initMethod = beanType.findMethod(initMethodName, Collections.<Type>emptyList());
    if (null == initMethod || initMethod.isStatic() || initMethod.getVisibility() != Visibility.PUBLIC) {
      throwInitMethodNotFound(bean, initMethodName);
    }

    final GeneratorContext context = this.getGeneratorContext();
View Full Code Here

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

    final Type serviceDefTarget = this.getServiceDefTarget();
    body.setBean(serviceDefTarget);

    final GeneratorContext context = this.getGeneratorContext();

    final Type string = context.getString();
    final Method setter = serviceDefTarget.getMostDerivedMethod(Constants.SET_SERVICE_ENTRY_POINT, Collections.nCopies(1, string));
    final StringValue addressValue = new StringValue();
    addressValue.setGeneratorContext(context);
    addressValue.setType(string);
View Full Code Here

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

    final GeneratorContext context = this.getGeneratorContext();
    final Type voidType = this.getGeneratorContext().getVoid();
    final Type beanType = bean.getType();
    context.debug(beanType.getName());

    final SetPropertiesTemplatedFile body = new SetPropertiesTemplatedFile();
    body.setBean(beanType);

    final NewType factoryBean = bean.getFactoryBean();
    final Method method = factoryBean.getMostDerivedMethod(Constants.SATISFY_PROPERTIES, this.getParameterListWithOnlyObject());

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

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

    newMethod.setBody(body);

    // loop thru all properties
    final Set<Property> properties = bean.getProperties();
    final Iterator<Property> propertyIterator = properties.iterator();
    while (propertyIterator.hasNext()) {
      final Property property = propertyIterator.next();
      final String propertyName = property.getName();
      final String setterName = GeneratorHelper.buildSetterName(propertyName);

      final Value value = property.getValue();
      this.prepareValue(value);

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

      final VirtualMethodVisitor visitor = new VirtualMethodVisitor() {
        protected boolean visit(final Method method) {

          while (true) {
            // names dont match
            if (false == method.getName().equals(setterName)) {
              break;
            }
            // return type must be void
            if (false == method.getReturnType().equals(voidType)) {
              break;
            }
            // parameter types must be compatible...
            final List<MethodParameter> parameters = method.getParameters();
            if (parameters.size() != 1) {
              break;
            }

            final MethodParameter parameter = (MethodParameter) parameters.get(0);
            final Type propertyType = parameter.getType();
            if (false == value.isCompatibleWith(propertyType)) {
              break;
            }

            value.setPropertyType(propertyType);
View Full Code Here

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

    final Type beanType = bean.getType();
    final String destroyMethodName = bean.getDestroyMethod();
    final Method destroyMethod = beanType.findMethod(destroyMethodName, Collections.<Type>emptyList());
    if (null == destroyMethod || destroyMethod.isStatic() || destroyMethod.getVisibility() != Visibility.PUBLIC) {
      throwCustomMethodNotFound(bean, destroyMethodName);
    }

    final GeneratorContext context = this.getGeneratorContext();
View Full Code Here

    context.debug("singleton");
    context.debug("lazy load");

    final String interfaceName = rpc.getServiceInterface();
    final String id = rpc.getId();
    final Type beanType = this.getInterfaceType(id, interfaceName + Constants.ASYNC_SUFFIX);
    rpc.setType(beanType);

    context.debug("service interface: " + interfaceName);
    context.debug("async service interface: " + beanType.getName());

    final Type superType = this.getSingletonFactoryBean();
    final NewConcreteType beanFactory = this.getBeanFactory();
    final NewNestedType factoryBean = beanFactory.newNestedType();
    factoryBean.setStatic(false);
    factoryBean.setNestedName(this.escapeBeanIdToBeClassNameSafe(id) + Constants.FACTORY_BEAN_SUFFIX);
    factoryBean.setSuperType(superType);
View Full Code Here

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

    final Type beanType = bean.getType();
    if (beanType.isFinal()) {
      this.throwProxyTargetCannotBeSubclassed(bean);
    }
  }
View Full Code Here

  protected void verifyAdvisorBean(final Aspect aspect) {
    Checker.notNull("parameter:aspect", aspect);

    final String id = aspect.getAdvisor();
    final Bean bean = this.getBean(id);
    final Type type = bean.getType();

    if (false == type.isAssignableTo(this.getAdvice())) {
      throwNotAnAdviceException(bean);
    }
  }
View Full Code Here

  protected void verifyMethodExpression(final Aspect aspect) {
    Checker.notNull("parameter:aspect", aspect);

    final String id = aspect.getTarget();
    final Bean bean = this.getBean(id);
    final Type type = bean.getType();
    final MethodMatcher matcher = aspect.getMethodMatcher();

    final GeneratorContext context = this.getGeneratorContext();
    context.branch();
    context.debug("Discovering methods that match: " + matcher + " against " + type);

    final List<Method> matchedMethods = new ArrayList<Method>();
    final Type object = context.getObject();

    final VirtualMethodVisitor visitor = new VirtualMethodVisitor() {

      @Override
      protected boolean visit(final Method method) {
View Full Code Here

TOP

Related Classes of rocket.generator.rebind.type.Type

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.