This commit is contained in:
@@ -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<Object, Object> 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<Object, Object> 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<String, DataJDBCSource> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class EntityInfo<T> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(EntityInfo.class);
|
||||
|
||||
static final Set<Class> cacheClasses = new HashSet<>();
|
||||
static boolean cacheForbidden = false;
|
||||
|
||||
//Entity类的类名
|
||||
private final Class<T> type;
|
||||
@@ -213,8 +213,7 @@ public final class EntityInfo<T> {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user