Spring bean reflection
This commit is contained in:
parent
64ec56073e
commit
fe5be0bfa8
|
@ -4,6 +4,7 @@ import com.loafle.overflow.module.discovery.model.Host;
|
|||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.spring.AppConfig;
|
||||
import com.loafle.overflow.spring.JdbcConfiguration;
|
||||
import com.loafle.overflow.spring.MailConfiguration;
|
||||
import org.codehaus.jackson.map.DeserializationConfig;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.junit.Ignore;
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
@ -30,7 +32,7 @@ import java.util.List;
|
|||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class})
|
||||
public class TargetDiscoveryServiceTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -77,6 +79,31 @@ public class TargetDiscoveryServiceTest {
|
|||
Method m = this.targetDiscoveryService.getClass().getMethod("saveAllTarget", List.class, Probe.class);
|
||||
// Method m = TargetDiscoveryService.class.getMethod("saveAllTarget", List.class, Probe.class);
|
||||
|
||||
Class<?> clazz = AopUtils.getTargetClass(this.targetDiscoveryService);
|
||||
Method[] ms = clazz.getMethods();
|
||||
|
||||
Method sm = null;
|
||||
for(Method mm : ms){
|
||||
if ("saveAllTarget".equals(mm.getName())) {
|
||||
sm = mm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sm != null) {
|
||||
Type[] ts = sm.getGenericParameterTypes();
|
||||
for(Type t : ts){
|
||||
if (t instanceof ParameterizedType) {
|
||||
ParameterizedType pt = (ParameterizedType)t;
|
||||
System.out.println(pt.getActualTypeArguments()[0].getTypeName());
|
||||
}
|
||||
System.out.println(t.getTypeName());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
System.out.println(m.getName());
|
||||
Type[] genericParameterTypes = m.getGenericParameterTypes();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user