Hi,

in my opinion, one of the major drawbacks of the "new" interface
attributes over the long-existing service properties is the missing
possibility to listen for attribute changes.

That is, the XPropertySet interface has methods
add-/removePropertyChangeListener, which take the name of a property and
an XPropertyChangeListener interface. This is a very generic and
flexible way to listen for changes in certain facets of a component.

For interface attributes, there's the syntactic element to declare an
attribute as bound, but no common mechanism to make use of it. You
either need to re-use XPropertySet.add/removePropertyChangeListener (and
thus the whole XPropertySet) in your implementation, or introduce
dedicated, non-generic methods/listeners.

My recent experience while designing new APIs is that the only reason
why I usually also include an XPropertySet is that it's the
only/fastest/generic way to allow for (property/attribute value) observers.

My suggestion now is to add something like the following:

namespace com { namespace sun { namespace star {
namespace beans {

  struct AttributeChangeEvent : com::sun::star::lang::EventObject
  {
    string  AttributeName;
    any     OldValue;
    any     NewValue;
  };

  interface XAttributeChangeListener
  {
    [oneway] void attributeChanged( [in] AttributeChangeEvent _Event );
  };

  exception UnknownAttributeException: com::sun::star::uno::Exception
  {
    string AttributeName;
  };

  interface XAttributeChangeBroadcaster
  {
    void addAttributeChangeListener(
      [in] string _AttributeName,
      [in] XAttributeChangeListener _Listener
    )
      raises ( UnknownAttributeException );

    void removeAttributeChangeListener(
      [in] string _AttributeName,
      [in] XAttributeChangeListener _Listener
    )
      raises ( UnknownAttributeException );
  };

}
} } }

The semantics of all those would be similar to the semantics of the
respective *PropertyChange* structs/interfaces, so I omitted the
documentation here for the moment.

Every interface which declares bound attributes could then additionally
inherit from XAttributeChangeBroadcaster, and thus offer its clients a
standardized way to be notified of attribute changes.

(Note that as a generalization, one could also imagine introducing
vetoable attributes, but for the moment, I think the above would be a
very useful first step.)

Opinions?

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer         [EMAIL PROTECTED] -
- Sun Microsystems                      http://www.sun.com/staroffice -
- OpenOffice.org Database                   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to