Skip Headers

# Using Java

Previous

Next

Example: Domain Object Method as a Descriptor Event Handler shows a domain object class with method `handlePostDelete` defined to handle `PostDeleteEvent` descriptor events. Example: Registering a Domain Object Method as a Descriptor Event Handlershows how to register this method as the `PostDeleteEvent` event handler. Whenever the TopLink runtime performs a post-delete operation on an instance of `Employee`, the runtime will dispatch a `PostDeleteEvent` to the `DescriptorEventManager` owned by the `Employee` object's descriptor. The `DescriptorEventManager` will then invoke the `handlePostDelete` method on the instance of `Employee` associated with that `PostDeleteEvent`.

Domain Object Method as a Descriptor Event Handler

    public class Employee {
        // domain object methods
        ...
        public void handlePostDelete(DescriptorEvent event) {
            // handler implementation
        }
    }

Registering a Domain Object Method as a Descriptor Event Handler

    employeeDescriptor.getEventManager().setPostDeleteSelector("handlePostDelete");