mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Remove unused ServerConfig debugSql options, Update Tests to use agentloader
This commit is contained in:
@@ -139,10 +139,6 @@ public class ServerConfig {
|
||||
|
||||
private boolean ddlRun;
|
||||
|
||||
private boolean debugSql;
|
||||
|
||||
private boolean debugLazyLoad;
|
||||
|
||||
private boolean useJtaTransactionManager;
|
||||
|
||||
/**
|
||||
@@ -150,17 +146,6 @@ public class ServerConfig {
|
||||
*/
|
||||
private ExternalTransactionManager externalTransactionManager;
|
||||
|
||||
/**
|
||||
* Set to true to log using java.util.logging and otherwise uses ebean
|
||||
* transaction loggers.
|
||||
*/
|
||||
private boolean loggingToJavaLogger;
|
||||
|
||||
/**
|
||||
* The directory transaction logs go (when loggingToJavaLogger is false).
|
||||
*/
|
||||
private String loggingDirectory = "logs";
|
||||
|
||||
/**
|
||||
* Used to unwrap PreparedStatements to perform JDBC Driver specific functions
|
||||
*/
|
||||
@@ -774,119 +759,6 @@ public class ServerConfig {
|
||||
this.dbEncrypt = dbEncrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true to get the generated SQL queries output to the console.
|
||||
* <p>
|
||||
* To get the SQL and bind variables for insert update delete statements you
|
||||
* should use transaction logging.
|
||||
* </p>
|
||||
*/
|
||||
public boolean isDebugSql() {
|
||||
return debugSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true to get the generated SQL queries output to the console.
|
||||
* <p>
|
||||
* To get the SQL and bind variables for insert update delete statements you
|
||||
* should use transaction logging.
|
||||
* </p>
|
||||
*/
|
||||
public void setDebugSql(boolean debugSql) {
|
||||
this.debugSql = debugSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is debug logging on lazy loading events.
|
||||
*/
|
||||
public boolean isDebugLazyLoad() {
|
||||
return debugLazyLoad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true to get debug logging on lazy loading events.
|
||||
*/
|
||||
public void setDebugLazyLoad(boolean debugLazyLoad) {
|
||||
this.debugLazyLoad = debugLazyLoad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the directory where transaction logs go.
|
||||
*/
|
||||
public String getLoggingDirectory() {
|
||||
return loggingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the transaction log directory substituting any expressions such as
|
||||
* ${catalina.base} etc.
|
||||
*/
|
||||
public String getLoggingDirectoryWithEval() {
|
||||
return GlobalProperties.evaluateExpressions(loggingDirectory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the directory that the transaction logs go in.
|
||||
* <p>
|
||||
* This will not be used if the transaction logging is going to java util
|
||||
* logging (via {@link #setLoggingToJavaLogger(boolean)}).
|
||||
* </p>
|
||||
* <p>
|
||||
* This can contain expressions like ${catalina.base} with environment
|
||||
* variables, java system properties and entries in ebean.properties.
|
||||
* </p>
|
||||
* <p>
|
||||
* e.g. ${catalina.base}/logs/trans
|
||||
* </p>
|
||||
*
|
||||
* @param loggingDirectory
|
||||
* the transaction log directory
|
||||
*/
|
||||
public void setLoggingDirectory(String loggingDirectory) {
|
||||
this.loggingDirectory = loggingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if you want to use a java.util.logging.Logger to log
|
||||
* transaction statements, bind values etc.
|
||||
* <p>
|
||||
* If this is false then the default transaction logger is used which logs the
|
||||
* transaction details to separate transaction log files.
|
||||
* </p>
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isLoggingToJavaLogger() {
|
||||
return loggingToJavaLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this to true if you want transaction logging to use a
|
||||
* java.util.logging.Logger to log the statements and bind variables etc
|
||||
* rather than the default one which creates separate transaction log files.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setLoggingToJavaLogger(boolean transactionLogToJavaLogger) {
|
||||
this.loggingToJavaLogger = transactionLogToJavaLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - please use isTransactionLogToJavaLogger();
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public boolean isUseJuliTransactionLogger() {
|
||||
return isLoggingToJavaLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - please use setTransactionLogToJavaLogger();
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public void setUseJuliTransactionLogger(boolean transactionLogToJavaLogger) {
|
||||
setLoggingToJavaLogger(transactionLogToJavaLogger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true to run the DDL generation on startup.
|
||||
*/
|
||||
@@ -1330,15 +1202,6 @@ public class ServerConfig {
|
||||
|
||||
ddlGenerate = p.getBoolean("ddl.generate", false);
|
||||
ddlRun = p.getBoolean("ddl.run", false);
|
||||
debugSql = p.getBoolean("debug.sql", false);
|
||||
debugLazyLoad = p.getBoolean("debug.lazyload", false);
|
||||
|
||||
String s = p.get("useJuliTransactionLogger", null);
|
||||
s = p.get("loggingToJavaLogger", s);
|
||||
loggingToJavaLogger = "true".equalsIgnoreCase(s);
|
||||
|
||||
s = p.get("log.directory", "logs");
|
||||
loggingDirectory = p.get("logging.directory", s);
|
||||
|
||||
classes = getClasses(p);
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.config.GlobalProperties;
|
||||
|
||||
/**
|
||||
* Helper used in producing debug output on lazy loading.
|
||||
*/
|
||||
public class DebugLazyLoad {
|
||||
|
||||
private final String[] ignoreList;
|
||||
|
||||
private final boolean debug;
|
||||
|
||||
public DebugLazyLoad(boolean lazyLoadDebug) {
|
||||
ignoreList = buildLazyLoadIgnoreList();
|
||||
debug = lazyLoadDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if debugging is on.
|
||||
*/
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the StackTraceElement that is believed to be the line of code that
|
||||
* triggered the lazy loading.
|
||||
* <p>
|
||||
* This is determined by going up the stack trace ignoring all the sections
|
||||
* of java and Ebean code etc until you find code not in the ignore list -
|
||||
* this is assumed to be your application code that triggered the lazy
|
||||
* loading (it could be a third party layer such as a web template).
|
||||
* </p>
|
||||
*/
|
||||
public StackTraceElement getStackTraceElement(Class<?> beanType) {
|
||||
|
||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
for (int i = 0; i < stackTrace.length; i++) {
|
||||
if (isStackLine(stackTrace[i], beanType)) {
|
||||
return stackTrace[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the code is expected to be application code.
|
||||
*/
|
||||
private boolean isStackLine(StackTraceElement element, Class<?> beanType) {
|
||||
|
||||
String stackClass = element.getClassName();
|
||||
|
||||
if (isBeanClass(beanType, stackClass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ignoreList.length; i++) {
|
||||
if (stackClass.startsWith(ignoreList[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recurse up the inheritance checking to see if the stackClass is
|
||||
* this beanType (or a parent type).
|
||||
*/
|
||||
private boolean isBeanClass(Class<?> beanType, String stackClass) {
|
||||
if (stackClass.startsWith(beanType.getName())) {
|
||||
return true;
|
||||
}
|
||||
Class<?> superCls = beanType.getSuperclass();
|
||||
if (superCls.equals(Object.class)){
|
||||
return false;
|
||||
} else {
|
||||
return isBeanClass(superCls, stackClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build list of prefixes used to find the application code that triggered
|
||||
* the lazy loading.
|
||||
*/
|
||||
private String[] buildLazyLoadIgnoreList() {
|
||||
|
||||
List<String> ignore = new ArrayList<String>();
|
||||
|
||||
// code that should be ignored when searching
|
||||
// the stack trace elements
|
||||
ignore.add("com.avaje.ebean");
|
||||
ignore.add("java");
|
||||
ignore.add("sun.reflect");
|
||||
ignore.add("org.codehaus.groovy.runtime.");
|
||||
|
||||
String extraIgnore = GlobalProperties.get("debug.lazyload.ignore", null);
|
||||
if (extraIgnore != null) {
|
||||
String[] split = extraIgnore.split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
ignore.add(split[i].trim());
|
||||
}
|
||||
}
|
||||
|
||||
return ignore.toArray(new String[ignore.size()]);
|
||||
}
|
||||
}
|
||||
@@ -69,8 +69,6 @@ public class InternalConfiguration {
|
||||
|
||||
private final BeanDescriptorManager beanDescriptorManager;
|
||||
|
||||
private final DebugLazyLoad debugLazyLoad;
|
||||
|
||||
private final TransactionManager transactionManager;
|
||||
|
||||
private final TransactionScopeManager transactionScopeManager;
|
||||
@@ -115,23 +113,18 @@ public class InternalConfiguration {
|
||||
this.beanDescriptorManager = new BeanDescriptorManager(this);
|
||||
beanDescriptorManager.deploy();
|
||||
|
||||
this.debugLazyLoad = new DebugLazyLoad(serverConfig.isDebugLazyLoad());
|
||||
|
||||
this.transactionManager = new TransactionManager(clusterManager, backgroundExecutor,
|
||||
serverConfig, beanDescriptorManager, this.getBootupClasses());
|
||||
|
||||
this.cQueryEngine = new CQueryEngine(serverConfig.getDatabasePlatform(), binder,
|
||||
backgroundExecutor);
|
||||
this.cQueryEngine = new CQueryEngine(serverConfig.getDatabasePlatform(), binder, backgroundExecutor);
|
||||
|
||||
ExternalTransactionManager externalTransactionManager = serverConfig
|
||||
.getExternalTransactionManager();
|
||||
ExternalTransactionManager externalTransactionManager = serverConfig.getExternalTransactionManager();
|
||||
if (externalTransactionManager == null && serverConfig.isUseJtaTransactionManager()) {
|
||||
externalTransactionManager = new JtaTransactionManager();
|
||||
}
|
||||
if (externalTransactionManager != null) {
|
||||
externalTransactionManager.setTransactionManager(transactionManager);
|
||||
this.transactionScopeManager = new ExternalTransactionScopeManager(transactionManager,
|
||||
externalTransactionManager);
|
||||
this.transactionScopeManager = new ExternalTransactionScopeManager(transactionManager, externalTransactionManager);
|
||||
logger.info("Using Transaction Manager [" + externalTransactionManager.getClass() + "]");
|
||||
} else {
|
||||
this.transactionScopeManager = new DefaultTransactionScopeManager(transactionManager);
|
||||
@@ -170,7 +163,6 @@ public class InternalConfiguration {
|
||||
}
|
||||
|
||||
public Persister createPersister(SpiEbeanServer server) {
|
||||
|
||||
return new DefaultPersister(server, binder, beanDescriptorManager, pstmtBatch);
|
||||
}
|
||||
|
||||
@@ -246,10 +238,6 @@ public class InternalConfiguration {
|
||||
return clusterManager;
|
||||
}
|
||||
|
||||
public DebugLazyLoad getDebugLazyLoad() {
|
||||
return debugLazyLoad;
|
||||
}
|
||||
|
||||
public SpiBackgroundExecutor getBackgroundExecutor() {
|
||||
return backgroundExecutor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user