[jboss-cvs] JBossAS SVN: r80784 - in trunk/tomcat/src/main/org/jboss/web/tomcat: statistics and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 10 23:01:12 EST 2008
Author: bstansberry at jboss.com
Date: 2008-11-10 23:01:11 -0500 (Mon, 10 Nov 2008)
New Revision: 80784
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/IntervalSnapshotManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionReplicationContext.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java
trunk/tomcat/src/main/org/jboss/web/tomcat/statistics/ReplicationStatistics.java
Log:
Clean up generics warns while the testsuite runs
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -22,7 +22,6 @@
package org.jboss.web.tomcat.service.session;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
@@ -160,9 +159,9 @@
int modCount = attrModifiedMap_.size();
if (modCount == 1)
{
- for (Map.Entry entry : attrModifiedMap_.entrySet())
+ for (Map.Entry<String, Object> entry : attrModifiedMap_.entrySet())
{
- distributedCacheManager.putAttribute(myRealId, (String) entry.getKey(), entry.getValue());
+ distributedCacheManager.putAttribute(myRealId, entry.getKey(), entry.getValue());
}
}
else if (modCount > 0)
@@ -175,9 +174,9 @@
// Go thru the remove attr list
if (attrRemovedMap_.size() > 0)
{
- for (Iterator it = attrRemovedMap_.keySet().iterator(); it.hasNext(); )
+ for (String key : attrRemovedMap_.keySet())
{
- distributedCacheManager.removeAttribute(myRealId, (String) it.next());
+ distributedCacheManager.removeAttribute(myRealId, key);
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -51,6 +51,7 @@
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -120,10 +121,10 @@
/**
* Set containing all members of {@link #excludedAttributes}.
*/
- protected static final Set replicationExcludes;
+ protected static final Set<String> replicationExcludes;
static
{
- HashSet set = new HashSet();
+ Set<String> set = new HashSet<String>();
for (int i = 0; i < excludedAttributes.length; i++)
{
set.add(excludedAttributes[i]);
@@ -135,7 +136,7 @@
/**
* The method signature for the <code>fireContainerEvent</code> method.
*/
- protected static final Class containerEventTypes[] = { String.class, Object.class };
+ protected static final Class<?> containerEventTypes[] = { String.class, Object.class };
protected static final Logger log = Logger.getLogger(ClusteredSession.class);
@@ -145,8 +146,10 @@
@SuppressWarnings("deprecation")
protected static javax.servlet.http.HttpSessionContext sessionContext = new javax.servlet.http.HttpSessionContext()
{
+ @SuppressWarnings("unchecked")
private final Map empty = Collections.EMPTY_MAP;
+ @SuppressWarnings("unchecked")
public Enumeration getIds()
{
return new Enumerator(empty);
@@ -228,7 +231,7 @@
/**
* The session event listeners for this Session.
*/
- private transient ArrayList listeners = new ArrayList();
+ private transient List<SessionListener> listeners = new ArrayList<SessionListener>();
/**
@@ -266,7 +269,7 @@
* and event listeners. <b>IMPLEMENTATION NOTE:</b> This object is
* <em>not</em> saved and restored across session serializations!
*/
- private final transient Map notes = new Hashtable();
+ private final transient Map<String, Object> notes = new Hashtable<String, Object>();
/**
@@ -728,6 +731,7 @@
return (notes.get(name));
}
+ @SuppressWarnings("unchecked")
public Iterator getNoteNames()
{
return (notes.keySet().iterator());
@@ -781,19 +785,27 @@
public HttpSession getSession()
{
- if (facade == null){
- if (SecurityUtil.isPackageProtectionEnabled()){
- final HttpSession fsession = this;
- facade = (StandardSessionFacade)AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
- return new StandardSessionFacade(fsession);
- }
- });
- } else {
- facade = new StandardSessionFacade(this);
+ if (facade == null)
+ {
+ if (SecurityUtil.isPackageProtectionEnabled())
+ {
+ final HttpSession fsession = this;
+ @SuppressWarnings("unchecked")
+ StandardSessionFacade ssf = (StandardSessionFacade)AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new StandardSessionFacade(fsession);
+ }
+ });
+ this.facade = ssf;
+ }
+ else
+ {
+ facade = new StandardSessionFacade(this);
}
- }
- return (facade);
+ }
+ return (facade);
}
// ------------------------------------------------------------ HttpSession
@@ -818,6 +830,7 @@
return getAttributeInternal(name);
}
+ @SuppressWarnings("unchecked")
public Enumeration getAttributeNames()
{
if (!isValid())
@@ -1547,7 +1560,7 @@
// Notify ActivationListeners
HttpSessionEvent event = null;
String keys[] = keys();
- Map attrs = getAttributesInternal();
+ Map<String, Object> attrs = getAttributesInternal();
for (int i = 0; i < keys.length; i++)
{
Object attribute = attrs.get(keys[i]);
@@ -1606,7 +1619,7 @@
HttpSessionEvent event = null;
String keys[] = keys();
- Map attrs = getAttributesInternal();
+ Map<String, Object> attrs = getAttributesInternal();
for (int i = 0; i < keys.length; i++)
{
Object attribute = attrs.get(keys[i]);
@@ -1727,7 +1740,7 @@
{
if (attribute instanceof Serializable || attribute == null)
return true;
- Class clazz = attribute.getClass().getComponentType();
+ Class<?> clazz = attribute.getClass().getComponentType();
return (clazz != null && clazz.isPrimitive());
}
@@ -1742,9 +1755,9 @@
* <code>attributes</code>, or <code>null</code> if no attributes
* were removed.
*/
- protected final Map removeExcludedAttributes(Map attributes)
+ protected final Map<String, Object> removeExcludedAttributes(Map<String, Object> attributes)
{
- Map excluded = null;
+ Map<String, Object> excluded = null;
for (int i = 0; i < excludedAttributes.length; i++) {
Object attr = attributes.remove(excludedAttributes[i]);
if (attr != null)
@@ -1756,7 +1769,7 @@
}
if (excluded == null)
{
- excluded = new HashMap();
+ excluded = new HashMap<String, Object>();
}
excluded.put(excludedAttributes[i], attr);
}
@@ -1941,7 +1954,7 @@
private String[] keys()
{
- Set keySet = getAttributesInternal().keySet();
+ Set<String> keySet = getAttributesInternal().keySet();
return ((String[]) keySet.toArray(new String[keySet.size()]));
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -22,7 +22,6 @@
package org.jboss.web.tomcat.service.session;
import java.io.IOException;
-import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletException;
@@ -124,13 +123,12 @@
{
// Cross-context request touched multiple sesssions;
// need to replicate them all
- Map sessions = ctx.getCrossContextSessions();
+ Map<ClusteredSession, SnapshotManager> sessions = ctx.getCrossContextSessions();
if (sessions != null && sessions.size() > 0)
{
- for (Iterator iter = sessions.entrySet().iterator(); iter.hasNext();)
+ for (Map.Entry<ClusteredSession, SnapshotManager> entry : sessions.entrySet())
{
- Map.Entry entry = (Map.Entry) iter.next();
- ((SnapshotManager) entry.getValue()).snapshot((ClusteredSession) entry.getKey());
+ entry.getValue().snapshot(entry.getKey());
}
}
}
@@ -191,13 +189,12 @@
{
// Cross-context request touched multiple sesssions;
// need to replicate them all
- Map sessions = ctx.getCrossContextSessions();
+ Map<ClusteredSession, SnapshotManager> sessions = ctx.getCrossContextSessions();
if (sessions != null && sessions.size() > 0)
{
- for (Iterator iter = sessions.entrySet().iterator(); iter.hasNext();)
+ for (Map.Entry<ClusteredSession, SnapshotManager> entry : sessions.entrySet())
{
- Map.Entry entry = (Map.Entry) iter.next();
- ((SnapshotManager) entry.getValue()).snapshot((ClusteredSession) entry.getKey());
+ entry.getValue().snapshot(entry.getKey());
}
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/IntervalSnapshotManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/IntervalSnapshotManager.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/IntervalSnapshotManager.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -42,7 +42,7 @@
private int interval = 1000;
// the modified sessions
- private Set sessions = new LinkedHashSet();
+ private Set<ClusteredSession> sessions = new LinkedHashSet<ClusteredSession>();
// the distribute thread
private Thread thread = null;
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossManager.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossManager.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -27,7 +27,6 @@
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -738,8 +737,6 @@
public String reportReplicationStatistics()
{
StringBuffer tmp = new StringBuffer();
- HashMap copy = new HashMap(stats_.getStats());
- Iterator iter = copy.entrySet().iterator();
tmp.append("<table><tr>");
tmp.append("<th>sessionID</th>");
tmp.append("<th>replicationCount</th>");
@@ -753,9 +750,10 @@
tmp.append("<th>minLoadTime</th>");
tmp.append("<th>maxLoadTime</th>");
tmp.append("<th>totalLoadTime</th>");
- while (iter.hasNext())
+
+ Map<String, ReplicationStatistics.TimeStatistic> copy = new HashMap<String, ReplicationStatistics.TimeStatistic>(stats_.getStats());
+ for (Map.Entry<String, ReplicationStatistics.TimeStatistic> entry : copy.entrySet())
{
- Map.Entry entry = (Map.Entry) iter.next();
ReplicationStatistics.TimeStatistic stat = (ReplicationStatistics.TimeStatistic) entry.getValue();
if (stat != null)
{
@@ -798,11 +796,9 @@
public String reportReplicationStatisticsCSV()
{
StringBuffer tmp = createCSVHeader();
- HashMap copy = new HashMap(stats_.getStats());
- Iterator iter = copy.entrySet().iterator();
- while (iter.hasNext())
+ Map<String, ReplicationStatistics.TimeStatistic> copy = new HashMap<String, ReplicationStatistics.TimeStatistic>(stats_.getStats());
+ for (Map.Entry<String, ReplicationStatistics.TimeStatistic> entry : copy.entrySet())
{
- Map.Entry entry = (Map.Entry) iter.next();
ReplicationStatistics.TimeStatistic stat = (ReplicationStatistics.TimeStatistic) entry.getValue();
if (stat != null)
{
@@ -843,7 +839,7 @@
public String reportReplicationStatisticsCSV(String sessionId)
{
StringBuffer tmp = createCSVHeader();
- Map stats = stats_.getStats();
+ Map<String, ReplicationStatistics.TimeStatistic> stats = stats_.getStats();
ReplicationStatistics.TimeStatistic stat =
(ReplicationStatistics.TimeStatistic) stats.get(sessionId);
if (stat != null)
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -113,22 +113,22 @@
private void testRecursively(Object obj)
{
- if (obj instanceof Collection)
+ if (obj instanceof Collection<?>)
{
- testCollectionSerializability((Collection) obj);
+ testCollectionSerializability((Collection<?>) obj);
}
- else if (obj instanceof Map)
+ else if (obj instanceof Map<?, ?>)
{
- testMapSerializability((Map) obj);
+ testMapSerializability((Map<?, ?>) obj);
}
}
- private void testCollectionSerializability(Collection coll)
+ private void testCollectionSerializability(Collection<?> coll)
{
System.out.println("Testing Collection elements");
int i = 0;
- for (Iterator iter = coll.iterator(); iter.hasNext(); i++)
+ for (Iterator<?> iter = coll.iterator(); iter.hasNext(); i++)
{
Object obj = iter.next();
if (!(testSerializability(obj)))
@@ -140,12 +140,11 @@
}
}
- private void testMapSerializability(Map map)
+ private void testMapSerializability(Map<?, ?> map)
{
System.out.println("Testing Map entries");
- for (Iterator iter = map.entrySet().iterator(); iter.hasNext();)
+ for (Map.Entry<?, ?> entry : map.entrySet())
{
- Map.Entry entry = (Map.Entry) iter.next();
if (!testSerializability(entry.getKey()))
{
System.out.println("Map Key " + entry.getKey() + " of type " +
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -69,7 +69,7 @@
@Override
public Map<String, Object> getSessionAttributeMap()
{
- Map attrs = new HashMap(getAttributesInternal());
+ Map<String, Object> attrs = new HashMap<String, Object>(getAttributesInternal());
removeExcludedAttributes(attrs);
return attrs;
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionReplicationContext.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionReplicationContext.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionReplicationContext.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -37,8 +37,8 @@
private int activityCount;
private SnapshotManager soleManager;
private ClusteredSession soleSession;
- private Map crossCtxSessions;
- private Map expiredSessions;
+ private Map<ClusteredSession, SnapshotManager> crossCtxSessions;
+ private Map<SnapshotManager, String> expiredSessions;
private Request outerRequest;
private Response outerResponse;
@@ -208,7 +208,7 @@
* with more than one SnapshotManager (i.e the request crossed session
* contexts.)
*/
- public Map getCrossContextSessions()
+ public Map<ClusteredSession, SnapshotManager> getCrossContextSessions()
{
return crossCtxSessions;
}
@@ -252,7 +252,7 @@
else if (!mgr.equals(soleManager))
{
// We have a cross-context call; need a Map for the sessions
- crossCtxSessions = new HashMap();
+ crossCtxSessions = new HashMap<ClusteredSession, SnapshotManager>();
crossCtxSessions.put(soleSession, soleManager);
crossCtxSessions.put(session, mgr);
soleManager = null;
@@ -282,7 +282,7 @@
{
if (this.expiredSessions == null)
{
- expiredSessions = new HashMap();
+ expiredSessions = new HashMap<SnapshotManager, String>();
}
expiredSessions.put(manager, session.getRealId());
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -40,8 +40,8 @@
public class Util
{
// Types that are considered "primitive".
- private static final Set immediates =
- new HashSet(Arrays.asList(new Object[]{
+ private static final Set<Class<?>> immediates =
+ new HashSet<Class<?>>(Arrays.asList(new Class<?>[]{
String.class,
Boolean.class,
Double.class,
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/statistics/ReplicationStatistics.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/statistics/ReplicationStatistics.java 2008-11-11 03:48:05 UTC (rev 80783)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/statistics/ReplicationStatistics.java 2008-11-11 04:01:11 UTC (rev 80784)
@@ -22,10 +22,8 @@
package org.jboss.web.tomcat.statistics;
import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+import java.util.concurrent.ConcurrentHashMap;
/** A session replication statistics collection class.
*
@@ -38,7 +36,7 @@
private static final long serialVersionUID = 9153807780893455734L;
/** A HashMap<String, TimeStatistic> of the method invocations */
- private ConcurrentReaderHashMap ctxStats;
+ private Map<String, TimeStatistic> ctxStats;
/** Time of the last resetStats call */
public long lastResetTime = System.currentTimeMillis();
@@ -75,7 +73,7 @@
public ReplicationStatistics()
{
- ctxStats = new ConcurrentReaderHashMap();
+ ctxStats = new ConcurrentHashMap<String, TimeStatistic>();
}
public void updatePassivationStats(String ctx, long elapsed)
@@ -136,10 +134,8 @@
{
synchronized( ctxStats )
{
- Iterator iter = ctxStats.values().iterator();
- while( iter.hasNext() )
+ for(TimeStatistic stat: ctxStats.values())
{
- TimeStatistic stat = (TimeStatistic) iter.next();
stat.reset();
}
}
@@ -155,7 +151,7 @@
*
* @return A HashMap<String, TimeStatistic> of the ctx invocations
*/
- public Map getStats()
+ public Map<String, TimeStatistic> getStats()
{
return ctxStats;
}
@@ -163,11 +159,8 @@
public String toString()
{
StringBuffer tmp = new StringBuffer();
- HashMap copy = new HashMap(ctxStats);
- Iterator iter = copy.entrySet().iterator();
- while( iter.hasNext() )
+ for(Map.Entry<String, TimeStatistic> entry : ctxStats.entrySet())
{
- Map.Entry entry = (Map.Entry) iter.next();
TimeStatistic stat = (TimeStatistic) entry.getValue();
if (stat != null)
{
More information about the jboss-cvs-commits
mailing list