Commit 65559df0 authored by guus's avatar guus

* Updating 'sip' plugin to make use of SLF4J instead of custom logging (OF-53).

* Applied java generics.
* Removed unused code.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11448 b35dd754-fafc-0310-a699-88a17e54d16e
parent 74c0d766
......@@ -44,6 +44,14 @@
SIP Plugin Changelog
</h1>
<p><b>1.0.6</b> -- December 2, 2009</p>
<ul>
<li>Now requires Openfire 3.6.5.</li>
<li>Applied Java generics.</li>
<li>Removed unused code.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/OF-53'>OF-53</a>] - Replace custom logging implementation with a third party library.</li>
</ul>
<p><b>1.0.5</b> -- March 11, 2008</p>
<ul>
......
......@@ -5,11 +5,11 @@
<name>SIP Phone Plugin</name>
<description>Provides support for SIP account management</description>
<author>Ignite Realtime</author>
<version>1.0.5</version>
<date>11/14/2008</date>
<version>1.0.6</version>
<date>12/2/2009</date>
<databaseKey>sip</databaseKey>
<databaseVersion>2</databaseVersion>
<minServerVersion>3.6.0</minServerVersion>
<minServerVersion>3.6.5</minServerVersion>
<adminconsole>
<tab id="tab-server">
......
......@@ -32,6 +32,8 @@ import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.util.PropertyEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
......@@ -42,6 +44,8 @@ import org.xmpp.component.ComponentManagerFactory;
*/
public class SipManager implements Plugin, PropertyEventListener {
private static final Logger Log = LoggerFactory.getLogger(SipManager.class);
private String serviceName;
private ComponentManager componentManager;
......@@ -71,13 +75,13 @@ public class SipManager implements Plugin, PropertyEventListener {
componentManager.addComponent(serviceName, sipComponent);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
componentManager.addComponent(LogComponent.NAME, logComponent);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
PropertyEventDispatcher.addListener(this);
......@@ -91,12 +95,12 @@ public class SipManager implements Plugin, PropertyEventListener {
try {
componentManager.removeComponent(serviceName);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
componentManager.removeComponent(LogComponent.NAME);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
sipComponent = null;
......@@ -139,12 +143,12 @@ public class SipManager implements Plugin, PropertyEventListener {
try {
componentManager.removeComponent(this.serviceName);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
componentManager.addComponent(serviceName, sipComponent);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
this.serviceName = serviceName;
}
......
......@@ -20,9 +20,6 @@
package org.jivesoftware.openfire.sip.calllog;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -32,6 +29,10 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.jivesoftware.database.DbConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Database persistence for CallLog class and database methods for call log store
*
......@@ -39,6 +40,8 @@ import java.util.List;
*/
public class CallLogDAO {
private static final Logger Log = LoggerFactory.getLogger(CallLogDAO.class);
final static CallFilter emptyFilter = new CallFilter("", new ArrayList<String>());
/**
......@@ -82,21 +85,21 @@ public class CallLogDAO {
}
rs.close();
} catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
return calls;
......@@ -226,21 +229,21 @@ public class CallLogDAO {
}
rs.close();
} catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
return count;
......
......@@ -21,7 +21,8 @@
package org.jivesoftware.openfire.sip.log;
import org.dom4j.Element;
import org.jivesoftware.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentManager;
import org.xmpp.packet.IQ;
......@@ -36,6 +37,8 @@ import org.xmpp.packet.Packet;
*/
public class LogComponent implements Component{
private static final Logger Log = LoggerFactory.getLogger(LogComponent.class);
ComponentManager componentManager = null;
private LogListener logListener = null;
......@@ -109,7 +112,7 @@ public class LogComponent implements Component{
try {
componentManager.sendPacket(this, reply);
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
} // Other Methods
......
......@@ -28,6 +28,8 @@ import org.jivesoftware.openfire.sip.calllog.CallLog;
import org.jivesoftware.openfire.sip.calllog.CallLogDAO;
import org.jivesoftware.openfire.sip.calllog.CallLogExtension;
import org.jivesoftware.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.ComponentManager;
import org.xmpp.packet.IQ;
......@@ -39,6 +41,8 @@ import org.xmpp.packet.IQ;
*/
public class LogListenerImpl implements LogListener {
private static final Logger Log = LoggerFactory.getLogger(LogListenerImpl.class);
ComponentManager componentManager = null;
public LogListenerImpl(ComponentManager componentmanager) {
......@@ -74,7 +78,7 @@ public class LogListenerImpl implements LogListener {
try {
CallLogDAO.insert(callLog);
} catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......
......@@ -20,9 +20,6 @@
package org.jivesoftware.openfire.sip.sipaccount;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -31,6 +28,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.jivesoftware.database.DbConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Database persistence for SipAccount class and database methods for stored SIP Accounts
......@@ -39,6 +40,8 @@ import java.util.List;
*/
public class SipAccountDAO {
private static final Logger Log = LoggerFactory.getLogger(SipAccountDAO.class);
public static SipAccount getAccountByUser(String username) {
String sql = "SELECT username, sipusername, sipauthuser, sipdisplayname, sippassword, sipserver, enabled, " +
......@@ -229,21 +232,21 @@ public class SipAccountDAO {
}
rs.close();
} catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
return sipAccounts;
......@@ -266,13 +269,13 @@ public class SipAccountDAO {
rs.close();
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
finally {
try { if (pstmt != null) { pstmt.close(); } }
catch (Exception e) { Log.error(e); }
catch (Exception e) { Log.error(e.getMessage(), e); }
try { if (con != null) { con.close(); } }
catch (Exception e) { Log.error(e); }
catch (Exception e) { Log.error(e.getMessage(), e); }
}
return count;
}
......
......@@ -26,7 +26,8 @@ import org.dom4j.Element;
import org.jivesoftware.openfire.event.SessionEventDispatcher;
import org.jivesoftware.openfire.event.SessionEventListener;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
......@@ -43,6 +44,8 @@ import org.xmpp.packet.PacketError;
*/
public class SipComponent implements Component, SessionEventListener {
private static final Logger Log = LoggerFactory.getLogger(SipComponent.class);
ComponentManager componentManager = null;
/**
......@@ -140,7 +143,7 @@ public class SipComponent implements Component, SessionEventListener {
SipAccountDAO.update(sipAccount);
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -156,7 +159,7 @@ public class SipComponent implements Component, SessionEventListener {
componentManager.sendPacket(this, reply);
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
Log.debug("PACKET SENT: " + reply.toXML());
} // Other Methods
......@@ -200,7 +203,7 @@ public class SipComponent implements Component, SessionEventListener {
SipAccountDAO.update(sipAccount);
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
......
......@@ -35,7 +35,7 @@ import java.util.Hashtable;
class CredentialsCache {
// Contains call->realms mappings
private Hashtable authenticatedRealms = new Hashtable();
private Hashtable<String, CredentialsCacheEntry> authenticatedRealms = new Hashtable<String, CredentialsCacheEntry>();
/**
* Cache credentials for the specified call and realm
......
......@@ -40,7 +40,7 @@ class CredentialsCacheEntry {
* not reached this class). The transactionHistory's elements are Strings
* corresponding to branch ids.
*/
private Vector transactionHistory = new Vector();
private Vector<String> transactionHistory = new Vector<String>();
/**
* Adds the specified branch id to the transaction history list.
......
......@@ -53,7 +53,7 @@ class RegisterProcessing {
private Timer reRegisterTimer = null;
private int keepAlivePort = 0;
//private int keepAlivePort = 0;
private Timer keepAliveTimer = null;
......@@ -242,7 +242,7 @@ class RegisterProcessing {
}
// User Agent Header
UserAgentHeader uaHeader = null;
ArrayList userAgentList = new ArrayList();
ArrayList<String> userAgentList = new ArrayList<String>();
userAgentList.add(SIPConfig.getStackName());
try {
......
......@@ -39,7 +39,7 @@ import java.util.List;
public class SIPTest implements CommunicationsListener {
private SipAccount sipAccount;
private InetAddress localAddress;
//private InetAddress localAddress;
private Result result = null;
private SipManager sipManager = null;
private List<TestListener> listeners = new ArrayList<TestListener>();
......@@ -52,7 +52,7 @@ public class SIPTest implements CommunicationsListener {
public SIPTest(InetAddress localAddress, SipAccount sipAccount) {
this.sipAccount = sipAccount;
this.localAddress = localAddress;
//this.localAddress = localAddress;
sipManager = new SipManager(localAddress);
}
......@@ -93,25 +93,25 @@ public class SIPTest implements CommunicationsListener {
sipManager.startRegisterProcess(sipAccount.getSipUsername(), sipAccount.getAuthUsername(), sipAccount.getPassword());
} catch (CommunicationsException e) {
setResult(Result.NetworkError);
Log.error(e);
Log.error(e.getMessage(), e);
}
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
if (getResult().equals(Result.Trying)) setResult(Result.Timeout);
} catch (CommunicationsException e) {
setResult(Result.NetworkError);
Log.error(e);
Log.error(e.getMessage(), e);
} finally {
try {
sipManager.stop();
} catch (CommunicationsException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -135,7 +135,7 @@ public class SIPTest implements CommunicationsListener {
try {
sipManager.unregister();
} catch (CommunicationsException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
......@@ -161,7 +161,7 @@ public class SIPTest implements CommunicationsListener {
sipManager.stop();
Log.debug("Stopped");
} catch (CommunicationsException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
......
......@@ -82,13 +82,13 @@ public class SipCommRouter implements Router {
*
* @param sipRequest is the sip request to route.
*/
public ListIterator getNextHops(Request sipRequest) {
public ListIterator<Hop> getNextHops(Request sipRequest) {
URI requestURI = sipRequest.getRequestURI();
if (requestURI == null) {
throw new IllegalArgumentException("Bad message: Null requestURI");
}
LinkedList hops = new LinkedList();
LinkedList<Hop> hops = new LinkedList<Hop>();
if (outboundProxy != null) {
hops.add(outboundProxy);
}
......
......@@ -77,7 +77,7 @@ public class SipManager implements SipListener {
protected int registrarPort = -1;
protected int registrationsExpiration = -1;
protected String registrarTransport = null;
private int registerRetries = 0;
//private int registerRetries = 0;
protected String stackAddress = null;
protected String stackName = "JiveSIP";
protected FromHeader fromHeader = null;
......@@ -102,7 +102,7 @@ public class SipManager implements SipListener {
this.localAddress = localAddress;
registerProcessing = new RegisterProcessing(this);
sipSecurityManager = new SipSecurityManager();
registerRetries = 0;
//registerRetries = 0;
}
/**
......@@ -258,8 +258,8 @@ public class SipManager implements SipListener {
if (sipStack != null) {
for (Iterator it = sipStack.getSipProviders(); it.hasNext();) {
SipProvider element = (SipProvider) it.next();
for (Iterator<SipProvider> it = sipStack.getSipProviders(); it.hasNext();) {
SipProvider element = it.next();
try {
sipStack.deleteSipProvider(element);
}
......@@ -580,7 +580,7 @@ public class SipManager implements SipListener {
* @throws CommunicationsException if a ParseException is to occur while initializing the array
* list.
*/
public ArrayList getLocalViaHeaders() throws CommunicationsException {
public ArrayList<ViaHeader> getLocalViaHeaders() throws CommunicationsException {
if (viaHeaders != null) {
return viaHeaders;
}
......@@ -739,7 +739,7 @@ public class SipManager implements SipListener {
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), 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