Commit 4e7c4762 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Replaced SimpleDateFormat with FastDateFormat. JM-360


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1747 b35dd754-fafc-0310-a699-88a17e54d16e
parent 227fab7b
...@@ -23,7 +23,6 @@ import java.io.StringReader; ...@@ -23,7 +23,6 @@ import java.io.StringReader;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
/** /**
...@@ -54,7 +53,7 @@ public class OfflineMessageStore extends BasicModule { ...@@ -54,7 +53,7 @@ public class OfflineMessageStore extends BasicModule {
"DELETE FROM jiveOffline WHERE username=? AND creationDate=?"; "DELETE FROM jiveOffline WHERE username=? AND creationDate=?";
private Cache sizeCache; private Cache sizeCache;
private SimpleDateFormat dateFormat; private FastDateFormat dateFormat;
/** /**
* Returns the instance of <tt>OfflineMessageStore</tt> being used by the XMPPServer. * Returns the instance of <tt>OfflineMessageStore</tt> being used by the XMPPServer.
...@@ -72,8 +71,7 @@ public class OfflineMessageStore extends BasicModule { ...@@ -72,8 +71,7 @@ public class OfflineMessageStore extends BasicModule {
*/ */
public OfflineMessageStore() { public OfflineMessageStore() {
super("Offline Message Store"); super("Offline Message Store");
dateFormat = new SimpleDateFormat("yyyyMMdd'T'hh:mm:ss"); dateFormat = FastDateFormat.getInstance("yyyyMMdd'T'hh:mm:ss", TimeZone.getTimeZone("UTC"));
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
sizeCache = new Cache("Offline Message Size Cache", 1024*100, JiveConstants.HOUR*12); sizeCache = new Cache("Offline Message Size Cache", 1024*100, JiveConstants.HOUR*12);
} }
......
...@@ -11,17 +11,20 @@ ...@@ -11,17 +11,20 @@
package org.jivesoftware.messenger.handler; package org.jivesoftware.messenger.handler;
import org.jivesoftware.messenger.disco.ServerFeaturesProvider;
import org.jivesoftware.messenger.IQHandlerInfo;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.messenger.IQHandlerInfo;
import org.jivesoftware.messenger.disco.ServerFeaturesProvider;
import org.jivesoftware.util.FastDateFormat;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import java.text.DateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.TimeZone;
/** /**
* Implements the TYPE_IQ jabber:iq:time protocol (time info) as * Implements the TYPE_IQ jabber:iq:time protocol (time info) as
* as defined by JEP-0090. Allows Jabber entities to query each * as defined by JEP-0090. Allows Jabber entities to query each
...@@ -47,11 +50,8 @@ public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider { ...@@ -47,11 +50,8 @@ public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider {
private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.MEDIUM); private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.MEDIUM);
private static final DateFormat TIME_FORMAT = DateFormat.getTimeInstance(DateFormat.LONG); private static final DateFormat TIME_FORMAT = DateFormat.getTimeInstance(DateFormat.LONG);
// UTC and not JEP-0082 time format is used as per the JEP-0090 specification. // UTC and not JEP-0082 time format is used as per the JEP-0090 specification.
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final FastDateFormat UTC_FORMAT = FastDateFormat
.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0"));
static {
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
}
private Element responseElement; private Element responseElement;
private IQHandlerInfo info; private IQHandlerInfo info;
...@@ -90,7 +90,7 @@ public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider { ...@@ -90,7 +90,7 @@ public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider {
return info; return info;
} }
public Iterator getFeatures() { public Iterator<String> getFeatures() {
return Collections.singleton("jabber:iq:time").iterator(); return Collections.singleton("jabber:iq:time").iterator();
} }
} }
\ No newline at end of file
...@@ -11,17 +11,17 @@ ...@@ -11,17 +11,17 @@
package org.jivesoftware.messenger.muc; package org.jivesoftware.messenger.muc;
import java.text.SimpleDateFormat; import org.dom4j.Element;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.FastDateFormat;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.TimeZone; import java.util.TimeZone;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.xmpp.packet.Message;
import org.xmpp.packet.JID;
import org.dom4j.Element;
/** /**
* Represent the data model for one <code>MUCRoom</code> history. Including chat transcript, * Represent the data model for one <code>MUCRoom</code> history. Including chat transcript,
* joining and leaving times. * joining and leaving times.
...@@ -30,10 +30,8 @@ import org.dom4j.Element; ...@@ -30,10 +30,8 @@ import org.dom4j.Element;
*/ */
public final class MUCRoomHistory { public final class MUCRoomHistory {
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final FastDateFormat UTC_FORMAT = FastDateFormat
static { .getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0"));
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
}
private MUCRoom room; private MUCRoom room;
......
...@@ -11,13 +11,6 @@ ...@@ -11,13 +11,6 @@
package org.jivesoftware.messenger.muc.spi; package org.jivesoftware.messenger.muc.spi;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
...@@ -31,18 +24,19 @@ import org.jivesoftware.messenger.forms.DataForm; ...@@ -31,18 +24,19 @@ import org.jivesoftware.messenger.forms.DataForm;
import org.jivesoftware.messenger.forms.FormField; import org.jivesoftware.messenger.forms.FormField;
import org.jivesoftware.messenger.forms.spi.XDataFormImpl; import org.jivesoftware.messenger.forms.spi.XDataFormImpl;
import org.jivesoftware.messenger.forms.spi.XFormFieldImpl; import org.jivesoftware.messenger.forms.spi.XFormFieldImpl;
import org.jivesoftware.messenger.muc.HistoryStrategy; import org.jivesoftware.messenger.muc.*;
import org.jivesoftware.messenger.muc.MUCRole;
import org.jivesoftware.messenger.muc.MUCRoom;
import org.jivesoftware.messenger.muc.MUCUser;
import org.jivesoftware.messenger.muc.MultiUserChatServer;
import org.jivesoftware.messenger.muc.NotAllowedException;
import org.jivesoftware.messenger.user.UserNotFoundException; import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.FastDateFormat;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.*;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
import org.xmpp.packet.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;
/** /**
* Implements the chat server as a cached memory resident chat server. The server is also * Implements the chat server as a cached memory resident chat server. The server is also
...@@ -63,10 +57,8 @@ import org.xmpp.component.ComponentManager; ...@@ -63,10 +57,8 @@ import org.xmpp.component.ComponentManager;
public class MultiUserChatServerImpl extends BasicModule implements MultiUserChatServer, public class MultiUserChatServerImpl extends BasicModule implements MultiUserChatServer,
ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler { ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler {
private static final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final FastDateFormat dateFormatter = FastDateFormat
static { .getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0"));
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
}
/** /**
* The time to elapse between clearing of idle chat users. * The time to elapse between clearing of idle chat users.
*/ */
...@@ -455,8 +447,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -455,8 +447,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public void removeChatRoom(String roomName) { public void removeChatRoom(String roomName) {
final MUCRoom room = rooms.remove(roomName.toLowerCase()); final MUCRoom room = rooms.remove(roomName.toLowerCase());
if (room != null) { if (room != null) {
final long chatLength = room.getChatLength(); totalChatTime += room.getChatLength();
totalChatTime += chatLength;
} }
} }
...@@ -750,7 +741,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -750,7 +741,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
super.start(); super.start();
// Add the route to this service // Add the route to this service
routingTable.addRoute(getAddress(), this); routingTable.addRoute(getAddress(), this);
ArrayList params = new ArrayList(); ArrayList<String> params = new ArrayList<String>();
params.clear(); params.clear();
params.add(getServiceDomain()); params.add(getServiceDomain());
Log.info(LocaleUtils.getLocalizedString("startup.starting.muc", params)); Log.info(LocaleUtils.getLocalizedString("startup.starting.muc", params));
...@@ -777,8 +768,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -777,8 +768,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
logQueue.add(new ConversationLogEntry(new Date(), room, message, sender)); logQueue.add(new ConversationLogEntry(new Date(), room, message, sender));
} }
public Iterator getItems() { public Iterator<DiscoServerItem> getItems() {
ArrayList items = new ArrayList(); ArrayList<DiscoServerItem> items = new ArrayList<DiscoServerItem>();
items.add(new DiscoServerItem() { items.add(new DiscoServerItem() {
public String getJID() { public String getJID() {
......
...@@ -7,11 +7,12 @@ ...@@ -7,11 +7,12 @@
*/ */
package org.jivesoftware.util.log.format; package org.jivesoftware.util.log.format;
import org.jivesoftware.util.FastDateFormat;
import org.jivesoftware.util.log.ContextMap; import org.jivesoftware.util.log.ContextMap;
import org.jivesoftware.util.log.LogEvent; import org.jivesoftware.util.log.LogEvent;
import org.jivesoftware.util.log.Priority; import org.jivesoftware.util.log.Priority;
import java.io.StringWriter; import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Stack; import java.util.Stack;
...@@ -117,7 +118,7 @@ public class PatternFormatter implements Formatter { ...@@ -117,7 +118,7 @@ public class PatternFormatter implements Formatter {
private PatternRun m_formatSpecification[]; private PatternRun m_formatSpecification[];
private SimpleDateFormat m_simpleDateFormat; private FastDateFormat m_simpleDateFormat;
private final Date m_date = new Date(); private final Date m_date = new Date();
/** /**
...@@ -512,7 +513,7 @@ public class PatternFormatter implements Formatter { ...@@ -512,7 +513,7 @@ public class PatternFormatter implements Formatter {
else { else {
synchronized (m_date) { synchronized (m_date) {
if (null == m_simpleDateFormat) { if (null == m_simpleDateFormat) {
m_simpleDateFormat = new SimpleDateFormat(format); m_simpleDateFormat = FastDateFormat.getInstance(format);
} }
m_date.setTime(time); m_date.setTime(time);
return m_simpleDateFormat.format(m_date); return m_simpleDateFormat.format(m_date);
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
*/ */
package org.jivesoftware.util.log.output.io.rotate; package org.jivesoftware.util.log.output.io.rotate;
import org.jivesoftware.util.FastDateFormat;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
/** /**
...@@ -31,7 +32,7 @@ public class UniqueFileStrategy ...@@ -31,7 +32,7 @@ public class UniqueFileStrategy
private File m_baseFile; private File m_baseFile;
private File m_currentFile; private File m_currentFile;
private SimpleDateFormat m_formatter; private FastDateFormat m_formatter;
private String m_suffix; private String m_suffix;
...@@ -41,7 +42,7 @@ public class UniqueFileStrategy ...@@ -41,7 +42,7 @@ public class UniqueFileStrategy
public UniqueFileStrategy(final File baseFile, String pattern) { public UniqueFileStrategy(final File baseFile, String pattern) {
this(baseFile); this(baseFile);
m_formatter = new SimpleDateFormat(pattern); m_formatter = FastDateFormat.getInstance(pattern);
} }
public UniqueFileStrategy(final File baseFile, String pattern, String suffix) { public UniqueFileStrategy(final File baseFile, String pattern, String suffix) {
......
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