//Getting the global configuration for notification type.
boolean coDoNotfication = Configuration.getConfiguration()
.getConfigItem(NOTIFICATION_ENABLED,
params.getControl().retrieveConfigContext())
.getBooleanValue();
if (coDoNotfication) {
//1. Instantiating the notification object
SINNumberChangeNotification scNotification = new SINNumberChangeNotification();
DWLControl control = params.getControl();
//2.Setting the needed information to the notification object
scNotification.setTxnType((String) control
.get(DWLControl.REQUEST_NAME));
scNotification.setTxnTime(new Timestamp(System
.currentTimeMillis()));
scNotification.setRequestId(control.get(
DWLControl.REQUEST_ID).toString());
scNotification.setUserId((String) control
.get(TCRMControlKeys.USER_NAME));
scNotification.setPrimaryKey(identificationBObj.getIdentificationIdPK());
scNotification.setElementName("IdentificationNumber");
scNotification.setElementAfterImage(identificationBObj
.getIdentificationNumber());
TCRMPartyIdentificationBObj beforeIdentificationBObj = (TCRMPartyIdentificationBObj) (identificationBObj
.BeforeImage());
if (beforeIdentificationBObj != null) {
String identificationNumberBefore = ((TCRMPartyIdentificationBObj) (identificationBObj
.BeforeImage())).getIdentificationNumber();
scNotification.setElementBeforeImage(identificationNumberBefore);
}
//3. Set the preferred destination. This is an optional step.
scNotification.addJMSDestination(ELEMENT_CHANGE_TOPIC);
scNotification.setControl(control);
//5. Invoke the sendNotification method. Which intern invokes
// the appropriate notify method.
sendNotification(scNotification);
}
/**
*
* Gets local home object of the NotificationTxn bean.
* <p>
*
* @return Local home object of the NotificationTxn bean.
* @throws Exception
* If lookup of the bean reference fails.
* @since 6.0
*/
protected final static NotificationLocalHome getNotificationLocalHome()
throws Exception {
ServiceLocator serviceLocator = ServiceLocator.getInstance();
NotificationLocalHome home = (NotificationLocalHome) serviceLocator
.getLocalHome("ejblocal:com/dwl/base/notification/NotificationLocal");
return home;
}
/**
* Sends notification to common notification framework
*
* @param theCommonNotification object
* @throws TCRMException
*/
public void sendNotification(CommonNotification theCommonNotification)
throws TCRMException {
PerformanceMonitorFactory performanceMonitorFactory = PerformanceMonitorConfig
.getInstance().getPerformanceMonitorFactory();
PerformanceMonitor performanceMonitor = performanceMonitorFactory
.newCustomerNotificationMonitor();
boolean success = false;
performanceMonitor.start(theCommonNotification.getControl(), MONITOR_TRANS_SEND_NOTIFICATION, getClass());
try {
NotificationLocal theNotificationBean = getNotificationLocalHome()
.create();
theNotificationBean.notify(theCommonNotification);
success = true;
} catch (TCRMException ex) {
throw ex;
} catch (Exception ex) {
if(logger.isErrorEnabled())
logger.error(ex.getLocalizedMessage());
TCRMException tcrmEx = new TCRMException(ex.getMessage());
throw tcrmEx;
} finally {
performanceMonitor.stop(success);
}
}