Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

To register a customized ObjectFactory, add or edit an entry in struts.properties

Code Block

 struts.objectFactory=foo.bar.MyCustomObjectFactory

where foo.bar.MyCustomObjectFactory is the custom object factory.

Code Block

public class MyObjectFactory extends ObjectFactory {
    .....
}

Define dedicated

...

factory

If you want to just extend one part of ObjectFactory, ie. to change how Result Types are build, you can implement dedicated ResultFactory interface below and register it with dedicated name, see Extension Points for more details. Original ObjectFactory will use these dedicated factories to do the work. It's already done this way - the original functionality of ObjectFactory was extracted to separated classes which implements the interfaces below. Check the source of ObjectFactory to see more details. All these builders factories are available as from version 2.3.16 when StrutsObjectFactory or its descendants is defined as struts.objectFactory - basically this should work with default Struts 2 installation and with the Spring plugin as well.

List of Builder Factory interfaces:

...

...

  • create Result Types

      ...

        • StrutsResultFactory it's internal implementation which checks if Result implements ParamNameAwareResult interface to restrict names of parameters set on the instance of Result, see Result Types for more info.
      • ActionFactory - dedicated interface used by ObjectFactory to actions
      • InterceptorFactory - dedicated interface used by ObjectFactory to create interceptors
      • ValidatorFactory - dedicated interface used by ObjectFactory to create validators
      • ConverterFactory - dedicated interface used by ObjectFactory to create instances of TypeConverter
      • UnknownHandlerFactory - dedicated interfaces used by ObjectFactory to create instances of Unknown Handlers (as from version 2.3.18)

      Next: ActionMapper