spring - @Autowire using singleton vs prototype -


take @ following code:

@controller public class homecontroller {        @autowired     private facaderemote fr;  // code omitted    } 

|

@component("user-details") public class customuserservicedetails implements userdetailsservice {      @autowired     private facaderemote fr;      @override     public userdetails loaduserbyusername(string email)             throws usernamenotfoundexception     {         // omitted     }  } 

configuration:

<!-- jndi properties -->     <util:properties id="jndiprops">         <beans:prop key="java.naming.factory.initial">org.jboss.naming.remote.client.initialcontextfactory</beans:prop>         <beans:prop key="java.naming.factory.url.pkgs">org.jboss.ejb.client.naming</beans:prop>         <beans:prop key="java.naming.provider.url">remote://127.0.0.1:4447</beans:prop>         <beans:prop key="java.naming.client.ejb.context">true</beans:prop>         <beans:prop key="boss.naming.client.connect.options.org.xnio.options.sasl_policy_noplaintext">false</beans:prop>     </util:properties>       <!-- ejb -->     <jee:remote-slsb id="ns" jndi-name="layer//myejb!com.uni.ag.facaderemote"         environment-ref="jndiprops" resource-ref="false"         business-interface="com.uni.ag.facaderemote"         lookup-home-on-startup="true">     </jee:remote-slsb> 

in following example how @autowire works:
2 classes using same instance of facaderemote ?
in general how can learn @autowire behaviour in relation thread-safety ?

there no relation between @autowired , thread-safety. responsibility of spring ioc inject declared dependencies, taking account scope etc. it's responsibility make sure, beans work correctly in multi-threaded applications. means example singleton beans state bean holds should synchronized.

regarding first question: there injected proxy facaderemote (to allow example transations of checked exception remoteexception unchecked exception). according spring spec inside proxy cached instance of remote interface facaderemote.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -