diff options
author | Vitaly Takmazov | 2016-02-01 22:17:33 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-02-01 22:17:33 +0300 |
commit | c8d875bfcf1b040881e9c18282905a1ff805eb0c (patch) | |
tree | f99b8b119090de4cca12110a30ac98481d01c6dc /src/main/java/com/juick/xmpp/s2s | |
parent | a725625b958eb13bea7ff2337dde519deff21845 (diff) |
refactoring
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s')
4 files changed, 9 insertions, 10 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java b/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java index 3fd514d0..c215e375 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java @@ -23,7 +23,7 @@ import java.util.logging.Logger; * * @author ugnich */ -public class ConnectionIn extends Connection implements Runnable { +public class ConnectionIn extends Connection { private static final Logger LOGGER = Logger.getLogger(ConnectionIn.class.getName()); @@ -37,8 +37,7 @@ public class ConnectionIn extends Connection implements Runnable { streamID = UUID.randomUUID().toString(); } - @Override - public void run() { + public void parseStream() { LOGGER.info("STREAM FROM ? " + streamID + " START"); try { parser.setInput(new InputStreamReader(Channels.newInputStream(socket))); @@ -90,7 +89,7 @@ public class ConnectionIn extends Connection implements Runnable { c.sendDialbackVerify(streamID, dbKey); } else { c = new ConnectionOut(dfrom, streamID, dbKey); - XMPPComponent.executorService.submit(c); + c.parseStream(); } } else { throw new Exception("STREAM FROM " + dfrom + " " + streamID + " DIALBACK RESULT FAIL"); diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java b/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java index de11f9a3..02a2be39 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java @@ -29,7 +29,7 @@ public class ConnectionListener implements Runnable { listener.accept(XMPPComponent.executorService, this); ConnectionIn client = new ConnectionIn(result); XMPPComponent.addConnectionIn(client); - XMPPComponent.executorService.submit(client); + client.parseStream(); } @Override diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java b/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java index c18ae342..c4334fed 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java @@ -18,7 +18,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author ugnich */ -public class ConnectionOut extends Connection implements Runnable { +public class ConnectionOut extends Connection { public boolean streamReady = false; public String to; @@ -37,8 +37,7 @@ public class ConnectionOut extends Connection implements Runnable { this.dbKey = dbKey; } - @Override - public void run() { + public void parseStream() { LOGGER.info("STREAM TO " + to + " START"); try { diff --git a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java index 9be8c744..50d2c1e4 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()); - public static final ExecutorService executorService = Executors.newCachedThreadPool(); + public static final ExecutorService executorService = Executors.newWorkStealingPool(); public static String HOSTNAME = null; public static String STATSFILE = null; @@ -143,7 +143,8 @@ public class XMPPComponent implements ServletContextListener { } if (!haveAnyConn) { - XMPPComponent.executorService.submit(new ConnectionOut(hostname)); + ConnectionOut connectionOut = new ConnectionOut(hostname); + connectionOut.parseStream(); } } |