public class SampleAbstractDMListener extends Object
The objectChanged method will be called with three different types of POJOs:
public class SampleAbstractDMListener extends AbstractDMListener { @Override public void objectChanged(Object oldObject, Object newObject) { if (oldObject instanceof DefaultAttribute || newObject instanceof DefaultAttribute) { // Objects are of type DefaultAttribute, when the attribute value // changed at "Service Global" level } if (oldObject instanceof ClusterDefaultAttribute || newObject instanceof ClusterDefaultAttribute) { // Objects are of type ClusterDefaultAttribute, when the attribute // value changed at "Service Clusters" level } if (oldObject instanceof AusAttribute || newObject instanceof AusAttribute) { // Objects are of type AusAttribute, when the attribute value // changed at "Service Profiles" level } } }The second example shows registration of listeners to receive attribute change notifications. The service should also unregister itself to stop Avaya Breeze sending attribute change notifications to it. The registration and removal of listeners can be done using EJBs, servlets, service life cycle methods, REST call or by using any other Java class. And once registered it will start getting notifications. This example shows registration and removal of listeners using Servlet life cycle methods. Here the DMFactory class provides access to components that implement Data Managers (DataMgr). The Data Manager represents a mechanism to store and use data that comes from a variety of data source (ie. postgres database, runtime data, etc.).
@WebServlet("/SampleServlet") public class SampleServlet extends HttpServlet { private SampleAbstractDMListener dmListener = new SampleAbstractDMListener(); @Override public void init() throws ServletException { // Listener registration with "AusServiceDAO" for notifications of // attribute changes at "Service Global" and "Service Clusters" level DMFactory.getInstance().getDataMgr(AusServiceDAO.class) .registerListener(dmListener); // Registration of Listener with "AusAttributeDAO" for notifications of // attribute value changes at "Service Profiles" level DMFactory.getInstance().getDataMgr(AusAttributeDAO.class) .registerListener(dmListener); } @Override public void destroy() { // Removal of Listener from "AusServiceDAO" DMFactory.getInstance().getDataMgr(AusServiceDAO.class) .removeListener(dmListener); // Removal of Listener from "AusAttributeDAO" DMFactory.getInstance().getDataMgr(AusAttributeDAO.class) .removeListener(dmListener); } }
Copyright © 2016 Avaya. All Rights Reserved.