public OneWayRequestSuite()
            : base(40, 20)
        {
            IoC.Container = new Agatha.Unity.Container();

            serviceLayerConfiguration = new ServiceLayerConfiguration(Assembly.GetExecutingAssembly(), Assembly.GetExecutingAssembly(), IoC.Container)
                                            {
                                                BusinessExceptionType = typeof(BusinessException),
                                                SecurityExceptionType = typeof(SecurityException),
                                                CacheManagerImplementation = typeof(CacheManagerSpy)
                                            };
            serviceLayerConfiguration.Initialize();

            // i want to take advantage of the automatic initialization, so i'm just resolving the requestprocessor instead of creating it
            requestProcessor = IoC.Container.Resolve<IRequestProcessor>();
            // the cache manager is a singleton so i can just resolve it and it'll be the same one the request processor uses
            cacheManager = (CacheManagerSpy)IoC.Container.Resolve<ICacheManager>();

            firstOneWayRequestHandler = MockRepository.GenerateMock<IOneWayRequestHandler<FirstOneWayRequest>>();
            secondOneWayRequestHandler = MockRepository.GenerateMock<IOneWayRequestHandler<SecondOneWayRequest>>();
            thirdOneWayRequestHandler = MockRepository.GenerateMock<IOneWayRequestHandler<ThirdOneWayRequest>>();

            IoC.Container.RegisterInstance(firstOneWayRequestHandler);
            IoC.Container.RegisterInstance(secondOneWayRequestHandler);
            IoC.Container.RegisterInstance(thirdOneWayRequestHandler);
        }
Example #2
0
        public void Initialize()
        {
            serviceLayerConfiguration.AsyncRequestProcessorImplementation = AsyncRequestProcessorImplementation;
            serviceLayerConfiguration.BusinessExceptionType          = BusinessExceptionType;
            serviceLayerConfiguration.RequestProcessorImplementation = RequestProcessorImplementation;
            serviceLayerConfiguration.SecurityExceptionType          = SecurityExceptionType;
            serviceLayerConfiguration.CacheManagerImplementation     = CacheManagerImplementation;
            serviceLayerConfiguration.CacheProviderImplementation    = CacheProviderImplementation;

            foreach (var assembly in requestHandlerAssemblies)
            {
                serviceLayerConfiguration.AddRequestHandlerAssembly(assembly);
            }

            foreach (var assembly in requestsAndResponseAssemblies)
            {
                serviceLayerConfiguration.AddRequestAndResponseAssembly(assembly);
            }

            serviceLayerConfiguration.Initialize();

            IoC.Container.Register(typeof(IRequestDispatcher), RequestDispatcherImplementation, Lifestyle.Transient);
            IoC.Container.Register(typeof(IRequestDispatcherFactory), RequestDispatcherFactoryImplementation, Lifestyle.Singleton);
            IoC.Container.Register(typeof(IAsyncRequestDispatcher), AsyncRequestDispatcherImplementation, Lifestyle.Transient);
            IoC.Container.Register(typeof(IAsyncRequestDispatcherFactory), AsyncRequestDispatcherFactoryImplementation, Lifestyle.Singleton);
        }
Example #3
0
 protected void Application_Start(object sender, EventArgs e)
 {
     var c = new ServiceLayerConfiguration(
         Assembly.Load("AgathaSample.Services"),
         Assembly.Load("AgathaSample.Common"),
         new Container(KernelContainer.Kernel))
                 {
                     SecurityExceptionType = typeof (SecurityException)
                 };
     c.Initialize();
 }
        public void Initialize()
        {
            serviceLayerConfiguration = new ServiceLayerConfiguration(IoC.Container)
            {
                AsyncRequestProcessorImplementation = AsyncRequestProcessorImplementation,
                BusinessExceptionType = BusinessExceptionType,
                RequestProcessorImplementation = RequestProcessorImplementation,
                SecurityExceptionType = SecurityExceptionType
            };

            foreach (var assembly in requestHandlerAssemblies)
                serviceLayerConfiguration.AddRequestHandlerAssembly(assembly);

            foreach (var assembly in requestsAndResponseAssemblies)
                serviceLayerConfiguration.AddRequestAndResponseAssembly(assembly);

            serviceLayerConfiguration.Initialize();

            IoC.Container.Register(typeof(IAsyncRequestDispatcher), AsyncRequestDispatcherImplementation, Lifestyle.Transient);
            IoC.Container.Register(typeof(IAsyncRequestDispatcherFactory), AsyncRequestDispatcherFactoryImplementation, Lifestyle.Singleton);
        }
Example #5
0
        /// <summary>
        /// Configures the agatha.
        /// </summary>
        /// <param name="appContainer">The app container.</param>
        protected virtual void ConfigureAgatha(IContainer appContainer)
        {
            var structureMapContainer = new Agatha.StructureMap.Container ( appContainer );
            IoC.Container = structureMapContainer;

            var assemblyLocator = appContainer.GetInstance<IAssemblyLocator> ();
            var infrastructureAssemblies = assemblyLocator.LocateInfrastructureAssemblies();

            var genericsToApply = new Dictionary<Type, Type> ();
            foreach (var infrastructureAssembly in infrastructureAssemblies)
            {
                var genericsToApplyInAssebmly = KnownTypeHelper.GetGenerics ( infrastructureAssembly );

                foreach ( KeyValuePair<Type, Type> keyValuePair in genericsToApplyInAssebmly )
                {
                    genericsToApply.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }

            var serviceLayerConfiguration = new ServiceLayerConfiguration ( structureMapContainer );

            var serviceAssemblies = assemblyLocator.LocateWebServiceAssemblies();

            foreach ( var assembly in serviceAssemblies )
            {
                var assemblyRef = assembly;
                Logger.Debug ( "Registering Requests, Responses, Handlers, and Dtos for Assembly: {0}", assemblyRef );

                KnownTypeHelper.RegisterNonGenericRequestsAndResponses ( assembly );
                serviceLayerConfiguration.AddRequestHandlerAssembly ( assembly );

                KnownTypeProvider.RegisterDerivedTypesOf<AbstractDataTransferObject> ( assembly.GetTypes ().Where ( t => !t.IsGenericType ) );

                KnownTypeHelper.RegisterGenerics ( genericsToApply, assembly );
            }

            KnownTypeProvider.Register<TerminologyConcept> ();
            KnownTypeProvider.Register<TerminologyProperty> ();
            KnownTypeProvider.Register<TerminologyPropertyType> ();
            KnownTypeProvider.Register<TerminologyVocabulary> ();

            // register the agatha interceptors
            serviceLayerConfiguration.RegisterRequestHandlerInterceptor<SecurityInterceptor>();
            serviceLayerConfiguration.RegisterRequestHandlerInterceptor<RuleViolationEventInterceptor> ();

            serviceLayerConfiguration.RequestProcessorImplementation = typeof ( Service.PerformanceLoggingRequestProcessor );
            serviceLayerConfiguration.Initialize ();

            RegisterIRequestHandlerOfGetRequestDtoByKey ( appContainer );
            CallKnownTypeProviders ( appContainer );
        }
 private static void RegisterAgathaFramework(IUnityContainer container)
 {
     var agathaContainer = new Agatha.Unity.Container(container); //UnityAgathaContainer(container);
     var agathaServiceLayer = new ServiceLayerConfiguration(agathaContainer);
     foreach (var assembly in AssemblyUtils.LoadMEDSEEKAssemblies(ServiceContext.HostSettings.ApplicationPath))
     {
         var types = AssemblyUtils.GetTypes(assembly);
         if (types.Any(t => typeof(Agatha.Common.Request).IsAssignableFrom(t)))
         {
             agathaServiceLayer.AddRequestAndResponseAssembly(assembly);
         }
         else if (types.Any(t => typeof(RequestHandler).IsAssignableFrom(t)))
         {
             agathaServiceLayer.AddRequestHandlerAssembly(assembly);
         }
     }
     agathaServiceLayer.BusinessExceptionType = typeof(BusinessException);
     agathaServiceLayer.RequestProcessorImplementation = typeof(TransactionalRequestProcessor);
     agathaServiceLayer.CacheManagerImplementation = typeof(RequestProcessorCacheManager);
     agathaServiceLayer.CacheProviderImplementation = typeof(RequestProcessorCacheProvider);
     agathaServiceLayer.Initialize();
     container.RegisterType(typeof(IWcfRequestProcessor), typeof(WcfRequestProcessor));
 }