Preconditions.checkArgument (callbacksProxy != null, "invalid callbacks (is null)");
Preconditions.checkArgument (ComponentCallbacks.class.isInstance (callbacksProxy), "invalid callbacks proxy `%s` (not an instance of `ComponentCallbacks`)", callbacksProxy.getClass ().getName ());
Preconditions.checkArgument (CallbackProxy.class.isInstance (callbacksProxy), "invalid callbacks proxy `%s` (not an instance of `CallbackProxy`)", callbacksProxy.getClass ().getName ());
callbacks = (ComponentCallbacks) callbacksProxy;
} else if (provideConstructor != null) {
final CallbackHandler callbacksHandler;
Threading.setDefaultContext (context.threading);
try {
try {
callbacksHandler = (CallbackHandler) provideConstructor.newInstance (context);
} catch (final InvocationTargetException wrapper) {
context.exceptions.trace (ExceptionResolution.Handled, wrapper);
throw (wrapper.getCause ());
}
} catch (final Throwable exception) {
context.exceptions.trace (ExceptionResolution.Handled, exception);
throw (new IllegalArgumentException (String.format ("invalid callbacks handler class `%s` (error encountered while instantiating)", this.clasz.getName ()), exception));
} finally {
Threading.setDefaultContext (null);
}
Preconditions.checkArgument (ComponentCallbacks.class.isInstance (callbacksHandler), "invalid callbacks handler class `%s` (not an instance of `ComponentCallbacks`)", callbacksHandler.getClass ().getName ());
Preconditions.checkArgument (CallbackHandler.class.isInstance (callbacksHandler), "invalid callbacks handler class `%s` (not an instance of `CallbackHandler`)", callbacksHandler.getClass ().getName ());
final CallbackIsolate callbacksIsolate = context.reactor.createIsolate ();
final ComponentCallbacks callbacksProxy = context.reactor.createProxy (ComponentCallbacks.class);
Preconditions.checkState (context.reactor.assignHandler (callbacksProxy, callbacksHandler, callbacksIsolate).await ());
callbacks = callbacksProxy;
} else