Uploaded image for project: 'XWork'
  1. XWork
  2. XW-122

Support for resolving component References in external IoC containers such as Spring

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta2
    • 1.0
    • Configuration, Interceptors
    • None

    Description

      As per the discussion late last week, we have a patch for Xwork so that it can use an external container to resolve component references.
      I've added a breakdown of the changes below, in summary, this is how it works-

      You can configure a action to have external references in the xwork.xml using a new <external-ref> tag on the action

      When the action is configured the external refs are stored on the action config.

      When the action is invoked, there is a new interceptor that will resolve these references. It does this by using a new attribute on the package config called externalReferenceResolver i.e.

      <package name="default" externalReferenceResolver="com.atlassian.xwork.ext.SpringServletContextReferenceResolver">

      In this case, the SpringServletContextReferenceResolver implementation will handle the work of looking up and setting the references on the action.
      Note, if a resolver is not found on the actions package, it will tranverse up the package heirarchy to find one.

      We have an implementation for Spring, but I have not included it in this patch as it should probably go into an xwork-ext sub-project. Let me know what you want me to do with this...

      Here are the changes and additions to the xwork codebase -

      1. added 2 new config attributes -

      • a new element external-ref to the action element in the config.
        i.e <external-ref name="foo">Foo</external-ref>
        where name is the setter method name and Foo is the reference to lookup.
      • added an attribute to the package element called externalReferenceResolver which supplies a FQ classname to an ExternalReferenceResolver implementation.

      2. Updated the xwork DTD accordingly.

      3. Added 4 new classes -

      • External Reference - an encapsulation of the external-ref tag
      • ExternalReferenceResolver - an interface to provide implementations for resolving references from an external container
      • ExternalReferencesInterceptor - will resolve references on a given ActionInvocation
      • ReferenceResolverException - thrown by ExternalReferenceResolver

      4. Added support for external references to the ActionConfig. I also added the attribute packageName to the ActionConfig, so that the Interceptor could determine which package the action belonged to in order to find the externalReferenceResolver.

      5. Added support for the externalReferenceResolver attribute to the PackageConfig.

      6. Added support for the extra configuration to the XMLConfigurationProvider and DefaultConfigurationProvider

      7. Added tests in the org.opensymphony.xwork.config.ExternalReferenceResolverTest

      I've attached a cvs patch with all the changes.

      Cheers,

      Ross

      Attachments

        Issue Links

          Activity

            People

              mike mike
              rossmason Ross Mason
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: