DeltaSpike
  1. DeltaSpike
  2. DELTASPIKE-56

Add BeanManagerProvider.getRequiredBeanManager() method

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 0.2-incubating
    • Component/s: Core
    • Labels:
      None

      Description

      While reviewing the implementation of BeanManagerProvider I saw that getBeanManager() may return null in some rare circumstances. Unfortunately this forces everyone calling this method to check the result for null. I think most code calling the method absolutely requires the BeanManager and cannot proceed without it.

      Therefore it would be nice to have some alternative getBeanManager() method that doesn't return null if the BeanManager is not available but instead throws a meaningful runtime exception. That's what Solder does per default. Calling Solder's BeanManagerLocator.getBeanManager() without a BeanManager being available will result in a BeanManagerUnavailableException.

      The attached patch adds a method getRequiredBeanManager() to the BeanManagerProvider implementing this behavior.

      I'm not sure if this minor thing should be discussed on the mailing list. If you think this should be discussed, please let me know, then I'll start a topic on deltaspike-dev.

      1. DELTASPIKE-56.patch
        2 kB
        Christian Kaltepoth

        Issue Links

          Activity

          Hide
          Mark Struberg added a comment -

          Hi Christian!

          Thanks for raising that.

          In fact, I would prefer to make this the default behaviour of getBeanManager to throw an IllegalStateException if it resolves to null.

          Show
          Mark Struberg added a comment - Hi Christian! Thanks for raising that. In fact, I would prefer to make this the default behaviour of getBeanManager to throw an IllegalStateException if it resolves to null.
          Hide
          Christian Kaltepoth added a comment -

          Hi Mark,

          I would also prefer to change the default behavior. I think throwing an exception makes more sense. Perhaps it would be a good idea to discuss this on the mailing list.

          Christian

          Show
          Christian Kaltepoth added a comment - Hi Mark, I would also prefer to change the default behavior. I think throwing an exception makes more sense. Perhaps it would be a good idea to discuss this on the mailing list. Christian
          Hide
          Gerhard Petracek added a comment -

          +1 >!< for moving this discussion to the mailing list.

          Show
          Gerhard Petracek added a comment - +1 >!< for moving this discussion to the mailing list.
          Hide
          Gerhard Petracek added a comment - - edited

          we agreed on a different approach (see http://s.apache.org/9MC ) -> there will be a new jira issue for it

          Show
          Gerhard Petracek added a comment - - edited we agreed on a different approach (see http://s.apache.org/9MC ) -> there will be a new jira issue for it

            People

            • Assignee:
              Gerhard Petracek
              Reporter:
              Christian Kaltepoth
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development