Package com.thoughtworks.proxy.kit

Examples of com.thoughtworks.proxy.kit.ObjectReference


     * @return the old delegate
     * @throws IllegalStateException if cyclic swapping action is detected
     * @since 0.1
     */
    protected Object hotswap(final Object newDelegate) {
        ObjectReference ref = getDelegateReference();
        Object result = ref.get();
        // Note, for the cycle detection the delegate have to be set first
        delegate.set(newDelegate);
        ref.set(newDelegate);
        if (newDelegate instanceof CycleCheck) {
            ((CycleCheck)newDelegate).checkForCycle();
        }
        return result;
    }
View Full Code Here


     * @return the created proxy implementing the <tt>types</tt> and {@link Swappable}
     * @since 0.2
     */
    public static Object object(
            final Class[] types, final ProxyFactory proxyFactory, final Object delegate, final int delegationMode) {
        final ObjectReference delegateReference = new SimpleReference(delegate);
        return new HotSwappingInvoker(types, proxyFactory, delegateReference, delegationMode).proxy();
    }
View Full Code Here

     * @since 0.2
     */
    public synchronized Object get() {
        final Object result;
        if (availableInstances.size() > 0 || getAvailable() > 0) {
            final ObjectReference delegate = (ObjectReference)availableInstances.remove(0);
            result = new PoolingInvoker(this, factory, delegate, Delegating.MODE_DIRECT).proxy();
            final Object weakReference = new WeakReference(result);
            busyInstances.put(delegate.get(), weakReference);
        } else {
            result = null;
        }
        return result;
    }
View Full Code Here

        ThreadLocal threadLocal = new ThreadLocal() {
            protected Object initialValue() {
                return Boolean.TRUE;
            }
        };
        ObjectReference ref = (ObjectReference)Delegating.object(ObjectReference.class, threadLocal);
        System.out.println("This ObjectReference has an initial value of <" + ref.get() + ">");
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.proxy.kit.ObjectReference

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.