protected override void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet) { if (AttributeUtils.FindAttribute(pf.TargetType, typeof(RepositoryAttribute)) != null) { DefaultListableObjectFactory of = new DefaultListableObjectFactory(); of.RegisterObjectDefinition("peti", new RootObjectDefinition(typeof(PersistenceExceptionTranslationInterceptor))); of.RegisterSingleton("pet", pet); pf.AddAdvice((PersistenceExceptionTranslationInterceptor)of.GetObject("peti")); } }
protected override void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet) { if (AttributeUtils.FindAttribute(pf.TargetType, typeof(RepositoryAttribute)) != null) { DefaultListableObjectFactory of = new DefaultListableObjectFactory(); of.RegisterObjectDefinition("peti", new RootObjectDefinition(typeof(PersistenceExceptionTranslationInterceptor))); of.RegisterSingleton("pet", pet); pf.AddAdvice((PersistenceExceptionTranslationInterceptor) of.GetObject("peti")); } }
/// <summary> /// Initializes a new instance of the <see cref="PersistenceExceptionTranslationAdvisor"/> class. /// </summary> /// <param name="persistenceExceptionTranslator">The persistence exception translator to use.</param> /// <param name="repositoryAttributeType">Type of the repository attribute to check for.</param> public PersistenceExceptionTranslationAdvisor(IPersistenceExceptionTranslator persistenceExceptionTranslator, Type repositoryAttributeType) { this.advice = new PersistenceExceptionTranslationInterceptor(persistenceExceptionTranslator); this.pointcut = new AttributeMatchingPointcut(repositoryAttributeType, true); }
/// <summary> /// Initializes a new instance of the <see cref="PersistenceExceptionTranslationInterceptor"/> class, autodetecting /// IPersistenceExceptionTranslators in the given object factory. /// </summary> /// <param name="objectFactory">The object factory to obtain all IPersistenceExceptionTranslators from.</param> public PersistenceExceptionTranslationInterceptor(IListableObjectFactory objectFactory) { this.persistenceExceptionTranslator = DetectPersistenceExceptionTranslators(objectFactory); }
/// <summary> /// Initializes a new instance of the <see cref="PersistenceExceptionTranslationInterceptor"/> class for the /// given IPersistenceExceptionTranslator /// </summary> /// <param name="persistenceExceptionTranslator">The persistence exception translator to use.</param> public PersistenceExceptionTranslationInterceptor(IPersistenceExceptionTranslator persistenceExceptionTranslator) { this.persistenceExceptionTranslator = persistenceExceptionTranslator; }
protected virtual void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet) { pf.AddAdvisor(new PersistenceExceptionTranslationAdvisor(pet, typeof(RepositoryAttribute))); }
/// <summary> /// Initializes a new instance of the <see cref="PersistenceExceptionTranslationInterceptor"/> class, autodetecting /// IPersistenceExceptionTranslators in the given object factory. /// </summary> /// <param name="objectFactory">The object factory to obtain all IPersistenceExceptionTranslators from.</param> public PersistenceExceptionTranslationInterceptor(IListableObjectFactory objectFactory) { this.persistenceExceptionTranslator = DetectPersistenceExceptionTranslators(objectFactory); }
/// <summary> /// Initializes a new instance of the <see cref="PersistenceExceptionTranslationInterceptor"/> class for the /// given IPersistenceExceptionTranslator /// </summary> /// <param name="persistenceExceptionTranslator">The persistence exception translator to use.</param> public PersistenceExceptionTranslationInterceptor(IPersistenceExceptionTranslator persistenceExceptionTranslator) { this.persistenceExceptionTranslator = persistenceExceptionTranslator; }
/// <summary> /// Adds the translator to the translator list. /// </summary> /// <param name="translator">The translator.</param> public void AddTranslator(IPersistenceExceptionTranslator translator) { AssertUtils.ArgumentNotNull(translator, "PersistenceExceptionTranslator must not be null"); this.translatorList.Add(translator); }
/// <summary> /// Adds the translator to the translator list. /// </summary> /// <param name="translator">The translator.</param> public void AddTranslator(IPersistenceExceptionTranslator translator) { AssertUtils.ArgumentNotNull(translator, "PersistenceExceptionTranslator must not be null"); this.translatorList.Add(translator); }
/// <summary> /// Return a translated exception if this is appropriate, or null if the exception could /// not be translated. /// </summary> /// <param name="rawException">The raw exception we may wish to translate.</param> /// <param name="pet">The PersistenceExceptionTranslator to use to perform the translation.</param> /// <returns>A translated exception if translation is possible, or or null if the exception could /// not be translated.</returns> public static DataAccessException TranslateIfNecessary(Exception rawException, IPersistenceExceptionTranslator pet) { AssertUtils.ArgumentNotNull(pet, "PersistenceExceptionTranslator must not be null"); return pet.TranslateExceptionIfPossible(rawException); }
protected virtual void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet) { pf.AddAdvisor(new PersistenceExceptionTranslationAdvisor(pet, typeof(RepositoryAttribute))); }
/// <summary> /// Initializes a new instance of the <see cref="PersistenceExceptionTranslationAdvisor"/> class. /// </summary> /// <param name="persistenceExceptionTranslator">The persistence exception translator to use.</param> /// <param name="repositoryAttributeType">Type of the repository attribute to check for.</param> public PersistenceExceptionTranslationAdvisor(IPersistenceExceptionTranslator persistenceExceptionTranslator, Type repositoryAttributeType) { this.advice = new PersistenceExceptionTranslationInterceptor(persistenceExceptionTranslator); this.pointcut = new AttributeMatchingPointcut(repositoryAttributeType, true); }
/// <summary> /// Return a translated exception if this is appropriate, or null if the exception could /// not be translated. /// </summary> /// <param name="rawException">The raw exception we may wish to translate.</param> /// <param name="pet">The PersistenceExceptionTranslator to use to perform the translation.</param> /// <returns>A translated exception if translation is possible, or or null if the exception could /// not be translated.</returns> public static DataAccessException TranslateIfNecessary(Exception rawException, IPersistenceExceptionTranslator pet) { AssertUtils.ArgumentNotNull(pet, "PersistenceExceptionTranslator must not be null"); return(pet.TranslateExceptionIfPossible(rawException)); }