PicoContainer
  1. PicoContainer
  2. PICO-97

pass expected type of the constructor/setter argument to Parameter.resolveAdapter(..) method

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-5
    • Fix Version/s: 1.0-beta-5
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      3

      Description

      I would like to suggest passing the expected type of the argument to
      the resolveAdapter method.

      The expected types are always explicitly known at the moment of the resolution, so there is no extra effort required.

      Paramter implementations that don't need this information may safely ignore it - there is no impact on existing implemenations except method signature change.

      Passing the type allows doing some some neat stuff:

      1) smart ComponentParameter() that looks up the required value in the
      componentRegistry using argument's expected type as a key. Fixes PICO-59, see accompanying patch.

      2) implementing a StringParamter(String stringValue) that performs the
      conversion of the value to the argument's expected type, at the time of resolution, see http://tinyurl.com/2bvme

      3) implementing a SequenceParameter(Parameter[]) that can be using for hinting attributes of composite types (Java arrays, and java.util.Collection flavours), related to PICO-33, see http://tinyurl.com/22rpo

      As for the latter two I would love to see them folded into PicoContainer (3) and PicoExtras-reflections (2). Contact me if you are interested.

      1. ExpectedType.diff
        7 kB
        Rafal Krzewski
      2. expectedType2.diff
        8 kB
        Rafal Krzewski
      3. expectedType3.diff
        6 kB
        Rafal Krzewski

        Issue Links

          Activity

          Hide
          Rafal Krzewski added a comment -

          a patch that performs described changes

          Show
          Rafal Krzewski added a comment - a patch that performs described changes
          Rafal Krzewski made changes -
          Field Original Value New Value
          Attachment ExpectedType.diff [ 11233 ]
          Hide
          Jon Tirsen added a comment -

          I agree. This has to be fixed before 1.0. I think for a while this information was actually passed to that method.

          Show
          Jon Tirsen added a comment - I agree. This has to be fixed before 1.0. I think for a while this information was actually passed to that method.
          Jon Tirsen made changes -
          Fix Version/s 1.0-beta-4 [ 10412 ]
          Hide
          Rafal Krzewski added a comment -

          an updated patch, REPLACES ExpectedType.diff

          I noticed that in certain contexts, the expected type hint may not be available - for example inside a SequenceParameter of a plain Collection type. This must be handled by the hint-less ComponentParameter.

          An alternative would be passing Object.class to the resolveAdapter(..)
          but this couldn't possibly yield an useful result.

          Show
          Rafal Krzewski added a comment - an updated patch, REPLACES ExpectedType.diff I noticed that in certain contexts, the expected type hint may not be available - for example inside a SequenceParameter of a plain Collection type. This must be handled by the hint-less ComponentParameter. An alternative would be passing Object.class to the resolveAdapter(..) but this couldn't possibly yield an useful result.
          Rafal Krzewski made changes -
          Attachment expectedType2.diff [ 11241 ]
          Hide
          Jon Tirsen added a comment -

          I don't see why the type shouldn't be available in that case? Java is a strongly typed language and the expected type for everything is always available and declared. If a component of type Object is declared then the component should be able to accept anything.

          Show
          Jon Tirsen added a comment - I don't see why the type shouldn't be available in that case? Java is a strongly typed language and the expected type for everything is always available and declared. If a component of type Object is declared then the component should be able to accept anything.
          Hide
          Rafal Krzewski added a comment -

          Given a little thought, I'm fine with both options. Feel free to ignore the updated patch.

          Show
          Rafal Krzewski added a comment - Given a little thought, I'm fine with both options. Feel free to ignore the updated patch.
          Aslak Hellesøy made changes -
          Fix Version/s 1.0-beta-4 [ 10412 ]
          Environment
          Fix Version/s 1.0 [ 10145 ]
          Affects Version/s 1.0 [ 10145 ]
          Hide
          Rafal Krzewski added a comment -

          updated patch against CVS HEAD, as of Jauary 30, 2004

          Show
          Rafal Krzewski added a comment - updated patch against CVS HEAD, as of Jauary 30, 2004
          Rafal Krzewski made changes -
          Attachment expectedType3.diff [ 11308 ]
          Aslak Hellesøy made changes -
          Assignee Aslak Hellesoy [ rinkrank ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          Aslak Hellesøy made changes -
          Link This issue depends upon PICO-59 [ PICO-59 ]

            People

            • Assignee:
              Aslak Hellesøy
              Reporter:
              Rafal Krzewski
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: