aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-02-01 20:22:46 +0300
committerGravatar Vitaly Takmazov2016-02-01 20:22:46 +0300
commit6cdc01aee58cddbfccefbf5def429d14367f6205 (patch)
tree3905dec2f4e0730b757e2f639508af7275d93524 /src/main/java/com/juick/xmpp/s2s/XMPPComponent.java
parenteca85d4f4af0a3519acc8c82865127e7b558dbb5 (diff)
refactoring
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s/XMPPComponent.java')
-rw-r--r--src/main/java/com/juick/xmpp/s2s/XMPPComponent.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java
index 3720d963..9be8c744 100644
--- a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java
+++ b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java
@@ -24,7 +24,7 @@ public class XMPPComponent implements ServletContextListener {
private static final Logger LOGGER = Logger.getLogger(XMPPComponent.class.getName());
- ExecutorService executorService;
+ public static final ExecutorService executorService = Executors.newCachedThreadPool();
public static String HOSTNAME = null;
public static String STATSFILE = null;
@@ -143,7 +143,7 @@ public class XMPPComponent implements ServletContextListener {
}
if (!haveAnyConn) {
- new Thread(new ConnectionOut(hostname)).start();
+ XMPPComponent.executorService.submit(new ConnectionOut(hostname));
}
}
@@ -151,7 +151,6 @@ public class XMPPComponent implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
LOGGER.info("component initialized");
- executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
Properties conf = new Properties();
try {
@@ -167,9 +166,9 @@ public class XMPPComponent implements ServletContextListener {
childParsers.put(JuickMessage.XMLNS, new JuickMessage());
connRouter = new ConnectionRouter(componentName);
- new Thread(connRouter).start();
- new Thread(new ConnectionListener()).start();
- new Thread(new CleaningUp()).start();
+ executorService.submit(connRouter);
+ executorService.submit(new ConnectionListener());
+ executorService.submit(new CleaningUp());
} catch (IOException | ClassNotFoundException | SQLException e) {
LOGGER.log(Level.SEVERE, "XMPPComponent error", e);
}