当前位置: 首页>>代码示例>>Java>>正文


Java ProxyHelper.getIndirectionHandler方法代码示例

本文整理汇总了Java中org.apache.ojb.broker.core.proxy.ProxyHelper.getIndirectionHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyHelper.getIndirectionHandler方法的具体用法?Java ProxyHelper.getIndirectionHandler怎么用?Java ProxyHelper.getIndirectionHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ojb.broker.core.proxy.ProxyHelper的用法示例。


在下文中一共展示了ProxyHelper.getIndirectionHandler方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initCld

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
private void initCld(final TransactionImpl tx)
{
    final IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj);
    if(handler != null)
    {
        this.handler = handler;
        isNew = Boolean.FALSE;
        identity = handler.getIdentity();
        if(handler.alreadyMaterialized())
        {
            cld = tx.getBroker().getClassDescriptor(handler.getRealSubject().getClass());
        }
        else
        {
            cld = tx.getBroker().getClassDescriptor(identity.getObjectsRealClass());
        }
    }
    else
    {
        cld = tx.getBroker().getClassDescriptor(obj.getClass());
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:RuntimeObject.java

示例2: hasNullPKField

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
/**
 * Detect if the given object has a PK field represents a 'null' value.
 */
public boolean hasNullPKField(ClassDescriptor cld, Object obj)
{
    FieldDescriptor[] fields = cld.getPkFields();
    boolean hasNull = false;
    // an unmaterialized proxy object can never have nullified PK's
    IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj);
    if(handler == null || handler.alreadyMaterialized())
    {
        if(handler != null) obj = handler.getRealSubject();
        FieldDescriptor fld;
        for(int i = 0; i < fields.length; i++)
        {
            fld = fields[i];
            hasNull = representsNull(fld, fld.getPersistentField().get(obj));
            if(hasNull) break;
        }
    }
    return hasNull;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:BrokerHelper.java

示例3: ContextEntry

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
ContextEntry(Object theUserObject)
{
    userObject = theUserObject;
    if (userObject != null)
    {
        handler = ProxyHelper.getIndirectionHandler(userObject);
        if ((handler != null) && handler.alreadyMaterialized())
        {
            userObject = handler.getRealSubject();
            handler = null;
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:14,代码来源:ConcreteEditingContext.java

示例4: RuntimeObject

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
public RuntimeObject(final Object obj, final Identity oid, final ClassDescriptor cld, final boolean isNew, final boolean isProxy)
{
    this.tx = null;
    this.obj = obj;
    this.identity = oid;
    this.isNew = isNew ? Boolean.TRUE : Boolean.FALSE;
    this.cld = cld;
    if(isProxy)
    {
        this.handler = ProxyHelper.getIndirectionHandler(obj);
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:13,代码来源:RuntimeObject.java

示例5: associateBatched

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
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(pb.serviceIdentity().buildIdentity(realSubject), 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);
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:34,代码来源:PlainPrefetcher.java

示例6: getKeyValues

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
/**
 * Returns an Array with an Objects PK VALUES if convertToSql is true, any
 * associated java-to-sql conversions are applied. If the Object is a Proxy
 * or a VirtualProxy NO conversion is necessary.
 *
 * @param objectOrProxy
 * @param convertToSql
 * @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);
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:25,代码来源:BrokerHelper.java

示例7: retrieveProxyReference

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
/**
 * Retrieve a single Reference.
 * This implementation retrieves a referenced object from the data backend
 * if <b>cascade-retrieve</b> is true or if <b>forced</b> is true.
 *
 * @param obj - object that will have it's field set with a referenced object.
 * @param cld - the ClassDescriptor describring obj
 * @param rds - the ObjectReferenceDescriptor of the reference attribute to be loaded
 * @param forced - if set to true, the reference is loaded even if the rds differs.
 */
public void retrieveProxyReference(Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean forced)
{
    PersistentField refField;
    Object refObj = null;

        pb.getInternalCache().enableMaterializationCache();
        try
        {
            Identity id = getReferencedObjectIdentity(obj, rds, cld);
            if (id != null){
                refObj = pb.createProxy(rds.getItemClass(), id);
            }
            refField = rds.getPersistentField();
            refField.set(obj, refObj);

            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,
                            rds, rds.getProxyPrefetchingLimit());
                }
            }
            

            pb.getInternalCache().disableMaterializationCache();
        }
        catch(RuntimeException e)
        {
            pb.getInternalCache().doLocalClear();
            throw e;
        }
    
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:50,代码来源:QueryReferenceBroker.java

示例8: addThisListenerTo

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
protected void addThisListenerTo(Object owner)
{
    _listenedHandler = ProxyHelper.getIndirectionHandler(owner);

    if (_listenedHandler != null)
    {
        _listenedHandler.addListener(this);
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:10,代码来源:QueryReferenceBroker.java

示例9: lockAndRegisterCollections

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
private void lockAndRegisterCollections(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException
{
    if (implicitLocking)
    {
        Iterator i = cld.getCollectionDescriptors(true).iterator();
        while (i.hasNext())
        {
            CollectionDescriptor cds = (CollectionDescriptor) i.next();
            Object col = cds.getPersistentField().get(sourceObject);
            if (col != null)
            {
                CollectionProxy proxy = ProxyHelper.getCollectionProxy(col);
                if (proxy != null)
                {
                    if (!proxy.isLoaded())
                    {
                        if (log.isDebugEnabled()) log.debug("adding self as listener to collection proxy");
                        proxy.addListener(this);
                        registeredCollectionProxies.add(proxy);
                        continue;
                    }
                }
                Iterator colIterator = BrokerHelper.getCollectionIterator(col);
                Object item = null;
                try
                {
                    while (colIterator.hasNext())
                    {
                        item = colIterator.next();
                        RuntimeObject rt = new RuntimeObject(item, this);
                        if (rt.isProxy())
                        {
                            IndirectionHandler handler = ProxyHelper.getIndirectionHandler(item);
                            if (!handler.alreadyMaterialized())
                            {
                                registerToIndirectionHandler(handler);
                                continue;
                            }
                            else
                            {
                                // @todo consider registering to hear when this is
                                // derefernced instead of just loading here -bmc
                                item = handler.getRealSubject();
                            }
                        }
                        if (!registrationList.contains(rt.getIdentity()))
                        {
                            lockAndRegister(rt, lockMode, registeredObjects);
                        }
                    }
                }
                catch (LockNotGrantedException e)
                {
                    String eol = SystemUtils.LINE_SEPARATOR;
                    log.error("Lock not granted, while lock collection references[" +
                            eol + "current reference descriptor:" +
                            eol + cds.toXML() +
                            eol + "object to lock: " + item +
                            eol + "main object class: " + sourceObject.getClass().getName() +
                            eol + "]", e);
                    throw e;
                }
            }
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:67,代码来源:TransactionImpl.java

示例10: cascadeInsertSingleReferences

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
private void cascadeInsertSingleReferences(ObjectEnvelope source, List descriptor, List alreadyPrepared)
{
    for(int i = 0; i < descriptor.size(); i++)
    {
        ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) descriptor.get(i);
        Object depObj = ord.getPersistentField().get(source.getObject());

        if(depObj != null)
        {
            // in any case we have to link the source object when the object needs insert
            source.addLinkOneToOne(ord, false);

            IndirectionHandler handler = ProxyHelper.getIndirectionHandler(depObj);
            // if the object is not materialized, nothing has changed
            if(handler == null || handler.alreadyMaterialized())
            {
                RuntimeObject rt;
                // if materialized
                if(handler != null)
                {
                    rt = new RuntimeObject(handler.getRealSubject(), getTransaction(), false);
                }
                else
                {
                    rt = new RuntimeObject(depObj, getTransaction());
                }
                Identity oid = rt.getIdentity();
                if(!alreadyPrepared.contains(oid))
                {
                    ObjectEnvelope depMod = getByIdentity(oid);
                    // if the object isn't registered and is a new object, register it
                    // else we have nothing to do
                    if(depMod == null && rt.isNew())
                    {
                        getTransaction().lockAndRegister(rt, Transaction.WRITE, false, getTransaction().getRegistrationList());
                        depMod = getByIdentity(oid);
                        cascadeInsertFor(depMod, alreadyPrepared);
                    }
                }
            }
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:44,代码来源:ObjectEnvelopeTable.java

示例11: retrieveReference

import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
/**
 * Retrieve a single Reference.
 * This implementation retrieves a referenced object from the data backend
 * if <b>cascade-retrieve</b> is true or if <b>forced</b> is true.
 *
 * @param obj - object that will have it's field set with a referenced object.
 * @param cld - the ClassDescriptor describring obj
 * @param rds - the ObjectReferenceDescriptor of the reference attribute to be loaded
 * @param forced - if set to true, the reference is loaded even if the rds differs.
 */
public void retrieveReference(Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean forced)
{
    PersistentField refField;
    Object refObj = null;
    
    if (forced || rds.getCascadeRetrieve())
    {
        pb.getInternalCache().enableMaterializationCache();
        try
        {
            Identity id = getReferencedObjectIdentity(obj, rds, cld);
            boolean isRefObjDefined = true;

            if (id == null)
            {
                refObj = null;
            } //JMM : why not see if the object has already been loaded
            else if ( pb.serviceObjectCache().lookup(id) != null )
            {
                refObj = pb.doGetObjectByIdentity(id);
                if (rds.isSuperReferenceDescriptor()) 
                {
                    // walk the super-references
                    ClassDescriptor superCld = cld.getRepository().getDescriptorFor(rds.getItemClass());
                    retrieveReferences(refObj, superCld, false);
                    retrieveCollections(refObj, superCld, false);                        
                }
            }
            else if ((m_retrievalTasks != null)
                    && !rds.isLazy()
                    && (rds.getItemProxyClass() == null))
            {
                addRetrievalTask(obj, rds);
                isRefObjDefined = false;
            }
            else
            {
                refObj = getReferencedObject(id, rds);
            }

            if (isRefObjDefined)
            {
                refField = rds.getPersistentField();
                refField.set(obj, refObj);

                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,
                                rds, rds.getProxyPrefetchingLimit());
                    }
                }
            }

            pb.getInternalCache().disableMaterializationCache();
        }
        catch(RuntimeException e)
        {
            pb.getInternalCache().doLocalClear();
            throw e;
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:80,代码来源:QueryReferenceBroker.java


注:本文中的org.apache.ojb.broker.core.proxy.ProxyHelper.getIndirectionHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。