protected NSObject proxy(Class<? extends NSObject> type) { if(null == proxy) { proxy = Rococoa.proxy(target, type); } return proxy; }
/** * Return a new Objective-C object that will forward messages to javaObject, * for use in delegates, notifications etc. * * You need to keep a reference to the returned value for as long as it is * active. When it is GC'd, it will release the Objective-C proxy. */ public static ObjCObject proxy(Object javaObject) { return proxy(javaObject, ObjCObject.class); }
/** * Create an new invocation based future task to run the given <code>Runnable</code> * * @param r the <code>Runnable</code> to run * @param result the result to return when the <code>Runnable</code> completes */ public InvocationFutureTask(Runnable r, V result) { super(r, result); originalRunnable = r; proxy = Rococoa.proxy(this); invocation = createInvocation(proxy); tasks.put(invocation.id(), this); }
/** * Create an new invocation based future task to run the given <code>Callable</code> * * @param callable the <code>Callable</code> to run */ public InvocationFutureTask(Callable<V> callable) { super(callable); originalRunnable = this; proxy = Rococoa.proxy(this); invocation = createInvocation(proxy); tasks.put(invocation.id(), this); }
/** Create an new invocation based future task to run the given <code>Callable</code> * @param callable the <code>Callable</code> to run */ public InvocationFutureTask(Callable<V> callable){ super(callable); originalRunnable = this; proxy = Rococoa.proxy(this); invocation = createInvocation(proxy); tasks.put(invocation.id(), this); } private NSInvocationOperation createInvocation(final ObjCObject toInvoke) {
/** Create an new invocation based future task to run the given <code>Runnable</code> * @param r the <code>Runnable</code> to run * @param result the result to return when the <code>Runnable</code> completes */ public InvocationFutureTask(Runnable r, V result) { super(r, result); originalRunnable = r; proxy = Rococoa.proxy(this); invocation = createInvocation(proxy); tasks.put(invocation.id(), this); }
/** Set the delegate that will receive events when speech is generated. * @param delegate the delegate to set, replacing any existing one */ public synchronized void setDelegate(final NSSpeechSynthesizerDelegate delegate) { if ( delegate != null ) { this.delegate = delegate; delegateProxy = Rococoa.proxy(delegate); setDelegate(this.delegateProxy.id()); } }