FileDocCategorySizeDatePackage
SessionFactoryStub.javaAPI DocHibernate 3.2.55968Mon Dec 05 16:37:00 GMT 2005org.hibernate.jmx

SessionFactoryStub

public class SessionFactoryStub extends Object implements org.hibernate.SessionFactory
A flyweight for SessionFactory. If the MBean itself does not have classpath to the persistent classes, then a stub will be registered with JNDI and the actual SessionFactoryImpl built upon first access.
author
Gavin King

Fields Summary
private static final Log
log
private static final org.hibernate.id.IdentifierGenerator
UUID_GENERATOR
private transient org.hibernate.SessionFactory
impl
private transient HibernateService
service
private String
uuid
private String
name
Constructors Summary
SessionFactoryStub(HibernateService service)


	  
		this.service = service;
		this.name = service.getJndiName();
		try {
			uuid = (String) UUID_GENERATOR.generate(null, null);
		}
		catch (Exception e) {
			throw new AssertionFailure("Could not generate UUID");
		}

		SessionFactoryObjectFactory.addInstance( uuid, name, this, service.getProperties() );
	
Methods Summary
public voidclose()

	
public voidevict(java.lang.Class persistentClass, java.io.Serializable id)

		getImpl().evict(persistentClass, id);
	
public voidevict(java.lang.Class persistentClass)

		getImpl().evict(persistentClass);
	
public voidevictCollection(java.lang.String roleName, java.io.Serializable id)

		getImpl().evictCollection(roleName, id);
	
public voidevictCollection(java.lang.String roleName)

		getImpl().evictCollection(roleName);
	
public voidevictEntity(java.lang.String entityName, java.io.Serializable id)

		getImpl().evictEntity(entityName, id);
	
public voidevictEntity(java.lang.String entityName)

		getImpl().evictEntity(entityName);
	
public voidevictQueries()

		getImpl().evictQueries();
	
public voidevictQueries(java.lang.String cacheRegion)

		getImpl().evictQueries(cacheRegion);
	
public java.util.MapgetAllClassMetadata()

		return getImpl().getAllClassMetadata();
	
public java.util.MapgetAllCollectionMetadata()

		return getImpl().getAllCollectionMetadata();
	
public org.hibernate.metadata.ClassMetadatagetClassMetadata(java.lang.Class persistentClass)

		return getImpl().getClassMetadata(persistentClass);
	
public org.hibernate.metadata.ClassMetadatagetClassMetadata(java.lang.String entityName)

		return getImpl().getClassMetadata(entityName);
	
public org.hibernate.metadata.CollectionMetadatagetCollectionMetadata(java.lang.String roleName)

		return getImpl().getCollectionMetadata(roleName);
	
public org.hibernate.classic.SessiongetCurrentSession()

		return getImpl().getCurrentSession();
	
public java.util.SetgetDefinedFilterNames()

		return getImpl().getDefinedFilterNames();
	
public org.hibernate.engine.FilterDefinitiongetFilterDefinition(java.lang.String filterName)

		return getImpl().getFilterDefinition( filterName );
	
private synchronized org.hibernate.SessionFactorygetImpl()

		if (impl==null) impl = service.buildSessionFactory();
		return impl;
	
public javax.naming.ReferencegetReference()

see
javax.naming.Referenceable#getReference()

		return new Reference(
			SessionFactoryStub.class.getName(),
			new StringRefAddr("uuid", uuid),
			SessionFactoryObjectFactory.class.getName(),
			null
		);
	
public org.hibernate.stat.StatisticsgetStatistics()

		return getImpl().getStatistics();
	
public booleanisClosed()

		return false;
	
public org.hibernate.classic.SessionopenSession(java.sql.Connection connection, org.hibernate.Interceptor interceptor)

		return getImpl().openSession(connection, interceptor);
	
public org.hibernate.classic.SessionopenSession(org.hibernate.Interceptor interceptor)

		return getImpl().openSession(interceptor);
	
public org.hibernate.classic.SessionopenSession()

		return getImpl().openSession();
	
public org.hibernate.classic.SessionopenSession(java.sql.Connection conn)

		return getImpl().openSession(conn);
	
public org.hibernate.StatelessSessionopenStatelessSession()

		return getImpl().openStatelessSession();
	
public org.hibernate.StatelessSessionopenStatelessSession(java.sql.Connection conn)

		return getImpl().openStatelessSession(conn);
	
private java.lang.ObjectreadResolve()

		// look for the instance by uuid
		Object result = SessionFactoryObjectFactory.getInstance(uuid);
		if (result==null) {
			// in case we were deserialized in a different JVM, look for an instance with the same name
			// (alternatively we could do an actual JNDI lookup here....)
			result = SessionFactoryObjectFactory.getNamedInstance(name);
			if (result==null) {
				throw new InvalidObjectException("Could not find a stub SessionFactory named: " + name);
			}
			else {
				log.debug("resolved stub SessionFactory by name");
			}
		}
		else {
			log.debug("resolved stub SessionFactory by uid");
		}
		return result;