mardi 12 décembre 2017

What is the advantage of @configuration on inner static class

I was working to integrate spring boot actuator with non spring boot application following this article

http://ift.tt/2BdJS8a

I noticed that RequestMappingEndpoint bean is being initialized through a static inner class, I saw this pattern in some other code samples too. I tried to figure out what it the advantage of this but could not get a clear idea, any explanation is appreciated

 @Bean  
   @Autowired  
   //Define the beans for exposing the mapping  
   public EndpointMvcAdapter requestMappingEndPoint(RequestMappingEndpoint delegate){  
     return new EndpointMvcAdapter(delegate);  
   }  


 @Configuration  
   protected static class RequestMappingEndpointConfiguration {  
     protected RequestMappingEndpointConfiguration() {  
     }  
     @Bean  
     public RequestMappingEndpoint requestMappingEndpoint() {  
       RequestMappingEndpoint endpoint = new RequestMappingEndpoint();  
       return endpoint;  
     }  
   }  

Aucun commentaire:

Enregistrer un commentaire