use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.
the class EntityManagerSetupImpl method updateProfiler.
/**
* Check for the PROFILER persistence or system property and set the Session's profiler.
* This can also set the QueryMonitor.
*/
protected void updateProfiler(Map persistenceProperties, ClassLoader loader) {
// This must use config property as the profiler is not in the PropertiesHandler and requires
// supporting generic profiler classes.
String newProfilerClassName = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.PROFILER, persistenceProperties, session);
if (newProfilerClassName == null) {
ServerPlatformBase plaftorm = ((ServerPlatformBase) session.getServerPlatform());
if (plaftorm != null) {
plaftorm.configureProfiler(session);
}
} else {
if (newProfilerClassName.equals(ProfilerType.NoProfiler)) {
session.setProfiler(null);
return;
}
if (newProfilerClassName.equals(ProfilerType.QueryMonitor)) {
session.setProfiler(null);
QueryMonitor.shouldMonitor = true;
return;
}
if (newProfilerClassName.equals(ProfilerType.PerformanceProfiler)) {
session.setProfiler(new PerformanceProfiler());
return;
}
if (newProfilerClassName.equals(ProfilerType.PerformanceMonitor)) {
session.setProfiler(new PerformanceMonitor());
return;
}
if (newProfilerClassName.equals(ProfilerType.DMSProfiler)) {
newProfilerClassName = ProfilerType.DMSProfilerClassName;
}
String originalProfilerClassNamer = null;
if (session.getProfiler() != null) {
originalProfilerClassNamer = session.getProfiler().getClass().getName();
if (originalProfilerClassNamer.equals(newProfilerClassName)) {
return;
}
}
// New profiler - create the new instance and set it.
try {
Class<? extends SessionProfiler> newProfilerClass = findClassForProperty(newProfilerClassName, PersistenceUnitProperties.PROFILER, loader);
SessionProfiler sessionProfiler = (SessionProfiler) buildObjectForClass(newProfilerClass, SessionProfiler.class);
if (sessionProfiler != null) {
session.setProfiler(sessionProfiler);
} else {
session.handleException(ValidationException.invalidProfilerClass(newProfilerClassName));
}
} catch (IllegalAccessException e) {
session.handleException(ValidationException.cannotInstantiateProfilerClass(newProfilerClassName, e));
} catch (PrivilegedActionException e) {
session.handleException(ValidationException.cannotInstantiateProfilerClass(newProfilerClassName, e));
} catch (InstantiationException e) {
session.handleException(ValidationException.cannotInstantiateProfilerClass(newProfilerClassName, e));
}
}
}
use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.
the class SessionsFactory method processSessionConfig.
/**
* INTERNAL:
* Process the common elements from a SessionConfig.
*/
protected void processSessionConfig(SessionConfig sessionConfig, AbstractSession session) {
// Name
session.setName(sessionConfig.getName().trim());
// Session Event Manager
processSessionEventManagerConfig(sessionConfig.getSessionEventManagerConfig(), session);
// server platform
((DatabaseSessionImpl) session).setServerPlatform(buildServerPlatformConfig(sessionConfig.getServerPlatformConfig(), (DatabaseSessionImpl) session));
// Session Log - BUG# 3442865, don't set the log if it is null
SessionLog log = buildSessionLog(sessionConfig.getLogConfig(), session);
if (log != null) {
session.setSessionLog(log);
}
// Remote command manager
buildRemoteCommandManagerConfig(sessionConfig.getRemoteCommandManagerConfig(), session);
// Profiler - XML Schema default is null
if (sessionConfig.getProfiler() != null) {
if (sessionConfig.getProfiler().equals("eclipselink")) {
session.setProfiler(new PerformanceProfiler());
}
}
// Exception handler
String exceptionHandlerClassName = sessionConfig.getExceptionHandlerClass();
if (exceptionHandlerClassName != null) {
try {
@SuppressWarnings({ "unchecked" }) Class<ExceptionHandler> exceptionHandlerClass = (Class<ExceptionHandler>) m_classLoader.loadClass(exceptionHandlerClassName);
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
session.setExceptionHandler(AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(exceptionHandlerClass)));
} else {
session.setExceptionHandler(PrivilegedAccessHelper.newInstanceFromClass(exceptionHandlerClass));
}
} catch (Exception e) {
throw SessionLoaderException.failedToLoadTag("exception-handler-class", exceptionHandlerClassName, e);
}
}
// Session customizer will be processed in the buildSessions method.
// Ensures it is run last.
}
use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.
the class RuntimeServices method printProfileSummaryByQuery.
/**
* This method assumes EclipseLink Profiling (as opposed to Java profiling).
* This will log at the INFO level a summary of all elements in the profile, categorized
* by Query.
*/
public void printProfileSummaryByQuery() {
if (!this.getUsesEclipseLinkProfiling()) {
return;
}
PerformanceProfiler performanceProfiler = (PerformanceProfiler) getSession().getProfiler();
getSession().getSessionLog().info(trimProfileString(performanceProfiler.buildProfileSummaryByQuery().toString()));
}
use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.
the class RuntimeServices method printProfileSummaryByClass.
/**
* This method assumes EclipseLink Profiling (as opposed to Java profiling).
* This will log at the INFO level a summary of all elements in the profile, categorized
* by Class.
*/
public void printProfileSummaryByClass() {
if (!this.getUsesEclipseLinkProfiling()) {
return;
}
PerformanceProfiler performanceProfiler = (PerformanceProfiler) getSession().getProfiler();
// trim the { and } from the beginning at end, because they cause problems for the logger
getSession().getSessionLog().info(trimProfileString(performanceProfiler.buildProfileSummaryByClass().toString()));
}
use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.
the class RuntimeServices method printProfileSummary.
/**
* This method assumes EclipseLink Profiling (as opposed to Java profiling).
* This will log at the INFO level a summary of all elements in the profile.
*/
public void printProfileSummary() {
if (!this.getUsesEclipseLinkProfiling()) {
return;
}
PerformanceProfiler performanceProfiler = (PerformanceProfiler) getSession().getProfiler();
getSession().getSessionLog().info(performanceProfiler.buildProfileSummary().toString());
}
Aggregations