Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4797

orphaned Factory code never called from spring-plugin

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3.31
    • Fix Version/s: 2.5.x
    • Component/s: Plugin - Spring
    • Labels:
    • Environment:

      JDK 1.8
      Struts-2.3.4
      Maven 3.3.1

    • Flags:
      Important

      Description

      org.springframework.beans.BeanWrapper not created in struts-spring-plugin
      org.apache.struts2.spring.ClassReloadingBeanFactory contains orphaned createBeanInstance which currently is not implemented in spring plugin

      public class ClassReloadingBeanFactory extends org.springframework.beans.factory.support.DefaultListableBeanFactory {
          @Override
          protected org.springframework.beans.BeanWrapper createBeanInstance(String beanName, org.springframework.beans.factory.support.RootBeanDefinition mbd, Object[] args) {
              Class beanClass = resolveBeanClass(mbd, beanName, null);
              if (mbd.getFactoryMethodName() != null) {
                  return instantiateUsingFactoryMethod(beanName, mbd, args);
              }
              //commented to cached constructor is not used
              /* // Shortcut when re-creating the same bean...
              if (mbd.resolvedConstructorOrFactoryMethod != null) {
                  if (mbd.constructorArgumentsResolved) {
                      return autowireConstructor(beanName, mbd, null, args);
                  } else {
                      return instantiateBean(beanName, mbd);
                  }
              }*/
              // Need to determine the constructor...
              Constructor[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
              if (ctors != null ||
                      mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR ||
                      mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
                  return autowireConstructor(beanName, mbd, ctors, args);
              }
              // No special handling: simply use no-arg constructor.
              return instantiateBean(beanName, mbd);
          }
      

      //orphaned org.apache.struts2.spring.ClassReloadingXMLWebApplicationContext

      org.apache.struts2.spring.ClassReloadingXMLWebApplicationContext:

      setupReloading(...)
      {
      <snip>
              //setup the bean factory
              beanFactory = new ClassReloadingBeanFactory();
              beanFactory.setInstantiationStrategy(new ClassReloadingInstantiationStrategy());
              beanFactory.setBeanClassLoader(classLoader);
      
      /* Where is  BeanWrapper created by createBeanInstance& return to client */
      
              //start watch thread
              fam.start();
      }
      

      this orphaned code contains RootBeanDefiniton parameter org.springframework.beans.factory.support.RootBeanDefinition mbd
      which is used to construct class of bean here:
      Class beanClass = resolveBeanClass(mbd, beanName, null);

      i assume createBeanInstance is implemented in possibly 2.4.x?
      Thanks!

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mgainty@hotmail.com Martin Gainty
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 168h
                168h
                Remaining:
                Remaining Estimate - 168h
                168h
                Logged:
                Time Spent - Not Specified
                Not Specified