Commit 493708d5 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Adding PicoContainer.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4502 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2a263641
......@@ -84,6 +84,15 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/src/plugins/gateway/lib/picocontainer.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntryProperties />
</component>
</module>
......
Name | Version
---------------------------------------------
joscar.jar | 0.9.3 (patched)
ymsg_network.jar | 0.61
Name | Version
---------------------------------------------
joscar.jar | 0.9.3 (patched)
picocontainer | 1.2.0
ymsg_network.jar | 0.61
\ No newline at end of file
......@@ -16,6 +16,8 @@ import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.gateway.util.GatewayInstance;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.picocontainer.MutablePicoContainer;
import org.picocontainer.defaults.DefaultPicoContainer;
import java.io.File;
......@@ -29,6 +31,8 @@ import java.util.Hashtable;
*/
public class GatewayPlugin implements Plugin {
private MutablePicoContainer picoContainer;
/**
* Represents all configured gateway handlers.
*/
......@@ -39,10 +43,15 @@ public class GatewayPlugin implements Plugin {
*/
private ComponentManager componentManager;
/**
* Configures and starts the plugin.
*/
public GatewayPlugin() {
picoContainer = new DefaultPicoContainer();
picoContainer.registerComponentImplementation(RegistrationManager.class);
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
picoContainer.start();
gateways = new Hashtable<String,GatewayInstance>();
componentManager = ComponentManagerFactory.getComponentManager();
......@@ -63,6 +72,25 @@ public class GatewayPlugin implements Plugin {
maybeStartService("yahoo");
}
public void destroyPlugin() {
for (GatewayInstance gwInstance : gateways.values()) {
gwInstance.stopInstance();
}
picoContainer.stop();
picoContainer.dispose();
picoContainer = null;
}
/**
* Returns the instance of a module registered with the plugin.
*
* @param clazz the module class.
* @return the instance of the module.
*/
public Object getModule(Class clazz) {
return picoContainer.getComponentInstanceOfType(clazz);
}
/**
* Starts a gateway service, identified by subdomain. The gateway
* service will only start if it is enabled.
......@@ -98,14 +126,4 @@ public class GatewayPlugin implements Plugin {
GatewayInstance gwInstance = gateways.get(serviceName);
return gwInstance.isEnabled();
}
/**
* Shuts down the plugin.
*/
public void destroyPlugin() {
for (GatewayInstance gwInstance : gateways.values()) {
gwInstance.stopInstance();
}
}
}
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ import org.xmpp.packet.JID;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import org.picocontainer.Startable;
import java.util.*;
import java.sql.Connection;
......@@ -27,7 +28,7 @@ import java.sql.ResultSet;
*
* @author Matt Tucker
*/
public class RegistrationManager {
public class RegistrationManager implements Startable {
private static final String DELETE_REGISTRATION =
"DELETE FROM gatewayRegistration WHERE registrationID=?";
......@@ -45,6 +46,14 @@ public class RegistrationManager {
private static final String USER_GATEWAY_REGISTRATIONS =
"SELECT registrationID FROM gatewayRegistration WHERE jid=? AND gatewayType=?";
public void start() {
}
public void stop() {
}
/**
* Creates a new registration.
*
......@@ -89,7 +98,7 @@ public class RegistrationManager {
* @param gatewayType the gateway type.
* @return all registrations for the gateway type.
*/
Collection<Registration> getRegistrations(GatewayType gatewayType) {
public Collection<Registration> getRegistrations(GatewayType gatewayType) {
List<Long> registrationIDs = new ArrayList<Long>();
Connection con = null;
PreparedStatement pstmt = null;
......@@ -123,7 +132,7 @@ public class RegistrationManager {
* @param jid the JID of the user.
* @return all registrations for the JID.
*/
Collection<Registration> getRegistrations(JID jid) {
public Collection<Registration> getRegistrations(JID jid) {
List<Long> registrationIDs = new ArrayList<Long>();
Connection con = null;
PreparedStatement pstmt = null;
......@@ -163,7 +172,7 @@ public class RegistrationManager {
* @param gatewayType the type of the gateway.
* @return all registrations for the JID of a particular gateway type.
*/
Collection<Registration> getRegistrations(JID jid, GatewayType gatewayType) {
public Collection<Registration> getRegistrations(JID jid, GatewayType gatewayType) {
List<Long> registrationIDs = new ArrayList<Long>();
Connection con = null;
PreparedStatement pstmt = null;
......@@ -193,7 +202,16 @@ public class RegistrationManager {
}
}
Registration getRegistration(JID jid, GatewayType gatewayType, String username)
/**
* Returns a registration given a JID, gateway type, and username.
*
* @param jid the JID of the user.
* @param gatewayType the gateway type.
* @param username the username on the gateway service.
* @return the registration.
* @throws NotFoundException if the registration could not be found.
*/
public Registration getRegistration(JID jid, GatewayType gatewayType, String username)
throws NotFoundException
{
long registrationID = -1;
......
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