/** * 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; }
/** 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; }
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: * 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; }
/** * Load the given class name with the given class loader. */ public static Class loadClass(String className, ClassLoader loader, boolean throwExceptionIfNotFound) { Class candidateClass = null; try { candidateClass = loader.loadClass(className); } catch (ClassNotFoundException exc){ if (throwExceptionIfNotFound){ throw PersistenceUnitLoadingException.exceptionLoadingClassWhileLookingForAnnotations(className, exc); } else { AbstractSessionLog.getLog().log(AbstractSessionLog.WARNING, "persistence_unit_processor_error_loading_class", exc.getClass().getName(), exc.getLocalizedMessage() , className); } } catch (Exception exception){ AbstractSessionLog.getLog().log(AbstractSessionLog.WARNING, "persistence_unit_processor_error_loading_class", exception.getClass().getName(), exception.getLocalizedMessage() , className); } return candidateClass; }
/** * 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; }
/** * Log an untranslated message to the TopLink log at FINER level. * @param msg message to be logged */ private void logMessage(String msg) { if (m_session == null){ AbstractSessionLog.getLog().log(SessionLog.FINER, msg); } else { m_session.logMessage(msg); } }
/** * Create a list of the entities that will be deployed. This list is built * from the information provided in the PersistenceUnitInfo argument. * The list contains Classes specified in the PersistenceUnitInfo's class * list and also files that are annotated with @Entity and @Embeddable in * the jar files provided in the persistence info. This list of classes will * used by TopLink to build a deployment project and to decide what classes * to weave. */ public static Collection<Class> buildEntityList(MetadataProcessor processor, ClassLoader loader) { ArrayList<Class> entityList = new ArrayList<Class>(); for (String className : processor.getProject().getWeavableClassNames()) { try { Class entityClass = loader.loadClass(className); entityList.add(entityClass); } catch (ClassNotFoundException exc) { AbstractSessionLog.getLog().log(SessionLog.CONFIG, "exception_loading_entity_class", className, exc); } } return entityList; }
/** 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; }
AbstractSessionLog.getLog().log(SessionLog.WARNING, ToStringLocalization.buildMessage("staticweave_processor_unknown_outcome", new Object[]{null}));
/** * Handle an exception that occured while processing ORM xml. */ private void handleORMException(RuntimeException e, String mf, boolean throwException){ if (m_session == null){ // Metadata processor is mainly used with a session. Java SE // bootstraping uses some functions such as ORM processing without // a session. In these cases, it is impossible to get the session // to properly handle the exception. As a result we log an error. // The same code will be called later in the bootstrapping code and // the error will be handled then. AbstractSessionLog.getLog().log(SessionLog.CONFIG, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, new Object[] {mf, e}); } else if (!throwException) { // fail quietly m_session.log(SessionLog.CONFIG, SessionLog.EJB_OR_METADATA, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, new Object[] {mf, e}); } else { // fail loudly m_session.handleException(e); } }
/** * INTERNAL * This method initializes the container. Essentially, it will try to load the * class that contains the list of entities and reflectively call the method that * contains that list. It will then initialize the container with that list. * If succeeded return true, false otherwise. */ public void initialize(Map m, PersistenceInitializationActivator persistenceActivator) { sessionClassLoader = getMainLoader(); final Set<Archive> pars = PersistenceUnitProcessor.findPersistenceArchives(); for (Archive archive: pars){ AbstractSessionLog.getLog().log(SessionLog.FINER, "cmp_init_initialize", archive); initPersistenceUnits(archive, m, persistenceActivator); } }
session.getSessionLog().log(SessionLog.FINEST, "skip_create_existing_tables", existedTableNames);
try { schemaManager.createObject(table); session.getSessionLog().log(SessionLog.FINEST, "default_tables_created", table.getFullName()); } catch (DatabaseException ex) { session.getSessionLog().log(SessionLog.FINEST, "default_tables_already_existed", table.getFullName()); if (!shouldIgnoreDatabaseException()) { throw ex;
/** * PUBLIC: * Log the log entry. */ public void log(SessionLogEntry entry) { if (shouldLog(entry.getLevel(), entry.getNameSpace())) { if (entry.getSession() == null) {// Used for proxy session. entry.setSession(this); } getSessionLog().log(entry); } }
m_project.addDescriptor(new MetadataDescriptor(m_loader.loadClass(className))); } catch (ClassNotFoundException e) { AbstractSessionLog.getLog().log(SessionLog.WARNING, "exception_loading_entity_class", className, e);
Object[] params = new Object[1]; params[0] = currentThread.getName(); AbstractSessionLog.getLog().log(SessionLog.FINER, "deferred_locks_released", params, true); return; } else {// Not done yet, wait and check again.
(databasePlatform.getFieldTypeDefinition(fieldType) == null))) { AbstractSessionLog.getLog().log(SessionLog.FINEST, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType);
params[0] = this.getOwnerCacheKey().getObject(); params[1] = currentThread.getName(); AbstractSessionLog.getLog().log(SessionLog.FINER, "acquiring_deferred_lock", params, true);
lockedCacheKey.releaseReadLock(); if (cachedObject == null){ session.getSessionLog().log(SessionLog.FINEST, SessionLog.CACHE, "Found null object in identity map on appendLock, retrying"); continue; }else{