diff --git a/src/com/wentch/redkale/source/DataJDBCSource.java b/src/com/wentch/redkale/source/DataJDBCSource.java index 6af939586..a8d76d2dd 100644 --- a/src/com/wentch/redkale/source/DataJDBCSource.java +++ b/src/com/wentch/redkale/source/DataJDBCSource.java @@ -153,14 +153,7 @@ public final class DataJDBCSource implements DataSource { this.conf = url; this.readPool = new JDBCPoolSource(this, "read", readprop); this.writePool = new JDBCPoolSource(this, "write", writeprop); - for (Map.Entry en : readprop.entrySet()) { - if ("cache".equalsIgnoreCase(en.getValue().toString())) { - try { - EntityInfo.cacheClasses.add(Class.forName(en.getKey().toString())); - } catch (Exception e) { - } - } - } + EntityInfo.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty("shared-cache-mode")); } public DataJDBCSource(String unitName, Properties readprop, Properties writeprop) { @@ -168,14 +161,7 @@ public final class DataJDBCSource implements DataSource { this.conf = null; this.readPool = new JDBCPoolSource(this, "read", readprop); this.writePool = new JDBCPoolSource(this, "write", writeprop); - for (Map.Entry en : readprop.entrySet()) { - if ("cache".equalsIgnoreCase(en.getValue().toString())) { - try { - EntityInfo.cacheClasses.add(Class.forName(en.getKey().toString())); - } catch (Exception e) { - } - } - } + EntityInfo.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty("shared-cache-mode")); } public static Map create(final InputStream in) { @@ -218,7 +204,8 @@ public final class DataJDBCSource implements DataSource { String value = reader.getAttributeValue(null, "value"); if (name == null) continue; result.put(name, value); - } else if (result.getProperty(JDBC_URL) != null) { + } else if (flag && "shared-cache-mode".equalsIgnoreCase(reader.getLocalName())) { + result.put(reader.getLocalName(), reader.getElementText()); } } } diff --git a/src/com/wentch/redkale/source/EntityInfo.java b/src/com/wentch/redkale/source/EntityInfo.java index 3721c3e5c..399b63c62 100644 --- a/src/com/wentch/redkale/source/EntityInfo.java +++ b/src/com/wentch/redkale/source/EntityInfo.java @@ -29,7 +29,7 @@ public final class EntityInfo { private static final Logger logger = Logger.getLogger(EntityInfo.class); - static final Set cacheClasses = new HashSet<>(); + static boolean cacheForbidden = false; //Entity类的类名 private final Class type; @@ -213,8 +213,7 @@ public final class EntityInfo { this.allocationSize = allocationSize0; //----------------cache-------------- Cacheable c = type.getAnnotation(Cacheable.class); - boolean cf = (c == null && cacheClasses != null && cacheClasses.contains(type)); - if ((c != null && c.value()) || cf) { + if (!cacheForbidden && c != null && c.value()) { this.cache = new EntityCache<>(type, creator, primary, attributes); } else { this.cache = null;