Example #1
0
        protected ICascadedInterceptor HandleServiceAnnotation(ServiceAttribute serviceAnnotation, IBeanContextFactory beanContextFactory, IServiceContext beanContext, IBeanConfiguration beanConfiguration, Type type)
        {
            if (serviceAnnotation.CustomExport)
            {
                // Do nothing if the service wants to be exported by some special way anywhere else
                return(null);
            }
            String beanName    = beanConfiguration.GetName();
            String serviceName = ExtractServiceName(serviceAnnotation.Name, type);

            if (!IsNetworkClientMode)
            {
                IMethodLevelBehavior <Attribute> behavior = CreateInterceptorModeBehavior(type);

                CacheInterceptor interceptor = new CacheInterceptor();
                if (beanContext.IsRunning)
                {
                    interceptor = beanContext.RegisterWithLifecycle(interceptor) //
                                  .PropertyValue("ServiceName", serviceName)     //
                                  .PropertyValue("Behavior", behavior)           //
                                  .IgnoreProperties("ProcessService")            //
                                  .Finish();
                    beanContext.Link(beanName).To <IServiceExtendable>().With(serviceName);
                }
                else
                {
                    beanContextFactory.RegisterWithLifecycle(interceptor) //
                    .PropertyValue("ServiceName", serviceName)            //
                    .PropertyValue("Behavior", behavior)                  //
                    .IgnoreProperties("ProcessService");
                    beanContextFactory.Link(beanName).To <IServiceExtendable>().With(serviceName);
                }
                if (Log.InfoEnabled)
                {
                    Log.Info("Registering application service '" + serviceName + "'");
                }
                return(interceptor);
            }
            else
            {
                if (Log.InfoEnabled)
                {
                    Log.Info("Registering application mock service '" + serviceName + "'");
                }
                if (beanContext.IsRunning)
                {
                    beanContext.Link(beanName).To <IServiceExtendable>().With(serviceName);
                }
                else
                {
                    beanContextFactory.Link(beanName).To <IServiceExtendable>().With(serviceName);
                }
                return(null);
            }
        }
Example #2
0
        protected override ICascadedInterceptor HandleServiceIntern(IBeanContextFactory beanContextFactory, IServiceContext beanContext, IBeanConfiguration beanConfiguration, Type type, ISet <Type> requestedTypes)
        {
            ServiceAttribute serviceAnnotation = serviceAnnotationCache.GetAnnotation(type);

            if (serviceAnnotation != null)
            {
                return(HandleServiceAnnotation(serviceAnnotation, beanContextFactory, beanContext, beanConfiguration, type));
            }
            AnnotationEntry <ServiceClientAttribute> serviceClientAnnotation = serviceClientAnnotationCache.GetAnnotationEntry(type);

            if (serviceClientAnnotation != null)
            {
                return(HandleServiceClientAnnotation(serviceClientAnnotation, beanContextFactory, beanContext, beanConfiguration, type));
            }
            return(null);
        }