/org/springframework/cloud/spring-cloud-netflix-eureka-server/2.1.0.RELEASE/spring-cloud-netflix-eureka-server-2.1.0.RELEASE.jar!/META-INF/spring.factories中
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration
进入EurekaServerAutoConfiguration类,看到
@Bean
@ConditionalOnProperty(
prefix = "eureka.dashboard",
name = {"enabled"},
matchIfMissing = true
)
public EurekaController eurekaController() {
return new EurekaController(this.applicationInfoManager);
}
@Bean
public Application jerseyApplication(Environment environment, ResourceLoader resourceLoader) {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false, environment);
provider.addIncludeFilter(new AnnotationTypeFilter(Path.class));
provider.addIncludeFilter(new AnnotationTypeFilter(Provider.class));
Set<Class<?>> classes = new HashSet();
String[] var5 = EUREKA_PACKAGES;
int var6 = var5.length;
for(int var7 = 0; var7 < var6; ++var7) {
String basePackage = var5[var7];
Set<BeanDefinition> beans = provider.findCandidateComponents(basePackage);
Iterator var10 = beans.iterator();
while(var10.hasNext()) {
BeanDefinition bd = (BeanDefinition)var10.next();
Class<?> cls = ClassUtils.resolveClassName(bd.getBeanClassName(), resourceLoader.getClassLoader());
classes.add(cls);
}
}
Map<String, Object> propsAndFeatures = new HashMap();
propsAndFeatures.put("com.sun.jersey.config.property.WebPageContentRegex", "/eureka/(fonts|images|css|js)/.*");
DefaultResourceConfig rc = new DefaultResourceConfig(classes);
rc.setPropertiesAndFeatures(propsAndFeatures);
return rc;
}
进入EurekaController类,作用:对控制面板页面的跳转的controller层的web对象
@Controller
@RequestMapping({"${eureka.dashboard.path:/}"})
public class EurekaController {
@Value("${eureka.dashboard.path:/}")
private String dashboardPath = "";
...
@RequestMapping(
value = {"/lastn"},
method = {RequestMethod.GET}
)
public String lastn(HttpServletRequest request, Map<String, Object> model) {
this.populateBase(request, model);
PeerAwareInstanceRegistryImpl registry = (PeerAwareInstanceRegistryImpl)this.getRegistry();
ArrayList<Map<String, Object>> lastNCanceled = new ArrayList();
List<Pair<Long, String>> list = registry.getLastNCanceledInstances();
Iterator var6 = list.iterator();
while(var6.hasNext()) {
Pair<Long, String> entry = (Pair)var6.next();
lastNCanceled.add(this.registeredInstance((String)entry.second(), (Long)entry.first()));
}
model.put("lastNCanceled", lastNCanceled);
list = registry.getLastNRegisteredInstances();
ArrayList<Map<String, Object>> lastNRegistered = new ArrayList();
Iterator var10 = list.iterator();
while(var10.hasNext()) {
Pair<Long, String> entry = (Pair)var10.next();
lastNRegistered.add(this.registeredInstance((String)entry.second(), (Long)entry.first()));
}
model.put("lastNRegistered", lastNRegistered);
return "eureka/lastn";
}
jerseyApplication:初始化jersey的有关配置,通过jersey快速搭建满足restful的web程序,看到
EUREKA_PACKAGES点进去
private static final String[] EUREKA_PACKAGES = new String[]{"com.netflix.discovery", "com.netflix.eureka"};
扫描{"com.netflix.discovery", "com.netflix.eureka"}包下的
@Path @Provider,@Produces注解