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

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


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


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

            */
            if(!rds.isSuperReferenceDescriptor())
            {
                Object referenceObject = rds.getPersistentField().get(myObj);

                IndirectionHandler handler = ProxyHelper.getIndirectionHandler(referenceObject);
                /*
                arminw:
                if object was serialized and anonymous FK are used in the main object, the FK
                values are null, we have to refresh (re-assign) these values before building field images.
                This will not touch the main object itself, because we only reassign anonymous FK fields.
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

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

            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

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

    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

    public Object createProxy(Class baseClassForProxy, Identity realSubjectsIdentity)
    {
        try
        {
            // the invocation handler manages all delegation stuff
            IndirectionHandler handler     = getProxyFactory().createIndirectionHandler(pbKey, realSubjectsIdentity);

            // the proxy simply provides the interface of the real subject
            if (VirtualProxy.class.isAssignableFrom(baseClassForProxy))
            {
                Constructor constructor = baseClassForProxy.getDeclaredConstructor(new Class[]{ IndirectionHandler.class });
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.