Announcement Announcement Module
Collapse
No announcement yet.
protected setter methods? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • protected setter methods?

    I apologize if this has been answered before.

    I've run a search and could not find any matching result, but surely this
    must have come up before - why can't I declare the setter methods of
    bean properties as protected (I keep getting a NotWritablePropertyException)? Or can I?

    This demonstrates my intention of making these setters inaccessible to
    the interface user. Hibernate (as an example) does allow you to declare
    setters and even getters using modifiers other than 'public' to allow for the
    domain semantics to be expressed more clearly and behind the scenes it
    uses whatever machinery to enable its own 'IoC' when constructing model
    beans from their DB representations.

  • #2
    AFAIK, this is a JavaBeans issue. Does seem restrictive.

    Comment


    • #3
      If you need a quick solution look inside a the bean package and find the class that does the introspection and extend it. Ofc, you can also add a JIRA issue .

      Comment


      • #4
        Re: protected setter methods?

        Originally posted by bonnyr
        This demonstrates my intention of making these setters inaccessible to the interface user.
        Doesn't constructor-based injection achieve the same thing?

        In fact, even if the setters are public, as long as they are not defined on the interface, they are inaccessible to the interface users, right? (yes, they can downcast, but if they are crazy enough to downcast, they might as well be determined to use introspection to call a protected setter.)

        Comment

        Working...
        X