コード例 #1
0
 private final void handleInitializeCallback(
     final CloudletCallbackGenericArguments callbackArguments) {
   synchronized (this) {
     final CallbackHandler<?> callbackHandler = this.internalsCallbackRecord.callbackHandler;
     final Object callbackState = this.internalsCallbackRecord.callbackState;
     boolean succeeded;
     try {
       if (callbackHandler instanceof GenericCallback)
         ((GenericCallback<Object>) callbackHandler)
             .callback(
                 callbackState,
                 BasicCallback.create(this.internals, callbackArguments.type, callbackArguments));
       else if (callbackHandler instanceof CloudletCallback)
         ((CloudletCallback<Object>) callbackHandler)
             .initialize(
                 callbackState,
                 BasicCallback.create(this.internals, callbackArguments.type, callbackArguments));
       else if (callbackHandler instanceof AnnotatedCallback) {
         final Method callbackMethod =
             this.resolveCallbackMethod(callbackHandler, callbackArguments.type);
         if (callbackMethod != null)
           this.invokeCallbackMethod(
               callbackMethod,
               callbackHandler,
               callbackState,
               callbackArguments.type,
               callbackArguments);
         else
           throw (new UnsupportedOperationException(
               String.format("unhandled callback type: %s", callbackArguments.type)));
       } else
         throw (new IllegalArgumentException(
             String.format("unknown callback class: %s", callbackHandler.getClass())));
       succeeded = true;
     } catch (final Throwable exception) {
       ExceptionTracer.traceIgnored(exception);
       succeeded = false;
     }
     if (succeeded)
       this.callbackTarget.callback(
           CloudletCallbackType.InitializeSucceeded,
           CloudletCallbackGenericArguments.createInitializeSucceeded(this.internals),
           this.internalsCallbackRecord);
     else
       this.callbackTarget.callback(
           CloudletCallbackType.InitializeFailed,
           CloudletCallbackGenericArguments.createInitializeFailed(this.internals),
           this.internalsCallbackRecord);
   }
 }
コード例 #2
0
 @Override
 public final boolean initialize(final Configuration configuration) {
   final CallbackMonitor monitor;
   synchronized (this) {
     this.configuration = configuration;
     this.callbackTarget = this.callbackReactor.createTarget(this.callbackDispatcher, this);
     monitor =
         this.callbackTarget.callback(
             CloudletCallbackType.Initialize,
             CloudletCallbackGenericArguments.createInitialize(this.internals),
             this.internalsCallbackRecord);
   }
   boolean succeeded;
   try {
     monitor.waitCompletion(0);
     succeeded = true;
     this.active = true;
   } catch (final InterruptedException exception) {
     ExceptionTracer.traceIgnored(exception);
     succeeded = false;
   }
   return (succeeded);
 }