Examples of PhysicalEntityManagerWrapper


Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

                EntityManagerFactory emf =
                        EntityManagerFactoryWrapper.lookupEntityManagerFactory(
                                ComponentInvocation.ComponentInvocationType.EJB_INVOCATION,
                                unitName, ejbDescriptor);
                if (emf != null) {
                    PhysicalEntityManagerWrapper physicalEntityManagerWrapper = findExtendedEMFromInvList(emf);

                    if (physicalEntityManagerWrapper == null) {
                        // We did not find an extended EM that we can inherit from. Create one
                        try {
                            EntityManager em = emf.createEntityManager(refDesc.getSynchronizationType(), refDesc.getProperties());
                            physicalEntityManagerWrapper = new PhysicalEntityManagerWrapper(em, refDesc.getSynchronizationType());
                        } catch (Throwable th) {
                            EJBException ejbEx = new EJBException
                                    ("Couldn't create EntityManager for"
                                            + " refName: " + refDesc.getName()
                                            + "; unitname: " + unitName);
                            ejbEx.initCause(th);
                            throw ejbEx;
                        }
                    } else {
                        // We found an extended EM we can inherit from. Validate that sync type matches
                        if(physicalEntityManagerWrapper.getSynchronizationType() != refDesc.getSynchronizationType()) {
                            throw new EJBException("The current invocation inherits a persistence context of synchronization type '" + physicalEntityManagerWrapper.getSynchronizationType() +
                                    "' where as it references a persistence context of synchronization type '" + refDesc.getSynchronizationType() +
                                    "' refName: " + refDesc.getName() +
                                    " unitName: " + unitName );
                        }
                    }
                    String emRefName = refDesc.getName();
                    long containerID = this.getContainerId();
                    EEMRefInfo refInfo = null;
                    synchronized (extendedEMReferenceCountMap) {
                        refInfo = extendedEMReferenceCountMap.get(physicalEntityManagerWrapper.getEM());
                        if (refInfo != null) {
                            refInfo.refCount++;
                        } else {
                            refInfo = new EEMRefInfo(emRefName, refDesc.getUnitName(), refDesc.getSynchronizationType(), containerID,
                                    sessionKey, physicalEntityManagerWrapper.getEM(), emf);
                            refInfo.refCount = 1;
                            extendedEMReferenceCountMap.put(physicalEntityManagerWrapper.getEM(), refInfo);
                            eemKey2EEMMap.put(refInfo.getKey(), refInfo.getEntityManager());
                        }
                    }
                    ctx.addExtendedEntityManagerMapping(emf, refInfo);
                    eemRefInfos.add(refInfo);
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

            ctx.setEEMRefInfos(eemRefInfos);
        }
    }

    private PhysicalEntityManagerWrapper findExtendedEMFromInvList(EntityManagerFactory emf) {
        PhysicalEntityManagerWrapper em = null;

        ComponentInvocation compInv = (ComponentInvocation)
                invocationManager.getCurrentInvocation();
        if (compInv != null) {
            if (compInv.getInvocationType() == ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

        return em;
    }

    public EntityManager lookupExtendedEntityManager(EntityManagerFactory emf) {
        PhysicalEntityManagerWrapper physicalEntityManagerWrapper = findExtendedEMFromInvList(emf);
        return physicalEntityManagerWrapper == null ? null : physicalEntityManagerWrapper.getEM();
    }
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

            }

            // Now see if there's already a *different* extended
            // persistence context within this transaction for the
            // same EntityManagerFactory.
            PhysicalEntityManagerWrapper physicalEM = (PhysicalEntityManagerWrapper) clientJ2EETx.getExtendedEntityManagerResource(emf);
            if( (physicalEM != null) && entry.getValue().getEM() != physicalEM.getEM() ) {
                throw new EJBException("Detected two different extended persistence contexts for the same EntityManagerFactory within a transaction");
            }

        }

View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

                sessionCtx.getExtendedEntityManagerMap();

            for (Map.Entry<EntityManagerFactory, PhysicalEntityManagerWrapper> entry :
                     entityManagerMap.entrySet()) {
                EntityManagerFactory emf = entry.getKey();
                PhysicalEntityManagerWrapper extendedEm = entry.getValue();

                PhysicalEntityManagerWrapper extendedEmAssociatedWithTx = EntityManagerWrapper.getExtendedEntityManager(j2eeTx, emf);

                // If there's not already an EntityManager registered for
                // this extended EntityManagerFactory within the current tx
                if (extendedEmAssociatedWithTx == null) {
                    j2eeTx.addExtendedEntityManagerMapping(emf, extendedEm);
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

                EntityManagerFactory emf =
                        EntityManagerFactoryWrapper.lookupEntityManagerFactory(
                                ComponentInvocation.ComponentInvocationType.EJB_INVOCATION,
                                unitName, ejbDescriptor);
                if (emf != null) {
                    PhysicalEntityManagerWrapper physicalEntityManagerWrapper = findExtendedEMFromInvList(emf);

                    if (physicalEntityManagerWrapper == null) {
                        // We did not find an extended EM that we can inherit from. Create one
                        try {
                            EntityManager em = emf.createEntityManager(refDesc.getSynchronizationType(), refDesc.getProperties());
                            physicalEntityManagerWrapper = new PhysicalEntityManagerWrapper(em, refDesc.getSynchronizationType());
                        } catch (Throwable th) {
                            EJBException ejbEx = new EJBException
                                    ("Couldn't create EntityManager for"
                                            + " refName: " + refDesc.getName()
                                            + "; unitname: " + unitName);
                            ejbEx.initCause(th);
                            throw ejbEx;
                        }
                    } else {
                        // We found an extended EM we can inherit from. Validate that sync type matches
                        if(physicalEntityManagerWrapper.getSynchronizationType() != refDesc.getSynchronizationType()) {
                            throw new EJBException("The current invocation inherits a persistence context of synchronization type '" + physicalEntityManagerWrapper.getSynchronizationType() +
                                    "' where as it references a persistence context of synchronization type '" + refDesc.getSynchronizationType() +
                                    "' refName: " + refDesc.getName() +
                                    " unitName: " + unitName );
                        }
                    }
                    String emRefName = refDesc.getName();
                    long containerID = this.getContainerId();
                    EEMRefInfo refInfo = null;
                    synchronized (extendedEMReferenceCountMap) {
                        refInfo = extendedEMReferenceCountMap.get(physicalEntityManagerWrapper.getEM());
                        if (refInfo != null) {
                            refInfo.refCount++;
                        } else {
                            refInfo = new EEMRefInfo(emRefName, refDesc.getUnitName(), refDesc.getSynchronizationType(), containerID,
                                    sessionKey, physicalEntityManagerWrapper.getEM(), emf);
                            refInfo.refCount = 1;
                            extendedEMReferenceCountMap.put(physicalEntityManagerWrapper.getEM(), refInfo);
                            eemKey2EEMMap.put(refInfo.getKey(), refInfo.getEntityManager());
                        }
                    }
                    ctx.addExtendedEntityManagerMapping(emf, refInfo);
                    eemRefInfos.add(refInfo);
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

            ctx.setEEMRefInfos(eemRefInfos);
        }
    }

    private PhysicalEntityManagerWrapper findExtendedEMFromInvList(EntityManagerFactory emf) {
        PhysicalEntityManagerWrapper em = null;

        ComponentInvocation compInv = (ComponentInvocation)
                invocationManager.getCurrentInvocation();
        if (compInv != null) {
            if (compInv.getInvocationType() == ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

        return em;
    }

    public EntityManager lookupExtendedEntityManager(EntityManagerFactory emf) {
        PhysicalEntityManagerWrapper physicalEntityManagerWrapper = findExtendedEMFromInvList(emf);
        return physicalEntityManagerWrapper == null ? null : physicalEntityManagerWrapper.getEM();
    }
View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

            }

            // Now see if there's already a *different* extended
            // persistence context within this transaction for the
            // same EntityManagerFactory.
            PhysicalEntityManagerWrapper physicalEM = (PhysicalEntityManagerWrapper) clientJ2EETx.getExtendedEntityManagerResource(emf);
            if( (physicalEM != null) && entry.getValue().getEM() != physicalEM.getEM() ) {
                throw new EJBException("Detected two different extended persistence contexts for the same EntityManagerFactory within a transaction");
            }

        }

View Full Code Here

Examples of com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper

                sessionCtx.getExtendedEntityManagerMap();

            for (Map.Entry<EntityManagerFactory, PhysicalEntityManagerWrapper> entry :
                     entityManagerMap.entrySet()) {
                EntityManagerFactory emf = entry.getKey();
                PhysicalEntityManagerWrapper extendedEm = entry.getValue();

                PhysicalEntityManagerWrapper extendedEmAssociatedWithTx = EntityManagerWrapper.getExtendedEntityManager(j2eeTx, emf);

                // If there's not already an EntityManager registered for
                // this extended EntityManagerFactory within the current tx
                if (extendedEmAssociatedWithTx == null) {
                    j2eeTx.addExtendedEntityManagerMapping(emf, extendedEm);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.