Package play.utils.crud

Source Code of play.utils.crud.RouterRestController

package play.utils.crud;

import play.utils.dyn.DynamicRestController;
import play.utils.meta.ControllerRegistry;
import play.utils.meta.IncompatibleControllerException;
import play.utils.meta.ModelMetadata;
import play.utils.meta.ModelRegistry;

public class RouterRestController extends RouterController {

  public RouterRestController(ControllerRegistry controllerRegistry, ModelRegistry modelRegistry) {
    super(controllerRegistry, modelRegistry);
  }

  @Override
  protected ControllerProxy<?, ?> getControllerProxy(Class<?> keyType, Class<?> modelType)
      throws IncompatibleControllerException {
    return controllerRegistry.getRestController(keyType, modelType);
  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  protected ControllerProxy<?, ?> getDynamicController(Class<?> keyType, Class<?> modelType, ModelMetadata model) {
    ControllerProxy<?, ?> proxy = dynamicRestControllers.get(modelType);
    if (proxy == null) {
      DynamicRestController dynController = new DynamicRestController(model);
      proxy = new ControllerProxyREST(dynController, model);
      dynamicRestControllers.put(modelType, proxy);
    }
    return proxy;
  }

}
TOP

Related Classes of play.utils.crud.RouterRestController

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.