Removed unused imports, polished license headers and suppres some compiler warnings.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
* Copyright 2010-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,19 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mongodb;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
public class InvalidMongoDbApiUsageException extends InvalidDataAccessApiUsageException {
|
||||
|
||||
public InvalidMongoDbApiUsageException(String msg) {
|
||||
private static final long serialVersionUID = 2034770973290508041L;
|
||||
|
||||
public InvalidMongoDbApiUsageException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public InvalidMongoDbApiUsageException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
* Copyright 2010-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,15 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mongodb;
|
||||
|
||||
import org.springframework.dao.UncategorizedDataAccessException;
|
||||
|
||||
public class UncategorizedMongoDbException extends UncategorizedDataAccessException {
|
||||
|
||||
public UncategorizedMongoDbException(String msg, Throwable cause) {
|
||||
private static final long serialVersionUID = -2336595514062364929L;
|
||||
|
||||
public UncategorizedMongoDbException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,17 +19,12 @@ package org.springframework.data.mongodb.config;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.mongodb.core.MongoFactoryBean;
|
||||
import org.springframework.data.mongodb.core.MongoOptionsFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mongodb.ServerAddress;
|
||||
|
||||
/**
|
||||
* Parser for <mongo;gt; definitions. If no name
|
||||
*
|
||||
@@ -37,6 +32,7 @@ import com.mongodb.ServerAddress;
|
||||
*/
|
||||
public class MongoParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return MongoFactoryBean.class;
|
||||
}
|
||||
@@ -53,10 +49,6 @@ public class MongoParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
@@ -66,6 +58,4 @@ public class MongoParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,23 +16,21 @@
|
||||
|
||||
package org.springframework.data.mongodb.core.convert;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.ConversionServiceFactory;
|
||||
import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverters.BigDecimalToStringConverter;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverters.BigIntegerToObjectIdConverter;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverters.ObjectIdToBigIntegerConverter;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverters.ObjectIdToStringConverter;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverters.StringToBigDecimalConverter;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverters.StringToObjectIdConverter;
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.data.mongodb.core.mapping.event;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
|
||||
/**
|
||||
* @author Jon Brisbin <jbrisbin@vmware.com>
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mongodb.core.mapping.event;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
@@ -23,6 +22,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
* @author Jon Brisbin <jbrisbin@vmware.com>
|
||||
*/
|
||||
@SuppressWarnings({ "hiding", "rawtypes" })
|
||||
public class LoggingEventListener<MongoMappingEvent> extends AbstractMappingEventListener {
|
||||
|
||||
private Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.mongodb.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -29,8 +28,6 @@ import org.springframework.data.mongodb.core.MongoFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoOptions;
|
||||
import com.mongodb.ServerAddress;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -40,15 +37,13 @@ public class MongoNamespaceReplicaSetTests extends NamespaceTestSupport {
|
||||
@Autowired
|
||||
private ApplicationContext ctx;
|
||||
|
||||
|
||||
@Test
|
||||
public void testMongoWithReplicaSets() throws Exception {
|
||||
assertTrue(ctx.containsBean("replicaSetMongo"));
|
||||
MongoFactoryBean mfb = (MongoFactoryBean) ctx.getBean("&replicaSetMongo");
|
||||
String host = readField("host", mfb);
|
||||
Integer port = readField("port", mfb);
|
||||
|
||||
List<ServerAddress> replicaSetSeeds = readField("replicaSetSeeds", mfb);
|
||||
assertNotNull(replicaSetSeeds);
|
||||
assertNotNull(replicaSetSeeds);
|
||||
|
||||
assertEquals("127.0.0.1", replicaSetSeeds.get(0).getHost());
|
||||
assertEquals(27017, replicaSetSeeds.get(0).getPort());
|
||||
@@ -56,11 +51,6 @@ public class MongoNamespaceReplicaSetTests extends NamespaceTestSupport {
|
||||
assertEquals("localhost", replicaSetSeeds.get(1).getHost());
|
||||
assertEquals(27018, replicaSetSeeds.get(1).getPort());
|
||||
|
||||
Mongo mongo = mfb.getObject();
|
||||
|
||||
//TODO test infrastructure to have replica sets
|
||||
//assertEquals(2, mongo.getAllAddress().size());
|
||||
|
||||
// TODO test infrastructure to have replica sets
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Friend {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoAdminOperations;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -39,8 +38,7 @@ public class MongoAdminIntegrationTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(MongoAdminIntegrationTests.class);
|
||||
|
||||
private MongoAdminOperations mongoAdmin;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private DB testAdminDb;
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -63,6 +63,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Risberg
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:infrastructure.xml")
|
||||
public class MongoTemplateTests {
|
||||
|
||||
@@ -30,12 +30,14 @@ public class GeoSpatialAppConfig extends AbstractMongoConfiguration {
|
||||
return "database";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public Mongo mongo() throws Exception {
|
||||
return new Mongo("localhost");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("rawtypes")
|
||||
public LoggingEventListener<MongoMappingEvent> mappingEventsListener() {
|
||||
return new LoggingEventListener<MongoMappingEvent>();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.springframework.data.mongodb.core.mapping;
|
||||
*/
|
||||
public class Address implements Comparable<Address> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String id;
|
||||
private String[] lines;
|
||||
private String city;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
public class CustomCollectionWithIndex {
|
||||
|
||||
@Id
|
||||
@SuppressWarnings("unused")
|
||||
private String id;
|
||||
@Indexed
|
||||
private String name;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
public class DetectedCollectionWithIndex {
|
||||
|
||||
@Id
|
||||
@SuppressWarnings("unused")
|
||||
private String id;
|
||||
@Indexed
|
||||
private String name;
|
||||
|
||||
@@ -28,6 +28,7 @@ public class GeneratedId {
|
||||
|
||||
@Id
|
||||
private ObjectId id;
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
|
||||
public GeneratedId(String name) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
public class PersonCustomCollection1 extends BasePerson {
|
||||
|
||||
@Id
|
||||
@SuppressWarnings("unused")
|
||||
private String id;
|
||||
|
||||
public PersonCustomCollection1(Integer ssn, String firstName, String lastName) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
public class PersonCustomCollection2 extends BasePerson {
|
||||
|
||||
@Id
|
||||
@SuppressWarnings("unused")
|
||||
private String id;
|
||||
|
||||
public PersonCustomCollection2(Integer ssn, String firstName, String lastName) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
public class PersonMultiDimArrays extends BasePerson {
|
||||
|
||||
@Id
|
||||
@SuppressWarnings("unused")
|
||||
private String id;
|
||||
private String[][] grid;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MongoMonitorIntegrationTests {
|
||||
@Test
|
||||
public void serverInfo() {
|
||||
ServerInfo serverInfo = new ServerInfo(mongo);
|
||||
String version = serverInfo.getVersion();
|
||||
serverInfo.getVersion();
|
||||
Assert.isTrue(StringUtils.hasText("1."));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class Person extends Contact {
|
||||
@Indexed(unique = true, dropDups = true)
|
||||
private String email;
|
||||
private Integer age;
|
||||
@SuppressWarnings("unused")
|
||||
private Sex sex;
|
||||
|
||||
@GeoSpatialIndexed
|
||||
|
||||
Reference in New Issue
Block a user