FileDocCategorySizeDatePackage
EntityManagerFactoryImpl.javaAPI DocGlassfish v2 API5688Tue May 22 16:54:24 BST 2007oracle.toplink.essentials.internal.ejb.cmp3.base

EntityManagerFactoryImpl

public abstract class EntityManagerFactoryImpl extends Object

Purpose: Provides the implementation for the EntityManager Factory.

Description: This class will store a reference to the active ServerSession. When a request is made for an EntityManager an new EntityManager is created with the ServerSession and returned. The primary consumer of these EntityManager is assumed to be either the Container. There is one EntityManagerFactory per deployment.

see
javax.persistence.EntityManager
see
oracle.toplink.essentials.ejb.cmp3.EntityManager
see
javax.persistence.EntityManagerFactory

Fields Summary
protected ServerSession
serverSession
protected EntityManagerSetupImpl
setupImpl
protected boolean
isOpen
protected Map
properties
Constructors Summary
public EntityManagerFactoryImpl(ServerSession serverSession)
Will return an instance of the Factory. Should only be called by TopLink.

param
serverSession


          

                         
      
        this.serverSession = serverSession;
    
public EntityManagerFactoryImpl(EntityManagerSetupImpl setupImpl, Map properties)

        this.setupImpl = setupImpl;
        this.properties = properties;
    
Methods Summary
public synchronized voidclose()
Closes this factory, releasing any resources that might be held by this factory. After invoking this method, all methods on the instance will throw an {@link IllegalStateException}, except for {@link #isOpen}, which will return false.

        verifyOpen();
        isOpen = false;
        setupImpl.undeploy();
    
protected oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImplcreateEntityManagerImpl(boolean extended)

        return createEntityManagerImpl(null, extended);
    
protected synchronized oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImplcreateEntityManagerImpl(java.util.Map properties, boolean extended)

        verifyOpen();

        if (!getServerSession().isConnected()) {
            getServerSession().login();
        }
        return createEntityManagerImplInternal(properties, extended);
    
protected abstract oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImplcreateEntityManagerImplInternal(java.util.Map properties, boolean extended)

protected voidfinalize()

        if(isOpen()) {
            close();
        }
    
public synchronized oracle.toplink.essentials.threetier.ServerSessiongetServerSession()
INTERNAL: Returns the ServerSession that the Factory will be using and initializes it if it is not available. This method makes use of the partially constructed session stored in our setupImpl and completes its construction

        if (serverSession == null){   
            ClassLoader realLoader = setupImpl.getPersistenceUnitInfo().getClassLoader();
            // the call top setupImpl.deploy() finishes the session creation
            serverSession = setupImpl.deploy(realLoader, properties);
        }
        return this.serverSession;
    
public booleanisOpen()
Indicates whether or not this factory is open. Returns true until a call to {@link #close} is made.

       return isOpen;
    
protected voidverifyOpen()

        if (!isOpen){
            throw new IllegalStateException(ExceptionLocalization.buildMessage("operation_on_closed_entity_manager_factory"));
        }