Package org.datanucleus.cache

Examples of org.datanucleus.cache.CachedPC


                return;
            }

            synchronized (l2Cache)
            {
                CachedPC cachedPC = sm.cache();
                if (cachedPC != null)
                {
                    // Update/add in the L2 cache
                    if (NucleusLogger.CACHE.isDebugEnabled())
                    {
                        if (l2Cache.containsOid(id))
                        {
                            NucleusLogger.CACHE.debug(LOCALISER.msg("004013",
                                StringUtils.toJVMIDString(sm.getObject()), id,
                                StringUtils.booleanArrayToString(cachedPC.getLoadedFields()),
                                StringUtils.objectArrayToString(cachedPC.getRelationFieldNames())));
                        }
                        else
                        {
                            NucleusLogger.CACHE.debug(LOCALISER.msg("004003",
                                StringUtils.toJVMIDString(sm.getObject()), id,
                                StringUtils.booleanArrayToString(cachedPC.getLoadedFields()),
                                StringUtils.objectArrayToString(cachedPC.getRelationFieldNames())));
                        }
                    }
                    l2Cache.put(id, cachedPC);
                }
            }
View Full Code Here


            return null;
        }

        // Create the cacheable object and add to cache state
        Object cachePC = myPC.jdoNewInstance(this, myPC.jdoGetObjectId());
        CachedPC cachedPC = new CachedPC(cachePC, getLoadedFields(), getTransactionalVersion(myPC));

        // Connect a StateManager - the lifecycle state is unimportant
        JDOStateManagerImpl cacheSM = new JDOStateManagerImpl(myOM, cmd);
        cacheSM.initialiseForDetached(cachePC, getExternalObjectId(myPC), getVersion(myPC));
View Full Code Here

        }

        Level2Cache l2cache = myOM.getNucleusContext().getLevel2Cache();
        if (l2cache != null && cmd.isCacheable())
        {
            CachedPC cachedPC = null;
            synchronized (l2cache)
            {
                cachedPC = l2cache.get(myID);
                if (cachedPC != null)
                {
                    int[] cacheFieldsToLoad = getFlagsSetTo(cachedPC.getLoadedFields(), fieldNumbers, true);
                    if (cacheFieldsToLoad != null && cacheFieldsToLoad.length > 0)
                    {
                        if (NucleusLogger.CACHE.isDebugEnabled())
                        {
                            NucleusLogger.CACHE.debug(LOCALISER.msg("026034", StringUtils.toJVMIDString(myPC), myID,
                                StringUtils.intArrayToString(cacheFieldsToLoad)));
                        }

                        Object cachePC = cachedPC.getPersistableObject();
                        JDOStateManagerImpl cacheSM = new JDOStateManagerImpl(myOM, cmd);
                        // TODO Change to use a specific method - lifecycle state is not strictly correct
                        cacheSM.initialiseForDetached(cachePC, getExternalObjectId(myPC), getVersion(myPC));

                        // Copy across the specified fields from the cached object
View Full Code Here

        }

        Level2Cache l2cache = myOM.getNucleusContext().getLevel2Cache();
        if (l2cache != null && cmd.isCacheable() && !myOM.isObjectModifiedInTransaction(myID))
        {
            CachedPC cachedPC = null;
            synchronized (l2cache)
            {
                cachedPC = l2cache.get(myID);
            }
            if (cachedPC != null)
            {
                int[] cacheFieldsToLoad = getFlagsSetTo(cachedPC.getLoadedFields(), fieldNumbers, false);
                if (cacheFieldsToLoad != null && cacheFieldsToLoad.length > 0)
                {
                    if (NucleusLogger.CACHE.isDebugEnabled())
                    {
                        NucleusLogger.CACHE.debug(LOCALISER.msg("026033", StringUtils.toJVMIDString(myPC), myID,
                            StringUtils.intArrayToString(cacheFieldsToLoad)));
                    }

                    // Connect a StateManager to the cachedPC
                    Object cachePC = cachedPC.getPersistableObject();
                    JDOStateManagerImpl cacheSM = new JDOStateManagerImpl(myOM, cmd);
                    // TODO Change to use a specific method - lifecycle state is not strictly correct
                    cacheSM.initialiseForDetached(cachePC, getExternalObjectId(myPC), getVersion(myPC));

                    // Copy across the specified fields into the cached object
View Full Code Here

        // Try Level 2 since not in Level 1
        if (context.hasLevel2Cache())
        {
            Level2Cache l2Cache = context.getLevel2Cache();
            CachedPC cachedPC = null;
            synchronized (l2Cache)
            {
                cachedPC = l2Cache.get(id);
            }

            // Create active version of cached object with StateManager connected and same id
            if (cachedPC != null)
            {
                if (NucleusLogger.CACHE.isDebugEnabled())
                {
                    NucleusLogger.CACHE.debug(LOCALISER.msg("004015",
                        getIdentityAsString(id),
                        StringUtils.booleanArrayToString(cachedPC.getLoadedFields()),
                        StringUtils.objectArrayToString(cachedPC.getRelationFieldNames())));
                }

                sm = (StateManager) ObjectProviderFactory.newForCachedPC(this, id, cachedPC);
                pc = sm.getObject(); // Object in P_CLEAN state
                if (NucleusLogger.CACHE.isDebugEnabled())
View Full Code Here

            return null;
        }

        // Create the cacheable object and add to cache state
        Object cachePC = myPC.jdoNewInstance(this, myPC.jdoGetObjectId());
        CachedPC cachedPC = new CachedPC(cachePC, getLoadedFields(), getTransactionalVersion(myPC));

        // Connect a StateManager
        JDOStateManagerImpl cacheSM = new JDOStateManagerImpl(myOM, cmd);
        // TODO Change to use a specific method - lifecycle state is not strictly correct
        cacheSM.initialiseForDetached(cachePC, getExternalObjectId(myPC), getVersion(myPC));
View Full Code Here

        Level2Cache l2cache = myOM.getObjectManagerFactory().getLevel2Cache();
        if (l2cache != null && cmd.isCacheable() && !myOM.isObjectModifiedInTransaction(myID))
        {
            synchronized (l2cache)
            {
                CachedPC cachedPC = l2cache.get(myID);
                if (cachedPC != null)
                {
                    int[] cacheFieldsToLoad = getFlagsSetTo(cachedPC.getLoadedFields(), fieldNumbers, false);
                    if (cacheFieldsToLoad != null && cacheFieldsToLoad.length > 0)
                    {
                        NucleusLogger.CACHE.debug(LOCALISER.msg("026033", StringUtils.toJVMIDString(myPC), myID,
                            StringUtils.intArrayToString(cacheFieldsToLoad)));

                        // Connect a StateManager to the cachedPC
                        Object cachePC = cachedPC.getPersistableObject();
                        JDOStateManagerImpl cacheSM = new JDOStateManagerImpl(myOM, cmd);
                        // TODO Change to use a specific method - lifecycle state is not strictly correct
                        cacheSM.initialiseForDetached(cachePC, getExternalObjectId(myPC), getVersion(myPC));

                        // Copy across the specified fields into the cached object
View Full Code Here

                return;
            }

            synchronized (l2Cache)
            {
                CachedPC cachedPC = sm.cache();
                if (cachedPC != null)
                {
                    // Update/add in the L2 cache
                    if (NucleusLogger.CACHE.isDebugEnabled())
                    {
                        if (l2Cache.containsOid(id))
                        {
                            NucleusLogger.CACHE.debug(LOCALISER.msg("004013",
                                StringUtils.toJVMIDString(sm.getObject()), id,
                                StringUtils.booleanArrayToString(cachedPC.getLoadedFields())));
                        }
                        else
                        {
                            NucleusLogger.CACHE.debug(LOCALISER.msg("004003",
                                StringUtils.toJVMIDString(sm.getObject()), id,
                                StringUtils.booleanArrayToString(cachedPC.getLoadedFields()),
                                StringUtils.objectArrayToString(cachedPC.getRelationFieldNames())));
                        }
                    }
                    l2Cache.put(id, cachedPC);
                }
            }
View Full Code Here

        if (omf.hasLevel2Cache())
        {
            Level2Cache l2Cache = omf.getLevel2Cache();
            synchronized (l2Cache)
            {
                CachedPC cachedPC = l2Cache.get(id);

                // Create active version of cached object with StateManager connected and same id
                if (cachedPC != null)
                {
                    sm = StateManagerFactory.newStateManagerForCachedPC(this, id, cachedPC);
                    pc = sm.getObject(); // Object in P_CLEAN state
                    if (NucleusLogger.CACHE.isDebugEnabled())
                    {
                        NucleusLogger.CACHE.debug(LOCALISER.msg("004006",
                            StringUtils.toJVMIDString(pc), getIdentityAsString(id),
                            StringUtils.booleanArrayToString(cachedPC.getLoadedFields()),
                            StringUtils.objectArrayToString(cachedPC.getRelationFieldNames()),
                            "" + l2Cache.getSize()));
                    }
                    if (tx.isActive() && tx.getOptimistic())
                    {
                        // Optimistic txns, so return as P_NONTRANS (as per JDO2 spec)
View Full Code Here

TOP

Related Classes of org.datanucleus.cache.CachedPC

Copyright © 2018 www.massapicom. 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.