Package org.apache.ojb.broker.core.proxy

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


                try
                {
                    while (colIterator.hasNext())
                    {
                        item = colIterator.next();
                        IndirectionHandler handler = ProxyHelper.getIndirectionHandler(item);
                        if (handler != null)
                        {
                            if (!handler.alreadyMaterialized())
                            {
                                continue;
                            }
                            else
                            {
                                // @todo consider registering to hear when this is
                                // derefernced instead of just loading here -bmc
                                item = handler.getRealSubject();
                            }
                        }
                        if(!cds.isMtoNRelation())
                        {
                            //if itemCld refers to an interface the foreignKeyFieldDescriptors
View Full Code Here


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

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

     * @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

    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));
View Full Code Here

             *
             * arminw:
             * wrap Object or Identity with a helper class. The main object will get
             * dirty when the 1:1 reference change: add or replaced by another object or deleted
             */
            IndirectionHandler handler = ProxyHelper.getIndirectionHandler(referenceObject);
            // if it is a not materialized proxy, use the Identity
            if(handler != null)
            {
                erh = handler.alreadyMaterialized()
                        ? new EqualsRefHelper(handler.getRealSubject())
                        : new EqualsRefHelper(handler.getIdentity());
            }
            else
            {
                erh = new EqualsRefHelper(referenceObject);
            }
View Full Code Here

            try
            {
                PersistenceBroker broker = capsule.getBroker();
                Iterator it = colProxy.ojbIterator();
                Object tempObj;
                IndirectionHandler tempHandler;
                while(it.hasNext())
                {
                    tempObj = it.next();
                    // the referenced objects can be proxy objects too
                    tempHandler = ProxyHelper.getIndirectionHandler(tempObj);
                    if(tempHandler != null)
                    {
                        addReference(tempHandler.getIdentity(), tempObj);
                    }
                    else
                    {
                        addReference(broker.serviceIdentity().buildIdentity(tempObj), tempObj);
                    }
View Full Code Here

    best performance, thus create Identity object only if needed
    and do 'is new object' check only if needed.
    */
    private void init(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());
            }
View Full Code Here

           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(rtObject.isProxy())
        {
            IndirectionHandler handler = rtObject.getHandler();
            if(handler == null)
            {
                throw new OJBRuntimeException("Unexpected error, expect an proxy object as indicated: " + rtObject);
            }
            if (handler.alreadyMaterialized())
            {
                objectToRegister = handler.getRealSubject();
            }
            else
            {
                registerToIndirectionHandler(handler);
                registerUnmaterializedLocks(rtObject.getObj());
View Full Code Here

                        {
                            item = colIterator.next();
                            RuntimeObject rt = new RuntimeObject(item, this);
                            if (rt.isProxy())
                            {
                                IndirectionHandler handler = ProxyHelper.getIndirectionHandler(item);
                                if (!handler.alreadyMaterialized())
                                {
                                    handler.addListener(this);
                                    continue;
                                }
                                else
                                {
                                    // @todo consider registering to hear when this is
                                    // derefernced instead of just loading here -bmc
                                    item = handler.getRealSubject();
                                }
                            }
                            lockAndRegister(rt, lockMode, true);
                        }
                    }
View Full Code Here

            if(depObj != null)
            {
                // in any case we have to link the source object when the object is 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());
                    }
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.core.proxy.IndirectionHandler

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.