Results 1 to 3 of 3

Thread: publishing PropertyChangeEvents with POJO using AOP

  1. #1
    Join Date
    Apr 2005
    Location
    Germany
    Posts
    13

    Default publishing PropertyChangeEvents with POJO using AOP

    Hi,

    I have to enable my simple POJO's used with Spring/Hibernate to publish property changes. One way would be to use PropertyChangeSupport for the POJO's and do a firePropertyChange in every setter method.

    This is not the preferred way because there are a lot of classes to be changed.

    I found an interesting article about enabing this functionality in simple Java Beans using AOP (see http://www.damnhandy.com/?page_id=17).

    I wonder if someone has managed to implement a similar approach using Spring's configuration?

    Thanks and regards,

    Michael

  2. #2
    Join Date
    Apr 2005
    Location
    Germany
    Posts
    13

    Default

    Hi,

    I've found some interesting solutions for this in the ProSpring book, chapter 7 (the isModified example). With some modifications, this seems quite usable for me, except one point:

    The classes I want to add the property change functionality to are my model objects that are used by Hibernate to save and retrieve data.

    If I configure these objects via Spring configuration I can get them as advised beans through the application context, but if they are instantiated by Hibernate they don't have the Spring configuration and are not advised.

    I wonder how the Hibernate generated objects could be advised also in a Springy way?

    Any ideas?

    Thanks and regards,

    Michael

  3. #3
    Join Date
    Sep 2005
    Posts
    26

    Default

    "I wonder how the Hibernate generated objects could be advised also in a Springy way?"

    1. look for the first part of http://forum.springframework.org/showthread.php?t=18260.
    2. look at hibernate interceptor. it has a method where you could create the POJO's by using Sping bean factory.
    3. from spring SessionFactoryUtils JavaDoc:
    Supports setting a Session-level Hibernate entity interceptor that allows to inspect and change property values before writing to and reading from the database. Such an interceptor can also be set at the SessionFactory level (i.e. on LocalSessionFactoryBean), on HibernateTransactionManager, or on HibernateInterceptor/HibernateTemplate.
    Last edited by robyn; May 14th, 2006 at 06:59 PM.

Similar Threads

  1. Replies: 1
    Last Post: Aug 22nd, 2005, 03:43 PM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. Replies: 11
    Last Post: Jun 15th, 2005, 05:23 AM
  4. Replies: 7
    Last Post: Apr 14th, 2005, 09:47 AM
  5. Access Principal from POJO
    By ram_2000 in forum EJB
    Replies: 1
    Last Post: Jan 11th, 2005, 03:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •