Commit eab6196e authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Refactoring changes


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@596 b35dd754-fafc-0310-a699-88a17e54d16e
parent fe5c6144
...@@ -13,11 +13,11 @@ package org.jivesoftware.messenger; ...@@ -13,11 +13,11 @@ package org.jivesoftware.messenger;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.dom4j.io.XMLWriter;
import org.xmlpull.v1.XmlPullParserException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
/** /**
* <p>Represents a connection on the server.</p> * <p>Represents a connection on the server.</p>
...@@ -62,7 +62,7 @@ public interface Connection { ...@@ -62,7 +62,7 @@ public interface Connection {
* @return The XmlSerializer underlying this connection * @return The XmlSerializer underlying this connection
* @throws UnauthorizedException If caller doesn't have permission to access this resource * @throws UnauthorizedException If caller doesn't have permission to access this resource
*/ */
XMLStreamWriter getSerializer() throws UnauthorizedException; XMLWriter getSerializer() throws UnauthorizedException;
/** /**
* Close this session including associated socket connection. * Close this session including associated socket connection.
...@@ -128,7 +128,7 @@ public interface Connection { ...@@ -128,7 +128,7 @@ public interface Connection {
* *
* @param packet The packet to deliver. * @param packet The packet to deliver.
* @throws UnauthorizedException If caller doesn't have permission to access this resource * @throws UnauthorizedException If caller doesn't have permission to access this resource
* @throws XMLStreamException if there was a problem sending the packet * @throws org.xmlpull.v1.XmlPullParserException if there was a problem sending the packet
*/ */
void deliver(Packet packet) throws UnauthorizedException, XMLStreamException; void deliver(Packet packet) throws UnauthorizedException, XmlPullParserException;
} }
...@@ -133,8 +133,7 @@ public class OfflineMessageStrategy extends BasicModule { ...@@ -133,8 +133,7 @@ public class OfflineMessageStrategy extends BasicModule {
session.getConnection().deliver(response); session.getConnection().deliver(response);
Message errorResponse = message.createCopy(); Message errorResponse = message.createCopy();
errorResponse.setError(new PacketError(PacketError.Condition.item_not_found, errorResponse.setError(new PacketError(PacketError.Type.continue_processing, PacketError.Condition.item_not_found));
PacketError.Type.continue_processing));
session.getConnection().deliver(errorResponse); session.getConnection().deliver(errorResponse);
} }
catch (Exception e) { catch (Exception e) {
......
...@@ -13,8 +13,7 @@ package org.jivesoftware.messenger; ...@@ -13,8 +13,7 @@ package org.jivesoftware.messenger;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.xmlpull.v1.XmlPullParserException;
import javax.xml.stream.XMLStreamException;
/** /**
* Delivers packets to locally connected streams. This is the opposite * Delivers packets to locally connected streams. This is the opposite
...@@ -34,6 +33,5 @@ public interface PacketDeliverer { ...@@ -34,6 +33,5 @@ public interface PacketDeliverer {
* @param packet The packet to route * @param packet The packet to route
* @throws java.lang.NullPointerException If the packet is null or the packet could not be routed * @throws java.lang.NullPointerException If the packet is null or the packet could not be routed
*/ */
public void deliver(Packet packet) throws public void deliver(Packet packet) throws UnauthorizedException, PacketException, XmlPullParserException;
UnauthorizedException, PacketException, XMLStreamException;
} }
...@@ -25,7 +25,6 @@ import java.util.Random; ...@@ -25,7 +25,6 @@ import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.xml.stream.XMLStreamException;
import org.jivesoftware.messenger.audit.AuditStreamIDFactory; import org.jivesoftware.messenger.audit.AuditStreamIDFactory;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.Container; import org.jivesoftware.messenger.container.Container;
...@@ -41,6 +40,7 @@ import org.xmpp.packet.JID; ...@@ -41,6 +40,7 @@ import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Manages the sessions associated with an account. The information * Manages the sessions associated with an account. The information
...@@ -261,7 +261,7 @@ public class SessionManager implements ConnectionCloseListener { ...@@ -261,7 +261,7 @@ public class SessionManager implements ConnectionCloseListener {
* *
* @param packet * @param packet
*/ */
private void broadcast(Packet packet) throws UnauthorizedException, PacketException, XMLStreamException { private void broadcast(Packet packet) throws UnauthorizedException, PacketException, XmlPullParserException {
Iterator entries = resources.values().iterator(); Iterator entries = resources.values().iterator();
while (entries.hasNext()) { while (entries.hasNext()) {
Session session = (Session)entries.next(); Session session = (Session)entries.next();
...@@ -746,7 +746,7 @@ public class SessionManager implements ConnectionCloseListener { ...@@ -746,7 +746,7 @@ public class SessionManager implements ConnectionCloseListener {
* *
* @param packet The packet to be broadcast * @param packet The packet to be broadcast
*/ */
public void broadcast(Packet packet) throws UnauthorizedException, PacketException, XMLStreamException { public void broadcast(Packet packet) throws UnauthorizedException, PacketException, XmlPullParserException {
sessionLock.readLock().lock(); sessionLock.readLock().lock();
try { try {
Iterator values = sessions.values().iterator(); Iterator values = sessions.values().iterator();
...@@ -776,7 +776,7 @@ public class SessionManager implements ConnectionCloseListener { ...@@ -776,7 +776,7 @@ public class SessionManager implements ConnectionCloseListener {
* *
* @param packet The packet to be broadcast * @param packet The packet to be broadcast
*/ */
public void userBroadcast(String username, Packet packet) throws UnauthorizedException, PacketException, XMLStreamException { public void userBroadcast(String username, Packet packet) throws UnauthorizedException, PacketException, XmlPullParserException {
sessionLock.readLock().lock(); sessionLock.readLock().lock();
try { try {
SessionMap sessionMap = (SessionMap)sessions.get(username); SessionMap sessionMap = (SessionMap)sessions.get(username);
......
...@@ -29,7 +29,6 @@ import java.net.UnknownHostException; ...@@ -29,7 +29,6 @@ import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.xml.stream.XMLStreamException;
public class ConnectionManagerImpl extends BasicModule implements ConnectionManager { public class ConnectionManagerImpl extends BasicModule implements ConnectionManager {
...@@ -109,7 +108,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -109,7 +108,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
public XMPPServer server; public XMPPServer server;
public PacketFactory packetFactory; public PacketFactory packetFactory;
public void addSocket(Socket sock, boolean isSecure) throws XMLStreamException { public void addSocket(Socket sock, boolean isSecure) {
try { try {
// the order of these calls is critical (stupid huh?) // the order of these calls is critical (stupid huh?)
Connection conn = new SocketConnection(deliverer, Connection conn = new SocketConnection(deliverer,
...@@ -118,7 +117,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -118,7 +117,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
isSecure); isSecure);
Session session = sessionManager.createSession(conn); Session session = sessionManager.createSession(conn);
SocketReadThread reader = new SocketReadThread(router, SocketReadThread reader = new SocketReadThread(router,
packetFactory, serverName, auditManager.getAuditor(), serverName, auditManager.getAuditor(),
sock, session); sock, session);
reader.setDaemon(true); reader.setDaemon(true);
reader.start(); reader.start();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment