public Object create(BeanCreationDirective directive) {
   Class<?> classToCreate = directive.getActualClass();
   String factoryBeanId = directive.getFactoryId();
   String beanId =
       !MappingUtils.isBlankOrNull(factoryBeanId) ? factoryBeanId : classToCreate.getName();
   return xmlBeanFactory.createBean(directive.getSrcObject(), directive.getSrcClass(), beanId);
 }
    public Object create(BeanCreationDirective directive) {
      Class<?> classToCreate = directive.getActualClass();
      String factoryName = directive.getFactoryName();
      String factoryBeanId = directive.getFactoryId();

      // By default, use dest object class name for factory bean id
      String beanId =
          !MappingUtils.isBlankOrNull(factoryBeanId) ? factoryBeanId : classToCreate.getName();

      BeanFactory factory = factoryCache.get(factoryName);
      if (factory == null) {
        Class<?> factoryClass = MappingUtils.loadClass(factoryName);
        if (!BeanFactory.class.isAssignableFrom(factoryClass)) {
          MappingUtils.throwMappingException(
              "Custom bean factory must implement "
                  + BeanFactory.class.getName()
                  + " interface : "
                  + factoryClass);
        }
        factory = (BeanFactory) ReflectionUtils.newInstance(factoryClass);
        // put the created factory in our factory map
        factoryCache.put(factoryName, factory);
      }

      Object result = factory.createBean(directive.getSrcObject(), directive.getSrcClass(), beanId);

      log.debug(
          "Bean instance created with custom factory -->\n  Bean Type: {}\n  Factory Name: {}",
          result.getClass().getName(),
          factoryName);

      if (!classToCreate.isAssignableFrom(result.getClass())) {
        MappingUtils.throwMappingException(
            "Custom bean factory ("
                + factory.getClass()
                + ") did not return correct type of destination data object. Expected : "
                + classToCreate
                + ", Actual : "
                + result.getClass());
      }
      return result;
    }
 public boolean isApplicable(BeanCreationDirective directive) {
   String factoryName = directive.getFactoryName();
   return !MappingUtils.isBlankOrNull(factoryName);
 }
 public boolean isApplicable(BeanCreationDirective directive) {
   String createMethod = directive.getCreateMethod();
   return !MappingUtils.isBlankOrNull(createMethod);
 }