private ITisServiceCreator InstanciateCreator( ITisServiceInfo oServiceInfo) { // Get creator type string sCreatorType = oServiceInfo.ServiceCreatorType; // Create Creator instance object oObjCreator = ActivatorHelper.CreateInstance( sCreatorType, EmptyArrays.ObjectArray); ITisServiceCreator oCreator = null; try { // Try to cast oCreator = (ITisServiceCreator)oObjCreator; } catch (InvalidCastException oExc) { throw new TisException( oExc, // Inner "Object [{0}] doesn't implements ITisServiceCreator", oObjCreator); } return(oCreator); }
public object GetService( TisServiceKey oServiceKey) { object oService = null; try { // Obtain service creator ITisServiceCreator oCreator = GetCreator(oServiceKey); // Create the service instance using creator oService = oCreator.CreateService(); } catch (Exception oExc) { Log.WriteError( "ServiceActivator.GetService({0}) Failed, {1}", oServiceKey, oExc.Message); throw; } // Return the service return(oService); }
private void SetCreatorContext( ITisServiceCreator oCreator, TisServiceKey oServiceKey) { // Set creator context m_oServicesHost.CreatorContextSetter.SetCreatorContext( oCreator, m_sAppName, oServiceKey, m_oServicesHost); }
public void ReleaseService( TisServiceKey oServiceKey, ITisServiceInfo serviceInfo = null, object oService = null) { if (oService == null && IsInstantiated(oServiceKey)) { oService = m_oCreatorsCache.Get(oServiceKey); } if (oService != null) { // Obtain service creator ITisServiceCreator oCreator = GetCreator(oServiceKey); oCreator.ReleaseService(oService); } }
protected override void SetCreatorContextImpl( ITisServiceCreator oCreator, string sAppName, TisServiceKey oServiceKey, ITisServicesHost oServicesHost) { // Query for ISupportsCreatorContext interface ISupportsCreatorContext oTarget = oCreator as ISupportsCreatorContext; if (oTarget != null) { // Set context oTarget.SetContext( sAppName, oServiceKey, oServicesHost); } }
private object CreatorsCache_OnCacheMiss( object oSender, CacheMissEventArgs oArgs) { TisServiceKey oServiceKey = (TisServiceKey)oArgs.Key; // Obtain service info ITisServiceInfo oServiceInfo = m_oServicesHost.CheckedGetServiceInfo(m_sAppName, oServiceKey.ServiceName); // Validate we can host the service ValidateCanHostService(oServiceInfo); // Obtain service creator ITisServiceCreator oCreator = InstanciateCreator(oServiceInfo); // Set creator context SetCreatorContext(oCreator, oServiceKey); return(oCreator); }
public virtual void SetCreatorContext( ITisServiceCreator oCreator, string sAppName, TisServiceKey oServiceKey, ITisServicesHost oServicesHost) { // Perform context set SetCreatorContextImpl( oCreator, sAppName, oServiceKey, oServicesHost); // If has next setter in the chain if (Next != null) { // Forward the request to next setter Next.SetCreatorContext( oCreator, sAppName, oServiceKey, oServicesHost); } }
protected abstract void SetCreatorContextImpl( ITisServiceCreator oCreator, string sAppName, TisServiceKey oServiceKey, ITisServicesHost oServicesHost);