Search in sources :

Example 1 with BrokerLifecycleListener

use of org.wso2.carbon.andes.listeners.BrokerLifecycleListener in project carbon-apimgt by wso2.

the class LifecycleComponent method setQpidService.

@Reference(name = "QpidService", service = org.wso2.carbon.andes.service.QpidService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetQpidService")
public void setQpidService(QpidService qpidService) {
    log.debug("Setting QpidService...");
    ServiceReferenceHolder.getInstance().setQpidService(qpidService);
    if (qpidService != null) {
        qpidService.registerBrokerLifecycleListener(new BrokerLifecycleListener() {

            @Override
            public void onShuttingdown() {
                if (ServiceReferenceHolder.getInstance().getListenerShutdownServices().isEmpty()) {
                    return;
                }
                log.debug("Triggering a Shutdown of the Listener...");
                for (JMSListenerShutDownService listenerShutdownService : ServiceReferenceHolder.getInstance().getListenerShutdownServices()) {
                    listenerShutdownService.shutDownListener();
                }
            }

            @Override
            public void onShutdown() {
            }
        });
    }
}
Also used : JMSListenerShutDownService(org.wso2.carbon.apimgt.impl.jms.listener.JMSListenerShutDownService) BrokerLifecycleListener(org.wso2.carbon.andes.listeners.BrokerLifecycleListener) Reference(org.osgi.service.component.annotations.Reference)

Aggregations

Reference (org.osgi.service.component.annotations.Reference)1 BrokerLifecycleListener (org.wso2.carbon.andes.listeners.BrokerLifecycleListener)1 JMSListenerShutDownService (org.wso2.carbon.apimgt.impl.jms.listener.JMSListenerShutDownService)1