本文整理汇总了Java中org.eclipse.persistence.logging.SessionLog类的典型用法代码示例。如果您正苦于以下问题:Java SessionLog类的具体用法?Java SessionLog怎么用?Java SessionLog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionLog类属于org.eclipse.persistence.logging包,在下文中一共展示了SessionLog类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Slf4jSessionLogger
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
public Slf4jSessionLogger()
{
super();
// Initialize loggers eagerly
categoryLoggers = new HashMap<>();
for( String category : SessionLog.loggerCatagories )
{
categoryLoggers.put( category, LoggerFactory.getLogger( ECLIPSELINK_NAMESPACE + "." + category ) );
}
categoryLoggers.put( DEFAULT_CATEGORY, LoggerFactory.getLogger( DEFAULT_ECLIPSELINK_NAMESPACE ) );
// Mapping between EclipseLink and SLF4J log levels.
mapLevels = new HashMap<>();
mapLevels.put( SessionLog.ALL, LogLevel.TRACE );
mapLevels.put( SessionLog.FINEST, LogLevel.TRACE );
mapLevels.put( SessionLog.FINER, LogLevel.TRACE );
mapLevels.put( SessionLog.FINE, LogLevel.DEBUG );
mapLevels.put( SessionLog.CONFIG, LogLevel.INFO );
mapLevels.put( SessionLog.INFO, LogLevel.INFO );
mapLevels.put( SessionLog.WARNING, LogLevel.WARN );
mapLevels.put( SessionLog.SEVERE, LogLevel.ERROR );
}
示例2: log
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
*
*/
@Override
public void log(SessionLogEntry sle) {
Logger lg = getLogger(sle);
String msg = getMessage(sle);
if(lg != null && StringUtils.isNotBlank(msg)) {
switch(sle.getLevel()) {
case SessionLog.SEVERE : lg.error(msg); break;
case SessionLog.WARNING : lg.warn (msg); break;
case SessionLog.INFO : lg.info (msg); break;
case SessionLog.FINE : lg.debug(msg); break;
case SessionLog.FINER : lg.trace(msg); break;
case SessionLog.FINEST : lg.trace(msg); break;
case SessionLog.ALL : lg.trace(msg); break;
default : lg.debug(msg); break;
}
}
}
示例3: createCategoryLoggers
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Initialize loggers eagerly
*/
private void createCategoryLoggers() {
for (String category : SessionLog.loggerCatagories) {
addLogger(category, ECLIPSELINK_NAMESPACE + "." + category);
}
// Logger default para cuando no hay categoría.
addLogger(DEFAULT_CATEGORY, DEFAULT_ECLIPSELINK_NAMESPACE);
}
示例4: initMapLevels
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Relación de los niveles de log de EclipseLink y los de SLF4J
*/
private void initMapLevels() {
mapLevels = new HashMap<Integer, LogLevel>();
mapLevels.put(SessionLog.ALL, LogLevel.TRACE);
mapLevels.put(SessionLog.FINEST, LogLevel.TRACE);
mapLevels.put(SessionLog.FINER, LogLevel.TRACE);
mapLevels.put(SessionLog.FINE, LogLevel.DEBUG);
mapLevels.put(SessionLog.CONFIG, LogLevel.INFO);
mapLevels.put(SessionLog.INFO, LogLevel.INFO);
mapLevels.put(SessionLog.WARNING, LogLevel.WARN);
mapLevels.put(SessionLog.SEVERE, LogLevel.ERROR);
}
示例5: createCategoryLoggers
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Initialize loggers eagerly
*/
private void createCategoryLoggers() {
for (String category : SessionLog.loggerCatagories) {
addLogger(category, ECLIPSELINK_NAMESPACE + "." + category);
}
// Logger default para cuando no hay categorÃa.
addLogger(DEFAULT_CATEGORY, DEFAULT_ECLIPSELINK_NAMESPACE);
}
示例6: initMapLevels
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Relación de los niveles de log de EclipseLink y los de SLF4J
*/
private void initMapLevels() {
mapLevels = new HashMap<Integer, LogLevel>();
mapLevels.put(SessionLog.ALL, LogLevel.TRACE);
mapLevels.put(SessionLog.FINEST, LogLevel.TRACE);
mapLevels.put(SessionLog.FINER, LogLevel.TRACE);
mapLevels.put(SessionLog.FINE, LogLevel.DEBUG);
mapLevels.put(SessionLog.CONFIG, LogLevel.INFO);
mapLevels.put(SessionLog.INFO, LogLevel.INFO);
mapLevels.put(SessionLog.WARNING, LogLevel.WARN);
mapLevels.put(SessionLog.SEVERE, LogLevel.ERROR);
}
示例7: getPropertiesForSchemaGeneration
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
private static Map getPropertiesForSchemaGeneration() {
Map<String, String> map = new HashMap<>();
map.put("eclipselink.ddl-generation", "create-tables");
map.put("eclipselink.create-ddl-jdbc-file-name", "createDDL_ddlGeneration.jdbc");
map.put("eclipselink.drop-ddl-jdbc-file-name", "dropDDL_ddlGeneration.jdbc");
map.put("eclipselink.ddl-generation.output-mode", "both");
map.put("eclipselink.ddl-generation.index-foreign-keys", "true");
map.put("eclipselink.logging.level", SessionLog.FINE_LABEL);
return map;
}
示例8: getLogLevel
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Hook to set the loglevel to be used
*/
protected String getLogLevel() {
return SessionLog.WARNING_LABEL;
}
示例9: generateFilteredDefaultTableCreator
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Generate a default TableCreator object from the EclipseLink project
* object, and perform the table existence check through jdbc table
* metadata, and filter out tables which are already in the database.
*/
public JPAMTableCreator generateFilteredDefaultTableCreator(AbstractSession session) throws DatabaseException {
JPAMTableCreator tblCreator = generateDefaultTableCreator();
try {
//table exisitence check.
java.sql.Connection conn = null;
if (session.isServerSession()) {
//acquire a connection from the pool
conn = ((ServerSession) session).getDefaultConnectionPool().acquireConnection().getConnection();
} else if (session.isDatabaseSession()) {
conn = ((DatabaseSessionImpl) session).getAccessor().getConnection();
}
if (conn == null) {
//TODO: this is not pretty, connection is not obtained for some reason.
return tblCreator;
}
DatabaseMetaData dbMetaData = conn.getMetaData();
ResultSet resultSet = dbMetaData.getTables(null, dbMetaData.getUserName(), null, new String[]{"TABLE"});
List tablesInDatabase = new ArrayList();
while (resultSet.next()) {
//save all tables from the database
tablesInDatabase.add(resultSet.getString("TABLE_NAME"));
}
resultSet.close();
List existedTables = new ArrayList();
List existedTableNames = new ArrayList();
Iterator tblDefIter = tblCreator.getTableDefinitions().iterator();
while (tblDefIter.hasNext()) {
TableDefinition tblDef = (TableDefinition) tblDefIter.next();
//check if the to-be-created table is already in the database
if (tablesInDatabase.contains(tblDef.getFullName())) {
existedTables.add(tblDef);
existedTableNames.add(tblDef.getFullName());
}
}
if (!existedTableNames.isEmpty()) {
session.getSessionLog().log(SessionLog.FINEST, SessionLog.DDL, "skip_create_existing_tables", existedTableNames);
//remove the existed tables, won't create them.
tblCreator.getTableDefinitions().removeAll(existedTables);
}
} catch (SQLException sqlEx) {
throw DatabaseException.errorRetrieveDbMetadataThroughJDBCConnection();
}
return tblCreator;
}
示例10: getFieldDefFromDBField
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
protected FieldDefinition getFieldDefFromDBField(Supplier<JPAMFieldDefinition> fieldDefSupplier, DatabaseField dbField) {
FieldDefinition fieldDef = this.fieldMap.get(dbField);
if (fieldDef == null) {
fieldDef = fieldDefSupplier.get();
fieldDef.setName(dbField.getNameDelimited(databasePlatform));
//added for extending tables where the field needs to be looked up
fieldDef.setDatabaseField(dbField);
if (dbField.getColumnDefinition() != null && dbField.getColumnDefinition().length() > 0) {
// This column definition would include the complete definition of the
// column like type, size, "NULL/NOT NULL" clause, unique key clause
fieldDef.setTypeDefinition(dbField.getColumnDefinition());
} else {
Class fieldType = dbField.getType();
FieldTypeDefinition fieldTypeDef = (fieldType == null) ? null : databasePlatform.getFieldTypeDefinition(fieldType);
// Check if the user field is a String and only then allow the length specified
// in the @Column annotation to be set on the field.
if (fieldType != null) {
// If a length has been specified, set it, otherwise let the
// field def from individual platforms handle it.
if (dbField.getLength() > 0) {
fieldDef.setSize(dbField.getLength());
} else if (dbField.getPrecision() > 0) {
fieldDef.setSize(dbField.getPrecision());
fieldDef.setSubSize(dbField.getScale());
}
}
if ((fieldType == null) || (!fieldType.isPrimitive() && (fieldTypeDef == null))) {
//TODO: log a warning for inaccessible type or not convertable type.
AbstractSessionLog.getLog().log(SessionLog.CONFIG, SessionLog.METADATA, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType);
//set the default type (lang.String) to all un-resolved java type, like null, Number, util.Date, NChar/NType, Calendar
//sql.Blob/Clob, Object, or unknown type). Please refer to bug 4352820.
fieldDef.setType(ClassConstants.STRING);
} else {
//need to convert the primitive type if applied.
fieldDef.setType(ConversionManager.getObjectClass(fieldType));
}
fieldDef.setShouldAllowNull(dbField.isNullable());
fieldDef.setUnique(dbField.isUnique());
}
this.fieldMap.put(dbField, fieldDef);
this.databaseFields.put(dbField, dbField);
}
return fieldDef;
}
示例11: dropTables
import org.eclipse.persistence.logging.SessionLog; //导入依赖的package包/类
/**
* Drop the tables from the database.
*/
public void dropTables(DatabaseSession session, JPAMSchemaManager schemaManager, boolean build) {
buildConstraints(schemaManager, build);
// CR 3870467, do not log stack, or log at all if not fine
boolean shouldLogExceptionStackTrace = session.getSessionLog().shouldLogExceptionStackTrace();
int level = session.getSessionLog().getLevel();
if (shouldLogExceptionStackTrace) {
session.getSessionLog().setShouldLogExceptionStackTrace(false);
}
if (level > SessionLog.FINE) {
session.getSessionLog().setLevel(SessionLog.SEVERE);
}
try {
dropConstraints(session, schemaManager, false);
String sequenceTableName = getSequenceTableName(session);
List<JPAMTableDefinition> tables = getTableDefinitions();
int trys = 1;
if (JPAMSchemaManager.FORCE_DROP) {
trys = 5;
}
while ((trys > 0) && !tables.isEmpty()) {
trys--;
List<JPAMTableDefinition> failed = new ArrayList<>();
for (JPAMTableDefinition table : tables) {
// Must not create sequence table as done in createSequences.
if (!table.getName().equals(sequenceTableName)) {
try {
schemaManager.dropObject(table);
} catch (DatabaseException exception) {
failed.add(table);
if (!shouldIgnoreDatabaseException()) {
throw exception;
}
}
}
}
tables = failed;
}
} finally {
if (shouldLogExceptionStackTrace) {
session.getSessionLog().setShouldLogExceptionStackTrace(true);
}
if (level > SessionLog.FINE) {
session.getSessionLog().setLevel(level);
}
}
}