public TestData getServiceDescriptionTestData() { String dataName = "ServiceDescription"; String xml = GetJavaTestXml(dataName); String xmlCS = GetCsTestXml(dataName); Type[] argTypes = { typeof(int), typeof(Material), typeof(String), typeof(MaterialGroup), typeof(Material), typeof(DateTime) }; MethodInfo serviceMethod = typeof(ITestService).GetMethod("MixedParamsNoReturn", argTypes); Object obj = SyncToAsyncUtil.CreateServiceDescription("TestService", serviceMethod, ColletionData); return(new TestData(xml, xmlCS, obj)); }
protected override Object InterceptApplication(IInvocation invocation, Boolean?isAsyncBegin) { Object[] arguments = invocation.Arguments; MethodInfo method = invocation.Method; if (isAsyncBegin.HasValue && !isAsyncBegin.Value) { return(((IAsyncResult)arguments[0]).AsyncState); } if (isAsyncBegin.HasValue) { AsyncCallback asyncCallback; Object[] syncArguments = SyncToAsyncUtil.BuildSyncArguments(arguments, out asyncCallback); MethodInfo syncMethod = SyncToAsyncUtil.GetSyncMethod(method, GetSyncServiceType()); ServiceDescription serviceDescription = SyncToAsyncUtil.CreateServiceDescription(ServiceName, syncMethod, syncArguments); IAsyncResult asyncResult = Client.BeginCallProgressableService(serviceDescription, delegate(IAsyncResult ar) { try { Object progressedResult = Client.EndCallProgressableService(ar); if (asyncCallback != null) { asyncCallback.Invoke(new AsyncResult(progressedResult)); } } catch (Exception e) { if (Log.ErrorEnabled) { Log.Error(e); } throw; } }, null); return(asyncResult); } ServiceDescription serviceDescription2 = SyncToAsyncUtil.CreateServiceDescription(ServiceName, method, arguments); Object result = Service.CallProgressableService(serviceDescription2); return(result); }
protected override Object InterceptApplication(IInvocation invocation, Attribute annotation, Boolean?isAsyncBegin) { bool oldProcessServiceActive = processServiceActiveTL.Value; if (oldProcessServiceActive || ProcessService == null || !AnnotationUtil.IsAnnotationPresent <ServiceClientAttribute>(invocation.Method.DeclaringType, false)) { return(base.InterceptApplication(invocation, annotation, isAsyncBegin)); } ISecurityScope[] securityScopes = SecurityScopeProvider.SecurityScopes; IServiceDescription serviceDescription = SyncToAsyncUtil.CreateServiceDescription(ServiceName, invocation.Method, invocation.Arguments, securityScopes); processServiceActiveTL.Value = true; try { return(ProcessService.InvokeService(serviceDescription)); } finally { processServiceActiveTL.Value = oldProcessServiceActive; } }
protected override Object InterceptLoad(IInvocation invocation, Attribute annotation, Boolean?isAsyncBegin) { ServiceDescription serviceDescription; IServiceResult serviceResult; MethodInfo method = invocation.Method; Object[] args = invocation.Arguments; CachedAttribute cached = annotation is CachedAttribute ? (CachedAttribute)annotation : null; if (cached == null && pauseCache.Value) { return(base.InterceptLoad(invocation, annotation, isAsyncBegin)); } Type returnType = method.ReturnType; if (ImmutableTypeSet.IsImmutableType(returnType)) { // No possible result which might been read by cache return(base.InterceptLoad(invocation, annotation, isAsyncBegin)); } if (cached == null) { ISecurityScope[] securityScopes = SecurityScopeProvider.SecurityScopes; serviceDescription = SyncToAsyncUtil.CreateServiceDescription(ServiceName, method, args, securityScopes); serviceResult = CacheService.GetORIsForServiceRequest(serviceDescription); return(CreateResultObject(serviceResult, returnType, args, annotation)); } if (args.Length != 1) { throw new Exception("This annotation is only allowed on methods with exactly 1 argument. Please check your " + typeof(CachedAttribute).FullName + " annotation on method " + method.ToString()); } Type entityType = cached.Type; if (entityType == null || typeof(void).Equals(entityType)) { entityType = TypeInfoItemUtil.GetElementTypeUsingReflection(returnType, null); } if (entityType == null || typeof(void).Equals(entityType)) { throw new Exception("Please specify a valid returnType for the " + typeof(CachedAttribute).FullName + " annotation on method " + method.ToString()); } IEntityMetaData metaData = GetSpecifiedMetaData(method, typeof(CachedAttribute), entityType); Member member = GetSpecifiedMember(method, typeof(CachedAttribute), metaData, cached.AlternateIdName); sbyte idIndex; try { idIndex = metaData.GetIdIndexByMemberName(member.Name); } catch (Exception e) { throw new Exception( "Member " + entityType.FullName + "." + cached.AlternateIdName + " is not configured as an alternate ID member. There must be a single-column unique contraint on the respective table column. Please check your " + typeof(CachedAttribute).FullName + " annotation on method " + method.ToString(), e); } bool returnMisses = cached.ReturnMisses; List <IObjRef> orisToGet = new List <IObjRef>(); FillOrisToGet(orisToGet, args, entityType, idIndex, returnMisses); return(CreateResultObject(orisToGet, returnType, returnMisses, annotation)); }