Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.amazonaws.services.simpleworkflow.flow;
  
 
 
     protected DataConverter dataConverter;
 
 
     protected GenericActivityClient genericClient;
 
 
     public DynamicActivitiesClientImpl() {
         this(nullnullnull);
     }
 
     public DynamicActivitiesClientImpl(ActivitySchedulingOptions schedulingOptions) {
         this(schedulingOptionsnullnull);
     }
 
     public DynamicActivitiesClientImpl(ActivitySchedulingOptions schedulingOptionsDataConverter dataConverter) {
         this(schedulingOptionsdataConverternull);
     }
 
     public DynamicActivitiesClientImpl(ActivitySchedulingOptions schedulingOptionsDataConverter dataConverter,
             GenericActivityClient genericClient) {
         this. = genericClient;
 
         if (schedulingOptions == null) {
             this. = new ActivitySchedulingOptions();
         }
         else {
             this. = schedulingOptions;
         }
 
         if (dataConverter == null) {
             this. = new JsonDataConverter();
         }
         else {
             this. = dataConverter;
         }
 
     }
 
     @Override
     public DataConverter getDataConverter() {
         return ;
     }
 
     public void setDataConverter(DataConverter dataConverter) {
         this. = dataConverter;
     }
 
     @Override
         return ;
     }
 
     public void setSchedulingOptions(ActivitySchedulingOptions schedulingOptions) {
         this. = schedulingOptions;
     }
 
     @Override
         return ;
     }
 
     public void setGenericClient(GenericActivityClient genericClient) {
         this. = genericClient;
     }
 
     public <T> Promise<T> scheduleActivity(final ActivityType activityTypefinal Promise<?>[] arguments,
             final ActivitySchedulingOptions optionsOverridefinal Class<T> returnTypefinal Promise<?>... waitFor) {
         return new Functor<T>(arguments) {
 
             @Override
             protected Promise<T> doExecute() throws Throwable {
                 Object[] input = new Object[arguments.length];
                 for (int i = 0; i < arguments.lengthi++) {
                     Promise<?> argument = arguments[i];
                     input[i] = argument.get();
                 }
                 return scheduleActivity(activityTypeinputoptionsOverridereturnTypewaitFor);
             }
 
         };
 
     }
 
     public <T> Promise<T> scheduleActivity(final ActivityType activityTypefinal Object[] arguments,
             final ActivitySchedulingOptions optionsOverridefinal Class<T> returnType, Promise<?>... waitFor) {
        final Settable<T> result = new Settable<T>();
        new TryCatchFinally(waitFor) {
            Promise<StringstringOutput;
            @Override
            protected void doTry() throws Throwable {
                ExecuteActivityParameters parameters = new ExecuteActivityParameters();
                parameters.setActivityType(activityType);
                String stringInput = .toData(arguments);
                parameters.setInput(stringInput);
                final ExecuteActivityParameters _scheduleParameters_ = parameters.createExecuteActivityParametersFromOptions(
                        optionsOverride);
                GenericActivityClient client;
                if ( == null) {
                    client = .getDecisionContext().getActivityClient();
                } else {
                    client = ;
                }
                 = client.scheduleActivityTask(_scheduleParameters_);
                result.setDescription(.getDescription());
            }
            @Override
            protected void doCatch(Throwable ethrows Throwable {
                if (e instanceof ActivityTaskFailedException) {
                    ActivityTaskFailedException taskFailedException = (ActivityTaskFailedExceptione;
                    try {
                        String details = taskFailedException.getDetails();
                        if (details != null) {
                            Throwable cause = .fromData(detailsThrowable.class);
                            if (cause != null && taskFailedException.getCause() == null) {
                                taskFailedException.initCause(cause);
                            }
                        }
                    }
                    catch (DataConverterException dataConverterException) {
                        if (dataConverterException.getCause() == null) {
                            dataConverterException.initCause(taskFailedException);
                        }
                        throw dataConverterException;
                    }
                }
                throw e;
            }
            @Override
            protected void doFinally() throws Throwable {
                if ( != null && .isReady()) {
                    if (returnType.equals(Void.class)) {
                        result.set(null);
                    }
                    else {
                        T output = .fromData(.get(), returnType);
                        result.set(output);
                    }
                }
            }
        };
        return result;
    }
New to GrepCode? Check out our FAQ X