Commit 17f199b4 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Some more code cleanup.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4383 b35dd754-fafc-0310-a699-88a17e54d16e
parent 61a17711
...@@ -68,9 +68,9 @@ public abstract class AbstractGatewaySession implements GatewaySession, Endpoint ...@@ -68,9 +68,9 @@ public abstract class AbstractGatewaySession implements GatewaySession, Endpoint
} }
/** /**
* Return the jabber <code>Endpoint</code>. * Return the Jabber <code>Endpoint</code>.
* *
* @return endpoint The jabber endpoint. * @return endpoint The Jabber endpoint.
* @see org.jivesoftware.wildfire.gateway.Endpoint * @see org.jivesoftware.wildfire.gateway.Endpoint
*/ */
public Endpoint getJabberEndpoint() { public Endpoint getJabberEndpoint() {
...@@ -114,4 +114,5 @@ public abstract class AbstractGatewaySession implements GatewaySession, Endpoint ...@@ -114,4 +114,5 @@ public abstract class AbstractGatewaySession implements GatewaySession, Endpoint
public EndpointValve getValve() { public EndpointValve getValve() {
return this.jabberEndpoint.getValve(); return this.jabberEndpoint.getValve();
} }
} }
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import java.util.*; import java.util.*;
...@@ -31,11 +41,10 @@ import org.xmpp.packet.Presence; ...@@ -31,11 +41,10 @@ import org.xmpp.packet.Presence;
import org.xmpp.packet.PacketError.Condition; import org.xmpp.packet.PacketError.Condition;
/** /**
* Handle a good share of the tasks for a gateway. Dealing with lookups for ids, * Handle a good share of the tasks for a gateway. Deals with lookups for
* dealing with registration, dealing with presence information. * ids, registration, and presence information.
* *
* @author ncampbell * @author ncampbell
* @version 1.0
*/ */
public abstract class BaseGateway implements Gateway, Component, Runnable { public abstract class BaseGateway implements Gateway, Component, Runnable {
...@@ -64,7 +73,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -64,7 +73,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
} }
/** /**
* @return version the version of the gateway * @return version The version of the gateway
*/ */
public abstract String getVersion(); public abstract String getVersion();
...@@ -84,7 +93,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -84,7 +93,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
protected JabberEndpoint jabberEndpoint; protected JabberEndpoint jabberEndpoint;
/** /**
* Component Manager to handle communication to the XMPP server. * Component Manager to handle communication with the XMPP server.
*/ */
public final ComponentManager componentManager = ComponentManagerFactory.getComponentManager(); public final ComponentManager componentManager = ComponentManagerFactory.getComponentManager();
...@@ -98,8 +107,6 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -98,8 +107,6 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
*/ */
public final PersistenceManager rosterManager = PersistenceManager.Factory.get(this); public final PersistenceManager rosterManager = PersistenceManager.Factory.get(this);
/** The threadPool. @see java.util.concurrent.ScheduledExecutorService */ /** The threadPool. @see java.util.concurrent.ScheduledExecutorService */
protected static final ScheduledExecutorService threadPool = Executors.newSingleThreadScheduledExecutor(new BackgroundThreadFactory()); protected static final ScheduledExecutorService threadPool = Executors.newSingleThreadScheduledExecutor(new BackgroundThreadFactory());
...@@ -109,7 +116,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -109,7 +116,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
private final Map<JID, String> foreignContacts = new HashMap<JID, String>(); private final Map<JID, String> foreignContacts = new HashMap<JID, String>();
/** /**
* helper method for getting the ns from a packet. * Helper method for getting the ns (namespace) from a packet.
* *
* @param packet * @param packet
* @return namespace The namespaceUri. * @return namespace The namespaceUri.
...@@ -127,7 +134,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -127,7 +134,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
/** /**
* Process an IQ packet. * Process an IQ packet.
* *
* @param iq the IQ packet sent from the client. * @param iq The IQ packet sent from the client.
* @return packetList A list of Packets to be sent to the client. * @return packetList A list of Packets to be sent to the client.
* @see java.util.List * @see java.util.List
* @see org.xmpp.packet.IQ * @see org.xmpp.packet.IQ
...@@ -135,24 +142,29 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -135,24 +142,29 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
private List<Packet> processPacket(IQ iq) { private List<Packet> processPacket(IQ iq) {
String namespace = getNS(iq); String namespace = getNS(iq);
List<Packet> response = new ArrayList<Packet>(); List<Packet> response = new ArrayList<Packet>();
if("http://jabber.org/protocol/disco#info".equals(namespace)) { if ("http://jabber.org/protocol/disco#info".equals(namespace)) {
response.add(handleServiceDiscovery(iq)); response.add(handleServiceDiscovery(iq));
} else if("jabber:iq:agents".equals(namespace)) { }
else if ("jabber:iq:agents".equals(namespace)) {
response.add(handleLegacyServiceDiscovery(iq)); response.add(handleLegacyServiceDiscovery(iq));
} else if("http://jabber.org/protocol/disco#items".equals(namespace)) { }
else if ("http://jabber.org/protocol/disco#items".equals(namespace)) {
response.add(handleDiscoveryItems(iq)); response.add(handleDiscoveryItems(iq));
} else if("jabber:iq:register".equals(namespace)) { }
else if ("jabber:iq:register".equals(namespace)) {
response.addAll(handleRegisterInBand(iq)); response.addAll(handleRegisterInBand(iq));
} else if("jabber:iq:version".equals(namespace)) { }
else if ("jabber:iq:version".equals(namespace)) {
response.add(handleVersion(iq)); response.add(handleVersion(iq));
} else if("jabber:iq:browse".equals(namespace)) { }
else if ("jabber:iq:browse".equals(namespace)) {
response.add(handleBrowse(iq)); response.add(handleBrowse(iq));
} }
return response; return response;
} }
/** /**
* Proces a browse request. * Process a browse request.
* *
* @param iq The client IQ packet. * @param iq The client IQ packet.
* @return iq The response IQ packet. * @return iq The response IQ packet.
...@@ -163,25 +175,22 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -163,25 +175,22 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
"query", "jabber:iq:browse")); "query", "jabber:iq:browse"));
try { try {
for (ForeignContact fc : PersistenceManager.Factory.get(this).getRegistrar().getGatewaySession(iq.getFrom()).getContacts()) {
for(ForeignContact fc : PersistenceManager.Factory.get(this).getRegistrar().getGatewaySession(iq.getFrom()).getContacts()) {
Element item = DocumentHelper.createElement("item"); Element item = DocumentHelper.createElement("item");
item.addAttribute("category", "user"); item.addAttribute("category", "user");
item.addAttribute("jid", fc + "@" + this.getName() + "." + this.getDomain()); item.addAttribute("jid", fc + "@" + this.getName() + "." + this.getDomain());
item.addAttribute("type", "client"); item.addAttribute("type", "client");
responseElement.add(item); responseElement.add(item);
} }
reply.setChildElement(responseElement); reply.setChildElement(responseElement);
}
} catch (Exception e) { catch (Exception e) {
logger.log(Level.WARNING, "basegateway.notfound", iq.getFrom().toBareJID()); logger.log(Level.WARNING, "basegateway.notfound", iq.getFrom().toBareJID());
} }
return reply; return reply;
} }
/** /**
* Process a version request. * Process a version request.
* *
...@@ -204,15 +213,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -204,15 +213,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* the registration process. * the registration process.
* *
* @param iq The client iq packet. * @param iq The client iq packet.
* @return response The <code>Collection</code> of <code>Packet</code> that * @return response The <code>Collection</code> of <code>Packet</code>s
* make up the response. * that make up the response.
*/ */
private Collection<Packet> handleRegisterInBand(final IQ iq) { private Collection<Packet> handleRegisterInBand(final IQ iq) {
Element remove = iq.getChildElement().element("remove"); Element remove = iq.getChildElement().element("remove");
Collection<Packet> response = new ArrayList<Packet>(); Collection<Packet> response = new ArrayList<Packet>();
if(remove != null) { if (remove != null) {
response.addAll(unregister(iq)); response.addAll(unregister(iq));
} else { }
else {
response.addAll(register(iq)); response.addAll(register(iq));
} }
...@@ -262,14 +272,12 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -262,14 +272,12 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* @return response A <code>Collection</code> of <code>Packet</code>s that make up the response. * @return response A <code>Collection</code> of <code>Packet</code>s that make up the response.
*/ */
private Collection<Packet> register(IQ iq) { private Collection<Packet> register(IQ iq) {
Collection<Packet> response = new ArrayList<Packet>(); Collection<Packet> response = new ArrayList<Packet>();
IQ reply = IQ.createResultIQ(iq); IQ reply = IQ.createResultIQ(iq);
Element responseElement = DocumentHelper.createElement(QName.get( Element responseElement = DocumentHelper.createElement(QName.get(
"query", "jabber:iq:register")); "query", "jabber:iq:register"));
if(iq.getType().equals(IQ.Type.set)) { if (iq.getType().equals(IQ.Type.set)) {
String username = null; String username = null;
String password = null; String password = null;
...@@ -277,11 +285,12 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -277,11 +285,12 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
DataForm form = new DataForm(iq.getChildElement().element("x")); DataForm form = new DataForm(iq.getChildElement().element("x"));
List<FormField> fields = form.getFields(); List<FormField> fields = form.getFields();
for(FormField field : fields) { for (FormField field : fields) {
String var = field.getVariable(); String var = field.getVariable();
if(var.equalsIgnoreCase("username")) { if (var.equalsIgnoreCase("username")) {
username = field.getValues().get(0); username = field.getValues().get(0);
} else if (var.equalsIgnoreCase("password")) { }
else if (var.equalsIgnoreCase("password")) {
/** /**
* The password is stored in Whack and DOM4J as a String * The password is stored in Whack and DOM4J as a String
* so the password is sent in the clear and stored in * so the password is sent in the clear and stored in
...@@ -290,33 +299,33 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -290,33 +299,33 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
password = field.getValues().get(0); password = field.getValues().get(0);
} }
} }
} catch (Exception e) { }
catch (Exception e) {
// unable to use dataform // unable to use dataform
logger.log(Level.FINER, "basegateway.dataformnotused", e); logger.log(Level.FINER, "basegateway.dataformnotused", e);
} }
if(username == null || password == null) { if (username == null || password == null) {
// try non DataForm. // try non DataForm.
Element usernameElement = iq.getChildElement().element("username"); Element usernameElement = iq.getChildElement().element("username");
Element passwordElement = iq.getChildElement().element("password"); Element passwordElement = iq.getChildElement().element("password");
if(usernameElement != null) { if (usernameElement != null) {
username = usernameElement.getTextTrim(); username = usernameElement.getTextTrim();
} }
if(passwordElement != null) { if (passwordElement != null) {
password = passwordElement.getTextTrim(); password = passwordElement.getTextTrim();
} }
} }
// make sure that something was collected, otherwise return an error. // make sure that something was collected, otherwise return an error
if(username == null || password == null) { if (username == null || password == null) {
IQ result = IQ.createResultIQ(iq); IQ result = IQ.createResultIQ(iq);
result.setError(Condition.bad_request); result.setError(Condition.bad_request);
response.add(result); response.add(result);
} else { }
else {
logger.log(Level.INFO, "basegateway.register", username.trim()); logger.log(Level.INFO, "basegateway.register", username.trim());
SubscriptionInfo info = new SubscriptionInfo(username.trim(), password); SubscriptionInfo info = new SubscriptionInfo(username.trim(), password);
PersistenceManager.Factory.get(this).getRegistrar().add(iq.getFrom(), info); PersistenceManager.Factory.get(this).getRegistrar().add(iq.getFrom(), info);
...@@ -328,11 +337,10 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -328,11 +337,10 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
subscribe.setFrom(iq.getTo()); subscribe.setFrom(iq.getTo());
response.add(subscribe); response.add(subscribe);
} }
}
} else if(iq.getType().equals(IQ.Type.get)) { else if (iq.getType().equals(IQ.Type.get)) {
DataForm form = new DataForm(DataForm.Type.form); DataForm form = new DataForm(DataForm.Type.form);
// This needs to ask the specific gateway what to say.
form.addInstruction("Please enter your AIM Screenname and Password"); form.addInstruction("Please enter your AIM Screenname and Password");
FormField usernameField = form.addField(); FormField usernameField = form.addField();
usernameField.setLabel("Username"); usernameField.setLabel("Username");
...@@ -346,12 +354,13 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -346,12 +354,13 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
/** /**
* Add standard elements to request. * Add standard elements to request.
*/ */
// This needs to ask the specific gateway what to say.
responseElement.addElement("instruction").addText("Please enter your AIM screenname and password"); responseElement.addElement("instruction").addText("Please enter your AIM screenname and password");
responseElement.addElement("username"); responseElement.addElement("username");
responseElement.addElement("password"); responseElement.addElement("password");
/** /**
* Add data form (for those that can support it. * Add data form for clients that can support it.
*/ */
responseElement.add(form.getElement()); responseElement.add(form.getElement());
...@@ -374,7 +383,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -374,7 +383,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
"query", "http://jabber.org/protocol/disco#info")); "query", "http://jabber.org/protocol/disco#info"));
Roster roster = this.rosterManager.getContactManager().getRoster(iq.getFrom()); Roster roster = this.rosterManager.getContactManager().getRoster(iq.getFrom());
for( ForeignContact entry : roster.getAll()) { for (ForeignContact entry : roster.getAll()) {
Element item = responseElement.addElement("item"); Element item = responseElement.addElement("item");
item.addAttribute("jid", entry.getJid().toBareJID()); item.addAttribute("jid", entry.getJid().toBareJID());
item.addAttribute("name", entry.getName()); item.addAttribute("name", entry.getName());
...@@ -395,6 +404,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -395,6 +404,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
return IQ.createResultIQ(iq); return IQ.createResultIQ(iq);
// TODO: Implement Legacy Service Discovery. // TODO: Implement Legacy Service Discovery.
} }
/** /**
* Handle service discovery. * Handle service discovery.
* *
...@@ -406,12 +416,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -406,12 +416,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
Element responseElement = DocumentHelper.createElement(QName.get( Element responseElement = DocumentHelper.createElement(QName.get(
"query", "http://jabber.org/protocol/disco#info")); "query", "http://jabber.org/protocol/disco#info"));
responseElement.addElement("identity").addAttribute("category", "gateway") responseElement.addElement("identity")
.addAttribute("category", "gateway")
.addAttribute("type", this.getType()) .addAttribute("type", this.getType())
.addAttribute("name", this.getDescription()); .addAttribute("name", this.getDescription());
responseElement.addElement("feature").addAttribute("var", "jabber:iq:time"); responseElement.addElement("feature")
responseElement.addElement("feature").addAttribute("var", "jabber:iq:version"); .addAttribute("var", "jabber:iq:time");
responseElement.addElement("feature").addAttribute("var", "jabber:iq:register"); responseElement.addElement("feature")
.addAttribute("var", "jabber:iq:version");
responseElement.addElement("feature")
.addAttribute("var", "jabber:iq:register");
reply.setChildElement(responseElement); reply.setChildElement(responseElement);
return reply; return reply;
} }
...@@ -424,30 +438,36 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -424,30 +438,36 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
public void processPacket(Packet packet) { public void processPacket(Packet packet) {
try { try {
List<Packet> response = new ArrayList<Packet>(); List<Packet> response = new ArrayList<Packet>();
if(packet instanceof IQ) { if (packet instanceof IQ) {
response.addAll( processPacket((IQ)packet) ); response.addAll( processPacket((IQ)packet) );
} else if (packet instanceof Presence) { }
else if (packet instanceof Presence) {
response.addAll( processPacket((Presence)packet) ); response.addAll( processPacket((Presence)packet) );
} else if (packet instanceof Message) { }
else if (packet instanceof Message) {
processPacket((Message)packet); processPacket((Message)packet);
} else { }
else {
System.out.println("UNHANDLED: " + packet.toString()); System.out.println("UNHANDLED: " + packet.toString());
} }
// process // process
if(response.size() > 0) { if (response.size() > 0) {
for(Packet p : response) { for (Packet p : response) {
componentManager.sendPacket(this, p); componentManager.sendPacket(this, p);
} }
} else { }
else {
//System.out.println("Request[" + packet.toString() + "] with no response"); //System.out.println("Request[" + packet.toString() + "] with no response");
} }
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
/** /**
* Process a message from the client. * Process a message from the client.
* *
...@@ -463,7 +483,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -463,7 +483,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
} }
/** /**
* Proces a presense packet. * Process a presense packet.
* *
* @param presence The presence packet from the client. * @param presence The presence packet from the client.
* @return list A <code>List</code> of <code>Presence</code> packets. * @return list A <code>List</code> of <code>Presence</code> packets.
...@@ -478,10 +498,10 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -478,10 +498,10 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
/* /*
* Unknown entity is trying to access the gateway. * Unknown entity is trying to access the gateway.
*/ */
if(!rosterManager.getRegistrar().isRegistered(NormalizedJID.wrap(from))) { if (!rosterManager.getRegistrar().isRegistered(NormalizedJID.wrap(from))) {
logger.log(Level.INFO, "basegateway.unabletofind", from); logger.log(Level.INFO, "basegateway.unabletofind", from);
// silently ignore a delete request // silently ignore a delete request
if(!Presence.Type.unavailable.equals(presence.getType())) { if (!Presence.Type.unavailable.equals(presence.getType())) {
logger.log(Level.INFO, "basegateway.unauthorizedrequest", new Object[] { presence.getType(), from.toString() }); logger.log(Level.INFO, "basegateway.unauthorizedrequest", new Object[] { presence.getType(), from.toString() });
Presence result = new Presence(); Presence result = new Presence();
result.setError(Condition.not_authorized); result.setError(Condition.not_authorized);
...@@ -495,15 +515,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -495,15 +515,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* Get the underlying session for this JID and handle accordingly. * Get the underlying session for this JID and handle accordingly.
*/ */
GatewaySession sessionInfo = rosterManager.getRegistrar().getGatewaySession(from); GatewaySession sessionInfo = rosterManager.getRegistrar().getGatewaySession(from);
if(sessionInfo == null) { if (sessionInfo == null) {
logger.log(Level.WARNING, "basegateway.unabletolocatesession" , from); logger.log(Level.WARNING, "basegateway.unabletolocatesession" , from);
return p; return p;
} }
if(Presence.Type.subscribe.equals(presence.getType())) { if (Presence.Type.subscribe.equals(presence.getType())) {
if(presence.getTo().equals(this.jid)) { if (presence.getTo().equals(this.jid)) {
sessionInfo.getSubscriptionInfo().serverRegistered = true; sessionInfo.getSubscriptionInfo().serverRegistered = true;
} else { }
else {
Presence subscribe = new Presence(Presence.Type.subscribe); Presence subscribe = new Presence(Presence.Type.subscribe);
subscribe.setTo(presence.getFrom()); subscribe.setTo(presence.getFrom());
subscribe.setFrom(presence.getTo()); subscribe.setFrom(presence.getTo());
...@@ -516,19 +537,19 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -516,19 +537,19 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
} }
else if (Presence.Type.subscribed.equals(presence.getType())) { else if (Presence.Type.subscribed.equals(presence.getType())) {
if(presence.getTo().equals(this.jid)) { // subscribed to server if (presence.getTo().equals(this.jid)) { // subscribed to server
sessionInfo.getSubscriptionInfo().clientRegistered = true; sessionInfo.getSubscriptionInfo().clientRegistered = true;
} else { // subscribe to legacy user }
else { // subscribe to legacy user
logger.log(Level.FINE,"basegateway.subscribed"); logger.log(Level.FINE,"basegateway.subscribed");
} }
} }
else if (Presence.Type.unavailable.equals(presence.getType())){ else if (Presence.Type.unavailable.equals(presence.getType())){
/** /**
* If an unavailable presence stanza is received then logout the * If an unavailable presence stanza is received then logout the
* current user and send back and unavailable stanza. * current user and send back and unavailable stanza.
*/ */
if(sessionInfo.isConnected()) { if (sessionInfo.isConnected()) {
sessionInfo.logout(); sessionInfo.logout();
} }
...@@ -553,7 +574,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -553,7 +574,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
Presence p2 = new Presence(); Presence p2 = new Presence();
p2.setFrom(presence.getTo()); p2.setFrom(presence.getTo());
p2.setTo(presence.getFrom()); p2.setTo(presence.getFrom());
if(status.isOnline()) { if (status.isOnline()) {
p2.setStatus(status.getValue()); p2.setStatus(status.getValue());
} }
else { else {
...@@ -636,18 +657,18 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -636,18 +657,18 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* subscribed the contact to the JID. * subscribed the contact to the JID.
*/ */
public void run() { public void run() {
logger.log(Level.FINEST, "basegateway.maintenancestart"); logger.log(Level.FINEST, "basegateway.maintenancestart");
for(SubscriptionInfo si : rosterManager.getRegistrar().getAllGatewaySessions()) { for (SubscriptionInfo si : rosterManager.getRegistrar().getAllGatewaySessions()) {
if(!si.clientRegistered) { if (!si.clientRegistered) {
Presence p = new Presence(); Presence p = new Presence();
p.setType(Presence.Type.subscribe); p.setType(Presence.Type.subscribe);
p.setTo(si.jid); p.setTo(si.jid);
p.setFrom(this.jid); p.setFrom(this.jid);
try { try {
componentManager.sendPacket(this, p); componentManager.sendPacket(this, p);
} catch (ComponentException e) { }
catch (ComponentException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
...@@ -664,7 +685,6 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -664,7 +685,6 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
// logger.log(Level.WARNING, "basegateway.unabletosendpresence", e); // logger.log(Level.WARNING, "basegateway.unabletosendpresence", e);
// } // }
// } // }
} }
// for(ForeignContact contact : rosterManager.getContactManager().getAllForeignContacts()) { // for(ForeignContact contact : rosterManager.getContactManager().getAllForeignContacts()) {
...@@ -692,13 +712,11 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -692,13 +712,11 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
*/ */
public SessionFactory getSessionFactory() { public SessionFactory getSessionFactory() {
return new SessionFactory() { return new SessionFactory() {
public GatewaySession newInstance(SubscriptionInfo info) { public GatewaySession newInstance(SubscriptionInfo info) {
GatewaySession session = getSessionInstance(info); GatewaySession session = getSessionInstance(info);
session.setJabberEndpoint(jabberEndpoint); session.setJabberEndpoint(jabberEndpoint);
return session; return session;
} }
}; };
} }
...@@ -718,4 +736,5 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -718,4 +736,5 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* @see Gateway#getSessionFactory() * @see Gateway#getSessionFactory()
*/ */
protected abstract GatewaySession getSessionInstance(SubscriptionInfo info); protected abstract GatewaySession getSessionInstance(SubscriptionInfo info);
} }
...@@ -30,7 +30,6 @@ public interface Endpoint { ...@@ -30,7 +30,6 @@ public interface Endpoint {
*/ */
public void sendPacket(Packet packet) throws ComponentException; public void sendPacket(Packet packet) throws ComponentException;
/** /**
* Return the <code>EndpointValve</code>. This provides the ability of the * Return the <code>EndpointValve</code>. This provides the ability of the
* caller to open or close the valve to control the follow of packets to the * caller to open or close the valve to control the follow of packets to the
...@@ -39,4 +38,5 @@ public interface Endpoint { ...@@ -39,4 +38,5 @@ public interface Endpoint {
* @return valve The <code>EndpointValve</code> associated with this <code>Endpoint</code> * @return valve The <code>EndpointValve</code> associated with this <code>Endpoint</code>
*/ */
public EndpointValve getValve(); public EndpointValve getValve();
} }
...@@ -34,6 +34,7 @@ public class JabberEndpoint implements Endpoint { ...@@ -34,6 +34,7 @@ public class JabberEndpoint implements Endpoint {
* @see ComponentManager * @see ComponentManager
*/ */
private final ComponentManager componentManager; private final ComponentManager componentManager;
/** /**
* The component * The component
* *
...@@ -41,7 +42,6 @@ public class JabberEndpoint implements Endpoint { ...@@ -41,7 +42,6 @@ public class JabberEndpoint implements Endpoint {
*/ */
private final Component component; private final Component component;
/** /**
* The value. * The value.
* @see EndpointValve * @see EndpointValve
...@@ -68,19 +68,6 @@ public class JabberEndpoint implements Endpoint { ...@@ -68,19 +68,6 @@ public class JabberEndpoint implements Endpoint {
this.component = component; this.component = component;
this.valve= valve; this.valve= valve;
} }
//
//
// /**
// * @param jid
// * @param string
// * @throws Exception
// */
// public void sendMessage(JID jid, String string) throws Exception {
// Message message = new Message();
// message.setBody(string);
// message.setTo(jid);
// this.componentManager.sendPacket(this.component, message);
// }
/** /**
* @see org.jivesoftware.wildfire.gateway.Endpoint#sendPacket(Packet) * @see org.jivesoftware.wildfire.gateway.Endpoint#sendPacket(Packet)
...@@ -103,7 +90,6 @@ public class JabberEndpoint implements Endpoint { ...@@ -103,7 +90,6 @@ public class JabberEndpoint implements Endpoint {
/** The backlog queue. */ /** The backlog queue. */
private final ConcurrentLinkedQueue<Packet> queue = new ConcurrentLinkedQueue<Packet>(); private final ConcurrentLinkedQueue<Packet> queue = new ConcurrentLinkedQueue<Packet>();
/** The logger. */ /** The logger. */
final static private Logger logger = Logger.getLogger("JabberEndpoint", "gateway_i18n"); final static private Logger logger = Logger.getLogger("JabberEndpoint", "gateway_i18n");
......
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