How to reference Spring.Net's ObjectFactory in the config?


How to reference Spring.Net's ObjectFactory in the config?



I would like to use prototype interceptors instead of a singleton interceptor so each session would get a new interceptor instance.

I looked into the HibernateTransactionManager Class and I think "EntityInterceptorObjectName" and "ObjectFactory" are the properties I have to set.

While EntityInterceptorObjectName is pretty obvious, I have no clue how to reference the ObjectFactory when it's the "mother of the ObjectFactories", e.g. the same ObjectFactory which creates the AppContext/the HibernateTransactionManager.

The relevant part of the config:

   <object id="HibernateTransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate20">     <property name="DbProvider" ref="DbProvider"/>     <property name="SessionFactory" ref="SessionFactory"/>     <!-- the name of my non-Singleton EntityInterceptor-->      <property name="EntityInterceptorObjectName" value="MyPrototypeEntityInterceptor" />     <!-- What should I put as ref here? -->     <property name="ObjectFactory" ref="" />   </object>    <object id="MyPrototypeEntityInterceptor" type="Hib.EntityInterceptor, Hib.Interceptors" singleton="false">   </object> 



Is customizing DispatcherServlet in Spring MVC a common practice?

1:



Injecting EntityManager Vs. EntityManagerFactory
As i understand it you can use your own Implementation of IObjectFactory creating the objects you want according to the given name.


property-placeholder location from another property
If you want to be able to use the objects defined within your Spring-ApplicationContext you can also implement IObjectFactoryAware to connect your ObjectFactory to your Spring IoC Container..
Integrating Spring 2.5 with Ibatis 3
This should enable you to do whatever you want.


Spring + GWT, how to disable User Authorization request for a Insert Query?
Create new instances of any class and fill its properties with objects from your IoC container (for example SessionFactory, ...)..
Spring can't see my imported classes
public class MyObjectFactoryAware : IObjectFactoryAware, IObjectFactory {    //this property will be set by the IoC container    ObjectFactory {get; set;}     //IObjectFactory implementation    virtual object GetObject(string objectName)    {       MyEntityInterceptor interceptor = new MyEntityInterceptor();       interceptor.SessionFactory = this.ObjectFactory.getObject("SessionFactory");       return interceptor;        //or of course if you just need it for wireing simply:       //return this.ObjectFactory.getObject(objectName);    }    } 
and the mapping:.
Programmatically call @Controller
<object id="HibernateTransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate20">   <property name="DbProvider" ref="DbProvider"/>   <property name="SessionFactory" ref="SessionFactory"/>   <!-- the name of my non-Singleton EntityInterceptor-->   <property name="EntityInterceptorObjectName" value="MyPrototypeEntityInterceptor" />   <!-- and the name of the objectFactory -->   <property name="ObjectFactory" ref="MyObjectFactory" /> </object>  <object id="MyObjectFactory" type="Hib.MyObjectFactoryAware, Hib.Interceptors"> </object>  <object id="MyPrototypeEntityInterceptor" type="Hib.EntityInterceptor, Hib.Interceptors" singleton="false"> </object> 


Database-sessions in Spring


76 out of 100 based on 76 user ratings 526 reviews

*