{@inheritDoc}

For use with zend-servicemanager v2; proxies to __invoke().
433674
public function createService(ServiceLocatorInterface $container)
    {
        // Retrieve the parent container when under zend-servicemanager v2
        if (method_exists($container, 'getServiceLocator')) {
            $container = $container->getServiceLocator() ?: $container;
        }

        return $this($container, LoggerInterface::class);
    }
550482
protected function _dispatch(Zend_Server_Method_Definition $invocable, array $params)
    {
        $callback = $invocable->getCallback();
        $type     = $callback->getType();

        if ('function' == $type) {
            $function = $callback->getFunction();
            return call_user_func_array($function, $params);
        }

        $class  = $callback->getClass();
        $method = $callback->getMethod();

        if ('static' == $type) {
            return call_user_func_array(array($class, $method), $params);
        }

        $object = $invocable->getObject();
        if (!is_object($object)) {
            $invokeArgs = $invocable->getInvokeArguments();
            if (!empty($invokeArgs)) {
                $reflection = new ReflectionClass($class);
                $object     = $reflection->newInstanceArgs($invokeArgs);
            } else {
                $object = new $class;
            }
        }
        return call_user_func_array(array($object, $method), $params);
    }
1184933
protected function proxy() {
        if (!$this->context) {
            $this->context = new BindingContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
668563
public function proxy(Invoker $invoker)
    {
        $interface = $invoker->getInterface();

        $className = $this->generateClassName($interface);

        $code = $this->populateStub($this->getStub(), $className, $interface);

        $this->load($className, $code);

        return $this->createProxyInstance($className, $interface, $invoker);
    }
849515
public function call($service, ...$params)
    {
        if (! $this->hasHandler($service)) {
            throw ServiceHandlerMethodException::notFound($service);
        }

        return $this->container->make($service)->{$this::$handlerMethod}(...$params);
    }
357954
public function invoke(MethodInvocation $invocation)
    {
        $annotation = $invocation->getMethod()->getAnnotation($this->annotation);
        $keys = $this->generateCacheName($annotation->cacheName, $invocation);
        if (!is_array($annotation->key)) {
            $annotation->key = [$annotation->key];
        }
        $keys = $this->detectCacheKeys($invocation, $annotation, $keys);

        // detect use cache driver
        $cache = $this->detectCacheRepository($annotation);

        if ($annotation->allEntries) {
            $cache->flush();

            return $invocation->proceed();
        }
        $result = $invocation->proceed();
        $cache->forget($this->recursiveImplode($this->join, $keys));

        return $result;
    }
2207
protected function proxy() {
        if (!$this->context) {
            $this->context = new SyncListContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
405970
@Override
  public Object invoke(Object[] argv) throws Throwable {
    if (handle == null) {
      throw new IllegalStateException(
          "Default method handler invoked before proxy has been bound.");
    }
    return handle.invokeWithArguments(argv);
  }
509447
public function invoke(MethodInvocation $invocation)
    {
        $ro = $invocation->proceed();
        if (! $ro instanceof ResourceObject) {
            throw new ReturnValueIsNotResourceObjectException(\get_class($invocation->getThis()));
        }

        if ($ro->code >= Code::BAD_REQUEST) {
            return $this;
        }

        foreach ($this->commands as $command) {
            $command->command($invocation, $ro);
        }

        return $ro;
    }
150002
@Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        if (SplitlogLoggerFactory.isLoggingEnabled()) {
            SplitlogLoggerFactory.increaseMessageCounter();
            return method.invoke(this.proxied, args);
        } else {
            // logging is not enabled, don't proxy the call
            return null;
        }
    }
603711
@Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = invocation.proceed();
        profilingContainer.register(group, System.currentTimeMillis() - start);
        return result;
    }
383019
protected function proxy() {
        if (!$this->context) {
            $this->context = new EnvironmentContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
497416
public function configureServiceManager(ZendServiceManager $serviceManager)
    {
        $pathManager = ($this->pathManagerConfig instanceof PathManager)? $this->pathManagerConfig : new PathManager($this->pathManagerConfig);
        $serviceManager->setService('rampage.PathManager', $pathManager, true);
        $serviceManager->setAlias('PathManager', 'rampage.PathManager');
        $serviceManager->setAllowOverride(true);

        parent::configureServiceManager($serviceManager);

        // Add the default delegator for the module manager
        if (!$serviceManager->has('rampage\core\services\ModuleManagerDelegator', false, false)) {
            $serviceManager->setInvokableClass('rampage\core\services\ModuleManagerDelegator', 'rampage\core\services\ModuleManagerDelegator');
        }

        $serviceManager->addDelegator('ModuleManager', 'rampage\core\services\ModuleManagerDelegator');
        $serviceManager->addPeeringServiceManager($serviceManager->get('AggregatedServiceLocator'));

        return $this;
    }
467651
public function invoke(FilterableServiceInterface $service, $perPageCount, array $parameters = array())
    {
        $page = $this->getPageNumber();
        $sort = $this->getSortingColumn();
        $desc = $this->getDesc();

        $records = $service->filter($this->getData(), $page, $perPageCount, $sort, $desc, $parameters);

        // Tweak pagination if available
        if (method_exists($service, 'getPaginator')) {
            $paginator = $service->getPaginator();

            if ($paginator instanceof PaginatorInterface) {
                $paginator->setUrl($this->getPaginationUrl($page, $sort, $desc));
            }
        }

        return $records;
    }
43897
@SuppressWarnings( "unchecked" )
    public <T> T getService( final Class<T> serviceType,
                             final long timeoutInMillis )
    {
        return (T) Proxy.newProxyInstance(
            getClass().getClassLoader(),
            new Class<?>[]{ serviceType },
            new InvocationHandler()
            {
                /**
                 * {@inheritDoc}
                 * Delegates the call to remote bundle context.
                 */
                public Object invoke( final Object proxy,
                                      final Method method,
                                      final Object[] params )
                    throws Throwable
                {
                    try
                    {
                        return getRemoteBundleContext().remoteCall(
                            method.getDeclaringClass(),
                            method.getName(),
                            method.getParameterTypes(),
                            timeoutInMillis,
                            params
                        );
                    }
                    catch( InvocationTargetException e )
                    {
                        throw e.getCause();
                    }
                    catch( RemoteException e )
                    {
                        throw new TestContainerException( "Remote exception", e );
                    }
                    catch( Exception e )
                    {
                        throw new TestContainerException( "Invocation exception", e );
                    }
                }
            }
        );
    }
874090
public function invoke(ServerRequestInterface $request, RouteParams $params)
    {
        $callable = $this->callable;

        // Controller Actions are lazy loaded so we need to call the factory to get the callable
        if ($this->isControllerAction()) {
            $callable = call_user_func($this->callable);
        }

        // Call the target action with any provided params
        if ($this->invoker) {
            return $this->invoker->setRequest($request)->call($callable, $params->toArray());
        } else {
            return call_user_func($callable, $params);
        }
    }
363843
protected function createProxy()
    {
        $config = $this->config;

        $interface = Arr::pull($config, 'interface');

        $client = $this->clientFactory->client(Arr::pull($config, 'client'));

        $invoker = new RemoteInvoker($this->context, $client, $interface, $config);

        $invoker = $this->withMiddleware($invoker, $interface, $config);

        return $this->proxyFactory->proxy($invoker);
    }