Permalink
Browse files

Reference doc updates

  • Loading branch information...
Craig Walls
Craig Walls committed Jun 28, 2011
1 parent 018b0ce commit 85c54bbf4ae4a083583394de1f1cfabb841e032b
Showing with 19 additions and 15 deletions.
  1. +8 −4 docs/src/reference/docbook/api.xml
  2. +11 −11 docs/src/reference/docbook/connecting.xml
@@ -21,13 +21,17 @@ Gowalla gowalla = new GowallaTemplate(accessToken);]]>
</para>
<programlisting language="java"><![CDATA[
-Connection<Gowalla> connection = connectionRepository.findPrimaryConnectionToApi(Gowalla.class);
-Gowalla gowalla = connection.getApi();]]>
+Connection<Gowalla> connection = connectionRepository.findPrimaryConnection(Gowalla.class);
+if (connection != null) {
+ Gowalla gowalla = connection.getApi();
+
+ // ... use GitHub API binding
+}]]>
</programlisting>
<para>
- Here, <interfacename>ConnectionRepository</interfacename> is being asked for the primary connections that the current user has with Gowalla.
- From that connection, it retrieves a <interfacename>Gowalla</interfacename> instance that is configured with the connection details received when the connection was first established.
+ Here, <interfacename>ConnectionRepository</interfacename> is being asked for the primary connection that the current user has with Gowalla.
+ If a connection to Gowalla is found, it retrieves a <interfacename>Gowalla</interfacename> instance that is configured with the connection details received when the connection was first established.
</para>
<para>
@@ -15,30 +15,29 @@
<programlisting language="java"><![CDATA[
@Configuration
-public class ConnectionFactoryConfig {
+public class SocialConfig {
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
- registry.addConnectionFactory(new GowallaConnectionFactory(gowallaClientId, gowallaClientSecret));
+ registry.addConnectionFactory(new GowallaConnectionFactory(
+ environment.getProperty("gowalla.clientId"),
+ environment.getProperty("gowalla.clientSecret")));
return registry;
}
- @Value("${gowalla.clientId}")
- private String gowallaClientId;
-
- @Value("${gowalla.clientSecret}")
- private String gowallaClientSecret;
-
}
]]></programlisting>
<para>
Here, a Gowalla connection factory is registered with <classname>ConnectionFactoryRegistry</classname> via the <methodname>addConnectionFactory()</methodname> method.
If we wanted to add support for connecting to other providers, we would simply register their connection factories here in the same way as <classname>GowallaConnectionFactory</classname>.
- Because consumer keys and secrets may be different across environments (e.g., test, production, etc) it is recommended that these values be externalized.
- Therefore, they are wired in with <code>@Value</code> as property placeholder values to be resolved by Spring's property placeholder support.
- </para>
+ </para>
+
+ <para>
+ Because client IDs and secrets may be different across environments (e.g., test, production, etc) it is recommended that these values be externalized.
+ As shown here, Spring 3.1's <interfacename>Environment</interfacename> is used to look up the application's client ID and secret.
+ </para>
<para>
Optionally, you may also configure <classname>ConnectionFactoryRegistry</classname> and <classname>GowallaConnectionFactory</classname> in XML:
@@ -60,6 +59,7 @@ public class ConnectionFactoryConfig {
<para>
This is functionally equivalent to the Java-based configuration of <classname>ConnectionFactoryRegistry</classname> shown before.
The only casual difference is that the connection factories are injected as a list into the <code>connectionFactories</code> property rather than with the <methodname>addConnectionFactory()</methodname> method.
+ As in the Java-based configuration, the application's consumer key and secret are externalized (shown here as property placeholders).
</para>
<para>

0 comments on commit 85c54bb

Please sign in to comment.