use of org.springframework.social.connect.ConnectionFactory in project engine by craftercms.
the class ConfigAwareConnectionFactoryLocator method getCurrentConnectionFactoryLocator.
protected ConnectionFactoryLocator getCurrentConnectionFactoryLocator() {
Callback<ConnectionFactoryLocator> callback = new Callback<ConnectionFactoryLocator>() {
@Override
public ConnectionFactoryLocator execute() {
HierarchicalConfiguration config = ConfigUtils.getCurrentConfig();
ConnectionFactoryRegistry registry = null;
if (config != null) {
try {
SubnodeConfiguration socialConnectionsConfig = config.configurationAt(SOCIAL_CONNECTIONS_KEY);
for (ConfigurationParser<?> parser : configParsers) {
ConnectionFactory<?> factory = (ConnectionFactory<?>) parser.parse(socialConnectionsConfig);
if (factory != null) {
if (registry == null) {
registry = new ConnectionFactoryRegistry();
}
registry.addConnectionFactory(factory);
}
}
} catch (IllegalArgumentException e) {
// Ignore if != 1
}
}
if (registry != null) {
return registry;
} else {
return defaultLocator;
}
}
};
SiteContext siteContext = SiteContext.getCurrent();
if (siteContext != null) {
return cacheTemplate.getObject(siteContext.getContext(), callback, CONNECTION_FACTORY_LOCATOR_CACHE_KEY);
} else {
return defaultLocator;
}
}
Aggregations