Skip to content

Commit f9dca4e

Browse files
committed
将listener移动到各个rpc框架下
1 parent 1d49a44 commit f9dca4e

8 files changed

Lines changed: 42 additions & 21 deletions

File tree

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
</execution>
133133
</executions>
134134
</plugin>
135+
<!-- 手动打包时,将下面的plugin注释掉 -->
135136
<plugin>
136137
<groupId>org.apache.maven.plugins</groupId>
137138
<artifactId>maven-gpg-plugin</artifactId>

tx-client/src/main/java/com/codingapi/tx/listener/TransactionSocketListener.java renamed to transaction-dubbo/src/main/java/com/codingapi/tx/dubbo/listener/TransactionSocketListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codingapi.tx.listener;
1+
package com.codingapi.tx.dubbo.listener;
22

33
import com.codingapi.tx.listener.service.InitService;
44
import org.springframework.beans.BeansException;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.codingapi.tx.motan.listener;
2+
3+
import com.codingapi.tx.listener.service.InitService;
4+
import org.springframework.beans.BeansException;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.ApplicationContext;
7+
import org.springframework.context.ApplicationContextAware;
8+
import org.springframework.stereotype.Component;
9+
10+
/**
11+
* Created by lorne on 2017/7/1.
12+
*/
13+
@Component
14+
public class TransactionSocketListener implements ApplicationContextAware {
15+
16+
17+
@Autowired
18+
private InitService initService;
19+
20+
21+
@Override
22+
public void setApplicationContext(ApplicationContext event) throws BeansException {
23+
initService.start();
24+
}
25+
26+
}

transaction-springcloud/src/main/java/com/codingapi/tx/springcloud/listener/ServerListener.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.codingapi.tx.springcloud.listener;
22

3+
import com.codingapi.tx.listener.service.InitService;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.beans.factory.annotation.Autowired;
37
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
48
import org.springframework.context.ApplicationListener;
59
import org.springframework.stereotype.Component;
@@ -8,11 +12,19 @@
812
@Component
913
public class ServerListener implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
1014

15+
private Logger logger = LoggerFactory.getLogger(ServerListener.class);
16+
1117
private int serverPort;
1218

19+
@Autowired
20+
private InitService initService;
21+
1322
@Override
1423
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
24+
logger.info("onApplicationEvent -> onApplicationEvent. "+event.getEmbeddedServletContainer());
1525
this.serverPort = event.getEmbeddedServletContainer().getPort();
26+
27+
initService.start();
1628
}
1729

1830
public int getPort() {

tx-client/src/main/java/com/codingapi/tx/Constants.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,5 @@ public class Constants {
2121
*/
2222
public static int maxOutTime = 10000;
2323

24-
/**
25-
* 模块唯一标示
26-
*/
27-
public static String uniqueKey;
28-
2924

3025
}

tx-client/src/main/java/com/codingapi/tx/listener/service/impl/InitServiceImpl.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.codingapi.tx.listener.service.impl;
22

3-
import com.codingapi.tx.Constants;
43
import com.codingapi.tx.listener.service.InitService;
5-
import com.codingapi.tx.listener.service.ModelNameService;
64
import com.codingapi.tx.netty.service.NettyService;
75
import org.slf4j.Logger;
86
import org.slf4j.LoggerFactory;
@@ -20,20 +18,9 @@ public class InitServiceImpl implements InitService {
2018
@Autowired
2119
private NettyService nettyService;
2220

23-
24-
@Autowired
25-
private ModelNameService modelNameService;
26-
27-
2821
@Override
2922
public void start() {
3023

31-
/**
32-
* 设置模块唯一标示
33-
*/
34-
35-
Constants.uniqueKey = modelNameService.getUniqueKey();
36-
3724
nettyService.start();
3825
logger.info("socket-start..");
3926

tx-manager/src/main/java/com/codingapi/tm/manager/service/impl/MicroServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private boolean isIp(String ipAddress) {
6060
public List<InstanceInfo> getConfigServiceInstances() {
6161
Application application = eurekaClient.getApplication(tmKey);
6262
if (application == null) {
63-
logger.error("获取eureka服务失败!");
63+
logger.error("get eureka server error!");
6464
}
6565
return application != null ? application.getInstances() : new ArrayList<>();
6666
}

tx-manager/src/main/java/com/codingapi/tm/netty/handler/TxCoreServerHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public TxCoreServerHandler(NettyService nettyService) {
4848
@Override
4949
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
5050
final String json = SocketUtils.getJson(msg);
51-
logger.info("接受->"+json);
51+
logger.info("request->"+json);
5252
threadPool.execute(new Runnable() {
5353
@Override
5454
public void run() {

0 commit comments

Comments
 (0)