Examples of IndirectionHandler


Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

    }

    protected void associateBatched(Collection proxies, Collection realSubjects)
    {
        PersistenceBroker pb = getBroker();
        IndirectionHandler handler;
        Identity id;
        Object proxy;
        Object realSubject;
        HashMap realSubjectsMap = new HashMap(realSubjects.size());

        for (Iterator it = realSubjects.iterator(); it.hasNext(); )
        {
            realSubject = it.next();
            realSubjectsMap.put(new Identity(realSubject, pb), realSubject);
        }

        for (Iterator it = proxies.iterator(); it.hasNext(); )
        {
            proxy = it.next();
            handler = ProxyHelper.getIndirectionHandler(proxy);

            if (handler == null)
            {
                continue;
            }

            id = handler.getIdentity();
            realSubject = realSubjectsMap.get(id);
            if (realSubject != null)
            {
                handler.setRealSubject(realSubject);
            }
        }
    }
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

    protected Query[] buildPrefetchQueries(Collection proxies, Collection realSubjects)
    {
        Collection queries = new ArrayList();
        Collection idsSubset;
        Object proxy;
        IndirectionHandler handler;
        Identity id;
        Class realClass;
        HashMap classToIds = new HashMap();
        Class topLevelClass = getItemClassDescriptor().getClassOfObject();
        PersistenceBroker pb = getBroker();
        ObjectCache cache = pb.serviceObjectCache();

        for (Iterator it = proxies.iterator(); it.hasNext(); )
        {
            proxy = it.next();
            handler = ProxyHelper.getIndirectionHandler(proxy);

            if (handler == null)
            {
                continue;
            }
           
            id = handler.getIdentity();
            if (cache.lookup(id) != null)
            {
                realSubjects.add(pb.getObjectByIdentity(id));
                continue;
            }
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

    private void init(Object objectToIdentify, PersistenceBroker targetBroker, ClassDescriptor cld)
    {
        if(objectToIdentify == null) throw new OJBRuntimeException("Can't create Identity for 'null'-object");
        try
        {
            IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objectToIdentify);

            if (handler != null)
            {
                Identity sourceOID = handler.getIdentity();
                m_objectsTopLevelClass = sourceOID.m_objectsTopLevelClass;
                m_objectsRealClass = sourceOID.m_objectsRealClass;
                m_pkValues = sourceOID.m_pkValues;
            }
            else
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

     * @return Object[]
     * @throws PersistenceBrokerException
     */
    public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy, boolean convertToSql) throws PersistenceBrokerException
    {
        IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objectOrProxy);

        if(handler != null)
        {
            return getKeyValues(cld, handler.getIdentity(), convertToSql)//BRJ: convert Identity
        }
        else
        {
            ClassDescriptor realCld = getRealClassDescriptor(cld, objectOrProxy);
            return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql);
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

             * if it's been materialized, we put it in the map, because it could change.
             * if it hasn't been materialized, it hasn't changed.
             *
             * Also handles virtual proxies.
             */
            IndirectionHandler handler = ProxyHelper.getIndirectionHandler(temp);

            if(handler != null)
            {
                /**
                 * only register if the proxy has been materialized
                 * if it's materialized later and the map is compared, it will
                 * trigger the update
                 */
                fieldValues.put(rds, handler.getIdentity());
            }
            else
            {
                fieldValues.put(rds, temp);
            }
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

                 * on a query for a class that is mapped to a table that has other classes
                 * mapped to that table as well, but aren't extents.
                 */
                if (candidate != null)
                {
                    IndirectionHandler handler = ProxyHelper.getIndirectionHandler(candidate);

                    if ((handler != null)
                            || itemClass.isAssignableFrom(candidate.getClass()))
                    {
                        result.ojbAdd(candidate);
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

                if ((refObj != null) && prefetchProxies
                        && (m_retrievalTasks != null)
                        && (rds.getProxyPrefetchingLimit() > 0))
                {
                    IndirectionHandler handler = ProxyHelper.getIndirectionHandler(refObj);

                    if ((handler != null)
                            && addRetrievalTask(obj, rds))
                    {
                        new PBMaterializationListener(obj, m_retrievalTasks,
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

            }
            else // PersistentBrokerImpl.this
            {
                // a special case: current collection being loaded contains proxies,
                // just load them without setting any fields
                IndirectionHandler handler = (IndirectionHandler) listenedObject;
                return new PlainPrefetcher(pb, handler.getIdentity().getObjectsTopLevelClass());
            }
        }
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

            throws LockingException
    {
        ContextEntry entry;
        LockManager lockManager;
        Swizzling swizzlingStrategy;
        IndirectionHandler handler = null;
        OTMKit kit = _tx.getKit();
        // Are we building object's relations for the userObject in the transaction?
        // Otherwise we just get data from the "userObject" and put it into
        // the previously loaded/created object in the transaction
        boolean buildingObject = false;
        boolean lazySwizzle = false;

        if (lock == LockType.NO_LOCK)
        {
            return null;
        }

        entry = (ContextEntry) _objects.get(oid);

        if (userObject == null)
        {
            // invalidating object...
            _original.remove(oid);
            _checkpointed.remove(oid);
            if (entry != null)
            {
                entry.userObject = null;
                entry.cacheObject = null;
            }
            return entry;
        }

        lockManager = LockManager.getInstance();
        swizzlingStrategy = kit.getSwizzlingStrategy();

        handler = ProxyHelper.getIndirectionHandler(userObject);
        if ((handler != null) && handler.alreadyMaterialized())
        {
            userObject = handler.getRealSubject();
            handler = null;
        }

        if ((entry == null) || (entry.userObject == null))
        {
View Full Code Here

Examples of org.apache.ojb.broker.core.proxy.IndirectionHandler

     */
    private synchronized void register(Object newTxObject, int lockMode)
            throws LockNotGrantedException, PersistenceBrokerException
    {
        Object objectToRegister = newTxObject;
        IndirectionHandler handler = null;

        // Proxies must be treated specially
        handler = ProxyHelper.getIndirectionHandler(newTxObject);

        /*
        if the object is a Proxy there are two options:
        1. The proxies real subject has already been materialized:
           we take this real subject as the object to register and proceed
           as if it were a ordinary object.
        2. The real subject has not been materialized: Then there is nothing
           to be registered now!
           Of course we might just materialize the real subject to have something
           to register. But this would make proxies useless for ODMG as proxies would
           get materialized even if their real subjects were not used by the
           client app.
           Thus we register the current transaction as a Listener to the IndirectionHandler
           of the Proxy.
           Only when the IndirectionHandler performs the materialization of the real subject
           at some later point in time it invokes callbacks on all it's listeners.
           Using this callback we can defer the registering until it's really needed.
        */
        if (handler != null)
        {
            if (handler.alreadyMaterialized())
            {
                objectToRegister = handler.getRealSubject();
            }
            else
            {
                registerToIndirectionHandler(handler);
                registerUnmaterializedLocks(newTxObject);
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.