KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > stat > SessionStatisticsImpl


1 //$Id: SessionStatisticsImpl.java,v 1.1 2005/05/11 15:26:04 oneovthafew Exp $
2
package org.hibernate.stat;
3
4 import java.util.Collections JavaDoc;
5 import java.util.Set JavaDoc;
6
7 import org.hibernate.engine.SessionImplementor;
8
9 /**
10  * @author Gavin King
11  */

12 public class SessionStatisticsImpl implements SessionStatistics {
13
14     private final SessionImplementor session;
15     
16     public SessionStatisticsImpl(SessionImplementor session) {
17         this.session = session;
18     }
19
20     public int getEntityCount() {
21         return session.getPersistenceContext().getEntityEntries().keySet().size();
22     }
23     
24     public int getCollectionCount() {
25         return session.getPersistenceContext().getCollectionEntries().keySet().size();
26     }
27     
28     public Set JavaDoc getEntityKeys() {
29         return Collections.unmodifiableSet( session.getPersistenceContext().getEntitiesByKey().keySet() );
30     }
31     
32     public Set JavaDoc getCollectionKeys() {
33         return Collections.unmodifiableSet( session.getPersistenceContext().getCollectionsByKey().keySet() );
34     }
35     
36     public String JavaDoc toString() {
37         return new StringBuffer JavaDoc()
38             .append("SessionStatistics[")
39             .append("entity count=").append( getEntityCount() )
40             .append("collection count=").append( getCollectionCount() )
41             .append(']')
42             .toString();
43     }
44
45 }
46
Popular Tags