From a0d7c9432628e89d26abddf5e842ddab8fedefe2 Mon Sep 17 00:00:00 2001 From: Jennifer Hickey Date: Tue, 24 Apr 2012 15:08:05 +0300 Subject: [PATCH] More test of README --- README.md | 172 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 134 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index dbb074d..e39ff9c 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ System.out.println("Mongo available at host: " + service.getHost() + " and port: ``` ## Connecting to services using Java API -If you don't care to use the cloud namespace, you can still take advantage of the [Java API](http://cf-runtime-api.cloudfoundry.com) to make programmatic service connections. See the javadoc for all extensions of [AbstractServiceCreator]. The service creators for Mongo and Redis require Spring Data. The RabbitServiceCreator requires Spring AMQP. Service creators for MySQL and PostgreSQL will create a Commons DBCP DataSource if the libraries are present, else they will attempt to create a Tomcat DataSource. +If you don't care to use the cloud namespace, you can still take advantage of the [Java API](http://cf-runtime-api.cloudfoundry.com) to make programmatic service connections. See the javadoc for all extensions of AbstractServiceCreator. The service creators for Mongo and Redis require Spring Data. The RabbitServiceCreator requires Spring AMQP. Service creators for MySQL and PostgreSQL will create a Commons DBCP DataSource if the libraries are present, else they will attempt to create a Tomcat DataSource. Here is an example that creates a connection to a Mongo service named "my-mongo": ```java @@ -86,7 +86,7 @@ A simple example DataSource configuration to be injected into a JdbcTemplate wou There are sub-elements that can be used to configure specific connections and pool settings. The \ namespace element supports the most commonly used configuration options via the \ and \ sub-elements. The supported options are explained below: -##### options +##### \ options @@ -103,24 +103,63 @@ There are sub-elements that can be used to configure specific connections and po
- options -Namespace attribute Description Type Default -pool-size Either the maximum number of connections in the pool or a range specifying minimum and maximum size separated by a dash. int Uses the default settings of the Apache Commons Pool which are 0 for min and 8 for max size -max-wait-time The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. -1 indicates unlimited wait. int Uses the default setting of the Apache Commons Pool which is unlimited (-1) +##### \ options -#### -The element provides a convenient way to configure the MongoDB connection factory for your Spring application. + + + + + + + + + + + + + + + + + + + +
Namespace attributeDescriptionTypeDefault
pool-sizeEither the maximum number of connections in the pool or a range specifying minimum and maximum size separated by a dash.intUses the default settings of the Apache Commons Pool which are 0 for min and 8 for max size
max-wait-timeThe maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. -1 indicates unlimited wait.intUses the default setting of the Apache Commons Pool which is unlimited (-1)
+ + +#### \ +The \ element provides a convenient way to configure the MongoDB connection factory for your Spring application. Basic attributes: id – defaults to service name service-name – only needed if you have multiple MongoDB services bound to the app write-concern – the WriteConcern to use for all DB connections created (NONE, NORMAL, SAFE, FSYNC_SAFE). If this is not specified then no WriteConcern will be set for the DB connections and all writes will default to NORMAL The values for the write-concern attribute correspond to the values available in the com.mongodb.WriteConcern class. -Value Description -NONE No exceptions are raised, even for network issues -NORMAL Exceptions are raised for network issues, but not server errors -SAFE Exceptions are raised for network issues, and server errors; waits on a server for the write operation -FSYNC_SAFE Exceptions are raised for network issues, and server errors and the write operation waits for the server to flush the data to disk + + + + + + + + + + + + + + + + + + + + + + + +
ValueDescription
NONENo exceptions are raised, even for network issues
NORMALExceptions are raised for network issues, but not server errors
SAFEExceptions are raised for network issues, and server errors; waits on a server for the write operation
FSYNC_SAFEExceptions are raised for network issues, and server errors and the write operation waits for the server to flush the data to disk
+ A simple example MongoDbFactory configuration to be injected into a MongoTemplate would look like this, with the only attribute used specifying the id of the mongoDbFactory bean. ```xml @@ -131,15 +170,35 @@ A simple example MongoDbFactory configuration to be injected into a MongoTemplat ``` -There are some advanced configuration attributes that are available using the sub-element and they are listed below. - -Namespace attribute Description Type Default -connections-per-host The maximum number of connections allowed per host for the Mongo instance. Those connections will be kept in a pool when idle. Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection. int The Mongo driver has a default of 10 -max-wait-time The maximum wait time in ms that a thread may wait for a connection to become available. int The Mongo driver has a default of 120000 +There are some advanced configuration attributes that are available using the \ sub-element and they are listed below. +##### \ -#### -The element provides a convenient way to configure the Redis connection factory for your Spring application. + + + + + + + + + + + + + + + + + + + + +
Namespace attributeDescriptionTypeDefault
connections-per-hostThe maximum number of connections allowed per host for the Mongo instance. Those connections will be kept in a pool when idle. Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection.intThe Mongo driver has a default of 10
max-wait-timeThe maximum wait time in ms that a thread may wait for a connection to become available.intThe Mongo driver has a default of 120000
+ + +#### \ +The \ element provides a convenient way to configure the Redis connection factory for your Spring application. Available attributes: id – defaults to service name service-name – only needed if you have multiple Redis services bound to the app @@ -152,14 +211,35 @@ A simple example RedisConnectionFactory configuration to be injected into a Redi ``` -The advanced configuration attributes that are available via the sub-element are listed below. - options -Namespace attribute Description Type Default -pool-size Either the maximum number of connections in the pool or a range specifying minimum and maximum size separated by a dash. int Uses the default settings of the Apache Commons Pool which are 0 for min and 8 for max size -max-wait-time The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. int Uses the default setting of the Apache Commons Pool which is unlimited (-1) - -#### -The element provides a convenient way to configure the RabbitMQ connection factory for your Spring application. +The advanced configuration attributes that are available via the \ sub-element are listed below. + +##### \ options + + + + + + + + + + + + + + + + + + + + + +
Namespace attributeDescriptionTypeDefault
pool-sizeEither the maximum number of connections in the pool or a range specifying minimum and maximum size separated by a dash.intUses the default settings of the Apache Commons Pool which are 0 for min and 8 for max size
max-wait-timeThe maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.intUses the default setting of the Apache Commons Pool which is unlimited (-1)
+ + +#### \ +The \ element provides a convenient way to configure the RabbitMQ connection factory for your Spring application. Available attributes: id – defaults to service name service-name – only needed if you have multiple RabbitMQ services bound to the app @@ -171,14 +251,30 @@ A simple example RabbitConnectionFactory configuration to be injected into a Rab ``` -The advanced configuration attributes that are available via the are listed below. - -Namespace attribute Description Type Default -channel-cache-size The size of the channel cache. int The default is 1 - -#### -The element scans all services bound to the application and creates a bean of an appropriate type for each. You can think of this element as a cloud extension of in core Spring, which scans the classpath for beans with certain annotations and creates a bean for each. The is especially useful during the initial phases of application development, where you want immediate access to service beans without adding a element for each new service bound. -Once you include a element in application context, then in your Java code, simply add @Autowired dependencies for each bound service: +The advanced configuration attributes that are available via the \ are listed below. + +##### \ + + + + + + + + + + + + + + + +
Namespace attributeDescriptionTypeDefault
channel-cache-sizeThe size of the channel cache.intThe default is 1
+ + +#### \ +The \ element scans all services bound to the application and creates a bean of an appropriate type for each. You can think of this element as a cloud extension of \ in core Spring, which scans the classpath for beans with certain annotations and creates a bean for each. The \ is especially useful during the initial phases of application development, where you want immediate access to service beans without adding a \ element for each new service bound. +Once you include a \ element in application context, then in your Java code, simply add @Autowired dependencies for each bound service: ```java @Autowired DataSource dataSource; @Autowired ConnectionFactory rabbitConnectionFactory; @@ -194,8 +290,8 @@ the @Qualifier to specify the service name (each automatically created bean is n ``` Here, the inventoryDataSource bean will be bound to the inventory-db service and the pricingDataSource bean will be bound to the pricing-db service. -#### +#### \ Available attributes: id – the name of the Properties bean -The element exposes basic information about services that can be consumed with Spring’s property placeholder support. The properties exposed match those automatically enabled for a Spring 3.1 application. +The \ element exposes basic information about services that can be consumed with Spring’s property placeholder support. The properties exposed match those automatically enabled for a Spring 3.1 application.