This commit is contained in:
@@ -153,14 +153,7 @@ public final class DataJDBCSource implements DataSource {
|
|||||||
this.conf = url;
|
this.conf = url;
|
||||||
this.readPool = new JDBCPoolSource(this, "read", readprop);
|
this.readPool = new JDBCPoolSource(this, "read", readprop);
|
||||||
this.writePool = new JDBCPoolSource(this, "write", writeprop);
|
this.writePool = new JDBCPoolSource(this, "write", writeprop);
|
||||||
for (Map.Entry<Object, Object> en : readprop.entrySet()) {
|
EntityInfo.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty("shared-cache-mode"));
|
||||||
if ("cache".equalsIgnoreCase(en.getValue().toString())) {
|
|
||||||
try {
|
|
||||||
EntityInfo.cacheClasses.add(Class.forName(en.getKey().toString()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataJDBCSource(String unitName, Properties readprop, Properties writeprop) {
|
public DataJDBCSource(String unitName, Properties readprop, Properties writeprop) {
|
||||||
@@ -168,14 +161,7 @@ public final class DataJDBCSource implements DataSource {
|
|||||||
this.conf = null;
|
this.conf = null;
|
||||||
this.readPool = new JDBCPoolSource(this, "read", readprop);
|
this.readPool = new JDBCPoolSource(this, "read", readprop);
|
||||||
this.writePool = new JDBCPoolSource(this, "write", writeprop);
|
this.writePool = new JDBCPoolSource(this, "write", writeprop);
|
||||||
for (Map.Entry<Object, Object> en : readprop.entrySet()) {
|
EntityInfo.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty("shared-cache-mode"));
|
||||||
if ("cache".equalsIgnoreCase(en.getValue().toString())) {
|
|
||||||
try {
|
|
||||||
EntityInfo.cacheClasses.add(Class.forName(en.getKey().toString()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, DataJDBCSource> create(final InputStream in) {
|
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");
|
String value = reader.getAttributeValue(null, "value");
|
||||||
if (name == null) continue;
|
if (name == null) continue;
|
||||||
result.put(name, value);
|
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);
|
private static final Logger logger = Logger.getLogger(EntityInfo.class);
|
||||||
|
|
||||||
static final Set<Class> cacheClasses = new HashSet<>();
|
static boolean cacheForbidden = false;
|
||||||
|
|
||||||
//Entity类的类名
|
//Entity类的类名
|
||||||
private final Class<T> type;
|
private final Class<T> type;
|
||||||
@@ -213,8 +213,7 @@ public final class EntityInfo<T> {
|
|||||||
this.allocationSize = allocationSize0;
|
this.allocationSize = allocationSize0;
|
||||||
//----------------cache--------------
|
//----------------cache--------------
|
||||||
Cacheable c = type.getAnnotation(Cacheable.class);
|
Cacheable c = type.getAnnotation(Cacheable.class);
|
||||||
boolean cf = (c == null && cacheClasses != null && cacheClasses.contains(type));
|
if (!cacheForbidden && c != null && c.value()) {
|
||||||
if ((c != null && c.value()) || cf) {
|
|
||||||
this.cache = new EntityCache<>(type, creator, primary, attributes);
|
this.cache = new EntityCache<>(type, creator, primary, attributes);
|
||||||
} else {
|
} else {
|
||||||
this.cache = null;
|
this.cache = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user