DATAMONGO-1490 - Change the XML data type of boolean flags to String.
We now accept String data types for boolean flags in XML configurations. Boolean data types in the XSD don't allows use of property placeholders even if the resolved value could be converted to boolean. Affected fields by this change are: * `<mongo:repositories create-query-indexes=… />` * `<mongo:options ssl=…/>` * `<mongo:client-options ssl=… />` Original Pull Request: #389
This commit is contained in:
committed by
Christoph Strobl
parent
fcb436dd30
commit
e0bc1e0f20
@@ -137,7 +137,7 @@ The MongoClientURI string.]]></xsd:documentation>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="create-query-indexes" type="xsd:boolean" default="false">
|
||||
<xsd:attribute name="create-query-indexes" type="xsd:string" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Enables creation of indexes for queries that get derived from the method name
|
||||
@@ -541,7 +541,7 @@ This controls if the driver is allowed to read from secondaries or slaves. Defa
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="ssl" type="xsd:boolean">
|
||||
<xsd:attribute name="ssl" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
This controls if the driver should us an SSL connection. Defaults to false.
|
||||
@@ -739,7 +739,7 @@ The socket timeout for connections used for the cluster heartbeat.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="ssl" type="xsd:boolean">
|
||||
<xsd:attribute name="ssl" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
This controls if the driver should us an SSL connection. Defaults to false.
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.authentication.UserCredentials;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.MongoClientFactoryBean;
|
||||
import org.springframework.data.mongodb.core.MongoFactoryBean;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.ReflectiveMongoOptionsInvokerTestUtil;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
import com.mongodb.MongoOptions;
|
||||
import com.mongodb.WriteConcern;
|
||||
|
||||
@@ -101,6 +103,19 @@ public class MongoNamespaceTests {
|
||||
assertTrue("socketFactory should be a SSLSocketFactory", options.getSocketFactory() instanceof SSLSocketFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-1490
|
||||
*/
|
||||
@Test
|
||||
public void testMongoClientSingletonWithSslEnabled() {
|
||||
|
||||
assertTrue(ctx.containsBean("mongoClientSsl"));
|
||||
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&mongoClientSsl");
|
||||
|
||||
MongoClientOptions options = (MongoClientOptions) getField(mfb, "mongoClientOptions");
|
||||
assertTrue("socketFactory should be a SSLSocketFactory", options.getSocketFactory() instanceof SSLSocketFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-764
|
||||
*/
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
|
||||
<mongo:db-factory dbname="database" mongo-ref="mongo"/>
|
||||
|
||||
<mongo:mongo-client id="mongoClientSsl">
|
||||
<mongo:client-options ssl="${mongoSsl.ssl}" />
|
||||
</mongo:mongo-client>
|
||||
|
||||
|
||||
<mongo:db-factory id="secondMongoDbFactory"
|
||||
host="localhost"
|
||||
port="27017"
|
||||
@@ -49,7 +51,7 @@
|
||||
<mongo:mongo id="defaultMongo" host="localhost" port="27017"/>
|
||||
|
||||
<mongo:mongo id="mongoSsl" host="localhost" port="27017">
|
||||
<mongo:options ssl="true"/>
|
||||
<mongo:options ssl="${mongoSsl.ssl}"/>
|
||||
</mongo:mongo>
|
||||
|
||||
<mongo:mongo id="mongoSslWithCustomSslFactory" host="localhost" port="27017">
|
||||
|
||||
@@ -10,3 +10,5 @@ mongo.socketKeepAlive=true
|
||||
mongo.fsync=true
|
||||
mongo.slaveOk=true
|
||||
|
||||
mongoSsl.ssl=true
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<mongo:db-factory dbname="repositories"/>
|
||||
<context:property-placeholder
|
||||
location="classpath:/org/springframework/data/mongodb/repository/mongo.properties"/>
|
||||
|
||||
<mongo:db-factory dbname="repositories"/>
|
||||
<mongo:mapping-converter base-package="org.springframework.data.mongodb.repository"/>
|
||||
|
||||
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
|
||||
@@ -15,6 +18,6 @@
|
||||
<constructor-arg ref="mappingConverter"/>
|
||||
</bean>
|
||||
|
||||
<mongo:repositories base-package="org.springframework.data.mongodb.repository" create-query-indexes="true" />
|
||||
<mongo:repositories base-package="org.springframework.data.mongodb.repository" create-query-indexes="${mongo.create-query-indexes}" />
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
mongo.create-query-indexes=true
|
||||
Reference in New Issue
Block a user