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

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


            init();
        }

        private void init()
        {
            CollectionProxy colProxy = ProxyHelper.getCollectionProxy(collectionOrArray);
            if(colProxy != null)
            {
                if(colProxy.isLoaded())
                {
                    status = IS_MATERIALIZED_PROXY;
                    /*
                    TODO: avoid this cast
                    e.g. change CollectionProxy interface - CollectionProxy should
                    extend Collection to support Iterator
                    */
                    handleReferencedObjects(((Collection) colProxy).iterator());
                }
                else
                {
                    status = IS_UNMATERIALIZED_PROXY;
                    if(log.isDebugEnabled()) log.debug("Unmaterialized proxy collection, use proxy listener");
                    colProxy.addListener(this);
                }
            }
            else
            {
                status = IS_NORMAL_OBJECT;
View Full Code Here


            }
            else
            {
                if(status == IS_UNMATERIALIZED_PROXY)
                {
                    CollectionProxy colProxy = ProxyHelper.getCollectionProxy(collectionOrArray);
                    if(colProxy != null)
                    {
                        colProxy.removeListener(this);
                    }
                }
            }
        }
View Full Code Here

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

        // PersistenceBroker pb = getTransaction().getBroker();
        for(int i = 0; i < descriptor.size(); i++)
        {
            CollectionDescriptor col = (CollectionDescriptor) descriptor.get(i);
            Object collOrArray = col.getPersistentField().get(source.getObject());
            CollectionProxy proxy = ProxyHelper.getCollectionProxy(collOrArray);
            /*
            on insert we perform only materialized collection objects. This should be
            sufficient, because in method #cascadingDependents() we make sure that on
            move of unmaterialized collection objects the proxy was materialized if needed.
            */
 
View Full Code Here

        query.create("select books from " + Book.class.getName() + " where title like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        assertEquals(1, result.size());
        Book b = (Book) result.iterator().next();
        CollectionProxy handler = ProxyHelper.getCollectionProxy(b.getReviews());
        assertFalse("Don't expect an materialized collection proxy", handler.isLoaded());
        handler.addListener(new CollectionProxyListener()
        {
            public void beforeLoading(CollectionProxyDefaultImpl colProxy)
            {
                fail("Collection proxy shouldn't be materialized");
            }
View Full Code Here

        {
            CollectionDescriptor cds = (CollectionDescriptor) i.next();
            Object col = cds.getPersistentField().get(newTxObject);
            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);
                        continue;
                    }
                }
                Iterator colIterator = BrokerHelper.getCollectionIterator(col);
                // get foreign info for collection elements
View Full Code Here

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

            }
        }

        void assignReferenceObject(Object collOrArray)
        {
            CollectionProxy colProxy = ProxyHelper.getCollectionProxy(collOrArray);
            if(colProxy != null)
            {
                if(colProxy.isLoaded())
                {
                    status = IS_MATERIALIZED_PROXY;
                    /*
                    TODO: avoid dependency to CollectionProxyDefaultImpl
                    e.g. change CollectionProxy interface - CollectionProxy should
                    extend Collection to support Iterator
                    */
                    handleCollectionOrArray(((CollectionProxyDefaultImpl) colProxy).getData());
                }
                else
                {
                    status = IS_UNMATERIALIZED_PROXY;
// TODO: ObjectEnvelopeTable#register take care of proxy objects/collection, no need to handle proxy objects??
                    colProxy.addListener(this);
                    collectionHandler = colProxy;
                }
            }
            else
            {
View Full Code Here

        PersistenceBroker pb = getTransaction().getBroker();
        for(int i = 0; i < descriptor.size(); i++)
        {
            CollectionDescriptor col = (CollectionDescriptor) descriptor.get(i);
            Object collOrArray = col.getPersistentField().get(source.getObject());
            CollectionProxy proxy = ProxyHelper.getCollectionProxy(collOrArray);
            /*
            on insert we perform only materialized collection objects. This should be
            sufficient, because in method #cascadingDependents() we make sure that on
            move of unmaterialized collection objects the proxy was materialized if needed.
            */
 
View Full Code Here

        query.create("select books from " + Book.class.getName() + " where title like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        assertEquals(1, result.size());
        Book b = (Book) result.iterator().next();
        CollectionProxy handler = ProxyHelper.getCollectionProxy(b.getReviews());
        assertFalse("Don't expect an materialized collection proxy", handler.isLoaded());
        handler.addListener(new CollectionProxyListener()
        {
            public void beforeLoading(CollectionProxyDefaultImpl colProxy)
            {
                fail("Collection proxy shouldn't be materialized");
            }
View Full Code Here

TOP

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

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.