/// <summary> /// Deploys test service and returns client-side proxy. /// </summary> private T DeployAndGetTestService <T>(Func <IServicesClient, IServicesClient> transform = null, IServiceCallContext callCtx = null) where T : class { ServerServices.DeployClusterSingleton(ServiceName, new TestService()); var services = Client.GetServices(); if (transform != null) { services = transform(services); } return(services.GetServiceProxy <T>(ServiceName, callCtx)); }
/// <inheritdoc /> public IEnumerable <IRequestHeader> ProduceFromContext(IServiceCallContext serviceContext, IServiceCallParametersContext parameters) { if (serviceContext == null) { throw new ArgumentNullException(nameof(serviceContext)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } //TODO: Caching return(AddServiceWideHeaders(serviceContext.ServiceType) .Concat(AddMethodSpecificHeaders(serviceContext.ServiceMethod)) .Concat(AddDynamicHeaders(serviceContext.ServiceMethod.GetParameters(), parameters.Parameters)) .ToArray()); }
/** <inheritDoc /> */ public T GetServiceProxy <T>(string name, bool sticky, IServiceCallContext callCtx) where T : class { IgniteArgumentCheck.NotNullOrEmpty(name, "name"); IgniteArgumentCheck.Ensure(typeof(T).IsInterface, "T", "Service proxy type should be an interface: " + typeof(T)); var javaProxy = DoOutOpObject(OpServiceProxy, w => { w.WriteString(name); w.WriteBoolean(sticky); }); var platform = GetServiceDescriptors().Cast <ServiceDescriptor>().Single(x => x.Name == name).PlatformType; var callAttrs = GetCallerContextAttributes(callCtx); return(ServiceProxyFactory <T> .CreateProxy((method, args) => InvokeProxyMethod(javaProxy, method.Name, method, args, platform, callAttrs))); }
/// <summary> /// Writes proxy method invocation data to the specified writer. /// </summary> /// <param name="writer">Writer.</param> /// <param name="methodName">Name of the method.</param> /// <param name="method">Method (optional, can be null).</param> /// <param name="arguments">Arguments.</param> /// <param name="platformType">The platform.</param> /// <param name="callCtx">Service call context.</param> public static void WriteProxyMethod(BinaryWriter writer, string methodName, MethodBase method, object[] arguments, PlatformType platformType, IServiceCallContext callCtx) { Debug.Assert(writer != null); writer.WriteString(methodName); if (arguments != null) { writer.WriteBoolean(true); writer.WriteInt(arguments.Length); if (platformType == PlatformType.DotNet) { // Write as is for .NET. foreach (var arg in arguments) { writer.WriteObjectDetached(arg); } } else { // Other platforms do not support Serializable, need to convert arrays and collections var mParams = method != null?method.GetParameters() : null; Debug.Assert(mParams == null || mParams.Length == arguments.Length); for (var i = 0; i < arguments.Length; i++) { WriteArgForPlatforms(writer, mParams != null ? mParams[i].ParameterType : null, arguments[i]); } } } else { writer.WriteBoolean(false); } writer.WriteDictionary(callCtx == null ? null : ((ServiceCallContext)callCtx).Values()); }