jeudi 25 juin 2015

@Autowire using same instance

Take a look at the 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">http://remote127.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 look up -->
    <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 the following example how does @Autowire works:
Are the two classes using the same instance of FacadeRemote ?
In general how can I learn @Autowire behaviour in relation to thread-safety ?




Aucun commentaire:

Enregistrer un commentaire