|
29 | 29 | import com.qq.tars.server.core.ServantHomeSkeleton; |
30 | 30 | import com.qq.tars.spring.annotation.TarsListener; |
31 | 31 | import com.qq.tars.spring.annotation.TarsServant; |
| 32 | +import org.slf4j.Logger; |
| 33 | +import org.slf4j.LoggerFactory; |
32 | 34 | import org.springframework.aop.framework.Advised; |
33 | 35 | import org.springframework.context.ApplicationContext; |
34 | 36 | import org.springframework.core.annotation.AnnotationUtils; |
35 | 37 |
|
36 | 38 | import java.util.Map; |
37 | 39 |
|
38 | 40 | public class SpringBootAppContext extends BaseAppContext { |
| 41 | + |
| 42 | + private static final Logger logger = LoggerFactory.getLogger(SpringBootAppContext.class); |
| 43 | + |
39 | 44 | private ApplicationContext applicationContext; |
40 | 45 |
|
41 | 46 | public SpringBootAppContext(ApplicationContext applicationContext) { |
@@ -71,11 +76,13 @@ private void loadAppServants() { |
71 | 76 | for (Map.Entry<String, Object> entry : servantMap.entrySet()) { |
72 | 77 | try { |
73 | 78 | ServantHomeSkeleton skeleton = loadServant(entry.getValue()); |
| 79 | + if(skeleton == null) { |
| 80 | + continue; |
| 81 | + } |
74 | 82 | skeletonMap.put(skeleton.name(), skeleton); |
75 | 83 | appServantStarted(skeleton); |
76 | 84 | } catch (Throwable e) { |
77 | | - System.err.println("init a Servant failed"); |
78 | | - e.printStackTrace(); |
| 85 | + logger.error("init a Servant failed exMsg:{}", e.getMessage(), e); |
79 | 86 | } |
80 | 87 | } |
81 | 88 |
|
@@ -123,12 +130,16 @@ private ServantHomeSkeleton loadServant(Object bean) throws Throwable { |
123 | 130 | } |
124 | 131 |
|
125 | 132 | ServantAdapterConfig servantAdapterConfig = serverCfg.getServantAdapterConfMap().get(homeName); |
| 133 | + if(servantAdapterConfig == null) { |
| 134 | + logger.warn("servant:{} 's servantAdapterConfig is null, not start this servant. If u need this servant, please config in tarsAdmin.",homeName); |
| 135 | + return null; |
| 136 | + } |
126 | 137 |
|
127 | | - ServantAdapter ServerAdapter = new ServantAdapter(servantAdapterConfig); |
| 138 | + ServantAdapter servantAdapter = new ServantAdapter(servantAdapterConfig); |
128 | 139 | skeleton = new ServantHomeSkeleton(homeName, homeClassImpl, homeApiClazz, maxLoadLimit); |
129 | 140 | skeleton.setAppContext(this); |
130 | | - ServerAdapter.bind(skeleton); |
131 | | - servantAdapterMap.put(homeName, ServerAdapter); |
| 141 | + servantAdapter.bind(skeleton); |
| 142 | + servantAdapterMap.put(homeName, servantAdapter); |
132 | 143 | return skeleton; |
133 | 144 | } |
134 | 145 | } |
0 commit comments