protected void initOrUpdateLogging(Map m, SessionLog log) { String logLevelString = PropertiesHandler.getPropertyValueLogDebug(TopLinkProperties.LOGGING_LEVEL, m, session); if(logLevelString != null) { log.setLevel(AbstractSessionLog.translateStringToLoggingLevel(logLevelString)); String category = (String)entry.getKey(); String value = (String)entry.getValue(); log.setLevel(AbstractSessionLog.translateStringToLoggingLevel(value), category); log.setShouldPrintDate(Boolean.parseBoolean(tsString)); log.setShouldPrintThread(Boolean.parseBoolean(threadString)); log.setShouldPrintSession(Boolean.parseBoolean(sessionString)); log.setShouldLogExceptionStackTrace(Boolean.parseBoolean(exString));
/** * PUBLIC: * <p> * Return the log level * </p><p> * @return the log level * </p> */ public int getLogLevel() { return getSessionLog().getLevel(); }
/** * PUBLIC: * Return the writer to which an accessor writes logged messages and SQL. * If not set, this reference defaults to a writer on System.out. * * @see #getSessionLog() */ public Writer getLog() { return getSessionLog().getWriter(); }
/** Matches target to pattern specified regExp. Returns false if there is * any error compiling regExp. * @param regExp The regular expression. * @param target The target against which we are trying to match regExp. * @param logger * @return false if there is error compiling regExp or target does not * match regExp. true if regExp matches pattern. */ private static boolean matchPattern(String regExp, String target, SessionLog logger) { boolean matches = false; try { matches = Pattern.matches(regExp,target); } catch (PatternSyntaxException e){ if(logger.shouldLog(SessionLog.FINE)) { logger.log(SessionLog.FINE, "dbPlaformHelper_patternSyntaxException", e); // NOI18N } } return matches; }
boolean shouldLogExceptionStackTrace = session.getSessionLog().shouldLogExceptionStackTrace(); session.getSessionLog().setShouldLogExceptionStackTrace(false); session.getSessionLog().setShouldLogExceptionStackTrace(true); session.getSessionLog().setShouldLogExceptionStackTrace(true);
/** * Allocate and initialize nameToVendorPlatform if not already done. */ private static Properties initializeNameToVendorPlatform(SessionLog logger) { synchronized(DBPlatformHelper.class) { if(_nameToVendorPlatform == null) { _nameToVendorPlatform = new Properties(); try { loadFromResource(_nameToVendorPlatform, VENDOR_NAME_TO_PLATFORM_RESOURCE_NAME, DBPlatformHelper.class.getClassLoader() ); } catch (IOException e) { logger.log(SessionLog.WARNING, "dbPlaformHelper_noMappingFound", VENDOR_NAME_TO_PLATFORM_RESOURCE_NAME); } } } return _nameToVendorPlatform; }
/** * PUBLIC: * <p> * Set the log level * </p><p> * * @param level the new log level * </p> */ public void setLogLevel(int level) { getSessionLog().setLevel(level); }
private void preProcess() throws URISyntaxException,MalformedURLException{ AbstractSessionLog.getLog().setLevel(this.logLevel); if(logWriter!=null){ ((DefaultSessionLog)AbstractSessionLog.getLog()).setWriter(logWriter); AbstractSessionLog.getLog().log(SessionLog.WARNING, ToStringLocalization.buildMessage("staticweave_processor_unknown_outcome", new Object[]{null}));
/** * PUBLIC: * <p> * Set the singleton SessionLog. * </p> * * @param sessionLog a SessionLog * </p> */ public static void setLog(SessionLog sessionLog) { defaultLog = sessionLog; defaultLog.setSession(null); }
/** * INTERNAL: * Log exceptions to the default log then throw them. */ private void logAndThrowException(int level, RuntimeException exception) throws RuntimeException { AbstractSessionLog.getLog().logThrowable(level, exception); throw exception; }
/** * Drop and recreate the default table schema for the TopLink project this session associated with. */ public void replaceDefaultTables() throws TopLinkException { boolean shouldLogExceptionStackTrace = getSession().getSessionLog().shouldLogExceptionStackTrace(); getSession().getSessionLog().setShouldLogExceptionStackTrace(false); try { TableCreator tableCreator = getDefaultTableCreator(); tableCreator.replaceTables(session, this); } catch (DatabaseException exception) { // Ignore error } finally { getSession().getSessionLog().setShouldLogExceptionStackTrace(shouldLogExceptionStackTrace); } }
protected ClassLoader createTempLoader(Collection col, boolean shouldOverrideLoadClassForCollectionMembers) { if (!shouldCreateInternalLoader) { return Thread.currentThread().getContextClassLoader(); } ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); if (!(currentLoader instanceof URLClassLoader)) { //we can't create a TempEntityLoader so just use the current one //shouldn't be a problem (and should only occur) in JavaSE return currentLoader; } URL[] urlPath = ((URLClassLoader)currentLoader).getURLs(); ClassLoader tempLoader = new TempEntityLoader(urlPath, currentLoader, col, shouldOverrideLoadClassForCollectionMembers); AbstractSessionLog.getLog().log(SessionLog.FINER, "cmp_init_tempLoader_created", tempLoader); AbstractSessionLog.getLog().log(SessionLog.FINER, "cmp_init_shouldOverrideLoadClassForCollectionMembers", new Boolean(shouldOverrideLoadClassForCollectionMembers)); return tempLoader; }
/** * INTERNAL: * Get the singleton entityContainer. * @return EnityContainer */ public static synchronized JavaSECMPInitializer getJavaSECMPInitializer() { if (javaSECMPInitializer == null) { javaSECMPInitializer = new JavaSECMPInitializer(); } AbstractSessionLog.getLog().setLevel(JavaSECMPInitializer.getTopLinkLoggingLevel()); return javaSECMPInitializer; }
/** Get Database Platform from vendor name. * @param vendorName Input vendor name. Typically this is obtained by querying * <code>DatabaseMetaData</code>. * @param logger The logger. * @return Database platform that corresponds to <code>vendorName</code>. * If vendorName does not match any of predefined vendor names, <code> * DEFAULTPLATFORM </code> is returned. */ public static String getDBPlatform(String vendorName, SessionLog logger) { initializeNameToVendorPlatform(logger); String detectedDbPlatform = null; if(vendorName != null) { detectedDbPlatform = matchVendorNameInProperties(vendorName, _nameToVendorPlatform, logger); } if (logger.shouldLog(SessionLog.FINE) ) { logger.log(SessionLog.FINE, "dbPlaformHelper_detectedVendorPlatform", detectedDbPlatform ); // NOI18N } if (detectedDbPlatform == null) { if(logger.shouldLog(SessionLog.INFO)) { logger.log(SessionLog.INFO, "dbPlaformHelper_defaultingPlatform", vendorName, DEFAULTPLATFORM); // NOI18N } detectedDbPlatform = DEFAULTPLATFORM; } return detectedDbPlatform; }
/** * PUBLIC: * Set the session log to which an accessor logs messages and SQL. * If not set, this will default to a session log on a writer on System.out. * To enable logging, log level can not be OFF. * Also set a backpointer to this session in SessionLog. To avoid a sessionLog * being shared by more than one session, it needs to be cloned. * * @see #logMessage(String) */ public void setSessionLog(SessionLog sessionLog) { this.sessionLog = (SessionLog)((AbstractSessionLog)sessionLog).clone(); if (this.sessionLog != null) { this.sessionLog.setSession(this); } }
/** * Drop and recreate the default table schema for the TopLink project this session associated with. */ public void replaceDefaultTables(boolean keepSequenceTables) throws TopLinkException { boolean shouldLogExceptionStackTrace = getSession().getSessionLog().shouldLogExceptionStackTrace(); getSession().getSessionLog().setShouldLogExceptionStackTrace(false); try { TableCreator tableCreator = getDefaultTableCreator(); tableCreator.replaceTables(session, this, keepSequenceTables); } catch (DatabaseException exception) { // Ignore error } finally { getSession().getSessionLog().setShouldLogExceptionStackTrace(shouldLogExceptionStackTrace); } }
/** * INTERNAL: * Create a list of java.lang.Class that contains the classes of all the entities * that we will be deploying */ protected Set loadEntityClasses(Collection entityNames, ClassLoader classLoader) { Set entityClasses = new HashSet(); // Load the classes using the loader passed in AbstractSessionLog.getLog().log(SessionLog.FINER, "cmp_loading_entities_using_loader", classLoader); for (Iterator iter = entityNames.iterator(); iter.hasNext();) { String entityClassName = (String)iter.next(); try { entityClasses.add(classLoader.loadClass(entityClassName)); } catch (ClassNotFoundException cnfEx) { throw ValidationException.entityClassNotFound(entityClassName, classLoader, cnfEx); } } return entityClasses; }
/** * INTERNAL: * Should be called only by the agent. (when weaving classes) * If succeeded return true, false otherwise. */ protected static void initializeFromAgent(Instrumentation instrumentation) throws Exception { AbstractSessionLog.getLog().setLevel(JavaSECMPInitializer.getTopLinkLoggingLevel()); // Squirrel away the instrumentation for later globalInstrumentation = instrumentation; // Create JavaSECMPInitializer singleton javaSECMPInitializer = new JavaSECMPInitializer(); // Initialize it javaSECMPInitializer.initialize(new HashMap(), javaSECMPInitializer); }
/** * Match vendorName in properties specifieid by _nameToVendorPlatform. */ private static String matchVendorNameInProperties(String vendorName, Properties nameToVendorPlatform, SessionLog logger) { String dbPlatform = null; //Iterate over all properties till we find match. for( Iterator iterator = nameToVendorPlatform.entrySet().iterator(); dbPlatform == null && iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); String regExpr = (String) entry.getKey(); String value = (String) entry.getValue(); if(logger.shouldLog(SessionLog.FINEST)) { logger.log(SessionLog.FINEST, "dbPlaformHelper_regExprDbPlatform", regExpr, value); // NOI18N } if( matchPattern(regExpr, vendorName, logger) ) { dbPlatform = value; } } return dbPlatform; }
session.getSessionLog().setSession(session);