aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-31 01:35:18 +0300
committerGravatar Vitaly Takmazov2016-07-31 01:35:18 +0300
commit27bb19646fe4046628e9a21e63a425c1f7a8f15f (patch)
tree8126844c7538d9d12db31813aaffa18ec6bcb14a
parent596d1dd390a30d8a88b3d37ac24ce69c964d074a (diff)
move components to api module
-rw-r--r--juick-api/build.gradle3
-rw-r--r--juick-api/src/main/java/com/juick/components/CrosspostComponent.java (renamed from juick-www/src/main/java/com/juick/www/CrosspostComponent.java)2
-rw-r--r--juick-api/src/main/java/com/juick/components/PushComponent.java (renamed from juick-www/src/main/java/com/juick/www/PushComponent.java)4
-rw-r--r--juick-api/src/main/java/com/juick/components/XMPPComponent.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java)125
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/CacheEntry.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/CacheEntry.java)0
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/CleaningUp.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/CleaningUp.java)20
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/Connection.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java)3
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java)7
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java)1
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/DNSQueries.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/DNSQueries.java)0
-rw-r--r--juick-api/src/main/java/com/juick/xmpp/s2s/JuickBot.java (renamed from juick-www/src/main/java/com/juick/xmpp/s2s/JuickBot.java)51
-rw-r--r--juick-api/src/main/webapp/WEB-INF/web.xml15
-rw-r--r--juick-www/build.gradle3
-rw-r--r--juick-www/src/main/webapp/WEB-INF/web.xml15
14 files changed, 140 insertions, 109 deletions
diff --git a/juick-api/build.gradle b/juick-api/build.gradle
index c4d5f074..046a8401 100644
--- a/juick-api/build.gradle
+++ b/juick-api/build.gradle
@@ -19,6 +19,9 @@ repositories {
dependencies {
compile project(':juick-core')
compile project(':deps:com.juick.xmpp')
+ compile 'org.slf4j:slf4j-jdk14:1.7.21'
+ compile 'com.ganyo:gcm-server:1.0.+'
+ compile 'com.notnoop.apns:apns:1.0.0.Beta6'
compile "org.apache.commons:commons-lang3:3.4"
compile "org.springframework:spring-jdbc:4.3.2.RELEASE"
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
diff --git a/juick-www/src/main/java/com/juick/www/CrosspostComponent.java b/juick-api/src/main/java/com/juick/components/CrosspostComponent.java
index e2ddbfa5..b0e55719 100644
--- a/juick-www/src/main/java/com/juick/www/CrosspostComponent.java
+++ b/juick-api/src/main/java/com/juick/components/CrosspostComponent.java
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.juick.www;
+package com.juick.components;
import com.juick.server.CrosspostQueries;
import com.juick.xmpp.JID;
diff --git a/juick-www/src/main/java/com/juick/www/PushComponent.java b/juick-api/src/main/java/com/juick/components/PushComponent.java
index 65fbcef0..baac2532 100644
--- a/juick-www/src/main/java/com/juick/www/PushComponent.java
+++ b/juick-api/src/main/java/com/juick/components/PushComponent.java
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.juick.www;
+package com.juick.components;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.MulticastResult;
@@ -83,7 +83,7 @@ public class PushComponent implements ServletContextListener, Stream.StreamListe
public void contextInitialized(final ServletContextEvent sce) {
logger.info("component initialized");
executorService = Executors.newSingleThreadExecutor();
- executorService.submit((Runnable) () -> {
+ executorService.submit(() -> {
Properties conf = new Properties();
try {
conf.load(sce.getServletContext().getResourceAsStream("/WEB-INF/juick.conf"));
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/juick-api/src/main/java/com/juick/components/XMPPComponent.java
index 57072cee..7b31ac59 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java
+++ b/juick-api/src/main/java/com/juick/components/XMPPComponent.java
@@ -1,4 +1,4 @@
-package com.juick.xmpp.s2s;
+package com.juick.components;
import com.juick.User;
import com.juick.server.MessagesQueries;
@@ -8,10 +8,9 @@ import com.juick.xmpp.*;
import com.juick.xmpp.extensions.JuickMessage;
import com.juick.xmpp.extensions.Nickname;
import com.juick.xmpp.extensions.XOOB;
+import com.juick.xmpp.s2s.*;
import org.apache.commons.dbcp2.BasicDataSource;
-import org.apache.commons.dbcp2.PoolingDataSource;
import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.xmlpull.v1.XmlPullParserException;
import javax.servlet.ServletContextEvent;
@@ -40,7 +39,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
private static final Logger logger = Logger.getLogger(XMPPComponent.class.getName());
public final ExecutorService executorService = Executors.newCachedThreadPool();
- StreamComponent router;
+ private StreamComponent router;
JuickBot bot;
public String HOSTNAME, componentName;
@@ -49,40 +48,40 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
public String keystorePassword;
public List<String> brokenSSLhosts;
public List<String> bannedHosts;
- final List<ConnectionIn> inConnections = Collections.synchronizedList(new ArrayList<>());
- final List<ConnectionOut> outConnections = Collections.synchronizedList(new ArrayList<>());
- final List<CacheEntry> outCache = Collections.synchronizedList(new ArrayList<>());
- JdbcTemplate sql;
+ private final List<ConnectionIn> inConnections = Collections.synchronizedList(new ArrayList<>());
+ private final List<ConnectionOut> outConnections = Collections.synchronizedList(new ArrayList<>());
+ private final List<CacheEntry> outCache = Collections.synchronizedList(new ArrayList<>());
+ private JdbcTemplate sql;
final public HashMap<String, StanzaChild> childParsers = new HashMap<>();
public void addConnectionIn(ConnectionIn c) {
- synchronized (inConnections) {
- inConnections.add(c);
+ synchronized (getInConnections()) {
+ getInConnections().add(c);
}
}
public void addConnectionOut(ConnectionOut c) {
- synchronized (outConnections) {
- outConnections.add(c);
+ synchronized (getOutConnections()) {
+ getOutConnections().add(c);
}
}
public void removeConnectionIn(ConnectionIn c) {
- synchronized (inConnections) {
- inConnections.remove(c);
+ synchronized (getInConnections()) {
+ getInConnections().remove(c);
}
}
public void removeConnectionOut(ConnectionOut c) {
- synchronized (outConnections) {
- outConnections.remove(c);
+ synchronized (getOutConnections()) {
+ getOutConnections().remove(c);
}
}
public String getFromCache(String hostname) {
CacheEntry ret = null;
- synchronized (outCache) {
- for (Iterator<CacheEntry> i = outCache.iterator(); i.hasNext();) {
+ synchronized (getOutCache()) {
+ for (Iterator<CacheEntry> i = getOutCache().iterator(); i.hasNext();) {
CacheEntry c = i.next();
if (c.hostname != null && c.hostname.equals(hostname)) {
ret = c;
@@ -95,8 +94,8 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
}
public ConnectionOut getConnectionOut(String hostname, boolean needReady) {
- synchronized (outConnections) {
- for (ConnectionOut c : outConnections) {
+ synchronized (getOutConnections()) {
+ for (ConnectionOut c : getOutConnections()) {
if (c.to != null && c.to.equals(hostname) && (!needReady || c.streamReady)) {
return c;
}
@@ -106,8 +105,8 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
}
public ConnectionIn getConnectionIn(String streamID) {
- synchronized (inConnections) {
- for (ConnectionIn c : inConnections) {
+ synchronized (getInConnections()) {
+ for (ConnectionIn c : getInConnections()) {
if (c.streamID != null && c.streamID.equals(streamID)) {
return c;
}
@@ -124,8 +123,8 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
boolean haveAnyConn = false;
ConnectionOut connOut = null;
- synchronized (outConnections) {
- for (ConnectionOut c : outConnections) {
+ synchronized (getOutConnections()) {
+ for (ConnectionOut c : getOutConnections()) {
if (c.to != null && c.to.equals(hostname)) {
if (c.streamReady) {
connOut = c;
@@ -147,8 +146,8 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
}
boolean haveCache = false;
- synchronized (outCache) {
- for (CacheEntry c : outCache) {
+ synchronized (getOutCache()) {
+ for (CacheEntry c : getOutCache()) {
if (c.hostname != null && c.hostname.equals(hostname)) {
c.xml += xml;
c.tsUpdated = System.currentTimeMillis();
@@ -157,7 +156,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
}
}
if (!haveCache) {
- outCache.add(new CacheEntry(hostname, xml));
+ getOutCache().add(new CacheEntry(hostname, xml));
}
}
@@ -189,7 +188,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver"));
dataSource.setUrl(conf.getProperty("datasource_url"));
- sql = new JdbcTemplate(dataSource);
+ setSql(new JdbcTemplate(dataSource));
bot = new JuickBot(this, Jid);
childParsers.put(JuickMessage.XMLNS, new JuickMessage());
@@ -198,12 +197,12 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
Socket routerSocket = null;
try {
routerSocket = new Socket("localhost", 5347);
- router = new StreamComponent(new JID("s2s"), routerSocket.getInputStream(), routerSocket.getOutputStream(), conf.getProperty("xmpp_password"));
- router.addChildParser(new JuickMessage());
- router.addListener((Stream.StreamListener) this);
- router.addListener((Message.MessageListener) this);
- router.addListener((Iq.IqListener) this);
- router.startParsing();
+ setRouter(new StreamComponent(new JID("s2s"), routerSocket.getInputStream(), routerSocket.getOutputStream(), conf.getProperty("xmpp_password")));
+ getRouter().addChildParser(new JuickMessage());
+ getRouter().addListener((Stream.StreamListener) this);
+ getRouter().addListener((Message.MessageListener) this);
+ getRouter().addListener((Iq.IqListener) this);
+ getRouter().startParsing();
} catch (IOException e) {
logger.log(Level.SEVERE, "router error", e);
}
@@ -233,16 +232,16 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
@Override
public void contextDestroyed(ServletContextEvent sce) {
- synchronized (outConnections) {
- for (Iterator<ConnectionOut> i = outConnections.iterator(); i.hasNext();) {
+ synchronized (getOutConnections()) {
+ for (Iterator<ConnectionOut> i = getOutConnections().iterator(); i.hasNext();) {
ConnectionOut c = i.next();
c.closeConnection();
i.remove();
}
}
- synchronized (inConnections) {
- for (Iterator<ConnectionIn> i = inConnections.iterator(); i.hasNext();) {
+ synchronized (getInConnections()) {
+ for (Iterator<ConnectionIn> i = getInConnections().iterator(); i.hasNext();) {
ConnectionIn c = i.next();
c.closeConnection();
i.remove();
@@ -258,18 +257,18 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
logger.info("component destroyed");
}
public void closeRouterConnection() throws IOException {
- router.logoff();
+ getRouter().logoff();
}
public void sendJuickMessage(JuickMessage jmsg) {
List<String> jids = new ArrayList<>();
if (jmsg.FriendsOnly) {
- jids = SubscriptionsQueries.getJIDSubscribedToUser(sql, jmsg.getUser().getUID(), jmsg.FriendsOnly);
+ jids = SubscriptionsQueries.getJIDSubscribedToUser(getSql(), jmsg.getUser().getUID(), jmsg.FriendsOnly);
} else {
- List<User> users = SubscriptionsQueries.getSubscribedUsers(sql, jmsg.getUser().getUID(), jmsg.getMID());
+ List<User> users = SubscriptionsQueries.getSubscribedUsers(getSql(), jmsg.getUser().getUID(), jmsg.getMID());
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(sql, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(getSql(), user.getUID())) {
jids.add(jid);
}
}
@@ -310,9 +309,9 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
String replyQuote;
String replyTo;
- users = SubscriptionsQueries.getUsersSubscribedToComments(sql, jmsg.getMID(), jmsg.getUser().getUID());
- com.juick.Message replyMessage = jmsg.ReplyTo > 0 ? MessagesQueries.getReply(sql, jmsg.getMID(), jmsg.ReplyTo)
- : MessagesQueries.getMessage(sql, jmsg.getMID());
+ users = SubscriptionsQueries.getUsersSubscribedToComments(getSql(), jmsg.getMID(), jmsg.getUser().getUID());
+ com.juick.Message replyMessage = jmsg.ReplyTo > 0 ? MessagesQueries.getReply(getSql(), jmsg.getMID(), jmsg.ReplyTo)
+ : MessagesQueries.getMessage(getSql(), jmsg.getMID());
replyTo = replyMessage.getUser().getUName();
replyQuote = getReplyQuote(replyMessage);
@@ -329,7 +328,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
msg.type = Message.Type.chat;
msg.addChild(jmsg);
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(sql, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(getSql(), user.getUID())) {
msg.to = new JID(jid);
sendOut(msg);
}
@@ -349,8 +348,8 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
public void sendJuickRecommendation(JuickMessage recomm) {
List<User> users;
JuickMessage jmsg;
- jmsg = new JuickMessage(MessagesQueries.getMessage(sql, recomm.getMID()));
- users = SubscriptionsQueries.getUsersSubscribedToUserRecommendations(sql,
+ jmsg = new JuickMessage(MessagesQueries.getMessage(getSql(), recomm.getMID()));
+ users = SubscriptionsQueries.getUsersSubscribedToUserRecommendations(getSql(),
recomm.getUser().getUID(), recomm.getMID(), jmsg.getUser().getUID());
String txt = "Recommended by @" + recomm.getUser().getUName() + ":\n";
@@ -387,7 +386,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
}
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(sql, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(getSql(), user.getUID())) {
msg.to = new JID(jid);
sendOut(msg);
}
@@ -444,4 +443,32 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe
public void onStreamFail(Exception ex) {
logger.log(Level.SEVERE, "STREAM ROUTER (FAIL)", ex);
}
+
+ public StreamComponent getRouter() {
+ return router;
+ }
+
+ public void setRouter(StreamComponent router) {
+ this.router = router;
+ }
+
+ public List<ConnectionIn> getInConnections() {
+ return inConnections;
+ }
+
+ public List<ConnectionOut> getOutConnections() {
+ return outConnections;
+ }
+
+ public List<CacheEntry> getOutCache() {
+ return outCache;
+ }
+
+ public JdbcTemplate getSql() {
+ return sql;
+ }
+
+ public void setSql(JdbcTemplate sql) {
+ this.sql = sql;
+ }
}
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/CacheEntry.java b/juick-api/src/main/java/com/juick/xmpp/s2s/CacheEntry.java
index 7cdb18ab..7cdb18ab 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/CacheEntry.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/CacheEntry.java
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/CleaningUp.java b/juick-api/src/main/java/com/juick/xmpp/s2s/CleaningUp.java
index 14d97ed8..812a88ba 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/CleaningUp.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/CleaningUp.java
@@ -1,5 +1,7 @@
package com.juick.xmpp.s2s;
+import com.juick.components.XMPPComponent;
+
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
@@ -22,12 +24,12 @@ public class CleaningUp implements Runnable {
try {
PrintWriter statsFile = new PrintWriter(xmpp.STATSFILE, "UTF-8");
statsFile.write("<html><body><h2>Threads: " + Thread.activeCount() + "</h2>");
- statsFile.write("<h2>Out (" + xmpp.outConnections.size() + ")</h2><table border=1><tr><th>to</th><th>sid</th><th>inactive</th><th>out packets</th><th>out bytes</th></tr>");
+ statsFile.write("<h2>Out (" + xmpp.getOutConnections().size() + ")</h2><table border=1><tr><th>to</th><th>sid</th><th>inactive</th><th>out packets</th><th>out bytes</th></tr>");
long now = System.currentTimeMillis();
- synchronized (xmpp.outConnections) {
- for (Iterator<ConnectionOut> i = xmpp.outConnections.iterator(); i.hasNext();) {
+ synchronized (xmpp.getOutConnections()) {
+ for (Iterator<ConnectionOut> i = xmpp.getOutConnections().iterator(); i.hasNext();) {
ConnectionOut c = i.next();
int inactive = (int) ((double) (now - c.tsLocalData) / 1000.0);
if (inactive > 900) {
@@ -45,10 +47,10 @@ public class CleaningUp implements Runnable {
}
}
- statsFile.write("</table><h2>In (" + xmpp.inConnections.size() + ")</h2><table border=1><tr><th>from</th><th>sid</th><th>inactive</th><th>in packets</th></tr>");
+ statsFile.write("</table><h2>In (" + xmpp.getInConnections().size() + ")</h2><table border=1><tr><th>from</th><th>sid</th><th>inactive</th><th>in packets</th></tr>");
- synchronized (xmpp.inConnections) {
- for (Iterator<ConnectionIn> i = xmpp.inConnections.iterator(); i.hasNext();) {
+ synchronized (xmpp.getInConnections()) {
+ for (Iterator<ConnectionIn> i = xmpp.getInConnections().iterator(); i.hasNext();) {
ConnectionIn c = i.next();
int inactive = (int) ((double) (now - c.tsRemoteData) / 1000.0);
if (inactive > 900) {
@@ -78,10 +80,10 @@ public class CleaningUp implements Runnable {
}
}
- statsFile.write("</table><h2>Cache (" + xmpp.outCache.size() + ")</h2><table border=1><tr><th>host</th><th>live</th><th>size</th></tr>");
+ statsFile.write("</table><h2>Cache (" + xmpp.getOutCache().size() + ")</h2><table border=1><tr><th>host</th><th>live</th><th>size</th></tr>");
- synchronized (xmpp.outCache) {
- for (Iterator<CacheEntry> i = xmpp.outCache.iterator(); i.hasNext();) {
+ synchronized (xmpp.getOutCache()) {
+ for (Iterator<CacheEntry> i = xmpp.getOutCache().iterator(); i.hasNext();) {
CacheEntry c = i.next();
int inactive = (int) ((double) (now - c.tsCreated) / 1000.0);
if (inactive > 600) {
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java b/juick-api/src/main/java/com/juick/xmpp/s2s/Connection.java
index b7837b06..fe82b878 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/Connection.java
@@ -1,5 +1,6 @@
package com.juick.xmpp.s2s;
+import com.juick.components.XMPPComponent;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -94,7 +95,7 @@ public class Connection {
packetsLocal++;
}
- void closeConnection() {
+ public void closeConnection() {
if (streamID != null) {
logger.info(String.format("CLOSING STREAM %s", streamID));
}
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java b/juick-api/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java
index 3b3c0316..d8b90f13 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java
@@ -1,5 +1,6 @@
package com.juick.xmpp.s2s;
+import com.juick.components.XMPPComponent;
import com.juick.xmpp.Iq;
import com.juick.xmpp.JID;
import com.juick.xmpp.Message;
@@ -11,8 +12,6 @@ import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSocket;
import java.io.EOFException;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
@@ -123,7 +122,7 @@ public class ConnectionIn extends Connection implements Runnable {
if (msg != null && (msg.type == null || !msg.type.equals(Message.Type.error))) {
LOGGER.info("STREAM " + streamID + ": " + msg.toString());
if (!bot.incomingMessage(msg)) {
- xmpp.router.send(msg.toString());
+ xmpp.getRouter().send(msg.toString());
}
}
} else if (tag.equals("iq") && checkFromTo(parser)) {
@@ -132,7 +131,7 @@ public class ConnectionIn extends Connection implements Runnable {
String xml = XmlUtils.parseToString(parser, true);
if (type == null || !type.equals(Iq.Type.error)) {
LOGGER.info("STREAM " + streamID + ": " + xml);
- xmpp.router.send(xml);
+ xmpp.getRouter().send(xml);
}
} else if (!isSecured() && tag.equals("starttls")) {
LOGGER.info("STREAM " + streamID + " SECURING");
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java b/juick-api/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
index 24ed3363..a5e7705b 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
@@ -1,5 +1,6 @@
package com.juick.xmpp.s2s;
+import com.juick.components.XMPPComponent;
import com.juick.xmpp.extensions.StreamFeatures;
import com.juick.xmpp.utils.XmlUtils;
import org.xmlpull.v1.XmlPullParser;
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/DNSQueries.java b/juick-api/src/main/java/com/juick/xmpp/s2s/DNSQueries.java
index e4c5f085..e4c5f085 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/DNSQueries.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/DNSQueries.java
diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/JuickBot.java b/juick-api/src/main/java/com/juick/xmpp/s2s/JuickBot.java
index f0b71689..ca7e6a34 100644
--- a/juick-www/src/main/java/com/juick/xmpp/s2s/JuickBot.java
+++ b/juick-api/src/main/java/com/juick/xmpp/s2s/JuickBot.java
@@ -1,6 +1,7 @@
package com.juick.xmpp.s2s;
import com.juick.User;
+import com.juick.components.XMPPComponent;
import com.juick.server.PMQueries;
import com.juick.server.TagQueries;
import com.juick.server.UserQueries;
@@ -74,7 +75,7 @@ public class JuickBot {
} else if (p.type.equals(Presence.Type.probe)) {
int uid_to = 0;
if (!toJuick) {
- uid_to = UserQueries.getUIDbyName(xmpp.sql, username);
+ uid_to = UserQueries.getUIDbyName(xmpp.getSql(), username);
}
if (toJuick || uid_to > 0) {
@@ -97,9 +98,9 @@ public class JuickBot {
if (toJuick) {
canSubscribe = true;
} else {
- int uid_to = UserQueries.getUIDbyName(xmpp.sql, username);
+ int uid_to = UserQueries.getUIDbyName(xmpp.getSql(), username);
if (uid_to > 0) {
- PMQueries.addPMinRoster(xmpp.sql, uid_to, p.from.Bare());
+ PMQueries.addPMinRoster(xmpp.getSql(), uid_to, p.from.Bare());
canSubscribe = true;
}
}
@@ -123,9 +124,9 @@ public class JuickBot {
}
} else if (p.type.equals(Presence.Type.unsubscribe)) {
if (!toJuick) {
- int uid_to = UserQueries.getUIDbyName(xmpp.sql, username);
+ int uid_to = UserQueries.getUIDbyName(xmpp.getSql(), username);
if (uid_to > 0) {
- PMQueries.removePMinRoster(xmpp.sql, uid_to, p.from.Bare());
+ PMQueries.removePMinRoster(xmpp.getSql(), uid_to, p.from.Bare());
}
}
@@ -145,9 +146,9 @@ public class JuickBot {
User user_from = null;
String signuphash = "";
- user_from = UserQueries.getUserByJID(xmpp.sql, msg.from.Bare());
+ user_from = UserQueries.getUserByJID(xmpp.getSql(), msg.from.Bare());
if (user_from == null) {
- signuphash = UserQueries.getSignUpHashByJID(xmpp.sql, msg.from.Bare());
+ signuphash = UserQueries.getSignUpHashByJID(xmpp.getSql(), msg.from.Bare());
}
if (user_from == null) {
@@ -165,7 +166,7 @@ public class JuickBot {
return incomingMessageJuick(user_from, msg);
}
- int uid_to = UserQueries.getUIDbyName(xmpp.sql, username);
+ int uid_to = UserQueries.getUIDbyName(xmpp.getSql(), username);
if (uid_to == 0) {
Message reply = new Message(msg.to, msg.from, Message.Type.error);
@@ -176,8 +177,8 @@ public class JuickBot {
}
boolean success = false;
- if (!UserQueries.isInBLAny(xmpp.sql, uid_to, user_from.getUID())) {
- success = PMQueries.createPM(xmpp.sql, user_from.getUID(), uid_to, msg.body);
+ if (!UserQueries.isInBLAny(xmpp.getSql(), uid_to, user_from.getUID())) {
+ success = PMQueries.createPM(xmpp.getSql(), user_from.getUID(), uid_to, msg.body);
}
if (success) {
@@ -188,19 +189,19 @@ public class JuickBot {
jmsg.setUser(user_from);
jmsg.setText(msg.body);
m.childs.add(jmsg);
- xmpp.router.send(m.toString());
+ xmpp.getRouter().send(m.toString());
m.to.Host = "ws.juick.com";
- xmpp.router.send(m.toString());
+ xmpp.getRouter().send(m.toString());
List<String> jids;
boolean inroster = false;
- jids = UserQueries.getJIDsbyUID(xmpp.sql, uid_to);
+ jids = UserQueries.getJIDsbyUID(xmpp.getSql(), uid_to);
for (String jid : jids) {
Message mm = new Message();
mm.to = new JID(jid);
mm.type = Message.Type.chat;
- inroster = PMQueries.havePMinRoster(xmpp.sql, user_from.getUID(), jid);
+ inroster = PMQueries.havePMinRoster(xmpp.getSql(), user_from.getUID(), jid);
if (inroster) {
mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick");
mm.body = msg.body;
@@ -276,7 +277,7 @@ public class JuickBot {
private void commandLogin(Message m, User user_from) throws Exception {
Message reply = new Message(JuickJID, m.from, Message.Type.chat);
- reply.body = "http://juick.com/login?" + UserQueries.getHashByUID(xmpp.sql, user_from.getUID());
+ reply.body = "http://juick.com/login?" + UserQueries.getHashByUID(xmpp.getSql(), user_from.getUID());
xmpp.sendOut(reply);
}
@@ -288,15 +289,15 @@ public class JuickBot {
boolean haveInRoster = false;
if (user_to.indexOf('@') > 0) {
- uid_to = UserQueries.getUIDbyJID(xmpp.sql, user_to);
+ uid_to = UserQueries.getUIDbyJID(xmpp.getSql(), user_to);
} else {
- uid_to = UserQueries.getUIDbyName(xmpp.sql, user_to);
+ uid_to = UserQueries.getUIDbyName(xmpp.getSql(), user_to);
}
if (uid_to > 0) {
- if (!UserQueries.isInBLAny(xmpp.sql, uid_to, user_from.getUID())) {
- if (PMQueries.createPM(xmpp.sql, user_from.getUID(), uid_to, body)) {
- jids_to = UserQueries.getJIDsbyUID(xmpp.sql, uid_to);
+ if (!UserQueries.isInBLAny(xmpp.getSql(), uid_to, user_from.getUID())) {
+ if (PMQueries.createPM(xmpp.getSql(), user_from.getUID(), uid_to, body)) {
+ jids_to = UserQueries.getJIDsbyUID(xmpp.getSql(), uid_to);
ret = 200;
} else {
ret = 500;
@@ -316,16 +317,16 @@ public class JuickBot {
jmsg.setUser(user_from);
jmsg.setText(body);
msg.childs.add(jmsg);
- xmpp.router.send(msg.toString());
+ xmpp.getRouter().send(msg.toString());
msg.to.Host = "ws.juick.com";
- xmpp.router.send(msg.toString());
+ xmpp.getRouter().send(msg.toString());
for (String jid : jids_to) {
Message mm = new Message();
mm.to = new JID(jid);
mm.type = Message.Type.chat;
- haveInRoster = PMQueries.havePMinRoster(xmpp.sql, user_from.getUID(), jid);
+ haveInRoster = PMQueries.havePMinRoster(xmpp.getSql(), user_from.getUID(), jid);
if (haveInRoster) {
mm.from = new JID(user_from.getUName(), "juick.com", "Juick");
mm.body = body;
@@ -349,8 +350,8 @@ public class JuickBot {
}
private void commandBLShow(Message m, User user_from) throws Exception {
- List<User> blusers = UserQueries.getUserBLUsers(xmpp.sql, user_from.getUID());
- List<String> bltags = TagQueries.getUserBLTags(xmpp.sql, user_from.getUID());
+ List<User> blusers = UserQueries.getUserBLUsers(xmpp.getSql(), user_from.getUID());
+ List<String> bltags = TagQueries.getUserBLTags(xmpp.getSql(), user_from.getUID());
String txt = "";
if (bltags.size() > 0) {
diff --git a/juick-api/src/main/webapp/WEB-INF/web.xml b/juick-api/src/main/webapp/WEB-INF/web.xml
index 533a6882..c79efd29 100644
--- a/juick-api/src/main/webapp/WEB-INF/web.xml
+++ b/juick-api/src/main/webapp/WEB-INF/web.xml
@@ -13,4 +13,19 @@
30
</session-timeout>
</session-config>
+ <listener>
+ <description>APNS/GCM/MPNS module</description>
+ <display-name>PushComponent</display-name>
+ <listener-class>com.juick.components.PushComponent</listener-class>
+ </listener>
+ <listener>
+ <description>Crossposting module</description>
+ <display-name>CrosspostComponent</display-name>
+ <listener-class>com.juick.components.CrosspostComponent</listener-class>
+ </listener>
+ <listener>
+ <description>XMPP module</description>
+ <display-name>XMPPComponent</display-name>
+ <listener-class>com.juick.components.XMPPComponent</listener-class>
+ </listener>
</web-app>
diff --git a/juick-www/build.gradle b/juick-www/build.gradle
index 85532c92..f609cc90 100644
--- a/juick-www/build.gradle
+++ b/juick-www/build.gradle
@@ -28,9 +28,6 @@ repositories {
dependencies {
compile project(':juick-core')
compile project(':deps:com.juick.xmpp')
- compile 'org.slf4j:slf4j-jdk14:1.7.21'
- compile 'com.ganyo:gcm-server:1.0.+'
- compile 'com.notnoop.apns:apns:1.0.0.Beta6'
compile 'com.github.scribejava:scribejava-apis:2.7.3'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'org.apache.commons:commons-lang3:3.4'
diff --git a/juick-www/src/main/webapp/WEB-INF/web.xml b/juick-www/src/main/webapp/WEB-INF/web.xml
index fe07d696..ed9e8e62 100644
--- a/juick-www/src/main/webapp/WEB-INF/web.xml
+++ b/juick-www/src/main/webapp/WEB-INF/web.xml
@@ -40,19 +40,4 @@
30
</session-timeout>
</session-config>
- <listener>
- <description>APNS/GCM/MPNS module</description>
- <display-name>PushComponent</display-name>
- <listener-class>com.juick.www.PushComponent</listener-class>
- </listener>
- <listener>
- <description>Crossposting module</description>
- <display-name>CrosspostComponent</display-name>
- <listener-class>com.juick.www.CrosspostComponent</listener-class>
- </listener>
- <listener>
- <description>XMPP module</description>
- <display-name>XMPPComponent</display-name>
- <listener-class>com.juick.xmpp.s2s.XMPPComponent</listener-class>
- </listener>
</web-app>