mirror of
				https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
				synced 2025-10-31 18:47:57 +00:00 
			
		
		
		
	simplified configuration of ApplicationListeners
This commit is contained in:
		| @@ -2,8 +2,10 @@ package com.telecominfraproject.wlan.opensync.external.integration.controller; | ||||
|  | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.ApplicationListener; | ||||
| import org.springframework.context.event.ContextStartedEvent; | ||||
| import org.springframework.stereotype.Component; | ||||
|  | ||||
| /** | ||||
|  * Listen for context started event so that we are register with routing service | ||||
| @@ -11,15 +13,13 @@ import org.springframework.context.event.ContextStartedEvent; | ||||
|  * @author yongli | ||||
|  *  | ||||
|  */ | ||||
| @Component | ||||
| public class OpensyncGatewayControllerStartListener implements ApplicationListener<ContextStartedEvent> { | ||||
|  | ||||
|     private static final Logger LOG = LoggerFactory.getLogger(OpensyncGatewayControllerStartListener.class); | ||||
|  | ||||
|     OpensyncCloudGatewayController controller; | ||||
|  | ||||
|     public OpensyncGatewayControllerStartListener(OpensyncCloudGatewayController controller) { | ||||
|         this.controller = controller; | ||||
|     } | ||||
|     @Autowired | ||||
|     private OpensyncCloudGatewayController controller; | ||||
|  | ||||
|     @Override | ||||
|     public void onApplicationEvent(ContextStartedEvent event) { | ||||
|   | ||||
| @@ -2,8 +2,10 @@ package com.telecominfraproject.wlan.opensync.external.integration.controller; | ||||
|  | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.ApplicationListener; | ||||
| import org.springframework.context.event.ContextClosedEvent; | ||||
| import org.springframework.stereotype.Component; | ||||
|  | ||||
| /** | ||||
|  * Register for stop event so that we can de-register from routing service | ||||
| @@ -11,14 +13,13 @@ import org.springframework.context.event.ContextClosedEvent; | ||||
|  * @author yongli | ||||
|  * | ||||
|  */ | ||||
| @Component | ||||
| public class OpensyncGatewayControllerStopListener implements ApplicationListener<ContextClosedEvent> { | ||||
| 	OpensyncCloudGatewayController controller; | ||||
|  | ||||
| 	private static final Logger LOG = LoggerFactory.getLogger(OpensyncGatewayControllerStopListener.class); | ||||
|  | ||||
| 	public OpensyncGatewayControllerStopListener(OpensyncCloudGatewayController controller) { | ||||
| 		this.controller = controller; | ||||
| 	} | ||||
| 	@Autowired | ||||
| 	private OpensyncCloudGatewayController controller; | ||||
|  | ||||
| 	@Override | ||||
| 	public void onApplicationEvent(ContextClosedEvent event) { | ||||
|   | ||||
| @@ -1,29 +0,0 @@ | ||||
| package com.telecominfraproject.wlan.opensync.external.integration.controller; | ||||
|  | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.ApplicationListener; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.event.ContextClosedEvent; | ||||
| import org.springframework.context.event.ContextStartedEvent; | ||||
| import org.springframework.stereotype.Component; | ||||
|  | ||||
| @Component | ||||
| public class OpensyncGatewayListenerConfiguration { | ||||
|     @Autowired | ||||
|     OpensyncCloudGatewayController controller; | ||||
|     private static final Logger LOG = LoggerFactory.getLogger(OpensyncGatewayControllerStartListener.class); | ||||
|  | ||||
|     @Bean | ||||
|     public ApplicationListener<ContextClosedEvent> myStopEventListner() { | ||||
|         LOG.debug("Creating stop event listener"); | ||||
|         return new OpensyncGatewayControllerStopListener(controller); | ||||
|     } | ||||
|      | ||||
|     @Bean | ||||
|     public ApplicationListener<ContextStartedEvent> myStartedEventListener() { | ||||
|         LOG.debug("Creating start event listener"); | ||||
|         return new OpensyncGatewayControllerStartListener(controller); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Dmitry Toptygin
					Dmitry Toptygin