|
@@ -1,15 +1,42 @@
|
|
|
package com.gzlh.event;
|
|
|
|
|
|
import com.gzlh.dto.EventDTO;
|
|
|
+import com.gzlh.infrared.config.RedPropertiesConfig;
|
|
|
+import com.gzlh.infrared.factory.RedFactory;
|
|
|
+import com.gzlh.led.factory.LedFactory;
|
|
|
+import com.gzlh.led.properties.LedPropertiesConfig;
|
|
|
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
|
|
|
+import com.gzlh.weighbridge.factory.WeighbridgeFactory;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.LinkedBlockingQueue;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
public class EventBus {
|
|
|
private List<EventDTO> eventDTOList;
|
|
|
+ @Resource
|
|
|
+ private LedFactory ledFactory;
|
|
|
+ @Resource
|
|
|
+ private RedFactory redFactory;
|
|
|
+ @Resource
|
|
|
+ WeighbridgeFactory weighbridgeFactory;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private WeighbridgePropertiesConfig weighbridgePropertiesConfig;
|
|
|
+ @Resource
|
|
|
+ private RedPropertiesConfig redPropertiesConfig;
|
|
|
+ @Resource
|
|
|
+ private LedPropertiesConfig ledPropertiesConfig;
|
|
|
+
|
|
|
+ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 20,
|
|
|
+ 10L, TimeUnit.SECONDS,
|
|
|
+ new LinkedBlockingQueue(100));
|
|
|
|
|
|
public void setEventDTOList(List<EventDTO> eventDTOList) {
|
|
|
this.eventDTOList = eventDTOList;
|
|
@@ -18,6 +45,6 @@ public class EventBus {
|
|
|
public void start(String eventName){
|
|
|
EventThread thread = new EventThread(eventName);
|
|
|
thread.setEventDTOList(eventDTOList);
|
|
|
- thread.start();
|
|
|
+ threadPoolExecutor.execute(thread);
|
|
|
}
|
|
|
}
|