Package eu.mosaic_cloud.tools.callbacks.core

Examples of eu.mosaic_cloud.tools.callbacks.core.CallbackHandler


        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
View Full Code Here


        final ActorAssignAction action = this.assignAction.get ();
        Preconditions.checkState (action != null);
        this.reactor.transcript.traceDebugging ("executing action `%{object}` on actor `%{object:identity}`...", action, this);
        Preconditions.checkState ((this.status.get () == Status.Active) || (this.status.get () == Status.Destroying));
        Preconditions.checkState (this.handlerStatus.get () == HandlerStatus.Registering);
        final CallbackHandler handler = this.handler.get ();
        Preconditions.checkState ((handler != null) && (handler == action.handler));
        final Scheduler scheduler = this.scheduler.get ();
        Preconditions.checkState ((scheduler != null) && (scheduler == action.scheduler));
        this.reactor.transcript.traceDebugging ("assigning handler `%{object}` for proxy `%{object:identity}` (owned by actor `%{object:identity}`) backed by isolate `%{object:identity}` (owned by scheduler `%{object:identity}`)...", handler, this.proxy, this, scheduler.isolate, scheduler);
        this.reactor.transcript.traceDebugging ("invocking register callback on handler `%{object}` for proxy `%{object:identity}` (owned by actor `%{object:identity}`) backed by isolate `%{object:identity}` (owned by scheduler `%{object:identity}`)...", handler, this.proxy, this, scheduler.isolate, scheduler);
        try {
          handler.registeredCallbacks (this.specification.cast (this.proxy), scheduler.isolate);
        } catch (final Throwable exception) {
          this.reactor.exceptions.traceDeferredException (exception);
          this.triggerFailure (exception);
          return;
        }
View Full Code Here

        }
        this.reactor.transcript.traceDebugging ("destroying proxy `%{object:identity}` (owned by actor `%{object:identity}`)...", this.proxy, this);
        final Throwable failure = this.failed.get ();
        if (failure == null) {
          final ActorAssignAction assign = this.assignAction.get ();
          final CallbackHandler handler = this.handler.get ();
          if ((handler != null) && (assign == null)) {
            final Scheduler scheduler = this.scheduler.get ();
            Preconditions.checkState (scheduler != null);
            this.reactor.transcript.traceDebugging ("invocking unregister callback on handler `%{object}` for proxy `%{object:identity}` (owned by actor `%{object:identity}`) backed by isolate `%{object:identity}` (owned by scheduler `%{object:identity}`)...", handler, this.proxy, this, scheduler.isolate, scheduler);
            try {
              handler.unregisteredCallbacks (this.specification.cast (this.proxy));
            } catch (final Throwable exception) {
              this.reactor.exceptions.traceDeferredException (exception);
              this.triggerFailure (exception);
              return;
            }
            scheduler.unregisterActor (this);
            Preconditions.checkState (this.handler.compareAndSet (handler, null));
            Preconditions.checkState (this.scheduler.compareAndSet (scheduler, null));
          } else {
            if (assign != null) {
              assign.future.triggerFailure (new CallbackCanceled ());
              Preconditions.checkState (this.assignAction.compareAndSet (assign, null));
            }
            for (final ActorAction<?> action : this.actions)
              action.future.triggerFailure (new CallbackCanceled ());
            this.actions.clear ();
          }
        } else {
          final ActorAssignAction assign = this.assignAction.get ();
          final CallbackHandler handler = this.handler.get ();
          if (handler != null) {
            final Scheduler scheduler = this.scheduler.get ();
            Preconditions.checkState (scheduler != null);
            this.reactor.transcript.traceDebugging ("invocking failure callback on handler `%{object}` for proxy `%{object:identity}` (owned by actor `%{object:identity}`) backed by isolate `%{object:identity}` (owned by scheduler `%{object:identity}`)...", handler, this.proxy, this, scheduler.isolate, scheduler);
            // FIXME: This should be called only if we have successfully called `registeredCallbacks`
            try {
              handler.failedCallbacks (this.specification.cast (this.proxy), failure);
            } catch (final Throwable exception) {
              this.reactor.exceptions.traceIgnoredException (exception);
            }
            scheduler.unregisterActor (this);
            Preconditions.checkState (this.handler.compareAndSet (handler, null));
View Full Code Here

   
    final void executeInvokeCallback (final ActorCallbackAction<?> action)
    {
      Preconditions.checkState (action != null);
      this.reactor.transcript.traceDebugging ("executing action `%{object}` on actor `%{object:identity}`...", action, this);
      final CallbackHandler handler;
      final Scheduler scheduler;
      synchronized (this.monitor) {
        Preconditions.checkState ((this.status.get () == Status.Active) || (this.status.get () == Status.Destroying));
        Preconditions.checkState (this.handlerStatus.get () == HandlerStatus.Assigned);
        handler = this.handler.get ();
View Full Code Here

TOP

Related Classes of eu.mosaic_cloud.tools.callbacks.core.CallbackHandler

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.