Commit b9b98fed authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-761] Misc fixes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4508 b35dd754-fafc-0310-a699-88a17e54d16e
parent 87e55847
......@@ -47,20 +47,28 @@ public abstract class BaseTransport implements Component {
/**
* Create a new BaseTransport instance.
*/
public BaseTransport() {
// We've got nothing to do here.
}
/**
* Set up the transport instance.
*
* @param jid JID associated with the transport.
* @param description Description of the transport (for Disco).
* @param type Type of the transport.
* @param description Description of the transport (for Disco).
*/
public BaseTransport(JID jid, String description, TransportType type) {
this.jid = jid;
public void setup(TransportType type, String description) {
this.description = description;
this.transportType = type;
}
// TODO: Why do I need this?
public BaseTransport() {
// I don't understand why I need this.
/**
* Handles initialization of the transport.
*/
public void initialize(JID jid, ComponentManager componentManager) {
this.jid = jid;
this.componentManager = componentManager;
}
/**
......@@ -451,13 +459,6 @@ public abstract class BaseTransport implements Component {
return new JID(username, this.jid.getDomain(), null);
}
/**
* Handles initialization of the transport.
*/
public void initialize(JID jid, ComponentManager componentManager) {
this.componentManager = componentManager;
}
/**
* Handles startup of the transport.
*/
......
......@@ -56,22 +56,18 @@ public class GatewayPlugin implements Plugin {
picoContainer.start();
transports = new Hashtable<String,TransportInstance>();
componentManager = ComponentManagerFactory.getComponentManager();
/* Set up AIM transport. */
transports.put("aim", new TransportInstance("aim",
"org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
transports.put("aim", new TransportInstance(TransportType.aim, "AIM Transport", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
maybeStartService("aim");
/* Set up ICQ transport. */
transports.put("icq", new TransportInstance("icq",
"org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
transports.put("icq", new TransportInstance(TransportType.icq, "ICQ Transport", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
maybeStartService("icq");
/* Set up Yahoo transport. */
transports.put("yahoo", new TransportInstance("yahoo",
"org.jivesoftware.wildfire.gateway.protocols.yahoo.YahooGateway", componentManager));
transports.put("yahoo", new TransportInstance(TransportType.yahoo, "Yahoo! Transport", "org.jivesoftware.wildfire.gateway.protocols.yahoo.YahooGateway", componentManager));
maybeStartService("yahoo");
}
......
......@@ -10,11 +10,12 @@
package org.jivesoftware.wildfire.gateway;
import org.jivesoftware.util.Log;
import org.xmpp.component.ComponentManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.xmpp.component.ComponentManager;
import org.xmpp.packet.JID;
/**
* Transport Instance
......@@ -26,24 +27,29 @@ import org.jivesoftware.util.PropertyEventDispatcher;
public class TransportInstance {
private ComponentManager componentManager;
private String serviceName = null;
private JID jid = null;
private String description = null;
private String nameOfClass = null;
private BaseTransport transport = null;
private TransportType type = null;
private Boolean enabled = false;
private Boolean running = false;
/**
* Creates a new transport instance.
*
* @param subdomain Part of transport domain prepended to server domain.
* @param jid Full jabber id of the transport.
* @param description Short description of transport.
* @param type Type of transport.
* @param classname Full name/path of class associated with instance.
* @param componentManager Component manager managing this instance.
*/
public TransportInstance(String subdomain, String classname, ComponentManager componentManager) {
this.serviceName = subdomain;
public TransportInstance(TransportType type, String description, String classname, ComponentManager componentManager) {
this.description = description;
this.type = type;
this.nameOfClass = classname;
this.componentManager = componentManager;
enabled = JiveGlobals.getBooleanProperty("plugin.gateway."+serviceName+"Enabled", false);
enabled = JiveGlobals.getBooleanProperty("plugin.gateway."+this.type.toString()+"Enabled", false);
}
/**
......@@ -52,7 +58,7 @@ public class TransportInstance {
* @return name of the service
*/
public String getName() {
return serviceName;
return this.type.toString();
}
/**
......@@ -78,7 +84,7 @@ public class TransportInstance {
*/
public void enable() {
enabled = true;
JiveGlobals.setProperty("plugin.gateway."+serviceName+"Enabled", "true");
JiveGlobals.setProperty("plugin.gateway."+this.type.toString()+"Enabled", "true");
if (!running) {
startInstance();
}
......@@ -89,7 +95,7 @@ public class TransportInstance {
*/
public void disable() {
enabled = false;
JiveGlobals.setProperty("plugin.gateway."+serviceName+"Enabled", "false");
JiveGlobals.setProperty("plugin.gateway."+this.type.toString()+"Enabled", "false");
if (running) {
stopInstance();
}
......@@ -109,6 +115,7 @@ public class TransportInstance {
try {
transport = (BaseTransport)Class.forName(nameOfClass).newInstance();
transport.setup(this.type, this.description);
}
catch (ClassNotFoundException e) {
Log.error("Unable to find class: "+nameOfClass);
......@@ -119,11 +126,9 @@ public class TransportInstance {
catch (IllegalAccessException e) {
Log.error("Unable to access class: "+nameOfClass);
}
//transport.setName(serviceName);
//componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, transport);
componentManager.addComponent(this.type.toString(), transport);
//PropertyEventDispatcher.addListener(transport);
running = true;
}
......@@ -142,8 +147,7 @@ public class TransportInstance {
//PropertyEventDispatcher.removeListener(transport);
try {
componentManager.removeComponent(serviceName);
//componentManager = null;
componentManager.removeComponent(this.type.toString());
}
catch (Exception e) {
componentManager.getLog().error(e);
......
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