Author: genman
Date: 2007-08-15 14:30:00 -0400 (Wed, 15 Aug 2007)
New Revision: 4298
Added:
core/trunk/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java
Removed:
core/trunk/src/main/java/org/jboss/cache/util/SimpleEntry.java
Modified:
core/trunk/
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/FqnComparator.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/Version.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
core/trunk/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
core/trunk/src/main/java/org/jboss/cache/lock/ReadWriteLockWithUpgrade.java
core/trunk/src/main/java/org/jboss/cache/lock/ThreadLocalMap.java
core/trunk/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java
core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
core/trunk/src/main/java/org/jboss/cache/transaction/DummyContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/main/java/org/jboss/cache/util/MapCopy.java
Log:
Clean up compiler warnings regarding unchecked conversion usage
Only 1448 more remaining warnings to fix
Property changes on: core/trunk
___________________________________________________________________
Name: svn:ignore
- output
build.log
junit*
0000*
je.lck
*.iml
*.ipr
*.iws
bin
jbossdb
dist
derby.log
+ output
build.log
junit*
0000*
je.lck
*.iml
*.ipr
*.iws
bin
jbossdb
dist
derby.log
target
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-08-15 12:33:48 UTC (rev
4297)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-08-15 18:30:00 UTC (rev
4298)
@@ -1838,7 +1838,7 @@
{
NodeSPI<K, V> n = findNode(fqn);
if (n == null) return null;
- Set childNames = new HashSet();
+ Set<E> childNames = new HashSet<E>();
Map childrenMap = n.getChildrenMapDirect();
if (childrenMap == null || childrenMap.isEmpty()) return Collections.emptySet();
Collection s = childrenMap.values();
@@ -1846,7 +1846,11 @@
for (Object c : s)
{
NodeSPI child = (NodeSPI) c;
- if (!child.isDeleted()) childNames.add(child.getFqn().getLastElement());
+ if (!child.isDeleted()) {
+ @SuppressWarnings("unchecked")
+ E e = (E)child.getFqn().getLastElement();
+ childNames.add(e);
+ }
}
return childNames;
}
@@ -2297,7 +2301,7 @@
if (tx != null && create_undo_ops)
{
// erase and set to previous hashmap contents
- MethodCall undo_op =
MethodCallFactory.create(MethodDeclarations.putDataEraseMethodLocal, tx, fqn, new
HashMap(rawData), false, true);
+ MethodCall undo_op =
MethodCallFactory.create(MethodDeclarations.putDataEraseMethodLocal, tx, fqn, new
HashMap<K, V>(rawData), false, true);
tx_table.addUndoOperation(tx, undo_op);
}
@@ -2651,7 +2655,7 @@
// Find the node. This will lock it (if <tt>locking</tt> is true) and
// add the temporarily created parent nodes to the TX's node list if tx !=
null)
- NodeSPI n = findNode(fqn, version);
+ NodeSPI<K, V> n = findNode(fqn, version);
if (n == null)
{
log.warn("node " + fqn + " not found");
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2007-08-15 12:33:48
UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2007-08-15 18:30:00
UTC (rev 4298)
@@ -18,14 +18,15 @@
*/
public class DefaultCacheFactory<K, V> implements CacheFactory<K, V>
{
- private static CacheFactory singleton = new DefaultCacheFactory();
+ private static CacheFactory<?, ?> singleton = new DefaultCacheFactory();
/**
* @return a singleton instance of this class.
*/
+ @SuppressWarnings("unchecked")
public static <K, V> CacheFactory<K, V> getInstance()
{
- return singleton;
+ return (CacheFactory<K, V>) singleton;
}
public Cache<K, V> createCache() throws ConfigurationException
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2007-08-15 12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2007-08-15 18:30:00 UTC (rev 4298)
@@ -195,7 +195,7 @@
{
if (stringRepresentation == null)
{
- return Fqn.ROOT;
+ return root();
}
List<String> list = new ArrayList<String>();
StringTokenizer tok = new StringTokenizer(stringRepresentation, SEPARATOR);
@@ -228,7 +228,7 @@
*/
public Fqn<E> getAncestor(int generation)
{
- if (generation == 0) return Fqn.ROOT;
+ if (generation == 0) return root();
return getSubFqn(0, generation);
}
@@ -279,6 +279,7 @@
/**
* Clones the Fqn.
*/
+ @SuppressWarnings("unchecked")
public Fqn<E> clone() throws CloneNotSupportedException
{
try
@@ -367,7 +368,9 @@
this.elements = new ArrayList<E>(length);
for (int i = 0; i < length; i++)
{
- elements.add((E) in.readObject());
+ @SuppressWarnings("unchecked")
+ E e = (E) in.readObject();
+ elements.add(e);
}
}
@@ -464,11 +467,16 @@
{
case 0:
case 1:
- return ROOT;
+ return root();
default:
return new Fqn<E>(elements.subList(0, elements.size() - 1));
}
}
+
+ @SuppressWarnings("unchecked")
+ public static <T> Fqn<T> root() {
+ return ROOT;
+ }
/**
* Returns true if this is a root Fqn.
Modified: core/trunk/src/main/java/org/jboss/cache/FqnComparator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/FqnComparator.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/FqnComparator.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -94,7 +94,7 @@
{
if (e1.getClass() == e2.getClass() && e1 instanceof Comparable)
{
- return ((Comparable) e1).compareTo(e2);
+ return ((Comparable<Object>) e1).compareTo(e2);
}
else
{
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -19,7 +19,7 @@
*/
public class RPCManagerImpl implements RPCManager
{
- private CacheImpl c;
+ private CacheImpl<?, ?> c;
/**
* Empty ctor for mock object creation/unit testing
@@ -35,6 +35,7 @@
// for now, we delegate RPC calls to deprecated methods in CacheImpl.
+ @SuppressWarnings("deprecation")
public List callRemoteMethods(List<Address> recipients, MethodCall methodCall,
int mode, boolean excludeSelf, long timeout) throws Exception
{
return c.callRemoteMethods(recipients, methodCall, mode, excludeSelf, timeout);
@@ -50,11 +51,13 @@
return c.getCoordinator();
}
+ @SuppressWarnings("deprecation")
public List callRemoteMethods(List<Address> recipients, MethodCall methodCall,
boolean synchronous, boolean excludeSelf, int timeout) throws Exception
{
return c.callRemoteMethods(recipients, methodCall, synchronous, excludeSelf,
timeout);
}
+ @SuppressWarnings("deprecation")
public List callRemoteMethods(List<Address> recipients, Method method, Object[]
arguments, boolean synchronous, boolean excludeSelf, long timeout) throws Exception
{
return c.callRemoteMethods(recipients, method, arguments, synchronous, excludeSelf,
timeout);
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -43,7 +43,7 @@
private Map<Fqn, Region> regionsRegistry = new ConcurrentHashMap<Fqn,
Region>();
private boolean defaultInactive;
private Log log = LogFactory.getLog(RegionManager.class);
- private CacheImpl cache;
+ private CacheImpl<?,?> cache;
private boolean usingEvictions;
private EvictionConfig evictionConfig;
private EvictionTimerTask evictionTimerTask = new EvictionTimerTask();
@@ -367,8 +367,6 @@
// so calls to _getState for the fqn can return quickly
activationChangeNodes.add(fqn);
- Region region = getRegion(fqn, true);
-
BuddyManager buddyManager = cache.getBuddyManager();
// Request partial state from the cluster and integrate it
if (buddyManager == null)
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -101,7 +101,7 @@
{
throw new IllegalArgumentException("no cache init for " + fqn);
}
- this.cache = (CacheImpl) cache;
+ this.cache = (CacheImpl<K, V>) cache;
this.fqn = fqn;
if (!fqn.isRoot() && !child_name.equals(fqn.getLastElement()))
{
@@ -219,28 +219,28 @@
return data.put(key, value);
}
- public NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx)
+ public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx)
{
return getOrCreateChild(child_name, gtx, true);
}
- private NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean
createIfNotExists)
+ private NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx,
boolean createIfNotExists)
{
- NodeSPI child;
+ NodeSPI<K, V> child;
if (child_name == null)
{
throw new IllegalArgumentException("null child name");
}
- child = (NodeSPI) children().get(child_name);
+ child = (NodeSPI<K, V>) children().get(child_name);
InvocationContext ctx = cache.getInvocationContext();
if (createIfNotExists && child == null)
{
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
Fqn child_fqn = new Fqn(this.fqn, child_name);
- NodeSPI newChild = (NodeSPI)
cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name, this,
null);
+ NodeSPI<K, V> newChild = (NodeSPI<K, V>)
cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name, this,
null);
if (newChild == null)
{
throw new IllegalStateException();
@@ -249,7 +249,7 @@
{
// check again to see if the child exists
// after acquiring exclusive lock
- child = (NodeSPI) children().get(child_name);
+ child = (NodeSPI<K, V>) children().get(child_name);
if (child == null)
{
cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
@@ -414,14 +414,14 @@
public Set<Object> getChildrenNamesDirect()
{
- return children == null ? Collections.emptySet() : new HashSet(children.keySet());
+ return children == null ? Collections.<Object>emptySet() : new
HashSet<Object>(children.keySet());
//return childrenNames();
}
public Set<K> getKeys()
{
Set<K> keys = cache.getKeys(getFqn());
- return (Set<K>) (keys == null ? Collections.emptySet() :
Collections.unmodifiableSet(keys));
+ return keys == null ? Collections.<K>emptySet() :
Collections.<K>unmodifiableSet(keys);
}
public Set<K> getKeysDirect()
@@ -528,12 +528,12 @@
this.children.putAll(children);
}
- public void putAll(Map data)
+ public void putAll(Map<K, V> data)
{
cache.put(fqn, data);
}
- public void replaceAll(Map data)
+ public void replaceAll(Map<K, V> data)
{
cache.put(fqn, data, true);
}
@@ -665,9 +665,9 @@
if (children == null || children.size() == 0) return Collections.emptySet();
Set<NodeSPI<K, V>> exclDeleted = new HashSet<NodeSPI<K,
V>>();
- for (Node n : children.values())
+ for (Node<K, V> n : children.values())
{
- NodeSPI spi = (NodeSPI) n;
+ NodeSPI<K, V> spi = (NodeSPI<K, V>) n;
if (!spi.isDeleted()) exclDeleted.add(spi);
}
return Collections.unmodifiableSet(exclDeleted);
Modified: core/trunk/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Version.java 2007-08-15 12:33:48 UTC (rev
4297)
+++ core/trunk/src/main/java/org/jboss/cache/Version.java 2007-08-15 18:30:00 UTC (rev
4298)
@@ -102,7 +102,7 @@
else if ("1.2.4.SP1".equals(versionString))
return 1241;
- StringTokenizer tokenizer = new StringTokenizer(versionString, ".");
+ StringTokenizer tokenizer = new StringTokenizer(versionString, ".-");
int major = 0;
int minor = 0;
@@ -112,8 +112,10 @@
major = Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
minor = Integer.parseInt(tokenizer.nextToken());
- if (tokenizer.hasMoreTokens())
- patch = Integer.parseInt(tokenizer.nextToken());
+ if (tokenizer.hasMoreTokens()) {
+ String ps = tokenizer.nextToken();
+ patch = Integer.parseInt(ps);
+ }
return encodeVersion(major, minor, patch);
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -70,7 +70,7 @@
/**
* back-refernce to the CacheImpl object
*/
- private CacheImpl cache;
+ private CacheImpl<?,?> cache;
/**
* The buddy group set up for this instance
@@ -108,7 +108,7 @@
* Constants representng the buddy backup subtree
*/
public static final String BUDDY_BACKUP_SUBTREE = "_BUDDY_BACKUP_";
- public static final Fqn BUDDY_BACKUP_SUBTREE_FQN =
Fqn.fromString(BUDDY_BACKUP_SUBTREE);
+ public static final Fqn<String> BUDDY_BACKUP_SUBTREE_FQN =
Fqn.fromString(BUDDY_BACKUP_SUBTREE);
/**
* number of times to retry communicating with a selected buddy if the buddy has not
been initialised.
@@ -208,7 +208,7 @@
}
}
- public void init(CacheImpl cache) throws CacheException
+ public void init(CacheImpl<?, ?> cache) throws CacheException
{
log.debug("Starting buddy manager");
this.cache = cache;
@@ -950,7 +950,7 @@
{
Object[] asArray = ((List) args[i]).toArray();
handleArgs(asArray, transformForCurrentCall);
- List newList = new ArrayList(asArray.length);
+ List<Object> newList = new ArrayList<Object>(asArray.length);
// Oops! JDK 5.0!
//Collections.addAll(newList, asArray);
newList.addAll(Arrays.asList(asArray));
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -87,9 +87,8 @@
// TODO this needs to be refactored obviously ...
try
{
- Class<EvictionPolicy> cpolicy = (Class<EvictionPolicy>)
Class.forName(defaultEvictionPolicyClass);
- EvictionPolicy policy;
- policy = cpolicy.newInstance();
+ Class<?> cpolicy = Class.forName(defaultEvictionPolicyClass);
+ EvictionPolicy policy = (EvictionPolicy) cpolicy.newInstance();
EvictionRegionConfig erc = new EvictionRegionConfig();
EvictionPolicyConfig epc =
policy.getEvictionConfigurationClass().newInstance();
// epc.set
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -42,7 +42,6 @@
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
-import java.util.concurrent.atomic.AtomicLong;
/**
* A CacheListener that creates JMX notifications from listener
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -18,7 +18,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
-import java.util.Collection;
+import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -89,13 +89,13 @@
* @return node
* @throws Exception
*/
- public Map get(Fqn name) throws Exception
+ public Map<Object, Object> get(Fqn name) throws Exception
{
lock.acquireLock(name, false);
try
{
- final Map node = loadNode(name);
- return node == NULL_NODE_IN_ROW ? new HashMap(0) : node;
+ final Map<Object, Object> node = loadNode(name);
+ return node == NULL_NODE_IN_ROW ? new HashMap<Object, Object>(0) : node;
}
finally
{
@@ -112,7 +112,7 @@
*/
public Set<String> getChildrenNames(Fqn fqn) throws Exception
{
- Set children = null;
+ Set<String> children = null;
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
@@ -130,7 +130,7 @@
rs = ps.executeQuery();
if (rs.next())
{
- children = new HashSet();
+ children = new HashSet<String>();
do
{
String child = rs.getString(1);
@@ -326,7 +326,7 @@
try
{
Object removedValue = null;
- Map node = loadNode(name);
+ Map<Object, Object> node = loadNode(name);
if (node != null && node != NULL_NODE_IN_ROW)
{
removedValue = node.remove(key);
@@ -356,10 +356,9 @@
* null if there is no row with the fqn in the table,
* NULL_NODE_IN_ROW if there is a row in the table with the fqn but the node
column contains null.
*/
- protected Map loadNode(Fqn name)
+ protected Map<Object, Object> loadNode(Fqn name)
{
boolean rowExists = false;
- Map oldNode = null;
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
@@ -389,8 +388,9 @@
// Object marshalledNode = ois.readObject();
// deserialize result
- Object marshalledNode = unmarshall(is);
- oldNode = (Map) marshalledNode;
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> oldNode = (Map<Object, Object>)
unmarshall(is);
+ return oldNode;
}
catch (Exception e)
{
@@ -414,7 +414,7 @@
cf.close(con);
}
- return oldNode == null ? (rowExists ? NULL_NODE_IN_ROW : null) : oldNode;
+ return rowExists ? NULL_NODE_IN_ROW : null;
}
@@ -503,7 +503,7 @@
* @param name the fqn
* @param node new node value
*/
- protected void updateNode(Fqn name, Map node)
+ protected void updateNode(Fqn name, Map<Object, Object> node)
{
Connection con = null;
PreparedStatement ps = null;
@@ -522,7 +522,7 @@
//ps.setNull(1, Types.BLOB);
// ps.setNull(1, Types.LONGVARBINARY);
// don't set it to null - simply use an empty hash map.
- node = new HashMap(0);
+ node = new HashMap<Object, Object>(0);
}
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -535,7 +535,7 @@
ps.setString(2, name.toString());
- int rows = ps.executeUpdate();
+ /*int rows = */ps.executeUpdate();
// if (rows != 1)
// {
// throw new IllegalStateException("Expected one updated row but
got " + rows);
@@ -719,67 +719,14 @@
// Inner
- protected static final Map NULL_NODE_IN_ROW = new Map()
+ protected static final Map<Object, Object> NULL_NODE_IN_ROW = new
AbstractMap<Object, Object>()
{
- public int size()
- {
- throw new UnsupportedOperationException();
- }
- public void clear()
- {
+ @Override
+ public Set<java.util.Map.Entry<Object, Object>> entrySet() {
throw new UnsupportedOperationException();
- }
-
- public boolean isEmpty()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsKey(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsValue(Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public Collection values()
- {
- throw new UnsupportedOperationException();
- }
-
- public void putAll(Map t)
- {
- throw new UnsupportedOperationException();
- }
-
- public Set entrySet()
- {
- throw new UnsupportedOperationException();
- }
-
- public Set keySet()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object get(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object remove(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object put(Object key, Object value)
- {
- throw new UnsupportedOperationException();
- }
+ }
+
};
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -14,6 +14,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -64,9 +65,9 @@
*/
public Object put(Fqn name, Object key, Object value) throws Exception
{
- Map toAdd = new HashMap();
- toAdd.put(key, value);
- Map existing = _put(name, toAdd);
+ Map<Object, Object> m = new HashMap<Object, Object>(1);
+ m.put(key, value);
+ Map existing = _put(name, m);
return existing == null ? null : existing.get(key);
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -367,7 +367,7 @@
* This operation is always non-transactional, even in a transactional
* environment.
*/
- public Map get(Fqn name)
+ public Map<Object, Object> get(Fqn name)
throws Exception
{
@@ -567,12 +567,12 @@
* Internal version of put(Fqn,Map) that allows passing a
* transaction and erases existing data.
*/
- private void doPutErase(Transaction txn, Fqn name, Map values)
+ private void doPutErase(Transaction txn, Fqn name, Map<Object, Object> values)
throws Exception
{
// JBCACHE-769 -- make a defensive copy
- values = (values == null ? null : new HashMap(values));
+ values = (values == null ? null : new HashMap<Object, Object>(values));
DatabaseEntry dataEntry = makeDataEntry(values);
DatabaseEntry keyEntry = makeKeyEntry(name);
@@ -1085,6 +1085,7 @@
*/
private Map<Object, Object> makeDataObject(DatabaseEntry entry, boolean
createIfNull)
{
+ @SuppressWarnings("unchecked")
Map<Object, Object> map = (Map<Object, Object>)
serialBinding.entryToObject(entry);
if (createIfNull && map == null)
{
@@ -1096,7 +1097,7 @@
/**
* Converts a Map to a database entry.
*/
- private DatabaseEntry makeDataEntry(Map map)
+ private DatabaseEntry makeDataEntry(Map<Object, Object> map)
{
if (map != null)
@@ -1107,7 +1108,7 @@
}
else if (!(map instanceof Serializable))
{
- map = new HashMap(map);
+ map = new HashMap<Object, Object>(map);
}
}
DatabaseEntry entry = new DatabaseEntry();
Modified: core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -25,7 +25,6 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
/**
* A persistent <code>CacheLoader</code> based on the JDBM project.
@@ -71,7 +70,6 @@
private String cacheDbName;
private RecordManager recman;
private BTree tree;
- private Map<Object, List<Modification>> transactions = new
ConcurrentHashMap<Object, List<Modification>>();
/*
* Service implementation -- lifecycle methods.
Modified: core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java 2007-08-15 12:33:48
UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java 2007-08-15 18:30:00
UTC (rev 4298)
@@ -130,7 +130,7 @@
*
* @return Set of readers
*/
- public Set getReaderOwners()
+ public Set<Object> getReaderOwners()
{
return map_.readerOwners();
}
@@ -439,7 +439,7 @@
public void toString(StringBuffer sb, boolean print_lock_details)
{
boolean printed_read_owners = false;
- Collection read_owners = lock_ != null ? getReaderOwners() : null;
+ Collection<Object> read_owners = lock_ != null ? getReaderOwners() : null;
if (read_owners != null && read_owners.size() > 0)
{
// Fix for JBCACHE-310 -- can't just call new ArrayList(read_owners) :(
@@ -447,7 +447,7 @@
// Looking at the details of how this is implemented vs. the 2 prev
// options, this doesn't look like it should be slower
Iterator iter = read_owners.iterator();
- read_owners = new ArrayList(read_owners.size());
+ read_owners = new ArrayList<Object>(read_owners.size());
while (iter.hasNext())
{
read_owners.add(iter.next());
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -25,7 +25,7 @@
private Object writeOwner_ = null;
// a CopyOnWriteArraySet is HUGELY inefficient since MANY LockMaps are created and are
frequently read from. Until we have a better impl ...
- private final Set readOwnerList_ = new CopyOnWriteArraySet();
+ private final Set<Object> readOwnerList_ = new
CopyOnWriteArraySet<Object>();
public LockMap()
{
@@ -116,7 +116,7 @@
/**
* Returns an unmodifiable set of reader owner objects.
*/
- public Set readerOwners()
+ public Set<Object> readerOwners()
{
return Collections.unmodifiableSet(readOwnerList_);
}
Modified: core/trunk/src/main/java/org/jboss/cache/lock/ReadWriteLockWithUpgrade.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/ReadWriteLockWithUpgrade.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/lock/ReadWriteLockWithUpgrade.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -61,7 +61,7 @@
private long waitingUpgrader_ = 0;
// Store a default object to signal that we are upgrade thread.
//protected final ThreadLocal upgraderLocal_ = new ThreadLocal();
- protected static final Map<ReadWriteLock, Object> upgraderLocal_ = new
ThreadLocalMap();
+ protected static final Map<ReadWriteLock, Object> upgraderLocal_ = new
ThreadLocalMap<ReadWriteLock, Object>();
protected static final Object dummy_ = new Object();
protected final ReaderLock readerLock_ = new ReaderLock();
protected final WriterLock writerLock_ = new WriterLock();
Modified: core/trunk/src/main/java/org/jboss/cache/lock/ThreadLocalMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/ThreadLocalMap.java 2007-08-15 12:33:48
UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/lock/ThreadLocalMap.java 2007-08-15 18:30:00
UTC (rev 4298)
@@ -11,28 +11,29 @@
* @author Brian Dueck
* @version $Id$
*/
-public class ThreadLocalMap implements Map {
+public class ThreadLocalMap<K, V> implements Map<K, V> {
- private ThreadLocal threadLocal = new ThreadLocal();
+ private ThreadLocal threadLocal = new ThreadLocal() {
+ @Override
+ protected Object initialValue() {
+ return new HashMap();
+ }
+ };
- private Map getThreadLocalMap() {
- Map map = (Map) threadLocal.get();
- if (map == null) {
- map = new HashMap();
- threadLocal.set(map);
- }
- return map;
+ @SuppressWarnings("unchecked")
+ private Map<K, V> getThreadLocalMap() {
+ return (Map<K, V>) threadLocal.get();
}
- public Object put(Object key, Object value) {
+ public V put(K key, V value) {
return getThreadLocalMap().put(key, value);
}
- public Object get(Object key) {
+ public V get(Object key) {
return getThreadLocalMap().get(key);
}
- public Object remove(Object key) {
+ public V remove(Object key) {
return getThreadLocalMap().remove(key);
}
@@ -56,19 +57,19 @@
return getThreadLocalMap().containsValue(arg0);
}
- public Collection values() {
+ public Collection<V> values() {
return getThreadLocalMap().values();
}
- public void putAll(Map arg0) {
+ public void putAll(Map<? extends K, ? extends V> arg0) {
getThreadLocalMap().putAll(arg0);
}
- public Set entrySet() {
+ public Set<Map.Entry<K, V>> entrySet() {
return getThreadLocalMap().entrySet();
}
- public Set keySet() {
+ public Set<K> keySet() {
return getThreadLocalMap().keySet();
}
Modified:
core/trunk/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java 2007-08-15
12:33:48 UTC (rev 4297)
+++
core/trunk/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -10,6 +10,9 @@
*/
public class IncorrectCacheListenerException extends CacheException
{
+
+ private static final long serialVersionUID = 3847404572671886703L;
+
public IncorrectCacheListenerException(String s)
{
super(s);
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -91,7 +91,7 @@
log.warn("Attempted to register listener of class " +
listener.getClass() + ", but no valid, public methods annotated with method-level
event annotations found! Ignoring listener.");
}
- private void testListenerClassValidity(Class listenerClass)
+ private void testListenerClassValidity(Class<?> listenerClass)
{
if (!listenerClass.isAnnotationPresent(CacheListener.class))
throw new IncorrectCacheListenerException("Cache listener class MUST be
annotated with org.jboss.cache.notifications.annotation.CacheListener");
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -164,7 +164,7 @@
*
* @param workspaceNode
*/
- void addChild(WorkspaceNode workspaceNode);
+ void addChild(WorkspaceNode<K,V> workspaceNode);
/**
* @return true if children have been added to or removed from this node. Not the
same as 'dirty'.
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -12,6 +12,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.VersionedNode;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -170,12 +171,14 @@
}
//see if we already have it
- NodeSPI child = optimisticChildNodeMap.get(child_name);
+ NodeSPI<K, V> child = optimisticChildNodeMap.get(child_name);
// if not we need to create it
if (child == null)
{
- child = (NodeSPI)
cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNodeOfType(parent,
child_name, parent, null);
+ @SuppressWarnings("unchecked")
+ NodeFactory<K, V> factory =
cache.getConfiguration().getRuntimeConfig().getNodeFactory();
+ child = (NodeSPI<K, V>) factory.createNodeOfType(parent, child_name,
parent, null);
optimisticChildNodeMap.put(child_name, child);
childrenAdded.add(child.getFqn());
childrenRemoved.remove(child.getFqn());
@@ -263,7 +266,7 @@
public Node<K, V> addChild(Fqn f)
{
CacheSPI cache = getCache();
- Node newNode = this;
+ Node<K, V> newNode = this;
GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
if (f.size() == 1)
@@ -273,22 +276,22 @@
else
{
// recursively create children
- Node currentParent = this;
+ Node<K,V> currentParent = this;
for (Object o : f.peekElements())
{
if (currentParent instanceof WorkspaceNode)
{
- newNode = ((WorkspaceNode) currentParent).getNode().getOrCreateChild(o,
gtx);
+ newNode = ((WorkspaceNode<K,V>)
currentParent).getNode().getOrCreateChild(o, gtx);
}
else
{
if (currentParent instanceof WorkspaceNode)
{
- newNode = ((WorkspaceNode) currentParent).getNode().getOrCreateChild(o,
gtx);
+ newNode = ((WorkspaceNode<K,V>)
currentParent).getNode().getOrCreateChild(o, gtx);
}
else
{
- newNode = ((NodeSPI) currentParent).getOrCreateChild(o, gtx);
+ newNode = ((NodeSPI<K,V>) currentParent).getOrCreateChild(o,
gtx);
}
}
currentParent = newNode;
@@ -297,7 +300,7 @@
return newNode;
}
- public void addChild(WorkspaceNode child)
+ public void addChild(WorkspaceNode<K,V> child)
{
optimisticChildNodeMap.put(child.getFqn().getLastElement(), child.getNode());
childrenAdded.add(child.getFqn());
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyContext.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyContext.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -27,7 +27,7 @@
public class DummyContext implements Context
{
- HashMap bindings = new HashMap();
+ HashMap<String, Object> bindings = new HashMap<String, Object>();
/**
* Retrieves the named object.
@@ -219,7 +219,7 @@
* @see #listBindings(Name)
* @see NameClassPair
*/
- public NamingEnumeration list(Name name) throws NamingException
+ public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
{
return null;
}
@@ -235,7 +235,7 @@
* enumeration is of type <tt>NameClassPair</tt>.
* @throws NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name) throws NamingException
+ public NamingEnumeration<NameClassPair> list(String name) throws
NamingException
{
return null;
}
@@ -257,7 +257,7 @@
* @see #list(Name)
* @see Binding
*/
- public NamingEnumeration listBindings(Name name) throws NamingException
+ public NamingEnumeration<Binding> listBindings(Name name) throws
NamingException
{
return null;
}
@@ -273,7 +273,7 @@
* <tt>Binding</tt>.
* @throws NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name) throws NamingException
+ public NamingEnumeration<Binding> listBindings(String name) throws
NamingException
{
return null;
}
@@ -536,7 +536,7 @@
* @see #addToEnvironment(String,Object)
* @see #removeFromEnvironment(String)
*/
- public Hashtable getEnvironment() throws NamingException
+ public Hashtable<?,?> getEnvironment() throws NamingException
{
return null;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java 2007-08-15
12:33:48 UTC (rev 4297)
+++
core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -172,6 +172,7 @@
{
Class[] signature = null;
Object[] args = null;
+ @SuppressWarnings("unchecked")
Method method = clazz.getMethod("getTransactionManager", signature);
tm = (TransactionManager) method.invoke(null, args);
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2007-08-15
12:33:48 UTC (rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -218,7 +218,7 @@
/**
* Adds a collection of locks to the global transaction.
*/
- public void addLocks(GlobalTransaction gtx, Collection locks)
+ public void addLocks(GlobalTransaction gtx, Collection<NodeLock> locks)
{
TransactionEntry entry = get(gtx);
if (entry == null)
Modified: core/trunk/src/main/java/org/jboss/cache/util/MapCopy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/MapCopy.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/util/MapCopy.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -11,6 +11,8 @@
import java.util.Map;
import java.util.Set;
+import net.jcip.annotations.Immutable;
+
/**
* Contains a fixed array of read-only map entries, from a copy of an existing map.
* This class is more lightweight for places where the copied map will just be iterated
over.
@@ -20,6 +22,7 @@
*
* @author Elias Ross
*/
+@Immutable
public class MapCopy<K, V> extends AbstractMap<K, V> implements Serializable
{
@@ -36,12 +39,11 @@
*/
public MapCopy(Map<K, V> m)
{
- int i = 0;
for (Map.Entry<K, V> me : m.entrySet())
{
if (me == null)
throw new NullPointerException();
- data.add(new SimpleEntry<K, V>(me));
+ data.add(new SimpleImmutableEntry<K, V>(me));
}
init();
}
@@ -51,6 +53,13 @@
this(new HashMap<K, V>());
}
+ /**
+ * Returns a copy of the given map.
+ */
+ public static <L, W> Map<L, W> copy(Map<L, W> m) {
+ return new MapCopy<L, W>(m);
+ }
+
private void init()
{
this.entrySet = new AbstractSet<Map.Entry<K, V>>()
Deleted: core/trunk/src/main/java/org/jboss/cache/util/SimpleEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/SimpleEntry.java 2007-08-15 12:33:48 UTC
(rev 4297)
+++ core/trunk/src/main/java/org/jboss/cache/util/SimpleEntry.java 2007-08-15 18:30:00 UTC
(rev 4298)
@@ -1,65 +0,0 @@
-package org.jboss.cache.util;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * Where is Java 1.6?
- */
-class SimpleEntry<K, V> implements Map.Entry<K, V>, Serializable
-{
- private static final long serialVersionUID = -6092752114794052323L;
-
- private K key;
-
- private V value;
-
- public SimpleEntry(Entry<K, V> me)
- {
- key = me.getKey();
- value = me.getValue();
- }
-
- public SimpleEntry(K key, V value)
- {
- this.key = key;
- this.value = value;
- }
-
- public K getKey()
- {
- return key;
- }
-
- public V getValue()
- {
- return value;
- }
-
- public V setValue(V arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean equals(Object o)
- {
- Map.Entry e2 = (Map.Entry) o;
- return (getKey() == null ? e2.getKey() == null : getKey().equals(e2.getKey()))
- && (getValue() == null ? e2.getValue() == null :
getValue().equals(e2.getValue()));
- }
-
- @Override
- public int hashCode()
- {
- return (getKey() == null ? 0 : getKey().hashCode()) ^
- (getValue() == null ? 0 : getValue().hashCode());
- }
-
- @Override
- public String toString()
- {
- return key + "=" + value;
- }
-}
\ No newline at end of file
Copied: core/trunk/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java (from rev
4297, core/trunk/src/main/java/org/jboss/cache/util/SimpleEntry.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java
(rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java 2007-08-15
18:30:00 UTC (rev 4298)
@@ -0,0 +1,65 @@
+package org.jboss.cache.util;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * Where is Java 1.6?
+ */
+class SimpleImmutableEntry<K, V> implements Map.Entry<K, V>, Serializable
+{
+ private static final long serialVersionUID = -6092752114794052323L;
+
+ private K key;
+
+ private V value;
+
+ public SimpleImmutableEntry(Entry<K, V> me)
+ {
+ key = me.getKey();
+ value = me.getValue();
+ }
+
+ public SimpleImmutableEntry(K key, V value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ public K getKey()
+ {
+ return key;
+ }
+
+ public V getValue()
+ {
+ return value;
+ }
+
+ public V setValue(V arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ Map.Entry e2 = (Map.Entry) o;
+ return (getKey() == null ? e2.getKey() == null : getKey().equals(e2.getKey()))
+ && (getValue() == null ? e2.getValue() == null :
getValue().equals(e2.getValue()));
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (getKey() == null ? 0 : getKey().hashCode()) ^
+ (getValue() == null ? 0 : getValue().hashCode());
+ }
+
+ @Override
+ public String toString()
+ {
+ return key + "=" + value;
+ }
+}
\ No newline at end of file