Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Copyright (c) 2012 LinkedIn Corp.
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.
*/
package com.linkedin.restli.internal.server;
import com.linkedin.common.callback.Callback;
import com.linkedin.parseq.BaseTask;
import com.linkedin.parseq.Context;
import com.linkedin.parseq.Engine;
import com.linkedin.parseq.Task;
import com.linkedin.parseq.promise.Promise;
import com.linkedin.parseq.promise.PromiseListener;
import com.linkedin.parseq.promise.Promises;
import com.linkedin.r2.message.rest.RestRequest;
import com.linkedin.restli.common.HttpStatus;
import com.linkedin.restli.internal.server.methods.MethodAdapterRegistry;
import com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder;
import com.linkedin.restli.internal.server.methods.response.ErrorResponseBuilder;
import com.linkedin.restli.internal.server.model.Parameter.ParamType;
import com.linkedin.restli.internal.server.model.ResourceMethodDescriptor;
import com.linkedin.restli.internal.server.util.RestUtils;
import com.linkedin.restli.server.RestLiServiceException;
import com.linkedin.restli.server.resources.BaseResource;
import com.linkedin.restli.server.resources.ResourceFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Invokes a resource method, binding contextual and URI-derived arguments to method
* parameters.
*
* @author dellamag
*/
public class RestLiMethodInvoker
{
private final ResourceFactory _resourceFactory;
private final Engine _engine;
private final ErrorResponseBuilder _errorResponseBuilder;
private final MethodAdapterRegistry _methodAdapterRegistry;
/**
* Constructor.
*
* @param resourceFactory {@link ResourceFactory}
* @param engine {@link Engine}
*/
public RestLiMethodInvoker(final ResourceFactory resourceFactory, final Engine engine)
{
this(resourceFactory, engine, new ErrorResponseBuilder());
}
/**
* Constructor.
*
* @param resourceFactory {@link ResourceFactory}
* @param engine {@link Engine}
* @param errorResponseBuilder {@link ErrorResponseBuilder}
*/
public RestLiMethodInvoker(final ResourceFactory resourceFactory, final Engine engine, final ErrorResponseBuilder errorResponseBuilder)
{
_resourceFactory = resourceFactory;
_engine = engine;
_errorResponseBuilder = errorResponseBuilder;
_methodAdapterRegistry = new MethodAdapterRegistry(errorResponseBuilder);
}
/**
* Invokes the method with the specified callback and arguments built from the request.
*
* @param invocableMethod {@link RoutingResult}
* @param request {@link RestRequest}
* @param callback {@link RestLiCallback}
*/
public void invoke(final RoutingResult invocableMethod,
final RestRequest request,
final RestLiCallback