/* * © 2010 GX creative online development B.V. All rights reserved. The contents of this work is confidential. * It is prohibited to copy, duplicate or alter this work in any manner without the express prior written * approval of GX creative online development B.V. */ package com.gxwebmanager.solutions.productmaintenancepanel.dao; import nl.gx.webmanager.services.datasource.DataSourceManager; import nl.gx.webmanager.services.event.Event; import nl.gx.webmanager.services.event.EventManagerService; import com.gxwebmanager.solutions.productmaintenancepanel.service.ValueObjectEvent; import com.gxwebmanager.solutions.productmaintenancepanel.vo.ValueObject; import com.gxwebmanager.solutions.productmaintenancepanel.vo.ValueObjectMapper; /** * Subclass of the DAOHelper that publishes events to the WebManager EventManagementService when changes are * made to any of the stored ValueObjects. * * @author markvc */ public class EventPublishingDAOHelper extends DAOHelper { private EventManagerService myEventManagerService; /** * Constructor for the EventPublishingDAOHelper. * * @param ds DataSource name to use. * @param dsm Reference to the DataSourceManager. * @param mapper The ValueObject mapping to use. * @param EventManagerService Reference to the EventManagementService. */ public EventPublishingDAOHelper(String ds, DataSourceManager dsm, ValueObjectMapper mapper, EventManagerService eventManagementService) { super(ds, dsm, mapper); myEventManagerService = eventManagementService; } /** * {@inheritDoc} */ @Override public void delete(ValueObject vo) { myEventManagerService .publish(new ValueObjectEvent(Event.Type.PRE, vo, ValueObjectEvent.DELETE, this)); super.delete(vo); myEventManagerService .publish(new ValueObjectEvent(Event.Type.POST, vo, ValueObjectEvent.DELETE, this)); } /** * {@inheritDoc} */ @Override public Integer insert(ValueObject vo) { myEventManagerService .publish(new ValueObjectEvent(Event.Type.PRE, vo, ValueObjectEvent.CREATE, this)); Integer voId = super.insert(vo); myEventManagerService .publish(new ValueObjectEvent(Event.Type.POST, vo, ValueObjectEvent.CREATE, this)); return voId; } /** * {@inheritDoc} */ @Override public void update(ValueObject vo) { myEventManagerService .publish(new ValueObjectEvent(Event.Type.PRE, vo, ValueObjectEvent.UPDATE, this)); super.update(vo); myEventManagerService .publish(new ValueObjectEvent(Event.Type.POST, vo, ValueObjectEvent.UPDATE, this)); } }