예제 #1
0
 protected virtual IServiceContext StartIntern(IBackgroundWorkerParamDelegate <IBeanContextFactory> content)
 {
     writeLock.Lock();
     try
     {
         if (Log.DebugEnabled)
         {
             Log.Debug("Looking for existing child context...");
         }
         IServiceContext childContext = GetChildContext();
         if (childContext == null || childContext.IsDisposed)
         {
             if (Log.DebugEnabled)
             {
                 Log.Debug("No valid child context found. Creating new child context");
             }
             IBackgroundWorkerParamDelegate <IBeanContextFactory> rpd = new IBackgroundWorkerParamDelegate <IBeanContextFactory>(delegate(IBeanContextFactory beanContextFactory)
             {
                 if (content != null)
                 {
                     content.Invoke(beanContextFactory);
                 }
                 beanContextFactory.RegisterBean <ChildContextFoot>().PropertyValue("ContextHandle", this);
             });
             if (ContextFactory != null)
             {
                 childContext = ContextFactory.CreateChildContext(rpd);
             }
             else
             {
                 childContext = BeanContext.CreateService(rpd);
             }
             SetChildContext(childContext);
             childContexts.Add(childContext);
         }
         else if (Log.DebugEnabled)
         {
             Log.Debug("Existing child context found and valid");
         }
         IList <IUpwakingBean> upwakingBeans = childContext.GetImplementingObjects <IUpwakingBean>();
         for (int a = 0, size = upwakingBeans.Count; a < size; a++)
         {
             upwakingBeans[a].WakeUp();
         }
         return(childContext);
     }
     finally
     {
         writeLock.Unlock();
     }
 }