// Path: src/main/java/org/springframework/social/tumblr/config/support/TumblrApiHelper.java
// public class TumblrApiHelper implements ApiHelper<Tumblr> {
// 
//     private final UsersConnectionRepository usersConnectionRepository;
// 
//     private final UserIdSource userIdSource;
// 
//     private TumblrApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
//         this.usersConnectionRepository = usersConnectionRepository;
//         this.userIdSource = userIdSource;        
//     }
// 
//     public Tumblr getApi() {
//         if (logger.isDebugEnabled()) {
//             logger.debug("Getting API binding instance for Tumblr");
//         }
//         
//         Connection<Tumblr> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Tumblr.class);
//         if (logger.isDebugEnabled() && connection == null) {
//             logger.debug("No current connection; Returning default TumblrTemplate instance.");
//         }
//         return connection != null ? connection.getApi() : new TumblrTemplate();
//     }
// 
//     private final static Log logger = LogFactory.getLog(TumblrApiHelper.class);
// 
// }
// 
// Path: src/main/java/org/springframework/social/tumblr/connect/TumblrConnectionFactory.java
// public class TumblrConnectionFactory extends OAuth1ConnectionFactory<Tumblr> {
// 
// 	public TumblrConnectionFactory(String consumerKey, String consumerSecret) {
// 		super("tumblr", new TumblrServiceProvider(consumerKey, consumerSecret), new TumblrAdapter());
// 	}
// 	
// }
// 
// Path: src/main/java/org/springframework/social/tumblr/security/TumblrAuthenticationService.java
// public class TumblrAuthenticationService extends OAuth1AuthenticationService<Tumblr> {
// 
//     public TumblrAuthenticationService(String apiKey, String appSecret) {
//         super(new TumblrConnectionFactory(apiKey, appSecret));
//     }
// }


import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.security.provider.SocialAuthenticationService;
import org.springframework.social.tumblr.config.support.TumblrApiHelper;
import org.springframework.social.tumblr.connect.TumblrConnectionFactory;
import org.springframework.social.tumblr.security.TumblrAuthenticationService;
import java.util.Map;
package org.springframework.social.tumblr.config.xml;



/**
 * Implementation of {@link AbstractProviderConfigBeanDefinitionParser} that creates a {@link TumblrConnectionFactory}.
 */
public class TumblrConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser {
    public TumblrConfigBeanDefinitionParser() {
        super(TumblrConnectionFactory.class, TumblrApiHelper.class);
    }

    @Override
    protected Class<? extends SocialAuthenticationService<?>> getAuthenticationServiceClass() {
        return TumblrAuthenticationService.class;
    }

    @Override
    protected BeanDefinition getConnectionFactoryBeanDefinition(String appId, String appSecret, Map<String, Object> allAttributes) {
// Path: src/main/java/org/springframework/social/tumblr/config/support/TumblrApiHelper.java
// public class TumblrApiHelper implements ApiHelper<Tumblr> {
// 
//     private final UsersConnectionRepository usersConnectionRepository;
// 
//     private final UserIdSource userIdSource;
// 
//     private TumblrApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
//         this.usersConnectionRepository = usersConnectionRepository;
//         this.userIdSource = userIdSource;        
//     }
// 
//     public Tumblr getApi() {
//         if (logger.isDebugEnabled()) {
//             logger.debug("Getting API binding instance for Tumblr");
//         }
//         
//         Connection<Tumblr> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Tumblr.class);
//         if (logger.isDebugEnabled() && connection == null) {
//             logger.debug("No current connection; Returning default TumblrTemplate instance.");
//         }
//         return connection != null ? connection.getApi() : new TumblrTemplate();
//     }
// 
//     private final static Log logger = LogFactory.getLog(TumblrApiHelper.class);
// 
// }
// 
// Path: src/main/java/org/springframework/social/tumblr/connect/TumblrConnectionFactory.java
// public class TumblrConnectionFactory extends OAuth1ConnectionFactory<Tumblr> {
// 
// 	public TumblrConnectionFactory(String consumerKey, String consumerSecret) {
// 		super("tumblr", new TumblrServiceProvider(consumerKey, consumerSecret), new TumblrAdapter());
// 	}
// 	
// }
// 
// Path: src/main/java/org/springframework/social/tumblr/security/TumblrAuthenticationService.java
// public class TumblrAuthenticationService extends OAuth1AuthenticationService<Tumblr> {
// 
//     public TumblrAuthenticationService(String apiKey, String appSecret) {
//         super(new TumblrConnectionFactory(apiKey, appSecret));
//     }
// }


// Path: src/main/java/org/springframework/social/tumblr/config/xml/TumblrConfigBeanDefinitionParser.java
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.security.provider.SocialAuthenticationService;
import org.springframework.social.tumblr.config.support.TumblrApiHelper;
import org.springframework.social.tumblr.connect.TumblrConnectionFactory;
import org.springframework.social.tumblr.security.TumblrAuthenticationService;
import java.util.Map;

package org.springframework.social.tumblr.config.xml;



/**
 * Implementation of {@link AbstractProviderConfigBeanDefinitionParser} that creates a {@link TumblrConnectionFactory}.
 */
public class TumblrConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser {
    public TumblrConfigBeanDefinitionParser() {
        super(TumblrConnectionFactory.class, TumblrApiHelper.class);
    }

    @Override
    protected Class<? extends SocialAuthenticationService<?>> getAuthenticationServiceClass() {
        return TumblrAuthenticationService.class;
    }

    @Override
    protected BeanDefinition getConnectionFactoryBeanDefinition(String appId, String appSecret, Map<String, Object> allAttributes) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(TumblrConnectionFactory.class).addConstructorArgValue(appId).addConstructorArgValue(appSecret);