Tapestry 5
  1. Tapestry 5
  2. TAP5-955

Add @Optional annotation to mark contribution methods that can be ignored if the indicated service does not exist

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.3
    • Component/s: tapestry-ioc
    • Labels:
      None

      Description

      Currently the registry wil not start if a module makes contributions to a service which does not exist (e.g. because the module with the service is not loaded). This makes problems with applications, that allow installations with a subset of all modules started. A module should be able to contribute to an extension point only if it is available. In case the service does not exist, the contribution should be ignored.

        Activity

        Hide
        Massimo Lusetti added a comment -

        Actually the current behavior is preferred in most situations. This could be a knob instead.

        Show
        Massimo Lusetti added a comment - Actually the current behavior is preferred in most situations. This could be a knob instead.
        Hide
        Peter Rietzler added a comment -

        I absolutely agree with you. The standard behavior should not change - I thought of something like this:

        @Contribute(to = "service-name", optional = true)
        public static void arbitraryContributeMethodName(....)

        or

        @Optional
        public static void contributeServiceName(...)

        Show
        Peter Rietzler added a comment - I absolutely agree with you. The standard behavior should not change - I thought of something like this: @Contribute(to = "service-name", optional = true) public static void arbitraryContributeMethodName(....) or @Optional public static void contributeServiceName(...)
        Hide
        Peter Niederwieser added a comment -

        Requiring that every contribution has a "target" takes away a lot of flexibility from the module system. None of the other module systems I know (Eclipse, OSGi) enforces such a constraint. At the very least, there should be an option to turn this feature off. Personally I consider it a misfeature that, although it might look attractive at first, brings more harm then benefit - especially for large apps. And large apps are where module systems are supposed to shine the most.

        It's perfectly sensible to only start the modules that are needed in the current situation (in particular but not only for testing), and Tapestry should not work against this. Otherwise modules will get deployed and started just to make Tapestry happy. I've seen this more than once in practice.

        Show
        Peter Niederwieser added a comment - Requiring that every contribution has a "target" takes away a lot of flexibility from the module system. None of the other module systems I know (Eclipse, OSGi) enforces such a constraint. At the very least, there should be an option to turn this feature off. Personally I consider it a misfeature that, although it might look attractive at first, brings more harm then benefit - especially for large apps. And large apps are where module systems are supposed to shine the most. It's perfectly sensible to only start the modules that are needed in the current situation (in particular but not only for testing), and Tapestry should not work against this. Otherwise modules will get deployed and started just to make Tapestry happy. I've seen this more than once in practice.
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #581 (See https://builds.apache.org/job/tapestry-trunk-freestyle/581/)
        TAP5-955: Add @Optional annotation to mark contribution methods that can be ignored if the indicated service does not exist

        hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1185442
        Files :

        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Contribute.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Optional.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/def/ContributionDef2.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/def/ContributionDef3.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ContributionDefImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/OptionalContributionModule.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributionDefImplTest.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #581 (See https://builds.apache.org/job/tapestry-trunk-freestyle/581/ ) TAP5-955 : Add @Optional annotation to mark contribution methods that can be ignored if the indicated service does not exist hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1185442 Files : /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Contribute.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Optional.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/def/ContributionDef2.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/def/ContributionDef3.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ContributionDefImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/OptionalContributionModule.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ContributionDefImplTest.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Peter Rietzler
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development