Examples of GenericBeanDefinition


Examples of org.springframework.beans.factory.support.GenericBeanDefinition

   * @param registry
   * @param definition
   */
  protected BeanDefinition register(String beanName, Class<?> clazz, String scope,
      BeanDefinitionRegistry registry) {
    GenericBeanDefinition def = new GenericBeanDefinition();
    def.setBeanClass(clazz);
    def.setScope(scope);
    registry.registerBeanDefinition(beanName, def);
    bindRegistry.register(clazz, beanName);
    logger.debug("Register definition {} for {}", beanName, clazz);
    return def;
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

    }
    if (bd.isLazyInit()) {
      sb.append("; lazyInit=true");
    }
    if (bd instanceof GenericBeanDefinition) {
      GenericBeanDefinition gbd = (GenericBeanDefinition) bd;
      if (gbd.getAutowireMode() > 0) {
        sb.append("; autowireMode=").append(gbd.getAutowireMode());
      }
      if (null != gbd.getFactoryBeanName()) {
        sb.append("; factoryBeanName=").append(gbd.getFactoryBeanName());
      }
      if (null != gbd.getFactoryMethodName()) {
        sb.append("; factoryMethodName=").append(gbd.getFactoryMethodName());
      }
      if (null != gbd.getInitMethodName()) {
        sb.append("; initMethodName=").append(gbd.getInitMethodName());
      }
      if (null != gbd.getDestroyMethodName()) {
        sb.append("; destroyMethodName=").append(gbd.getDestroyMethodName());
      }
    }
    return sb.toString();
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

  private void registerBean(String beanName, File file, String scope) throws IOException {
    log.info("Registering groovy bean:" + beanName);
    beans.add(beanName);
    DefaultListableBeanFactory fact = (DefaultListableBeanFactory) applicationContext
        .getAutowireCapableBeanFactory();
    GenericBeanDefinition bd = new GenericBeanDefinition();
    bd.setBeanClassName("org.jibeframework.core.util.ViewComponentFactory");
    bd.setScope(scope);
    bd.setAutowireMode(GenericBeanDefinition.AUTOWIRE_NO);
    bd.setDependencyCheck(AbstractBeanDefinition.DEPENDENCY_CHECK_NONE);
    ConstructorArgumentValues cav = bd.getConstructorArgumentValues();
    cav.addIndexedArgumentValue(0, file);
    BeanDefinitionHolder holder = new BeanDefinitionHolder(bd, beanName, new String[] {});
    BeanDefinitionReaderUtils.registerBeanDefinition(holder, fact);

  }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

        String location = child.getAttribute("location");
        String inline = DomUtils.getTextValue(child);
        boolean hasScriptInlined = StringUtils.hasText(inline);


        GenericBeanDefinition def = new GenericBeanDefinition();
        def.setSource(child);
        def.setBeanClass(PigScript.class);

        Object resource = null;

        if (StringUtils.hasText(location)) {
          if (hasScriptInlined) {
            context.getReaderContext().error("cannot specify both 'location' and a nested script; use only one", element);
          }
          resource = location;
        }
        else {
          if (!hasScriptInlined) {
            context.getReaderContext().error("no 'location' or nested script specified", element);
          }

          resource = BeanDefinitionBuilder.genericBeanDefinition(ByteArrayResource.class).
              addConstructorArgValue(inline).
              addConstructorArgValue("resource for inlined script").getBeanDefinition();
        }

        def.getConstructorArgumentValues().addIndexedArgumentValue(0, resource, Resource.class.getName());

        String args = DomUtils.getChildElementValueByTagName(child, "arguments");

        if (args != null) {
          // create linked properties
          BeanDefinition params = BeanDefinitionBuilder.genericBeanDefinition(LinkedProperties.class).addConstructorArgValue(args).getBeanDefinition();
          def.getConstructorArgumentValues().addIndexedArgumentValue(1, params);
        }
        defs.add(def);
      }

      return defs;
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

      builder.addPropertyValue("extension", StringUtils.getFilenameExtension(location));
    }

    // parse properties
    BeanDefinition bd = new GenericBeanDefinition();
    parserContext.getDelegate().parsePropertyElements(element, bd);

    ManagedMap<String, Object> args = new ManagedMap<String, Object>();
    List<PropertyValue> list = bd.getPropertyValues().getPropertyValueList();

    for (PropertyValue pv : list) {
      args.put(pv.getName(), pv.getValue());
    }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

                // parse source
                String location = child.getAttribute("location");
                String inline = DomUtils.getTextValue(child);
                boolean hasScriptInlined = StringUtils.hasText(inline);

                GenericBeanDefinition def = new GenericBeanDefinition();
                def.setSource(child);
                def.setBeanClass(HiveScript.class);

                Object resource = null;

                if (StringUtils.hasText(location)) {
                    if (hasScriptInlined) {
                        context.getReaderContext().error("cannot specify both 'location' and a nested script; use only one", element);
                    }
                    resource = location;
                }
                else {
                    if (!hasScriptInlined) {
                        context.getReaderContext().error("no 'location' or nested script specified", element);
                    }

                    resource = BeanDefinitionBuilder.genericBeanDefinition(ByteArrayResource.class).
                            addConstructorArgValue(inline).
                            addConstructorArgValue("resource for inlined script").getBeanDefinition();
                }

                def.getConstructorArgumentValues().addIndexedArgumentValue(0, resource, Resource.class.getName());
                String args = DomUtils.getChildElementValueByTagName(child, "arguments");

                if (args != null) {
                    BeanDefinition params = BeanDefinitionBuilder.genericBeanDefinition(LinkedProperties.class).addConstructorArgValue(args).getBeanDefinition();
                    def.getConstructorArgumentValues().addIndexedArgumentValue(1, params);
                }
                defs.add(def);

            }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

            if (beanDefinitions.isEmpty()) {
                logger.warn("No MyBatis mapper was found in '" + MapperScannerConfigurer.this.basePackage
                        + "' package. Please check your configuration.");
            } else {
                for (BeanDefinitionHolder holder : beanDefinitions) {
                    GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();

                    if (logger.isDebugEnabled()) {
                        logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '"
                                + definition.getBeanClassName() + "' mapperInterface");
                    }

                    // the mapper interface is the original class of the bean
                    // but, the actual class of the bean is MapperFactoryBean
                    definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
                    definition.setBeanClass(MapperFactoryBean.class);

                    definition.getPropertyValues().add("addToConfig", MapperScannerConfigurer.this.addToConfig);

                    if (MapperScannerConfigurer.this.sqlSessionFactory != null) {
                        definition.getPropertyValues().add("sqlSessionFactory",
                                MapperScannerConfigurer.this.sqlSessionFactory);
                    }

                    if (MapperScannerConfigurer.this.sqlSessionTemplate != null) {
                        definition.getPropertyValues().add("sqlSessionTemplate",
                                MapperScannerConfigurer.this.sqlSessionTemplate);
                    }
                }
            }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

        }
    }else{
      throw new BeanCreationException("Loxia bean definition error with name:" + element.getAttribute(ID_ATTRIBUTE));
    }
   
    AbstractBeanDefinition rootDefinition = new GenericBeanDefinition();
    rootDefinition.setParentName("parentGenericDaoProxy");
    rootDefinition.getPropertyValues().addPropertyValue("proxyInterfaces",interfaces);
    rootDefinition.getPropertyValues().addPropertyValue("target",beanDefinition);   
    //rootDefinition.getPropertyValues().addPropertyValue("interceptorNames", new String[]{"queryInterceptor"});
    return rootDefinition;
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

                new ReplaceOverride(method.getName(), null));
          }
        }
      }     
      //bean.setAttribute(ID_ATTRIBUTE, beanName);
      AbstractBeanDefinition rootDefinition = new GenericBeanDefinition();
      rootDefinition.setParentName("parentGenericDaoProxy");
      rootDefinition.getPropertyValues().addPropertyValue("proxyInterfaces",interfaces);
      rootDefinition.getPropertyValues().addPropertyValue("target",targetBean)
     
      BeanComponentDefinition definition =
                new BeanComponentDefinition(rootDefinition, beanName);
      parserContext.registerBeanComponent(definition);
    } catch (ClassNotFoundException e) {
View Full Code Here

Examples of org.springframework.beans.factory.support.GenericBeanDefinition

  }

  private GenericApplicationContext setupSqlSessionTemplate() {

    GenericApplicationContext genericApplicationContext = setupSqlSessionFactory();
    GenericBeanDefinition definition = new GenericBeanDefinition();
    definition.setBeanClass(SqlSessionTemplate.class);
    ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
    constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory"));
    definition.setConstructorArgumentValues(constructorArgs);
    genericApplicationContext.registerBeanDefinition("sqlSessionTemplate", definition);
    return genericApplicationContext;
  }
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.