|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package com.salesmanager.shop.spring.cloud.service.provider; |
| 18 | + |
| 19 | +import org.slf4j.Logger; |
| 20 | +import org.slf4j.LoggerFactory; |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; |
| 22 | +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
| 23 | +import org.springframework.boot.builder.SpringApplicationBuilder; |
| 24 | +import org.springframework.cloud.sleuth.Tracer; |
| 25 | +import org.springframework.cloud.sleuth.annotation.NewSpan; |
| 26 | +import org.springframework.context.annotation.Bean; |
| 27 | +import org.springframework.context.annotation.EnableAspectJAutoProxy; |
| 28 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 29 | +import org.springframework.web.bind.annotation.RestController; |
| 30 | + |
| 31 | +/** |
| 32 | + * TODO Comment |
| 33 | + * |
| 34 | + * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> |
| 35 | + * @since TODO |
| 36 | + */ |
| 37 | +@EnableAutoConfiguration |
| 38 | +@RestController |
| 39 | +@EnableAspectJAutoProxy(proxyTargetClass = true) |
| 40 | +public class ServiceProviderApplication { |
| 41 | + |
| 42 | + private static final Logger log = LoggerFactory.getLogger(ServiceProviderApplication.class); |
| 43 | + |
| 44 | + @Autowired |
| 45 | + private Tracer tracer; |
| 46 | + |
| 47 | + @Autowired |
| 48 | + private EchoService echoService; |
| 49 | + |
| 50 | + |
| 51 | + @RequestMapping("/") |
| 52 | + @NewSpan |
| 53 | + String home() { |
| 54 | + log.info("Hello,World"); |
| 55 | + return echoService.echo("Hello world!"); |
| 56 | + } |
| 57 | + |
| 58 | + @RequestMapping("/hello/world") |
| 59 | + String helloWorld() { |
| 60 | + log.info("Hello world 2021!"); |
| 61 | + return echoService.echo("Hello world 2021!"); |
| 62 | + } |
| 63 | + |
| 64 | +// @RequestMapping("/trace/id") |
| 65 | +// String traceId() { |
| 66 | +// log.info(tracer.toString()); |
| 67 | +// return tracer.toString(); |
| 68 | +// } |
| 69 | +// |
| 70 | +// @RequestMapping("/span/id") |
| 71 | +// String spanId() { |
| 72 | +// Span span = tracer.currentSpan(); |
| 73 | +// log.info(span.toString()); |
| 74 | +// return span.toString(); |
| 75 | +// } |
| 76 | + |
| 77 | + @Bean |
| 78 | + public EchoService echoService() { |
| 79 | + return new EchoService(); |
| 80 | + } |
| 81 | + |
| 82 | + public static void main(String[] args) { |
| 83 | + new SpringApplicationBuilder(ServiceProviderApplication.class) |
| 84 | + .run("--spring.config.additional-location=classpath:/META-INF/service-provider.yaml"); |
| 85 | + } |
| 86 | + |
| 87 | + |
| 88 | +} |
0 commit comments