Clover icon

sunshower-base

  1. Project Clover database Mon May 7 2018 22:12:38 UTC
  2. Package io.sunshower.test.ws

File ProviderDependencyReorderingFactoryPostProcessor.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
12
2
1
37
33
3
0.25
6
2
1.5

Classes

Class Line # Actions
ProviderDependencyReorderingFactoryPostProcessor 13 12 3
1.0100%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.test.ws;
2   
3    import java.util.ArrayList;
4    import java.util.Arrays;
5    import java.util.List;
6    import javax.ws.rs.client.Client;
7    import javax.ws.rs.ext.Provider;
8    import org.springframework.beans.BeansException;
9    import org.springframework.beans.factory.config.BeanDefinition;
10    import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
11    import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
12   
 
13    public class ProviderDependencyReorderingFactoryPostProcessor implements BeanFactoryPostProcessor {
14   
 
15  1 toggle @Override
16    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
17    throws BeansException {
18  1 String[] beanNames = beanFactory.getBeanNamesForType(Client.class);
19  1 String[] providerNames = beanFactory.getBeanNamesForAnnotation(Provider.class);
20  1 for (String name : beanNames) {
21  1 BeanDefinition definition = beanFactory.getBeanDefinition(name);
22  1 for (String providerName : providerNames) {
23  5 String[] dependencies = reconfigure(providerName, definition.getDependsOn());
24  5 definition.setDependsOn(dependencies);
25    }
26    }
27    }
28   
 
29  5 toggle private String[] reconfigure(String providerName, String[] dependsOn) {
30  5 if (dependsOn == null) {
31  1 return new String[] {providerName};
32    }
33  4 List<String> result = new ArrayList<>(Arrays.asList(dependsOn));
34  4 result.add(providerName);
35  4 return result.toArray(new String[dependsOn.length + 1]);
36    }
37    }