Commit dfc172a1 by Yiming Liu

Remove unused code

parent 53ed6342
......@@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-biz</artifactId>
<name>Apollo BizLogic</name>
<name>Apollo Biz</name>
<packaging>jar</packaging>
<dependencies>
......
......@@ -2,3 +2,4 @@ spring.datasource.url = jdbc:h2:file:~/fxapolloconfigdb;mode=mysql
spring.datasource.username = sa
spring.datasource.password =
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.h2.console.enabled = true
\ No newline at end of file
package com.ctrip.apollo.client.loader.impl;
import com.ctrip.apollo.client.loader.ConfigLoader;
import com.ctrip.apollo.client.model.ApolloRegistry;
import com.ctrip.apollo.client.util.ConfigUtil;
import com.ctrip.apollo.core.model.ApolloConfig;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.CompositePropertySource;
......@@ -16,11 +21,11 @@ import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import com.ctrip.apollo.client.loader.ConfigLoader;
import com.ctrip.apollo.client.model.ApolloRegistry;
import com.ctrip.apollo.client.util.ConfigUtil;
import com.ctrip.apollo.core.model.ApolloConfig;
import com.google.common.collect.Lists;
/**
* Load config from remote config server
......@@ -116,7 +121,7 @@ public class RemoteConfigLoader implements ConfigLoader {
ApolloConfig getRemoteConfig(RestTemplate restTemplate, String uri, long appId, String cluster, String version) {
logger.info("Loading config from {}, appId={}, cluster={}, version={}", uri, appId, cluster, version);
String path = "/{appId}/{cluster}";
String path = "config/{appId}/{cluster}";
Object[] args = new String[] {String.valueOf(appId), cluster};
if (StringUtils.hasText(version)) {
args = new String[] {String.valueOf(appId), cluster, version};
......
......@@ -18,17 +18,6 @@
<artifactId>apollo-biz</artifactId>
</dependency>
<!-- end of apollo -->
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- end of web -->
<!-- redis -->
<dependency>
<groupId>org.springframework.data</groupId>
......@@ -45,17 +34,6 @@
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<!-- end of eureka -->
<!-- jsp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- end of jsp -->
</dependencies>
<build>
<plugins>
......
package com.ctrip.apollo.configserver.config;
import org.h2.server.web.WebServlet;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("welcome");
registry.addViewController("/index").setViewName("welcome");
}
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver
= new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("/");
}
@Bean
ServletRegistrationBean h2servletRegistration(){
ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
registrationBean.addUrlMappings("/console/*");
return registrationBean;
}
}
......@@ -16,6 +16,7 @@ import java.io.IOException;
* @author Jason Song(song_s@ctrip.com)
*/
@RestController
@RequestMapping("/config")
public class ConfigController {
@Resource(name = "configService")
private ConfigService configService;
......
package com.ctrip.apollo.configserver.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;
import com.ctrip.apollo.core.ServiceIdConsts;
@Service
public class DiscoveryService {
@Autowired
private DiscoveryClient discoveryClient;
public List<ServiceInstance> getConfigServerServiceInstances() {
List<ServiceInstance> instances =
discoveryClient.getInstances(ServiceIdConsts.APOLLO_CONFIGSERVER);
return instances;
}
public List<ServiceInstance> getMetaServerServiceInstances() {
List<ServiceInstance> instances =
discoveryClient.getInstances(ServiceIdConsts.APOLLO_METASERVER);
return instances;
}
}
<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Apollo Config Server</title>
<body>
<h2>Welcome to Apollo Config Server!</h2>
</body>
</html>
package com.ctrip.apollo.configserver.service;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import com.ctrip.apollo.configserver.AbstractConfigServerTest;
public class DiscoveryServiceTest extends AbstractConfigServerTest {
@Autowired
private DiscoveryService discoveryService;
@Test
public void testGetLocalMetaServerServices() {
List<ServiceInstance> instances = discoveryService.getMetaServerServiceInstances();
System.out.println(instances);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment