diff --git a/src/docbkx/reference/jmx.xml b/src/docbkx/reference/jmx.xml index 2e2367c64..5535566b4 100644 --- a/src/docbkx/reference/jmx.xml +++ b/src/docbkx/reference/jmx.xml @@ -34,30 +34,28 @@ http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - <beans> +<beans> - <!-- Default bean name is 'mongo' --> - <mongo:mongo host="localhost" port="27017"/> + <!-- Default bean name is 'mongo' --> + <mongo:mongo host="localhost" port="27017"/> - <!-- by default look for a Mongo object named 'mongo' --> - <mongo:jmx/> + <!-- by default look for a Mongo object named 'mongo' --> + <mongo:jmx/> - <context:mbean-export/> + <context:mbean-export/> - <!-- To translate any MongoExceptions thrown in @Repository annotated classes --> - <context:annotation-config/> + <!-- To translate any MongoExceptions thrown in @Repository annotated classes --> + <context:annotation-config/> - <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean" - p:port="1099" /> + <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean" p:port="1099" /> - <!-- Expose JMX over RMI --> - <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" + <!-- Expose JMX over RMI --> + <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" depends-on="registry" p:objectName="connector:name=rmi" p:serviceUrl="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector" /> - </beans> - +</beans> This will expose several MBeans diff --git a/src/docbkx/reference/mapping.xml b/src/docbkx/reference/mapping.xml index 2b1038a90..147186361 100644 --- a/src/docbkx/reference/mapping.xml +++ b/src/docbkx/reference/mapping.xml @@ -25,8 +25,7 @@ @Configuration class to configure MongoDB mapping support - -@Configuration + @Configuration public class GeoSpatialAppConfig extends AbstractMongoConfiguration { @Bean @@ -49,8 +48,6 @@ public class GeoSpatialAppConfig extends AbstractMongoConfiguration { public LoggingEventListener<MongoMappingEvent> mappingEventsListener() { return new LoggingEventListener<MongoMappingEvent>(); } - - } @@ -219,7 +216,7 @@ public class Person { Here is an example of a more complex mapping. - @Document + @Document @CompoundIndexes({ @CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}") }) diff --git a/src/docbkx/reference/mongo-repositories.xml b/src/docbkx/reference/mongo-repositories.xml index 0aa55abe0..90532278c 100644 --- a/src/docbkx/reference/mongo-repositories.xml +++ b/src/docbkx/reference/mongo-repositories.xml @@ -111,7 +111,7 @@ Paging access to Person entities - @RunWith(SpringJUnit4ClassRunner.class) + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class PersonRepositoryTests { @@ -145,7 +145,7 @@ public class PersonRepositoryTests { PersonRepository with query methods - public interface PersonRepository extends MongoRepository<Person, String> { + public interface PersonRepository extends MongoRepository<Person, String> { List<Person> findByLastname(String lastname); @@ -266,7 +266,7 @@ public class PersonRepositoryTests {
- Mongo JSON based query methods and field restriction + Mongo JSON based query methods and field restriction By adding the annotation org.springframework.data.document.mongodb.repository.Query @@ -274,7 +274,7 @@ public class PersonRepositoryTests { use instead of having the query derived from the method name. For example - public interface PersonRepository extends MongoRepository<Person, String> + public interface PersonRepository extends MongoRepository<Person, String> @Query("{ 'firstname' : ?0 }") List<Person> findByThePersonsFirstname(String firstname); @@ -285,10 +285,9 @@ public class PersonRepositoryTests { arguments into the JSON query string. You can also use the filter property to restrict the set of - properties that will be mapped into the Java object. For example, - + properties that will be mapped into the Java object. For example, - public interface PersonRepository extends MongoRepository<Person, String> + public interface PersonRepository extends MongoRepository<Person, String> @Query(value="{ 'firstname' : ?0 }", fields="firstname,lastname") List<Person> findByThePersonsFirstname(String firstname); @@ -330,7 +329,7 @@ public class PersonRepositoryTests { - Incremental query definition is easier + Incremental query definition is easier @@ -344,7 +343,7 @@ public class PersonRepositoryTests { Using QueryDSL you will be able to write queries as shown below - QPerson person = new QPerson("person"); + QPerson person = new QPerson("person"); List<Person> result = repository.findAll(person.address.zipCode.eq("C0123")); Page<Person> page = repository.findAll(person.lastname.contains("a"), @@ -361,7 +360,7 @@ Page<Person> page = repository.findAll(person.lastname.contains("a"), QueryDslPredicateExecutor which is shown below - public interface QueryDslPredicateExecutor<T> { + public interface QueryDslPredicateExecutor<T> { T findOne(Predicate predicate); @@ -379,7 +378,7 @@ Page<Person> page = repository.findAll(person.lastname.contains("a"), it in additiion to other repository interfaces. This is shown below - public interface PersonRepository extends MongoRepository<Person, String>, QueryDslPredicateExecutor<Person> { + public interface PersonRepository extends MongoRepository<Person, String>, QueryDslPredicateExecutor<Person> { // additional finder methods go here diff --git a/src/docbkx/reference/mongodb.xml b/src/docbkx/reference/mongodb.xml index 5fa9215c1..f2f5f245a 100644 --- a/src/docbkx/reference/mongodb.xml +++ b/src/docbkx/reference/mongodb.xml @@ -117,7 +117,7 @@ configuration style. Also change the version of Spring in the pom.xml to be - <spring.framework.version>3.0.5.RELEASE</spring.framework.version> + <spring.framework.version>3.0.5.RELEASE</spring.framework.version> You may also want to set the logging level to DEBUG to see some additional information, edit the log4j.properties file and add @@ -127,7 +127,7 @@ Next, in the org.spring.mongodb package in the sr/ctest/java directory create a class as shown below. - package org.spring.mongodb; + package org.spring.mongodb; import org.springframework.context.annotation.Configuration; import org.springframework.data.document.mongodb.MongoTemplate; @@ -525,7 +525,7 @@ public class AppConfig { You can also configure a MongoTemplate using Spring's XML <beans/> schema. - <mongo:mongo host="localhost" port="27017"/> + <mongo:mongo host="localhost" port="27017"/> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> @@ -595,7 +595,7 @@ public class AppConfig { Given a simple class such as Person - public class Person { + public class Person { private String id; private String firstName; @@ -790,7 +790,7 @@ import static org.springframework.data.document.mongodb.query.Criteria.query; over the mapping of an object into a DBObject. The MongoWriter interface is - /** + /** * A MongoWriter is responsible for converting an object of type T to the native MongoDB representation DBObject. * * @param <T> the type of the object to convert to a DBObject @@ -873,8 +873,8 @@ import static org.springframework.data.document.mongodb.query.Update ... - WriteResult wr = mongoTemplate.updateMulti(query(where("accounts.accountType").is(Account.Type.SAVINGS)), - update.inc("accounts.$.balance", 50.00)); + WriteResult wr = mongoTemplate.updateMulti(query(where("accounts.accountType").is(Account.Type.SAVINGS)), + update.inc("accounts.$.balance", 50.00)); @@ -1456,7 +1456,7 @@ import static org.springframework.data.document.mongodb.query.Query.query; the role of RowMapper in JdbcTemplate. The MongoReader interface is - /** + /** * A MongoWriter is responsible for converting a native MongoDB DBObject to an object of type T. * * @param <T> the type of the object to convert from a DBObject @@ -1535,30 +1535,30 @@ public class Venue { To find locations within a circle, the following query can be used. - Circle circle = new Circle(-73.99171, 40.738868, 0.01); + Circle circle = new Circle(-73.99171, 40.738868, 0.01); List<Venue> venues = template.find(new Query(Criteria.where("location").withinCenter(circle)), Venue.class); To find venues within a circle using Spherical coordinates the following query can be used - Circle circle = new Circle(-73.99171, 40.738868, 0.003712240453784); + Circle circle = new Circle(-73.99171, 40.738868, 0.003712240453784); List<Venue> venues = template.find(new Query(Criteria.where("location").withinCenterSphere(circle)), Venue.class); To find venues within a Box the following query can be used - Box box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404)); //lower-left then upper-right + Box box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404)); //lower-left then upper-right List<Venue> venues = template.find(new Query(Criteria.where("location").withinBox(box)), Venue.class); To find venues near a Point, the following query can be used - Point point = new Point(-73.99171, 40.738868); + Point point = new Point(-73.99171, 40.738868); List<Venue> venues = template.find(new Query(Criteria.where("location").near(point).maxDistance(0.01)), Venue.class); To find venues near a Point using Spherical coordines the following query can be used - Point point = new Point(-73.99171, 40.738868); + Point point = new Point(-73.99171, 40.738868); List<Venue> venues = template.find(new Query(Criteria.where("location").nearSphere(point).maxDistance(0.003712240453784)), Venue.class); @@ -1584,9 +1584,7 @@ List<Venue> venues = template.find(new Query(Criteria.where("location").ne Creating an index using the MongoTemplate - mongoTemplate.ensureIndex("MyCollection", new Index().on("name", - Order.ASCENDING)); - + mongoTemplate.ensureIndex("MyCollection", new Index().on("name",Order.ASCENDING)); @@ -1611,7 +1609,7 @@ List<Venue> venues = template.find(new Query(Criteria.where("location").ne the Venue class defined in a previous section, you would declare a geospatial query as shown below - mongoTemplate.ensureIndex(new GeospatialIndex("location")); + mongoTemplate.ensureIndex(new GeospatialIndex("location"));
@@ -1625,12 +1623,11 @@ List<Venue> venues = template.find(new Query(Criteria.where("location").ne Working with collections using the MongoTemplate DBCollection collection = null; - if (!mongoTemplate.getCollectionNames().contains("MyNewCollection")) { - collection = mongoTemplate.createCollection("MyNewCollection"); - } +if (!mongoTemplate.getCollectionNames().contains("MyNewCollection")) { + collection = mongoTemplate.createCollection("MyNewCollection"); +} - mongoTemplate.dropCollection("MyNewCollection"); - +mongoTemplate.dropCollection("MyNewCollection");