Examples of Proxy


Examples of org.apache.openjpa.util.Proxy

        assertNotNull(proxy.getDeclaredMethod("removeElementAt", new Class[] { int.class }));
        assertNotNull(proxy.getDeclaredMethod("setElementAt", new Class[] { Object.class, int.class }));
    }

    public void testListChangeTracker() {
        Proxy coll = _mgr.newCollectionProxy(ArrayList.class, null, null, true);
        assertNotNull(coll);
        assertNotNull(coll.getChangeTracker());
        assertTrue(coll.getChangeTracker() instanceof CollectionChangeTrackerImpl);
        CollectionChangeTrackerImpl ct = (CollectionChangeTrackerImpl) coll.getChangeTracker();
        assertTrue(ct.allowsDuplicates());
        assertTrue(ct.isOrdered());
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

        assertTrue(ct.allowsDuplicates());
        assertTrue(ct.isOrdered());
    }

    public void testSetChangeTracker() {
        Proxy coll = _mgr.newCollectionProxy(HashSet.class, null, null, true);
        assertNotNull(coll);
        assertNotNull(coll.getChangeTracker());
        assertTrue(coll.getChangeTracker() instanceof CollectionChangeTrackerImpl);
        CollectionChangeTrackerImpl ct = (CollectionChangeTrackerImpl) coll.getChangeTracker();
        assertFalse(ct.allowsDuplicates());
        assertFalse(ct.isOrdered());
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

        assertFalse(ct.allowsDuplicates());
        assertFalse(ct.isOrdered());
    }

    public void testCollectionInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(Collection.class, null, null, true);
        assertNotNull(coll);
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

        Proxy coll = _mgr.newCollectionProxy(Collection.class, null, null, true);
        assertNotNull(coll);
    }

    public void testListInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(List.class, null, null, true);
        assertNotNull(coll);
        assertTrue(coll instanceof List);
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

        assertNotNull(coll);
        assertTrue(coll instanceof List);
    }

    public void testSetInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(Set.class, null, null, true);
        assertNotNull(coll);
        assertTrue(coll instanceof Set);
        assertFalse(coll instanceof SortedSet);
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

        assertTrue(coll instanceof Set);
        assertFalse(coll instanceof SortedSet);
    }

    public void testSortedSetInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(SortedSet.class, null, null, true);
        assertNotNull(coll);
        assertTrue(coll instanceof SortedSet);
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

    public void testQueueInterfaceProxy() {
        Class queue = getQueueClass();
        if (queue == null)
            return;

        Proxy coll = _mgr.newCollectionProxy(queue, null, null, true);
        assertNotNull(coll);
        assertTrue(queue.isInstance(coll));
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

        populate(cal);
        assertCalendarsEquals(cal, (Calendar) orig.clone());
    }

    public void testCalendarAbstractClassProxy() {
        Proxy cal = _mgr.newCalendarProxy(Calendar.class, null);
        assertNotNull(cal);
    }
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

     * Proxy the held field if needed. Return true if the field needs to
     * be replaced with the now-proxied instance.
     */
    public boolean proxy(boolean reset, boolean replaceNull) {
        FieldMetaData fmd = _sm.getMetaData().getField(field);
        Proxy proxy = null;
        boolean ret = false;
        switch (fmd.getDeclaredTypeCode()) {
            case JavaTypes.DATE:
                if (objval == null)
                    return false;
                proxy = checkProxy(fmd);
                if (proxy == null) {
                    proxy = (Proxy) _sm.newFieldProxy(field);
                    ((Date) proxy).setTime(((Date) objval).getTime());
                    if (proxy instanceof Timestamp && objval instanceof Timestamp)
                        ((Timestamp) proxy).setNanos(((Timestamp) objval).getNanos());
                    ret = true;
                }
                break;
            case JavaTypes.CALENDAR:
                if (objval == null)
                    return false;
                proxy = checkProxy(fmd);
                if (proxy == null) {
                    proxy = (Proxy) _sm.newFieldProxy(field);
                    ((Calendar) proxy).setTime(((Calendar) objval).getTime());
                    ret = true;
                } else {
                    Object init = fmd.getInitializer();
                    if (init != null && init instanceof TimeZone) {
                        ((Calendar) proxy).setTimeZone((TimeZone)init);
                    }
                }
                break;
            case JavaTypes.COLLECTION:
                if (objval == null && !replaceNull)
                    return false;
                proxy = checkProxy(fmd);
                if (proxy == null) {
                    proxy = (Proxy) _sm.newFieldProxy(field);
                    if (objval != null)
                        ((Collection) proxy).addAll((Collection) objval);
                    ret = true;
                }
                break;
            case JavaTypes.MAP:
                if (objval == null && !replaceNull)
                    return false;
                proxy = checkProxy(fmd);
                if (proxy == null) {
                    proxy = (Proxy) _sm.newFieldProxy(field);
                    if (objval != null)
                        ((Map) proxy).putAll((Map) objval);
                    ret = true;
                }
                break;
            case JavaTypes.OBJECT:
                if (objval == null)
                    return false;
                proxy = checkProxy(fmd);
                if (proxy == null) {
                    proxy = getProxyManager().newCustomProxy(objval,
                        _sm.getBroker().getConfiguration().
                        getCompatibilityInstance().getAutoOff());
                    ret = proxy != null;
                }
                break;
        }

        if (proxy != null) {
            proxy.setOwner(_sm, field);
            ChangeTracker tracker = proxy.getChangeTracker();
            if (reset && tracker != null) {
                if (fmd.getDeclaredTypeCode() == JavaTypes.MAP) {
                    // track values if key is derived from value, else keys
                    boolean keys = fmd.getKey().getValueMappedBy() == null;
                    ((MapChangeTracker) tracker).setTrackKeys(keys);
View Full Code Here

Examples of org.apache.openjpa.util.Proxy

     */
    private Proxy checkProxy(FieldMetaData fmd) {
        if (!(objval instanceof Proxy))
            return null;

        Proxy proxy = (Proxy) objval;
        if (proxy.getOwner() == null || Proxies.isOwner(proxy, _sm, field)) {
            if (fmd.getProxyType().isAssignableFrom(proxy.getClass())
                    || (fmd.isLRS() && (objval instanceof LRSProxy))) {
                return proxy;
            }
        }
        return null;
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.