Esempio n. 1
0
 public AbstractRunnableHandle(IList <V> items, IThreadLocalCleanupController threadLocalCleanupController)
 {
     this.latch    = new CountDownLatch(items.Count);
     this.exHolder = new InterruptingParamHolder(Thread.CurrentThread);
     this.items    = items;
     this.threadLocalCleanupController = threadLocalCleanupController;
     this.forkState = threadLocalCleanupController.CreateForkState();
 }
Esempio n. 2
0
 public CatchingRunnable(IForkState forkState, Runnable runnable, CountDownLatch latch, IParamHolder <Exception> throwableHolder,
                         IThreadLocalCleanupController threadLocalCleanupController)
 {
     this.forkState       = forkState;
     this.runnable        = runnable;
     this.latch           = latch;
     this.throwableHolder = throwableHolder;
     this.threadLocalCleanupController = threadLocalCleanupController;
 }
Esempio n. 3
0
 public void DisposeContext()
 {
     if (testClassLevelContext != null)
     {
         IThreadLocalCleanupController tlCleanupController = testClassLevelContext.GetService <IThreadLocalCleanupController>();
         testClassLevelContext.GetRoot().Dispose();
         testClassLevelContext = null;
         beanContext           = null;
         tlCleanupController.CleanupThreadLocal();
     }
 }
Esempio n. 4
0
        public static IAmbethPlatformContext Create(Properties props, Type[] providerModules, Type[] frameworkModules, Type[] bootstrapModules,
                                                    IInitializingModule[] providerModuleInstances, IInitializingModule[] frameworkModuleInstances,
                                                    IInitializingModule[] bootstrapModuleInstances)
        {
            ParamChecker.AssertParamNotNull(props, "props");

            IServiceContext       bootstrapContext = null;
            AmbethPlatformContext apc = new AmbethPlatformContext();

            try
            {
                IInitializingModule[] providerModuleInstancesCopy = new IInitializingModule[providerModuleInstances.Length + 1];
                Array.Copy(providerModuleInstances, 0, providerModuleInstancesCopy, 0, providerModuleInstances.Length);
                providerModuleInstancesCopy[providerModuleInstancesCopy.Length - 1] = new AmbethPlatformContextModule(apc);
                providerModuleInstances = providerModuleInstancesCopy;

                bootstrapContext = BeanContextFactory.CreateBootstrap(props, providerModules, providerModuleInstances);

                IList <IModuleProvider> moduleProviders = bootstrapContext.GetImplementingObjects <IModuleProvider>();
                for (int a = moduleProviders.Count; a-- > 0;)
                {
                    IModuleProvider moduleProvider     = moduleProviders[a];
                    Type[]          mpFrameworkModules = moduleProvider.GetFrameworkModules();
                    Type[]          mpBootstrapModules = moduleProvider.GetBootstrapModules();
                    frameworkModules = ModuleUtil.MergeModules(mpFrameworkModules, frameworkModules);
                    bootstrapModules = ModuleUtil.MergeModules(mpBootstrapModules, bootstrapModules);
                }
                IServiceContext frameworkBeanContext = bootstrapContext;

                if (frameworkModules.Length > 0 || frameworkModuleInstances.Length > 0)
                {
                    frameworkBeanContext = bootstrapContext.CreateService("framework", delegate(IBeanContextFactory childContextFactory)
                    {
                        for (int a = frameworkModuleInstances.Length; a-- > 0;)
                        {
                            childContextFactory.RegisterExternalBean(frameworkModuleInstances[a]);
                        }
                    }, frameworkModules);
                }

                ILightweightTransaction transaction = frameworkBeanContext.GetService <ILightweightTransaction>(false);
                if (transaction != null)
                {
                    ILogger log = LoggerFactory.GetLogger(typeof(AmbethPlatformContext), props);
                    if (log.InfoEnabled)
                    {
                        log.Info("Starting initial database transaction to receive metadata for OR-Mappings...");
                    }
                    transaction.RunInTransaction(delegate()
                    {
                        // Intended blank
                    });
                    if (log.InfoEnabled)
                    {
                        log.Info("Initial database transaction processed successfully");
                    }
                }
                IServiceContext applicationBeanContext = frameworkBeanContext;

                if (bootstrapModules.Length > 0 || bootstrapModuleInstances.Length > 0)
                {
                    applicationBeanContext = frameworkBeanContext.CreateService("application", delegate(IBeanContextFactory childContextFactory)
                    {
                        for (int a = bootstrapModuleInstances.Length; a-- > 0;)
                        {
                            childContextFactory.RegisterExternalBean(bootstrapModuleInstances[a]);
                        }
                    }, bootstrapModules);
                }
                apc.beanContext = applicationBeanContext;
                return(apc);
            }
            catch (Exception)
            {
                if (bootstrapContext != null)
                {
                    IThreadLocalCleanupController tlCleanupController = bootstrapContext.GetService <IThreadLocalCleanupController>();
                    bootstrapContext.Dispose();
                    tlCleanupController.CleanupThreadLocal();
                }
                throw;
            }
        }
Esempio n. 5
0
        public void ClearThreadLocal()
        {
            IThreadLocalCleanupController threadLocalCleanupController = beanContext.GetService <IThreadLocalCleanupController>();

            threadLocalCleanupController.CleanupThreadLocal();
        }
Esempio n. 6
0
 public RunnableHandle(IBackgroundWorkerParamDelegate <V> run, IList <V> items, IThreadLocalCleanupController threadLocalCleanupController) : base(items, threadLocalCleanupController)
 {
     this.run = run;
 }
Esempio n. 7
0
 public ResultingRunnableHandle(IResultingBackgroundWorkerParamDelegate <R, V> run, IAggregrateResultHandler <R, V> aggregrateResultHandler, IList <V> items, IThreadLocalCleanupController threadLocalCleanupController) : base(items, threadLocalCleanupController)
 {
     this.run = run;
     this.aggregrateResultHandler = aggregrateResultHandler;
 }