RooUsersConnectionRepository implementation using Roo-managed entities for persistence as an alternative to JDBC versions in spring-social-core
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A UsersConnectionRepository/ConnectionRepository implementation using Roo managed entities for persistence as an alternative to the JDBC versions in spring-social-core. You can see this implementation in action in the SocialSignin Roo Showcase ->

To use this implementation in your application:

*1 Add our snapshot repository and dependency to your project, eg. in pom.xml:


*2 Component scan for the RooTemplate implementation, and the UserConnection roo-managed entity:

    <context:component-scan base-package="">
        <context:exclude-filter expression=".*_Roo_.*" type="regex"/>

*3 Replace JdbcUsersConnectionRepository/JdbcConnectionRepository bean configurations with RooUsersConnectionRepository/RooConnectionRepository implementations.

The construction of these beans should only need to change in respect to the first argument of the RooUsersConnectionRepository constructor, which must be the component-scanned RooTemplate (registered under the bean name "rooUserConnectionTemplate") instead of a DataSource bean.

Your datasource bean will be autowired into the RooTemplate implementation instead by the component-scan.

Your configuration should now resemble the following:

private RooTemplate rooTemplate:

    @Scope(value="singleton", proxyMode=ScopedProxyMode.INTERFACES) 
    public UsersConnectionRepository usersConnectionRepository() {
        return new RooUsersConnectionRepository(rooTemplate, connectionFactoryLocator(), Encryptors.noOpText());

    @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)   
    public ConnectionRepository connectionRepository() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication == null) {
            throw new IllegalStateException("Unable to get a ConnectionRepository: no user signed in");
        return usersConnectionRepository().createConnectionRepository(authentication.getName());

or in xml...

    <bean id="usersConnectionRepository"
        <constructor-arg ref="rooUserConnectionTemplate" />
        <constructor-arg ref="connectionFactoryLocator" />
        <constructor-arg ref="textEncryptor" />

        id="connectionRepository" factory-method="createConnectionRepository"
        factory-bean="usersConnectionRepository" scope="request">
        <constructor-arg value="#{}" />
        <aop:scoped-proxy proxy-target-class="true" />

*4 Add to your persistence.xml, eg:

        <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">

With this configuration, there is no need to create the user connection table, as Roo will take care of ORM for the UserConnection entity, which you can now use amongst any other persistent classes in your application.

This implementation contains an associated Test class for the repositories which subclasses AbstractUsersConnectionRepositoryTest from This applies the same suite of tests to the repositories as for the JDBC version from spring-core