Package com.betfair.cougar.health.service.v3

Source Code of com.betfair.cougar.health.service.v3.HealthServiceExecutableResolver

/*
* Copyright 2013, The Sporting Exchange Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright 2013, The Sporting Exchange Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated from serviceExecutableResolver.ftl
package com.betfair.cougar.health.service.v3;

import com.betfair.cougar.health.service.v3.to.*;
import com.betfair.cougar.health.service.v3.enumerations.*;
import com.betfair.cougar.api.ExecutionContext;
import com.betfair.cougar.api.RequestContext;
import com.betfair.cougar.api.fault.CougarApplicationException;
import com.betfair.cougar.core.api.ev.Executable;
import com.betfair.cougar.core.api.ev.ExecutableResolver;
import com.betfair.cougar.core.api.ev.ExecutionObserver;
import com.betfair.cougar.core.api.ev.ExecutionVenue;
import com.betfair.cougar.core.api.ev.OperationKey;
import com.betfair.cougar.core.api.ev.TimeConstraints;
import com.betfair.cougar.core.impl.ev.ServiceExceptionHandlingObserver;

import java.util.*;

/**
* Resolves Executables for all operations in the HealthService.
*/
@SuppressWarnings("all")
public class HealthServiceExecutableResolver implements ExecutableResolver {
  private Map<OperationKey, Executable> executableMap = new HashMap<OperationKey, Executable>();
  private HealthAsyncService service;

  public HealthServiceExecutableResolver() {
 
      executableMap.put(HealthServiceDefinition.isHealthyKey,
          new Executable() {
          @Override
          public void execute(ExecutionContext ctx, OperationKey key,
              Object[] args, ExecutionObserver observer,
              ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
                    ServiceExceptionHandlingObserver exceptionHandlingObserver = new ServiceExceptionHandlingObserver(observer);
            service.isHealthy((RequestContext)ctx, exceptionHandlingObserver, timeConstraints);           
        }
      });
 
      executableMap.put(HealthServiceDefinition.getDetailedHealthStatusKey,
          new Executable() {
          @Override
          public void execute(ExecutionContext ctx, OperationKey key,
              Object[] args, ExecutionObserver observer,
              ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
                    ServiceExceptionHandlingObserver exceptionHandlingObserver = new ServiceExceptionHandlingObserver(observer);
            service.getDetailedHealthStatus((RequestContext)ctx, exceptionHandlingObserver, timeConstraints);           
        }
      });
  }

  public void setService(HealthAsyncService service) {
      this.service = service;
  }

  @Override
  public Executable resolveExecutable(OperationKey operationKey, ExecutionVenue ev) {
    return executableMap.get(operationKey);
  }
 

}
TOP

Related Classes of com.betfair.cougar.health.service.v3.HealthServiceExecutableResolver

TOP
Copyright © 2018 www.massapi.com. 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.