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

Lots of code cleanup. Removal of Serialization. Filled in versions.txt.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4409 b35dd754-fafc-0310-a699-88a17e54d16e
parent 88bfdf89
......@@ -18,7 +18,6 @@ import org.xmpp.packet.Packet;
* underlying implementation, providing translation if necessary.
*
* @author Noah Campbell
* @version 1.0
*/
public interface Endpoint {
......
......@@ -16,11 +16,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author Noah Campbell
*/
public class EndpointValve {
/** The valve handle. */
private final AtomicBoolean open;
/**
* Construct a new <code>EndpointValve</code>. The valve is closed by
* default.
......@@ -28,7 +27,7 @@ public class EndpointValve {
public EndpointValve() {
this(false);
}
/**
* Construct a new <code>EndpointValve</code>.
*
......@@ -38,27 +37,25 @@ public class EndpointValve {
this.open = new AtomicBoolean(open);
}
/**
* @return open If the valve is open or not.
*/
public boolean isOpen() {
return this.open.get();
}
/**
* Open the valve and let any pending message get processed.
*/
public void open() {
this.open.set(true);
}
/**
* Close the valve and queue any new messeages destine for the endpoint.
*/
public void close() {
this.open.set(false);
}
}
......@@ -16,7 +16,6 @@ import org.xmpp.packet.JID;
* A gateway to an external or legacy messaging system.
*
* @author ncampbell
* @version 1.0
*/
public interface Gateway extends Endpoint {
......@@ -44,30 +43,31 @@ public interface Gateway extends Endpoint {
* @return domain
*/
public String getDomain();
/**
* Lookup a contact name for the JID
* @param jid The jabber id
* @return contact The legacy name
*/
public String whois(JID jid);
/**
* Lookup a JID for a legacy contact name
* @param contact The name of legacy contact
* @return JID
*/
public JID whois(String contact);
/**
* The JID of the gateway
* @return JID
*/
public JID getJID();
/**
* Return the session gateway for this gateway
* @return SessionFactory
*/
public SessionFactory getSessionFactory();
}
......@@ -27,6 +27,7 @@ import java.util.Hashtable;
* @author Daniel Henninger
*/
public class GatewayPlugin implements Plugin {
/**
* Represents all configured gateway handlers.
*/
......@@ -102,4 +103,5 @@ public class GatewayPlugin implements Plugin {
gwInstance.stopInstance();
}
}
}
......@@ -49,7 +49,7 @@ public interface GatewaySession {
* @return boolean
*/
public boolean isConnected();
/**
* Returns all sessions associated with this session/login.
*
......@@ -57,7 +57,7 @@ public interface GatewaySession {
* @see java.util.List
*/
public List<ForeignContact> getContacts();
/**
* Return the endpoint for the legacy system.
*
......@@ -65,7 +65,7 @@ public interface GatewaySession {
* @return Endpoint legacy endpoint.
*/
public Endpoint getLegacyEndpoint();
/**
* Get the Jabber endpoint.
*
......@@ -89,7 +89,7 @@ public interface GatewaySession {
* @return status The status for the particular JID.
*/
public String getStatus(JID id);
/**
* Add a contact to this session. This method will typically update the
* roster on the legacy system.
......@@ -99,7 +99,7 @@ public interface GatewaySession {
* @see org.xmpp.packet.JID
*/
public void addContact(JID jid) throws Exception;
/**
* Remove a contact from this session. This will typically update the
* roster on the legacy system.
......@@ -109,7 +109,7 @@ public interface GatewaySession {
* @see org.xmpp.packet.JID
*/
public void removeContact(JID jid) throws Exception;
/**
* Sets the XMPP Server endpoint.
*
......@@ -117,7 +117,7 @@ public interface GatewaySession {
* @see org.jivesoftware.wildfire.gateway.Endpoint
*/
public void setJabberEndpoint(Endpoint jabberEndpoint);
/**
* Get the gateway that is associated with this session. Every session
* has an orinating gateway from which is was created.
......@@ -127,7 +127,6 @@ public interface GatewaySession {
*/
public Gateway getGateway();
/**
* The session will return a foreign contact identified by the JID. If it
* does not exist then an exception will be thrown. The Session is responsible
......@@ -139,4 +138,5 @@ public interface GatewaySession {
* @throws UnknownForeignContactException
*/
public ForeignContact getContact(JID to) throws UnknownForeignContactException;
}
......@@ -57,4 +57,5 @@ public enum GatewayType {
* A gateway to a service not covered by the other options..
*/
other
}
\ No newline at end of file
}
......@@ -24,7 +24,6 @@ import org.xmpp.packet.Packet;
* XMPP server.
*
* @author Noah Campbell
* @version 1.0
*/
public class JabberEndpoint implements Endpoint {
......@@ -73,20 +72,21 @@ public class JabberEndpoint implements Endpoint {
* @see org.jivesoftware.wildfire.gateway.Endpoint#sendPacket(Packet)
*/
public void sendPacket(Packet packet) throws ComponentException {
if(valve.isOpen()) {
if (valve.isOpen()) {
/**
* Push all pending packets to the XMPP Server.
*/
while(!queue.isEmpty()) {
while (!queue.isEmpty()) {
this.componentManager.sendPacket(this.component, queue.poll());
}
this.componentManager.sendPacket(this.component, packet);
} else {
}
else {
queue.add(packet);
logger.log(Level.FINE, "jabberendpoint.sendpacketenqueue", packet.getFrom());
}
}
/** The backlog queue. */
private final ConcurrentLinkedQueue<Packet> queue = new ConcurrentLinkedQueue<Packet>();
......
......@@ -14,10 +14,9 @@ package org.jivesoftware.wildfire.gateway;
* {@code SessionFactory} is used to generate a new {@code GatewaySession}.
*
* @author Noah Campbell
* @version 1.0
*/
public interface SessionFactory {
/**
* Return a new instance of a {@code GatewaySession}.
*
......@@ -25,4 +24,5 @@ public interface SessionFactory {
* @return gatewaySession The gateway session.
*/
public GatewaySession newInstance(SubscriptionInfo info);
}
\ No newline at end of file
}
......@@ -10,8 +10,6 @@
package org.jivesoftware.wildfire.gateway;
import java.io.Serializable;
import org.xmpp.packet.JID;
/**
......@@ -22,8 +20,8 @@ import org.xmpp.packet.JID;
*
* @author Noah Campbell
*/
public class SubscriptionInfo implements Serializable {
public class SubscriptionInfo {
/**
* Construct a new <code>SubscriptionInfo</code>
* @param username The username
......@@ -33,27 +31,27 @@ public class SubscriptionInfo implements Serializable {
this.username = username;
this.password = password;
}
/**
* Has the session been registered on the client?
*/
public boolean clientRegistered;
/**
* Has the server registered with the client?
*/
public boolean serverRegistered;
/**
* The username.
*/
public String username;
/**
* The password.
*/
public String password;
/**
* The jid.
*
......@@ -61,4 +59,4 @@ public class SubscriptionInfo implements Serializable {
*/
public transient JID jid;
}
\ No newline at end of file
}
......@@ -24,6 +24,7 @@ import org.xmpp.packet.Packet;
* @author Daniel Henninger
*/
public class OSCARGateway extends BaseGateway {
/* Gateway Name String */
private static String NameString = "oscar";
......@@ -69,4 +70,5 @@ public class OSCARGateway extends BaseGateway {
Log.debug("Getting session instance");
return new OSCARGatewaySession(info, this);
}
}
/**
* $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.protocols.oscar;
import java.util.ArrayList;
......
......@@ -29,20 +29,12 @@ import ymsg.network.event.SessionNotifyEvent;
* for the ymsg9 library.
*
* @author Noah Campbell
* @version 1.0
*/
public class NoopSessionListener implements SessionListener {
/** The logger. @see java.util.logging.Logger */
private static final Logger logger = Logger.getLogger("NoopSessionListener");
/**
* @see ymsg.network.event.SessionListener#fileTransferReceived(ymsg.network.event.SessionFileTransferEvent)
*/
/**
* @see ymsg.network.event.SessionListener#fileTransferReceived(ymsg.network.event.SessionFileTransferEvent)
*/
/**
* @see ymsg.network.event.SessionListener#fileTransferReceived(ymsg.network.event.SessionFileTransferEvent)
*/
......@@ -55,7 +47,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void connectionClosed(SessionEvent arg0) {
logger.info(arg0.toString());
}
/**
......@@ -63,7 +54,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void listReceived(SessionEvent arg0) {
logger.info(arg0.toString());
}
/**
......@@ -71,7 +61,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void messageReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -79,7 +68,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void buzzReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -87,7 +75,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void offlineMessageReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -95,7 +82,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void errorPacketReceived(SessionErrorEvent arg0) {
logger.severe(arg0.toString());
}
/**
......@@ -111,7 +97,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void newMailReceived(SessionNewMailEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -119,7 +104,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void notifyReceived(SessionNotifyEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -127,7 +111,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void contactRequestReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -135,7 +118,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void contactRejectionReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -143,7 +125,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void conferenceInviteReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -151,7 +132,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void conferenceInviteDeclinedReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -159,18 +139,13 @@ public class NoopSessionListener implements SessionListener {
*/
public void conferenceLogonReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#conferenceLogoffReceived(ymsg.network.event.SessionConferenceEvent)
*/
/**
* @see ymsg.network.event.SessionListener#conferenceLogoffReceived(ymsg.network.event.SessionConferenceEvent)
*/
public void conferenceLogoffReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -178,7 +153,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void conferenceMessageReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -186,7 +160,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void friendsUpdateReceived(SessionFriendEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -194,7 +167,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void friendAddedReceived(SessionFriendEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -202,7 +174,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void friendRemovedReceived(SessionFriendEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -210,7 +181,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void chatLogonReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -218,7 +188,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void chatLogoffReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -226,7 +195,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void chatMessageReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -234,7 +202,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void chatUserUpdateReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
}
/**
......@@ -242,6 +209,6 @@ public class NoopSessionListener implements SessionListener {
*/
public void chatConnectionClosed(SessionEvent arg0) {
logger.finest(arg0.toString());
}
}
......@@ -24,19 +24,12 @@ import ymsg.network.YahooUser;
/**
* @author Noah Campbell
* @version 1.0
*/
public class YahooForeignContact extends AbstractForeignContact {
/** The serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The yahoo user. */
final private YahooUser user;
/**
* Construct a new <code>YahooForeignContact</code>.
* @param user A YahooUser
......@@ -57,7 +50,6 @@ public class YahooForeignContact extends AbstractForeignContact {
}
/**
* @param user2
* @return
......@@ -65,39 +57,69 @@ public class YahooForeignContact extends AbstractForeignContact {
private Status getStatusMessage(YahooUser user2, Status status) {
long id = user2.getStatus();
status.setOnline(true);
if( StatusConstants.STATUS_AVAILABLE == id) { status.updateValue( resource.getString("STATUS_AVAILABLE" ));
} else if( StatusConstants.STATUS_BRB == id) { status.updateValue( resource.getString("STATUS_BRB " ));
} else if( StatusConstants.STATUS_BUSY == id) { status.updateValue( resource.getString("STATUS_BUSY" ));
} else if( StatusConstants.STATUS_NOTATHOME == id) { status.updateValue( resource.getString("STATUS_NOTATHOME" ));
} else if( StatusConstants.STATUS_NOTATDESK == id) { status.updateValue( resource.getString("STATUS_NOTATDESK" ));
} else if( StatusConstants.STATUS_NOTINOFFICE == id) { status.updateValue( resource.getString("STATUS_NOTINOFFICE" ));
} else if( StatusConstants.STATUS_ONPHONE == id) { status.updateValue( resource.getString("STATUS_ONPHONE" ));
} else if( StatusConstants.STATUS_ONVACATION == id) { status.updateValue( resource.getString("STATUS_ONVACATION" ));
} else if( StatusConstants.STATUS_OUTTOLUNCH == id) { status.updateValue( resource.getString("STATUS_OUTTOLUNCH" ));
} else if( StatusConstants.STATUS_STEPPEDOUT == id) { status.updateValue( resource.getString("STATUS_STEPPEDOUT" ));
} else if( StatusConstants.STATUS_INVISIBLE == id) { status.updateValue( resource.getString("STATUS_INVISIBLE" ));
} else if( StatusConstants.STATUS_BAD == id) { status.updateValue( resource.getString("STATUS_BAD" )); // Bad login?
} else if( StatusConstants.STATUS_LOCKED == id) { status.updateValue( resource.getString("STATUS_LOCKED" )); // You've been naughty
} else if( StatusConstants.STATUS_CUSTOM == id) { status.updateValue( user.getCustomStatusMessage() );
} else if( StatusConstants.STATUS_IDLE == id) { status.updateValue( resource.getString("STATUS_IDLE" ));
} else if( StatusConstants.STATUS_OFFLINE == id) { status.setOnline(false);
} else if( StatusConstants.STATUS_TYPING == id) { status.updateValue( resource.getString("STATUS_TYPING" ));
} else {
logger.log(Level.WARNING, "yahooforeigncontact.unabletolocatestatus");
status.updateValue( "????" );
if (StatusConstants.STATUS_AVAILABLE == id) {
status.updateValue(resource.getString("STATUS_AVAILABLE"));
}
else if (StatusConstants.STATUS_BRB == id) {
status.updateValue(resource.getString("STATUS_BRB"));
}
else if (StatusConstants.STATUS_BUSY == id) {
status.updateValue(resource.getString("STATUS_BUSY"));
}
else if (StatusConstants.STATUS_NOTATHOME == id) {
status.updateValue(resource.getString("STATUS_NOTATHOME"));
}
else if (StatusConstants.STATUS_NOTATDESK == id) {
status.updateValue(resource.getString("STATUS_NOTATDESK"));
}
else if (StatusConstants.STATUS_NOTINOFFICE == id) {
status.updateValue(resource.getString("STATUS_NOTINOFFICE"));
}
else if (StatusConstants.STATUS_ONPHONE == id) {
status.updateValue(resource.getString("STATUS_ONPHONE"));
}
else if (StatusConstants.STATUS_ONVACATION == id) {
status.updateValue(resource.getString("STATUS_ONVACATION"));
}
else if (StatusConstants.STATUS_OUTTOLUNCH == id) {
status.updateValue(resource.getString("STATUS_OUTTOLUNCH"));
}
else if (StatusConstants.STATUS_STEPPEDOUT == id) {
status.updateValue(resource.getString("STATUS_STEPPEDOUT"));
}
else if (StatusConstants.STATUS_INVISIBLE == id) {
status.updateValue(resource.getString("STATUS_INVISIBLE"));
else if (StatusConstants.STATUS_BAD == id) {
status.updateValue(resource.getString("STATUS_BAD")); // Bad login?
}
else if (StatusConstants.STATUS_LOCKED == id) {
status.updateValue(resource.getString("STATUS_LOCKED")); // You've been naughty
}
else if (StatusConstants.STATUS_CUSTOM == id) {
status.updateValue(user.getCustomStatusMessage());
}
else if (StatusConstants.STATUS_IDLE == id) {
status.updateValue(resource.getString("STATUS_IDLE"));
}
else if (StatusConstants.STATUS_OFFLINE == id) {
status.setOnline(false);
}
else if (StatusConstants.STATUS_TYPING == id) {
status.updateValue(resource.getString("STATUS_TYPING"));
}
else {
logger.log(Level.WARNING, "yahooforeigncontact.unabletolocatestatus");
status.updateValue("????");
}
return status;
}
/** The logger. */
final static private Logger logger = Logger.getLogger("yahooforeigncontact",
"gateway_i18n");
/** The resource. */
private static ResourceBundle resource = PropertyResourceBundle.getBundle("yahoostatus");
......
......@@ -22,14 +22,12 @@ import org.xmpp.packet.Packet;
/**
* @author Noah Campbell
* @version 1.0
*/
public class YahooGateway extends BaseGateway {
public class YahooGateway extends BaseGateway {
/** The YAHOO. */
private static String YAHOO = "yahoo";
/**
* @see org.jivesoftware.wildfire.gateway.BaseGateway#getName()
*/
......@@ -53,8 +51,7 @@ public class YahooGateway extends BaseGateway {
public String getDescription() {
return "Yahoo! Gateway (ymsg9)";
}
/** The logger. @see java.util.logging.Logger */
static public final Logger logger = Logger.getLogger("YahooGateway");
......@@ -101,4 +98,5 @@ public class YahooGateway extends BaseGateway {
protected GatewaySession getSessionInstance(SubscriptionInfo info) {
return new YahooGatewaySession(info, this);
}
}
......@@ -47,29 +47,24 @@ import ymsg.network.YahooUser;
* Manages the session to the underlying legacy system.
*
* @author Noah Campbell
* @version 1.0
*/
public class YahooGatewaySession extends AbstractGatewaySession implements Endpoint {
/** The serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The logger. */
private static Logger logger = Logger.getLogger("YahooGatewaySession", "gateway_i18n");
/**
* Yahoo Session
*/
public final Session session;
/**
* The JID associated with this session.
*
* @see org.xmpp.packet.JID
*/
private final JID jid; // JID associated with this session
/**
* Initialize a new session object for Yahoo!
*
......@@ -79,23 +74,20 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
public YahooGatewaySession(SubscriptionInfo info, Gateway gateway) {
super(info, gateway);
this.jid = info.jid;
session = new Session();
session.addSessionListener(new YahooSessionListener(this));
}
/** The attemptingLogin. */
private boolean attemptingLogin = false;
/** The loginFailed. */
private boolean loginFailed = false;
/** The loginFailedCount. */
private int loginFailedCount = 0;
/**
* Manage presense information.
*/
......@@ -148,7 +140,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
* @throws Exception
*/
public synchronized void login() throws Exception {
if(!isConnected() && !loginFailed && !attemptingLogin) {
if (!isConnected() && !loginFailed && !attemptingLogin) {
attemptingLogin = true;
new Thread() {
@Override
......@@ -163,26 +155,26 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
logger.log(Level.INFO, "yahoogatewaysession.login", new Object[]{jid, getSubscriptionInfo().username});
getJabberEndpoint().getValve().open(); // allow any buffered messages to pass through
// updatePresence();
} catch (LoginRefusedException lre) {
}
catch (LoginRefusedException lre) {
session.reset();
if( loginFailedCount++ > 3) {
if (loginFailedCount++ > 3) {
loginFailed = true;
}
logger.warning("Login failed for " + getSubscriptionInfo().username);
} catch (IOException ioe) {
}
catch (IOException ioe) {
ioe.printStackTrace();
}
attemptingLogin = false;
}
}.run(); // intentionally not forked.
} else {
}
else {
logger.warning(this.jid + " is already logged in");
}
}
/**
* Is the connection connected?
* @return connected is the session connected?
......@@ -190,7 +182,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
public boolean isConnected() {
return session.getSessionStatus() == Session.MESSAGING;
}
/**
* Logout from Yahoo!
* @throws Exception
......@@ -200,12 +192,14 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
session.logout();
session.reset();
}
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString() { return "[" + this.getSubscriptionInfo().username + " CR:" + clientRegistered + " SR:" + serverRegistered + "]"; }
public String toString() {
return "[" + this.getSubscriptionInfo().username + " CR:" + clientRegistered + " SR:" + serverRegistered + "]";
}
/**
* Return the id of this session as a <code>String</code>.
......@@ -224,7 +218,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
public List<ForeignContact> getContacts() {
Map users = session.getUsers();
ArrayList<ForeignContact> contacts = new ArrayList<ForeignContact>(users.size());
for(YahooUser user : (Collection<YahooUser>)session.getUsers().values()) {
for (YahooUser user : (Collection<YahooUser>)session.getUsers().values()) {
contacts.add(new YahooForeignContact(user, this.gateway));
}
return contacts;
......@@ -255,12 +249,12 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
* @return String status of JID
*/
public String getStatus(JID to) {
Map table = this.session.getUsers();
if(isConnected() && table != null && to.getNode() != null && table.containsKey(to.getNode())) {
if (isConnected() && table != null && to.getNode() != null && table.containsKey(to.getNode())) {
YahooUser user = this.session.getUser(to.getNode());
return user.getCustomStatusMessage();
} else {
}
else {
return null;
}
}
......@@ -294,11 +288,12 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
*/
public void sendPacket(Packet packet) {
logger.log(Level.FINE, packet.toString());
if(packet instanceof Message) {
if (packet instanceof Message) {
Message m = (Message)packet;
try {
session.sendMessage(packet.getTo().getNode(), m.getBody());
} catch (IOException ioe) {
}
catch (IOException ioe) {
logger.warning(ioe.getLocalizedMessage());
}
}
......@@ -309,9 +304,10 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
*/
public ForeignContact getContact(JID to) throws UnknownForeignContactException {
String node = to.getNode();
if(node == null || node.length() == 0) throw new UnknownForeignContactException("invalidnode", node.toString());
if (node == null || node.length() == 0) throw new UnknownForeignContactException("invalidnode", node.toString());
YahooUser user = session.getUser(node);
if(user == null) throw new UnknownForeignContactException("invaliduser");
if (user == null) throw new UnknownForeignContactException("invaliduser");
return new YahooForeignContact(session.getUser(to.getNode()), this.gateway);
}
}
......@@ -27,7 +27,6 @@ import ymsg.network.event.SessionNewMailEvent;
* api.
*
* @author Noah Campbell
* @version 1.0
*/
public class YahooSessionListener extends NoopSessionListener {
......@@ -35,10 +34,10 @@ public class YahooSessionListener extends NoopSessionListener {
* Gateway session associated with this listener.
*/
private YahooGatewaySession gatewaySession;
/** The logger. */
private static final Logger logger = Logger.getLogger("YahooSessionListener");
/**
* Creates a YahooSessionListener that will translate events from the Yahoo!
* connection into XMPP formated packets.
......@@ -61,7 +60,8 @@ public class YahooSessionListener extends NoopSessionListener {
message.setBody("New Mail Received (" + snme.getMailCount() + ")");
message.setType(Message.Type.headline);
gatewaySession.getJabberEndpoint().sendPacket(message);
} catch (Exception e) {
}
catch (Exception e) {
logger.severe("Unable to send message: " + e.getLocalizedMessage());
}
}
......@@ -81,7 +81,8 @@ public class YahooSessionListener extends NoopSessionListener {
message.setFrom(this.gatewaySession.getGateway().whois(sessionEvent.getFrom()));
gatewaySession.getJabberEndpoint().sendPacket(message);
logger.fine(message.getElement().asXML());
} catch (Exception e) {
}
catch (Exception e) {
logger.severe("unable to send message: "+ e.getLocalizedMessage());
}
}
......@@ -93,12 +94,12 @@ public class YahooSessionListener extends NoopSessionListener {
public void friendsUpdateReceived(SessionFriendEvent event) {
try {
updateStatus(event);
} catch (Exception e) {
}
catch (Exception e) {
logger.log(Level.SEVERE, "yahoosessionlistener.friendupdateerror", e.getLocalizedMessage());
}
}
/**
* Update a friends status.
*
......@@ -125,7 +126,8 @@ public class YahooSessionListener extends NoopSessionListener {
message.setBody(sessionEvent.getMessage());
message.setFrom(this.gatewaySession.getGateway().whois(sessionEvent.getFrom()));
gatewaySession.getJabberEndpoint().sendPacket(message);
} catch (Exception e) {
}
catch (Exception e) {
logger.severe("unable to send message: "+ e.getLocalizedMessage());
}
}
......@@ -155,7 +157,5 @@ public class YahooSessionListener extends NoopSessionListener {
// TODO Auto-generated method stub
super.friendRemovedReceived(arg0);
}
}
......@@ -11,7 +11,6 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.IOException;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.HashSet;
import java.util.Set;
......@@ -24,14 +23,9 @@ import org.xmpp.packet.JID;
* All maintanence information pretaining to a gateway user.
*
* @author Noah Campbell
* @version 1.0
*/
public abstract class AbstractForeignContact implements Serializable, ForeignContact {
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
public abstract class AbstractForeignContact implements ForeignContact {
/**
* The id for this contact. This maps directly to the legacy userid.
*/
......@@ -43,38 +37,38 @@ public abstract class AbstractForeignContact implements Serializable, ForeignCon
* @see Status
*/
public final Status status;
/**
* The jid associated with this foreign contact.
*
* @see JID
*/
private transient JID jid;
/**
* The gatewayDomain.
*/
private final String gatewayDomain;
/**
* The gatewayName.
*/
private final String gatewayName;
/**
* The associatedSessions that are currently active for this <code>ForeignContact</code>.
*
* @see java.util.Set
*/
private transient Set<GatewaySession> associatedSessions = new HashSet<GatewaySession>();
/**
* The format for a JID
*
* @see java.text.MessageFormat
*/
private static final MessageFormat mf = new MessageFormat("{0}@{1}.{2}");
/**
* Create a ForeignContact relating to the gateway it originated from.
*
......@@ -93,12 +87,12 @@ public abstract class AbstractForeignContact implements Serializable, ForeignCon
* @see org.jivesoftware.wildfire.gateway.roster.ForeignContact#getJid()
*/
public JID getJid() {
if(jid == null) {
if (jid == null) {
jid = new JID(mf.format(new Object[]{id, gatewayName, gatewayDomain}));
}
return jid;
}
/**
* @param in
* @throws IOException
......@@ -110,28 +104,28 @@ public abstract class AbstractForeignContact implements Serializable, ForeignCon
associatedSessions = new HashSet<GatewaySession>();
getJid();
}
/**
* @see org.jivesoftware.wildfire.gateway.roster.ForeignContact#addSession(org.jivesoftware.wildfire.gateway.GatewaySession)
*/
public void addSession(GatewaySession session) {
associatedSessions.add(session);
}
/**
* @see org.jivesoftware.wildfire.gateway.roster.ForeignContact#removeSession(org.jivesoftware.wildfire.gateway.GatewaySession)
*/
public void removeSession(GatewaySession session) {
associatedSessions.remove(session);
}
/**
* @see org.jivesoftware.wildfire.gateway.roster.ForeignContact#isConnected()
*/
public boolean isConnected() {
boolean connected = true;
for(GatewaySession session : associatedSessions) {
if(!session.isConnected()) {
for (GatewaySession session : associatedSessions) {
if (!session.isConnected()) {
connected = false;
break;
}
......@@ -144,10 +138,11 @@ public abstract class AbstractForeignContact implements Serializable, ForeignCon
*/
@Override
public boolean equals(Object obj) {
if(obj instanceof AbstractForeignContact) {
if (obj instanceof AbstractForeignContact) {
AbstractForeignContact fc = (AbstractForeignContact)obj;
return fc.id.equalsIgnoreCase(this.id);
} else {
}
else {
return super.equals(obj);
}
}
......@@ -167,7 +162,5 @@ public abstract class AbstractForeignContact implements Serializable, ForeignCon
public String toString() {
return "Foreign Contact: " + this.getJid() + "[Gateway: " + this.gatewayName + ", Connected: " + isConnected() + "]";
}
}
......@@ -10,7 +10,6 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
......@@ -24,31 +23,26 @@ import org.xmpp.packet.JID;
*
* @author Noah Campbell
*/
public class ContactManager implements Serializable {
public class ContactManager {
/**
* Construct a new <code>ContactManager</code>
*/
ContactManager() { }
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* The fcs
*
* @see java.util.Set
*/
private final Set<AbstractForeignContact> fcs = new HashSet<AbstractForeignContact>();
/**
* Maintain a mapping of JIDs to their contact list.
*/
private final Map<NormalizedJID, Roster> contactLists =
new HashMap<NormalizedJID, Roster>();
/**
* Return a roster for a JID.
*
......@@ -57,14 +51,14 @@ public class ContactManager implements Serializable {
*/
public synchronized Roster getRoster(JID name) {
Roster r = contactLists.get(NormalizedJID.wrap(name));
if(r == null) {
if (r == null) {
r = new Roster();
contactLists.put(NormalizedJID.wrap(name), r);
}
return r;
}
/**
* @return foreignContacts A {@code java.util.Set} of {@code ForeignContact}s.
*/
......@@ -72,7 +66,6 @@ public class ContactManager implements Serializable {
return this.fcs;
}
/**
* Remove the <code>JID</code> from the contact list.
*
......@@ -81,4 +74,5 @@ public class ContactManager implements Serializable {
void remove(NormalizedJID jid) {
contactLists.remove(jid);
}
}
......@@ -15,7 +15,6 @@ import org.xmpp.packet.JID;
/**
* @author Noah Campbell
* @version 1.0
*/
public interface ForeignContact {
......@@ -46,16 +45,14 @@ public interface ForeignContact {
* @return connected
*/
public boolean isConnected();
/**
* Return the translated status for the contact.
*
* @return Status
*/
public Status getStatus();
/**
* Return the name of the contact.
*
......
......@@ -10,23 +10,18 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.xmpp.packet.JID;
/**
* @author Noah Campbell
*
*/
/**
* Ignore the resource portion of the JID.
*
* @author Noah Campbell
*
*/
public final class NormalizedJID implements Serializable {
public final class NormalizedJID {
/**
* The JID.
......@@ -34,18 +29,13 @@ public final class NormalizedJID implements Serializable {
* @see JID
*/
public final String JID;
/**
* The toStringValue. Stored to increase efficiency.
*
* @see NormalizedJID
*/
private final String toStringValue;
/**
* The serialVersionUID.
*/
private static final long serialVersionUID = 1L;
/**
* Construct a new <code>NormalizedJID</code>
......@@ -55,28 +45,30 @@ public final class NormalizedJID implements Serializable {
JID = jid.toBareJID();
toStringValue = JID + " (normalized)";
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if(obj instanceof NormalizedJID) {
if (obj instanceof NormalizedJID) {
NormalizedJID jid = (NormalizedJID)obj;
return JID.equalsIgnoreCase(jid.JID);
} else if(obj instanceof JID) {
}
else if (obj instanceof JID) {
JID jid = new JID( ((JID)obj).toBareJID() );
return JID.equalsIgnoreCase(jid.toBareJID());
} else if( obj instanceof String) {
}
else if (obj instanceof String) {
JID jid = new JID((String)obj);
jid = new JID(jid.toBareJID());
return JID.equalsIgnoreCase(jid.toBareJID());
} else {
}
else {
return super.equals(obj);
}
}
/**
* @see java.lang.Object#hashCode()
*/
......@@ -84,7 +76,7 @@ public final class NormalizedJID implements Serializable {
public int hashCode() {
return JID.hashCode();
}
/**
* Wrap a <code>JID</code> and return a <code>NormalizedJID</code>. If the
* <code>JID</code> has already been wrapped, then the cached version is returned.
......@@ -93,15 +85,16 @@ public final class NormalizedJID implements Serializable {
* @return normalizedJID
*/
public static NormalizedJID wrap(JID jid) {
if(cache.containsKey(jid)) {
if (cache.containsKey(jid)) {
return cache.get(jid);
} else {
}
else {
NormalizedJID nJID = new NormalizedJID(jid);
cache.put(jid, nJID);
return nJID;
}
}
/**
* @see java.lang.Object#toString()
*/
......@@ -109,12 +102,12 @@ public final class NormalizedJID implements Serializable {
public String toString() {
return toStringValue;
}
/**
* The cache of <code>NormailzedJID</code>s.
*
* @see java.util.Map
*/
private transient static final Map<JID, NormalizedJID> cache = new ConcurrentHashMap<JID, NormalizedJID>();
}
......@@ -15,7 +15,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
......@@ -46,22 +45,22 @@ import org.xmpp.packet.JID;
* @author Noah Campbell
*
*/
public class PersistenceManager implements Serializable {
public class PersistenceManager {
/**
* The contactManager.
*
* @see ContactManager
*/
private ContactManager contactManager = null;
/**
* The registrar.
*
* @see Registrar
*/
private Registrar registrar = null;
/**
* The gateway.
*
......@@ -69,13 +68,14 @@ public class PersistenceManager implements Serializable {
*/
@SuppressWarnings("unused")
private Gateway gateway;
/**
* Factory for accessing the various RosterManagers.
*
* @author Noah Campbell
*/
public final static class Factory {
/**
* The <code>PersistanceManager</code> associated with a particular
* <code>Gateway</code>
......@@ -84,7 +84,7 @@ public class PersistenceManager implements Serializable {
*/
private final static Map<Gateway, PersistenceManager> instances =
new HashMap<Gateway, PersistenceManager>();
/**
* Given a <code>Gateway</code> return a <code>PersistenceManager</code>
* @param gateway
......@@ -99,12 +99,12 @@ public class PersistenceManager implements Serializable {
}
return rm;
}
}
/** The db file. */
private final File db;
/**
* Construct a new <code>PersistanceManager</code>.
*
......@@ -117,8 +117,7 @@ public class PersistenceManager implements Serializable {
timer.scheduleAtFixedRate(archiver, 5, 5, TimeUnit.SECONDS);
}
/**
* Unregister a JID.
* @param jid
......@@ -129,17 +128,17 @@ public class PersistenceManager implements Serializable {
NormalizedJID njid = NormalizedJID.wrap(jid);
contactManager.remove(njid);
registrar.remove(jid);
} catch (Exception e) {
}
catch (Exception e) {
logger.severe("Unable to remove " + bareJID + ": " + e.getLocalizedMessage());
}
}
/**
* Load the roster manager (we simply read a binary file from the file system).
* @param gateway
*/
private void load(Gateway gateway) {
ContactManager contactManager = null;
Registrar registrar = null;
try {
......@@ -149,7 +148,7 @@ public class PersistenceManager implements Serializable {
*/
byte[] rawKey = Preferences.systemNodeForPackage(this.getClass()).getByteArray(".key", null);
if(rawKey == null) {
if (rawKey == null) {
logger.log(GatewayLevel.SECURITY, "persistencemanager.nokey");
return;
}
......@@ -164,38 +163,34 @@ public class PersistenceManager implements Serializable {
contactManager = (ContactManager)is.readObject() ;
registrar = (Registrar) is.readObject() ;
is.close();
} catch (Exception e) {
if(db.exists()) {
}
catch (Exception e) {
if (db.exists()) {
db.delete();
}
logger.log(Level.WARNING, "persistencemanager.loadrosterfailed",e);
} finally {
}
finally {
this.contactManager = (contactManager != null) ? contactManager : new ContactManager();
this.registrar = (registrar != null) ? registrar : new Registrar();
this.registrar.setGateway(gateway); // re-vitialize the registrar.
}
}
/**
* A timer for executing tasks related to PersistanceManager.
*
* @see java.util.concurrent.ScheduledExecutorService
*/
private final ScheduledExecutorService timer = Executors.newScheduledThreadPool(1, new BackgroundThreadFactory());
/**
* The serialVersionUID.
*
* @see PersistenceManager
*/
private static final long serialVersionUID = 1L;
/**
* The logger.
*
* @see PersistenceManager
*/
private static final Logger logger = Logger.getLogger("PersistenceManager", "gateway_i18n");
/**
* Responsible for flushing the in-memory database.
*/
......@@ -203,32 +198,31 @@ public class PersistenceManager implements Serializable {
public void run() {
try {
store();
} catch (Exception e) {
}
catch (Exception e) {
logger.log(Level.WARNING, "persistencemanager.unabletoflush", e);
e.printStackTrace();
}
}
};
/**
* Write the contact manager and registrar to the file system.
*
* @throws Exception
*/
public synchronized void store() throws Exception {
Preferences prefs = Preferences.systemNodeForPackage(this.getClass());
byte[] rawKey = prefs.getByteArray(".key", null);
if(rawKey == null) {
if (rawKey == null) {
logger.log(GatewayLevel.SECURITY, "persistencemanager.gennewkey");
KeyGenerator kg = KeyGenerator.getInstance("AES");
SecretKey key = kg.generateKey();
rawKey = key.getEncoded();
prefs.putByteArray(".key", rawKey);
}
SecretKeySpec key = new SecretKeySpec(rawKey, "AES");
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.ENCRYPT_MODE, key);
......@@ -238,10 +232,8 @@ public class PersistenceManager implements Serializable {
oos.writeObject(registrar);
oos.flush();
oos.close();
}
/**
* @return Returns the contactManager.
*/
......@@ -249,7 +241,6 @@ public class PersistenceManager implements Serializable {
return contactManager;
}
/**
* @return Returns the registrar.
*/
......@@ -257,7 +248,6 @@ public class PersistenceManager implements Serializable {
return registrar;
}
/**
* @see java.lang.Object#finalize()
*/
......@@ -267,4 +257,5 @@ public class PersistenceManager implements Serializable {
this.timer.shutdownNow();
logger.log(Level.FINER, "persistencemanager.registrarFinalize");
}
}
......@@ -12,7 +12,6 @@ package org.jivesoftware.wildfire.gateway.roster;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
......@@ -29,23 +28,16 @@ import org.xmpp.packet.JID;
* legacy system and the XMPP Server.
*
* @author Noah Campbell
* @version 1.0
*/
public class Registrar implements Serializable {
/**
* The serialVersionUID.
*
* @see Registrar
*/
private static final long serialVersionUID = 1L;
public class Registrar {
/**
* Construct a new <code>Registrar</code>.
*/
Registrar() {
createSessionCache();
}
/**
* Initializes a new session cache
*/
......@@ -57,13 +49,14 @@ public class Registrar implements Serializable {
* GatewaySessions are maintained in the registration
*/
private final Map<NormalizedJID, SubscriptionInfo> registrar = new HashMap<NormalizedJID, SubscriptionInfo>();
/**
* The <code>GatewaySessions</code> mapped by <code>JID</code>
*
* @see java.util.Map
*/
private transient Map<JID, GatewaySession> sessions;
/**
* Determine if the JID is registered (based on the bare JID)
* @param id
......@@ -72,7 +65,7 @@ public class Registrar implements Serializable {
public boolean isRegistered(NormalizedJID id) {
return registrar.containsKey(id);
}
/**
* Add a JID to the registrar.
* @param id
......@@ -82,7 +75,7 @@ public class Registrar implements Serializable {
registrar.put(NormalizedJID.wrap(id), info);
//timer.scheduleAtFixedRate(info, 10, 10, TimeUnit.SECONDS);
}
/**
* Get the Session for a JID.
*
......@@ -92,10 +85,10 @@ public class Registrar implements Serializable {
*/
public GatewaySession getGatewaySession(JID jid) throws Exception {
SubscriptionInfo info = registrar.get(NormalizedJID.wrap(jid));
if(info == null) {
if (info == null) {
throw new IllegalStateException("Please register before attempting to get a session");
}
if(!sessions.containsKey(jid)) {
if (!sessions.containsKey(jid)) {
info.jid = jid;
GatewaySession session = this.gateway.getSessionFactory().newInstance(info);
......@@ -119,14 +112,14 @@ public class Registrar implements Serializable {
void setGateway(Gateway gateway) {
this.gateway = gateway;
}
/**
* The gateway.
*
* @see Gateway
*/
private transient Gateway gateway;
/**
* The logger.
*
......@@ -142,15 +135,16 @@ public class Registrar implements Serializable {
NormalizedJID wrapped = NormalizedJID.wrap(jid);
registrar.remove(wrapped);
GatewaySession session = sessions.get(jid);
if(session.isConnected()) {
if (session.isConnected()) {
try {
session.logout();
} catch (Exception e) {
}
catch (Exception e) {
// silently ignore
}
}
}
/**
* @param ois
* @throws IOException
......@@ -160,4 +154,5 @@ public class Registrar implements Serializable {
ois.defaultReadObject();
this.createSessionCache();
}
}
......@@ -10,7 +10,6 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
......@@ -23,19 +22,13 @@ import org.jivesoftware.wildfire.gateway.Gateway;
* to a particular <code>JID</code>
*
* @author Noah Campbell
* @version 1.0
*
* @see AbstractForeignContact
* @see org.xmpp.packet.JID
* @deprecated
*/
public class Roster implements Serializable {
/**
* The serialVersionUID.
*/
private static final long serialVersionUID = 1L;
public class Roster {
/**
* The foreignContacts.
*
......@@ -54,7 +47,6 @@ public class Roster implements Serializable {
* @return ForeignContact
*/
public ForeignContact getForeignContact(String foreignId, Gateway gateway) {
AbstractForeignContact fc = this.foreignContacts.get(foreignId);
if(fc == null) {
// fc = new ForeignContact(foreignId, new Status(), gateway);
......@@ -69,5 +61,5 @@ public class Roster implements Serializable {
public Collection<AbstractForeignContact> getAll() {
return Collections.unmodifiableCollection(this.foreignContacts.values());
}
}
......@@ -10,59 +10,58 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
/**
* Status object.
*
* @author Noah Campbell
*/
public final class Status implements Serializable {
/** The serialVersionUID. */
private static final long serialVersionUID = 1L;
public final class Status {
/** The subscribed. */
private boolean subscribed = false;
/** The online. */
private boolean online = false;
/** The value. */
private String value;
/**
* @return status a string representation of the status's state.
*/
public String getValue() { return value; }
/**
* @param value the new value of the status
*/
public void updateValue(String value) { this.value = value; }
/**
* @return Returns the subscribed.
*/
public boolean isSubscribed() {
return subscribed;
}
/**
* @param subscribed The subscribed to set.
*/
public void setSubscribed(boolean subscribed) {
this.subscribed = subscribed;
}
/**
* @return Returns the online.
*/
public boolean isOnline() {
return this.online;
}
/**
* @param online The online to set.
*/
public void setOnline(boolean online) {
this.online = online;
}
}
......@@ -21,7 +21,7 @@ public class UnknownForeignContactException extends Exception {
/** The args. */
private final Object[] args;
/**
* Constructs a new <code>UnknownForeignContactException</code>.
*/
......@@ -62,4 +62,5 @@ public class UnknownForeignContactException extends Exception {
super(cause);
args = new Object[0];
}
}
\ No newline at end of file
}
......@@ -19,10 +19,9 @@ import java.util.concurrent.ThreadFactory;
*/
public class BackgroundThreadFactory implements ThreadFactory {
/** The background thread group. */
private static ThreadGroup group = new ThreadGroup("background");
/**
* @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
*/
......@@ -33,5 +32,4 @@ public class BackgroundThreadFactory implements ThreadFactory {
return thread;
}
}
......@@ -24,6 +24,7 @@ import org.jivesoftware.util.PropertyEventDispatcher;
* @author Daniel Henninger
*/
public class GatewayInstance {
private ComponentManager componentManager;
private String serviceName = null;
private String nameOfClass = null;
......@@ -31,6 +32,13 @@ public class GatewayInstance {
private Boolean enabled = false;
private Boolean running = false;
/**
* Creates a new gateway instance.
*
* @param subdomain Part of gateway domain prepended to server domain.
* @param classname Full name/path of class associated with instance.
* @param componentManager Component manager managing this instance.
*/
public GatewayInstance(String subdomain, String classname, ComponentManager componentManager) {
this.serviceName = subdomain;
this.nameOfClass = classname;
......@@ -38,18 +46,36 @@ public class GatewayInstance {
enabled = JiveGlobals.getBooleanProperty("plugin.gateway."+serviceName+"Enabled", false);
}
/**
* Retrieves the name of the service (aka, subdomain)
*
* @return name of the service
*/
public String getName() {
return serviceName;
}
/**
* Returns whether this gateway instance is enabled.
*
* @return true or false if instance is enabled
*/
public Boolean isEnabled() {
return enabled;
}
/**
* Returns whether this gateway instance is currently running.
*
* @return true or false if instance is currently running
*/
public Boolean isRunning() {
return running;
}
/**
* Enables the gateway instance and starts it if it's not already running.
*/
public void enable() {
enabled = true;
JiveGlobals.setProperty("plugin.gateway."+serviceName+"Enabled", "true");
......@@ -58,6 +84,9 @@ public class GatewayInstance {
}
}
/**
* Disables the gateway instance and stops it if it's running.
*/
public void disable() {
enabled = false;
JiveGlobals.setProperty("plugin.gateway."+serviceName+"Enabled", "false");
......@@ -66,6 +95,9 @@ public class GatewayInstance {
}
}
/**
* Starts the gateway instance if it's enabled and not already running.
*/
public void startInstance() {
if (!enabled || running) {
return;
......@@ -101,6 +133,9 @@ public class GatewayInstance {
}
}
/**
* Stops the gateway instance if it's running.
*/
public void stopInstance() {
if (!running) {
return;
......@@ -117,4 +152,5 @@ public class GatewayInstance {
gateway = null;
running = false;
}
}
......@@ -20,10 +20,9 @@ import java.util.logging.Level;
*/
public class GatewayLevel extends Level {
/** SECURITY log level. */
public static final Level SECURITY = new GatewayLevel("SECURITY", 501);
/**
* Construct a new <code>GatewayLevel</code>.
*
......@@ -34,7 +33,4 @@ public class GatewayLevel extends Level {
super(name, value, "gateway_i18n");
}
/** The serialVersionUID. */
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
}
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