Package eu.mosaic_cloud.components.core

Examples of eu.mosaic_cloud.components.core.ComponentCallbacks


    final BasicChannel channel = BasicChannel.create (pipe.source (), pipe.sink (), coder, reactor, threading, exceptions);
    final BasicComponent component = BasicComponent.create (reactor, exceptions);
    Assert.assertTrue (channel.initialize (BasicComponentTest.defaultPollTimeout));
    Assert.assertTrue (component.initialize (BasicComponentTest.defaultPollTimeout));
    final ComponentController componentController = component.getController ();
    final ComponentCallbacks componentCallbacksProxy = reactor.createProxy (ComponentCallbacks.class);
    Assert.assertTrue (componentController.bind (componentCallbacksProxy, channel.getController ()).await (BasicComponentTest.defaultPollTimeout));
    final QueueingComponentCallbacks componentCallbacks = QueueingComponentCallbacks.create (componentController, exceptions);
    final CallbackIsolate componentCallbacksIsolate = reactor.createIsolate ();
    Assert.assertTrue (reactor.assignHandler (componentCallbacksProxy, componentCallbacks, componentCallbacksIsolate).await (BasicComponentTest.defaultPollTimeout));
    final ComponentIdentifier peer = ComponentIdentifier.resolve (Strings.repeat ("00", 20));
View Full Code Here


    environment.transcript.traceDebugging ("initializing component...");
    component.initialize ();
    environment.transcript.traceDebugging ("creating callbacks...");
    final ComponentController componentController = component.getController ();
    final ComponentEnvironment componentEnvironment = ComponentEnvironment.create (environment.identifier, environment.classLoader, environment.reactor, environment.threading, environment.exceptions, environment.options);
    final ComponentCallbacks componentCallbacks;
    try {
      componentCallbacks = callbacksProvider.provide (componentEnvironment);
    } catch (final CaughtException.Wrapper wrapper) {
      throw (wrapper.exception.caught);
    } catch (final Throwable exception) {
View Full Code Here

    Assert.assertTrue (clientChannel.initialize (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (serverComponent.initialize (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (clientComponent.initialize (AbacusTest.defaultPollTimeout));
    final ComponentController serverComponentController = serverComponent.getController ();
    final ComponentController clientComponentController = clientComponent.getController ();
    final ComponentCallbacks serverComponentCallbacksProxy = reactor.createProxy (ComponentCallbacks.class);
    final ComponentCallbacks clientComponentCallbacksProxy = reactor.createProxy (ComponentCallbacks.class);
    Assert.assertTrue (serverComponentController.bind (serverComponentCallbacksProxy, serverChannel.getController ()).await (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (clientComponentController.bind (clientComponentCallbacksProxy, clientChannel.getController ()).await (AbacusTest.defaultPollTimeout));
    final AbacusComponentCallbacks serverComponentCallbacks = new AbacusComponentCallbacks (ComponentEnvironment.create (ComponentIdentifier.standalone, this.getClass ().getClassLoader (), reactor, threading, exceptions));
    final QueueingComponentCallbacks clientComponentCallbacks = QueueingComponentCallbacks.create (clientComponentController, exceptions);
    final CallbackIsolate serverComponentCallbacksIsolate = reactor.createIsolate ();
View Full Code Here

      } catch (final Throwable exception) {
        context.exceptions.trace (ExceptionResolution.Ignored, exception);
        provideConstructor = null;
      }
      Preconditions.checkArgument ((provideMethod != null) || (provideConstructor != null));
      final ComponentCallbacks callbacks;
      if (provideMethod != null) {
        final CallbackProxy callbacksProxy;
        Threading.setDefaultContext (context.threading);
        try {
          try {
            callbacksProxy = (CallbackProxy) provideMethod.invoke (null, 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 provider class `%s` (error encountered while invocking)", this.clasz.getName ()), exception));
        } finally {
          Threading.setDefaultContext (null);
        }
        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
        throw (new AssertionError ());
      Preconditions.checkNotNull (callbacks);
View Full Code Here

TOP

Related Classes of eu.mosaic_cloud.components.core.ComponentCallbacks

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.