[hibernate-commits] Hibernate SVN: r20017 - in core/trunk/core/src/main/java/org/hibernate: stat and 1 other directory.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Jul 23 12:33:39 EDT 2010
Author: steve.ebersole at jboss.com
Date: 2010-07-23 12:33:39 -0400 (Fri, 23 Jul 2010)
New Revision: 20017
Modified:
core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImplementor.java
Log:
HHH-5331 - Remove reflection calls on SessionFactory for JDK 1.5 detection in relation to Statistics
Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-07-22 20:40:12 UTC (rev 20016)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-07-23 16:33:39 UTC (rev 20017)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.impl;
@@ -30,17 +29,16 @@
import java.io.ObjectOutputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
-import java.lang.reflect.Constructor;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.LinkedHashSet;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
@@ -50,20 +48,19 @@
import org.slf4j.LoggerFactory;
import org.hibernate.AssertionFailure;
+import org.hibernate.Cache;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode;
+import org.hibernate.EntityNameResolver;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.QueryException;
import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
import org.hibernate.SessionFactoryObserver;
-import org.hibernate.EntityNameResolver;
-import org.hibernate.Cache;
+import org.hibernate.StatelessSession;
import org.hibernate.TypeHelper;
-import org.hibernate.tuple.entity.EntityTuplizer;
import org.hibernate.cache.CacheKey;
import org.hibernate.cache.CollectionRegion;
import org.hibernate.cache.EntityRegion;
@@ -90,9 +87,9 @@
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.profile.FetchProfile;
-import org.hibernate.engine.profile.Fetch;
import org.hibernate.engine.profile.Association;
+import org.hibernate.engine.profile.Fetch;
+import org.hibernate.engine.profile.FetchProfile;
import org.hibernate.engine.query.QueryPlanCache;
import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.event.EventListeners;
@@ -109,23 +106,24 @@
import org.hibernate.persister.PersisterFactory;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.persister.entity.Queryable;
import org.hibernate.persister.entity.Loadable;
+import org.hibernate.persister.entity.Queryable;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.proxy.EntityNotFoundDelegate;
+import org.hibernate.stat.ConcurrentStatisticsImpl;
import org.hibernate.stat.Statistics;
-import org.hibernate.stat.StatisticsImpl;
import org.hibernate.stat.StatisticsImplementor;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.tuple.entity.EntityTuplizer;
import org.hibernate.type.AssociationType;
import org.hibernate.type.Type;
import org.hibernate.type.TypeResolver;
import org.hibernate.util.CollectionHelper;
-import org.hibernate.util.ReflectHelper;
import org.hibernate.util.EmptyIterator;
+import org.hibernate.util.ReflectHelper;
/**
@@ -201,28 +199,10 @@
SessionFactoryObserver observer) throws HibernateException {
log.info("building session factory");
- Statistics concurrentStatistics = null;
- try {
- Class concurrentStatsClass = ReflectHelper.classForName("org.hibernate.stat.ConcurrentStatisticsImpl");
- Constructor constructor = concurrentStatsClass.getConstructor(new Class[]{SessionFactoryImplementor.class});
- concurrentStatistics = (Statistics) constructor.newInstance(new Object[]{this});
- log.trace("JDK 1.5 concurrent classes present");
- } catch ( NoClassDefFoundError noJava5 ) {
- log.trace("JDK 1.5 concurrent classes missing");
- } catch (Exception noJava5) {
- log.trace("JDK 1.5 concurrent classes missing");
- }
+ this.statistics = new ConcurrentStatisticsImpl( this );
+ getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() );
+ log.debug( "Statistics initialized [enabled={}]}", settings.isStatisticsEnabled() );
- if (concurrentStatistics != null) {
- this.statistics = concurrentStatistics;
- } else {
- this.statistics = new StatisticsImpl(this);
- }
-
- if ( log.isTraceEnabled() ) {
- log.trace("Statistics initialized with " + statistics.getClass().getName());
- }
-
this.properties = new Properties();
this.properties.putAll( cfg.getProperties() );
this.interceptor = cfg.getInterceptor();
@@ -444,9 +424,6 @@
}
}
- //stats
- getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() );
-
// EntityNotFoundDelegate
EntityNotFoundDelegate entityNotFoundDelegate = cfg.getEntityNotFoundDelegate();
if ( entityNotFoundDelegate == null ) {
Modified: core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java 2010-07-22 20:40:12 UTC (rev 20016)
+++ core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java 2010-07-23 16:33:39 UTC (rev 20017)
@@ -36,7 +36,10 @@
* @see org.hibernate.stat.Statistics
*
* @author Gavin King
+ *
+ * @deprecated Use {@link org.hibernate.stat.ConcurrentStatisticsImpl} instead
*/
+ at Deprecated
public class StatisticsImpl implements Statistics, StatisticsImplementor {
//TODO: we should provide some way to get keys of collection of statistics to make it easier to retrieve from a GUI perspective
Modified: core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImplementor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImplementor.java 2010-07-22 20:40:12 UTC (rev 20016)
+++ core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImplementor.java 2010-07-23 16:33:39 UTC (rev 20017)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -20,39 +20,185 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.stat;
/**
- * Statistics SPI for the Hibernate core
+ * Statistics SPI for the Hibernate core. This is essentially the "statistic collector" API, its the contract
+ * called to collect various stats.
*
* @author Emmanuel Bernard
*/
public interface StatisticsImplementor {
+ /**
+ * Callback about a session being opened.
+ */
public void openSession();
+
+ /**
+ * Callback about a session being closed.
+ */
public void closeSession();
+
+ /**
+ * Callback about a flush occurring
+ */
public void flush();
+
+ /**
+ * Callback about a connection being obtained from {@link org.hibernate.connection.ConnectionProvider}
+ */
public void connect();
+
+ /**
+ * Callback about a statement being prepared.
+ */
+ public void prepareStatement();
+
+ /**
+ * Callback about a statement being closed.
+ */
+ public void closeStatement();
+
+ /**
+ * Callback about a transaction completing.
+ *
+ * @param success Was the transaction successful?
+ */
+ public void endTransaction(boolean success);
+
+ /**
+ * Callback about an entity being loaded. This might indicate a proxy or a fully initialized entity, but in either
+ * case it means without a separate SQL query being needed.
+ *
+ * @param entityName The name of the entity loaded.
+ */
public void loadEntity(String entityName);
+
+ /**
+ * Callback about an entity being fetched. Unlike {@link #loadEntity} this indicates a separate query being
+ * performed.
+ *
+ * @param entityName The name of the entity fetched.
+ */
public void fetchEntity(String entityName);
+
+ /**
+ * Callback about an entity being updated.
+ *
+ * @param entityName The name of the entity updated.
+ */
public void updateEntity(String entityName);
+
+ /**
+ * Callback about an entity being inserted
+ *
+ * @param entityName The name of the entity inserted
+ */
public void insertEntity(String entityName);
+
+ /**
+ * Callback about an entity being deleted.
+ *
+ * @param entityName The name of the entity deleted.
+ */
public void deleteEntity(String entityName);
+
+ /**
+ * Callback about an optimistic lock failure on an entity
+ *
+ * @param entityName The name of the entity.
+ */
+ public void optimisticFailure(String entityName);
+
+ /**
+ * Callback about a collection loading. This might indicate a lazy collection or an initialized collection being
+ * created, but in either case it means without a separate SQL query being needed.
+ *
+ * @param role The collection role.
+ */
public void loadCollection(String role);
+
+ /**
+ * Callback to indicate a collection being fetched. Unlike {@link #loadCollection}, this indicates a separate
+ * query was needed.
+ *
+ * @param role The collection role.
+ */
public void fetchCollection(String role);
+
+ /**
+ * Callback indicating a collection was updated.
+ *
+ * @param role The collection role.
+ */
public void updateCollection(String role);
+
+ /**
+ * Callback indicating a collection recreation (full deletion + full (re-)insertion).
+ *
+ * @param role The collection role.
+ */
public void recreateCollection(String role);
+
+ /**
+ * Callback indicating a collection removal.
+ *
+ * @param role The collection role.
+ */
public void removeCollection(String role);
+
+ /**
+ * Callback indicating a put into second level cache.
+ *
+ * @param regionName The name of the cache region
+ */
public void secondLevelCachePut(String regionName);
+
+ /**
+ * Callback indicating a get from second level cache resulted in a hit.
+ *
+ * @param regionName The name of the cache region
+ */
public void secondLevelCacheHit(String regionName);
+
+ /**
+ * Callback indicating a get from second level cache resulted in a miss.
+ *
+ * @param regionName The name of the cache region
+ */
public void secondLevelCacheMiss(String regionName);
- public void queryExecuted(String hql, int rows, long time);
+
+ /**
+ * Callback indicating a put into the query cache.
+ *
+ * @param hql The query
+ * @param regionName The cache region
+ */
+ public void queryCachePut(String hql, String regionName);
+
+ /**
+ * Callback indicating a get from the query cache resulted in a hit.
+ *
+ * @param hql The query
+ * @param regionName The name of the cache region
+ */
public void queryCacheHit(String hql, String regionName);
+
+ /**
+ * Callback indicating a get from the query cache resulted in a miss.
+ *
+ * @param hql The query
+ * @param regionName The name of the cache region
+ */
public void queryCacheMiss(String hql, String regionName);
- public void queryCachePut(String hql, String regionName);
- public void endTransaction(boolean success);
- public void closeStatement();
- public void prepareStatement();
- public void optimisticFailure(String entityName);
+
+ /**
+ * Callback indicating execution of a sql/hql query
+ *
+ * @param hql The query
+ * @param rows Number of rows returned
+ * @param time execution time
+ */
+ public void queryExecuted(String hql, int rows, long time);
}
\ No newline at end of file
More information about the hibernate-commits
mailing list