Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
297127e0
Commit
297127e0
authored
Jun 02, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Add influxDB java client auto-configuration"
Closes gh-9066
parent
6a70b901
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
153 additions
and
61 deletions
+153
-61
pom.xml
spring-boot-autoconfigure/pom.xml
+5
-5
InfluxDbAutoConfiguration.java
.../boot/autoconfigure/influx/InfluxDbAutoConfiguration.java
+15
-14
InfluxDbProperties.java
...amework/boot/autoconfigure/influx/InfluxDbProperties.java
+47
-34
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+2
-2
InfluxDbAutoConfigurationTest.java
...t/autoconfigure/influx/InfluxDbAutoConfigurationTest.java
+73
-0
pom.xml
spring-boot-dependencies/pom.xml
+6
-6
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+5
-0
No files found.
spring-boot-autoconfigure/pom.xml
View file @
297127e0
...
@@ -641,6 +641,11 @@
...
@@ -641,6 +641,11 @@
<artifactId>
aspectjweaver
</artifactId>
<artifactId>
aspectjweaver
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
org.jooq
</groupId>
<groupId>
org.jooq
</groupId>
<artifactId>
jooq
</artifactId>
<artifactId>
jooq
</artifactId>
...
@@ -661,11 +666,6 @@
...
@@ -661,11 +666,6 @@
<artifactId>
quartz
</artifactId>
<artifactId>
quartz
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
<optional>
true
</optional>
</dependency>
<!-- Annotation processing -->
<!-- Annotation processing -->
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxD
B
AutoConfiguration.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxD
b
AutoConfiguration.java
View file @
297127e0
...
@@ -23,6 +23,7 @@ import org.influxdb.InfluxDBFactory;
...
@@ -23,6 +23,7 @@ import org.influxdb.InfluxDBFactory;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -31,32 +32,32 @@ import org.springframework.context.annotation.Configuration;
...
@@ -31,32 +32,32 @@ import org.springframework.context.annotation.Configuration;
* {@link EnableAutoConfiguration Auto-configuration} for InfluxDB.
* {@link EnableAutoConfiguration Auto-configuration} for InfluxDB.
*
*
* @author Sergey Kuptsov
* @author Sergey Kuptsov
* @author Stephane Nicoll
* @since 2.0.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
(
InfluxDB
.
class
)
@ConditionalOnClass
(
InfluxDB
.
class
)
@EnableConfigurationProperties
(
InfluxD
B
Properties
.
class
)
@EnableConfigurationProperties
(
InfluxD
b
Properties
.
class
)
public
class
InfluxD
B
AutoConfiguration
{
public
class
InfluxD
b
AutoConfiguration
{
private
final
InfluxD
B
Properties
properties
;
private
final
InfluxD
b
Properties
properties
;
public
InfluxD
BAutoConfiguration
(
InfluxDB
Properties
properties
)
{
public
InfluxD
bAutoConfiguration
(
InfluxDb
Properties
properties
)
{
this
.
properties
=
properties
;
this
.
properties
=
properties
;
}
}
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
InfluxDB
influxDB
()
{
@ConditionalOnProperty
(
"spring.influx.client.url"
)
if
(
Strings
.
isNullOrEmpty
(
this
.
properties
.
getUser
())
)
{
public
InfluxDB
influxDb
(
)
{
return
InfluxDBFactory
.
connect
(
InfluxDbProperties
.
Client
client
=
this
.
properties
.
getClient
();
this
.
properties
.
getUrl
()
if
(
Strings
.
isNullOrEmpty
(
client
.
getUser
()))
{
);
return
InfluxDBFactory
.
connect
(
client
.
getUrl
()
);
}
}
else
{
else
{
return
InfluxDBFactory
.
connect
(
return
InfluxDBFactory
.
connect
(
client
.
getUrl
(),
client
.
getUser
(),
this
.
properties
.
getUrl
(),
client
.
getPassword
());
this
.
properties
.
getUser
(),
this
.
properties
.
getPassword
()
);
}
}
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxD
B
Properties.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxD
b
Properties.java
View file @
297127e0
...
@@ -22,46 +22,59 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -22,46 +22,59 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* Configuration properties for InfluxDB.
* Configuration properties for InfluxDB.
*
*
* @author Sergey Kuptsov
* @author Sergey Kuptsov
* @author Stephane Nicoll
* @since 2.0.0
*/
*/
@ConfigurationProperties
(
prefix
=
"spring.data.influx"
)
@ConfigurationProperties
(
prefix
=
"spring.influx"
)
public
class
InfluxDBProperties
{
public
class
InfluxDbProperties
{
/**
* The url to connect to.
*/
private
String
url
;
/**
* The username which is used to authorize against the influxDB instance.
*/
private
String
user
;
/**
* The password for the username which is used to authorize against the influxDB.
*/
private
String
password
;
public
String
getUrl
()
{
return
this
.
url
;
}
public
void
setUrl
(
String
url
)
{
private
final
Client
client
=
new
Client
();
this
.
url
=
url
;
}
public
String
getUser
()
{
public
Client
getClient
()
{
return
this
.
user
;
return
this
.
client
;
}
}
public
void
setUser
(
String
user
)
{
public
static
class
Client
{
this
.
user
=
user
;
}
public
String
getPassword
()
{
/**
return
this
.
password
;
* Url of the InfluxDB instance to connect to.
}
*/
private
String
url
;
/**
* Login user.
*/
private
String
user
;
/**
* Login password.
*/
private
String
password
;
public
String
getUrl
()
{
return
this
.
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getUser
()
{
return
this
.
user
;
}
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
public
String
getPassword
()
{
return
this
.
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
}
}
spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
297127e0
...
@@ -62,6 +62,7 @@ org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
...
@@ -62,6 +62,7 @@ org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\
org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration,\
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
...
@@ -122,8 +123,7 @@ org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\
...
@@ -122,8 +123,7 @@ org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.reactive.WebSocketReactiveAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.reactive.WebSocketReactiveAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration,\
org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration,\
org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration
org.springframework.boot.autoconfigure.influx.InfluxDBAutoConfiguration
# Failure analyzers
# Failure analyzers
org.springframework.boot.diagnostics.FailureAnalyzer=\
org.springframework.boot.diagnostics.FailureAnalyzer=\
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/influx/InfluxD
B
AutoConfigurationTest.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/influx/InfluxD
b
AutoConfigurationTest.java
View file @
297127e0
...
@@ -16,29 +16,25 @@
...
@@ -16,29 +16,25 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
influx
;
package
org
.
springframework
.
boot
.
autoconfigure
.
influx
;
import
org.assertj.core.api.Java6Assertions
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDB
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.util.
EnvironmentTestUtil
s
;
import
org.springframework.boot.test.util.
TestPropertyValue
s
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Tests for {@link InfluxD
B
AutoConfiguration}.
* Tests for {@link InfluxD
b
AutoConfiguration}.
*
*
* @author Sergey Kuptsov
* @author Sergey Kuptsov
* @author Stephane Nicoll
*/
*/
public
class
InfluxD
B
AutoConfigurationTest
{
public
class
InfluxD
b
AutoConfigurationTest
{
private
AnnotationConfigApplicationContext
context
;
private
AnnotationConfigApplicationContext
context
;
@Before
public
void
setUp
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
}
@After
@After
public
void
tearDown
()
{
public
void
tearDown
()
{
if
(
this
.
context
!=
null
)
{
if
(
this
.
context
!=
null
)
{
...
@@ -47,20 +43,31 @@ public class InfluxDBAutoConfigurationTest {
...
@@ -47,20 +43,31 @@ public class InfluxDBAutoConfigurationTest {
}
}
@Test
@Test
public
void
canEnableConfiguration
()
{
public
void
clientRequiresUrl
()
{
this
.
context
.
register
(
InfluxDBAutoConfiguration
.
class
);
load
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.influx.url=http://localhost"
);
assertThat
(
this
.
context
.
getBeansOfType
(
InfluxDB
.
class
)).
isEmpty
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.influx.password:password"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.influx.user:user"
);
this
.
context
.
refresh
();
Java6Assertions
.
assertThat
(
this
.
context
.
getBeansOfType
(
InfluxDB
.
class
)).
isNotEmpty
();
}
}
@Test
@Test
public
void
c
anEnableWithEmptyUserConfiguration
()
{
public
void
c
lientCanBeCustomized
()
{
this
.
context
.
register
(
InfluxDBAutoConfiguration
.
class
);
load
(
"spring.influx.client.url=http://localhost"
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.influx.url=http://localhost"
);
"spring.influx.client.password:password"
,
this
.
context
.
refresh
(
);
"spring.influx.client.user:user"
);
Java6Assertions
.
assertThat
(
this
.
context
.
getBeansOfType
(
InfluxDB
.
class
)).
isNotEmpty
(
);
assertThat
(
this
.
context
.
getBeansOfType
(
InfluxDB
.
class
)).
hasSize
(
1
);
}
}
@Test
public
void
clientCanBeCreatedWithoutCredentials
()
{
load
(
"spring.influx.client.url=http://localhost"
);
assertThat
(
this
.
context
.
getBeansOfType
(
InfluxDB
.
class
)).
hasSize
(
1
);
}
private
void
load
(
String
...
environment
)
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
TestPropertyValues
.
of
(
environment
).
applyTo
(
ctx
);
ctx
.
register
(
InfluxDbAutoConfiguration
.
class
);
ctx
.
refresh
();
this
.
context
=
ctx
;
}
}
}
spring-boot-dependencies/pom.xml
View file @
297127e0
...
@@ -93,6 +93,7 @@
...
@@ -93,6 +93,7 @@
<httpclient.version>
4.5.3
</httpclient.version>
<httpclient.version>
4.5.3
</httpclient.version>
<httpcore.version>
4.4.6
</httpcore.version>
<httpcore.version>
4.4.6
</httpcore.version>
<infinispan.version>
8.2.6.Final
</infinispan.version>
<infinispan.version>
8.2.6.Final
</infinispan.version>
<influxdb-java.version>
2.5
</influxdb-java.version>
<jackson.version>
2.9.0.pr3
</jackson.version>
<jackson.version>
2.9.0.pr3
</jackson.version>
<janino.version>
3.0.7
</janino.version>
<janino.version>
3.0.7
</janino.version>
<javassist.version>
3.21.0-GA
</javassist.version>
<!-- Same as Hibernate -->
<javassist.version>
3.21.0-GA
</javassist.version>
<!-- Same as Hibernate -->
...
@@ -190,7 +191,6 @@
...
@@ -190,7 +191,6 @@
<webjars-locator.version>
0.32-1
</webjars-locator.version>
<webjars-locator.version>
0.32-1
</webjars-locator.version>
<wsdl4j.version>
1.6.3
</wsdl4j.version>
<wsdl4j.version>
1.6.3
</wsdl4j.version>
<xml-apis.version>
1.4.01
</xml-apis.version>
<xml-apis.version>
1.4.01
</xml-apis.version>
<influxdb-java.version>
2.5
</influxdb-java.version>
<!-- Plugin versions -->
<!-- Plugin versions -->
<build-helper-maven-plugin.version>
1.10
</build-helper-maven-plugin.version>
<build-helper-maven-plugin.version>
1.10
</build-helper-maven-plugin.version>
<exec-maven-plugin.version>
1.5.0
</exec-maven-plugin.version>
<exec-maven-plugin.version>
1.5.0
</exec-maven-plugin.version>
...
@@ -1857,6 +1857,11 @@
...
@@ -1857,6 +1857,11 @@
</exclusion>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
<version>
${influxdb-java.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.javassist
</groupId>
<groupId>
org.javassist
</groupId>
<artifactId>
javassist
</artifactId>
<artifactId>
javassist
</artifactId>
...
@@ -2473,11 +2478,6 @@
...
@@ -2473,11 +2478,6 @@
<artifactId>
xml-apis
</artifactId>
<artifactId>
xml-apis
</artifactId>
<version>
${xml-apis.version}
</version>
<version>
${xml-apis.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
<version>
${influxdb-java.version}
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
<build>
<build>
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
297127e0
...
@@ -714,6 +714,11 @@ content into your application; rather pick only the properties that you need.
...
@@ -714,6 +714,11 @@ content into your application; rather pick only the properties that you need.
spring.h2.console.settings.trace=false # Enable trace output.
spring.h2.console.settings.trace=false # Enable trace output.
spring.h2.console.settings.web-allow-others=false # Enable remote access.
spring.h2.console.settings.web-allow-others=false # Enable remote access.
# InfluxDB ({sc-spring-boot-autoconfigure}/influx/InfluxProperties.{sc-ext}[InfluxProperties])
spring.influx.client.password= # Login password.
spring.influx.client.url= # Url of the InfluxDB instance to connect to.
spring.influx.client.user= # Login user.
# JOOQ ({sc-spring-boot-autoconfigure}/jooq/JooqAutoConfiguration.{sc-ext}[JooqAutoConfiguration])
# JOOQ ({sc-spring-boot-autoconfigure}/jooq/JooqAutoConfiguration.{sc-ext}[JooqAutoConfiguration])
spring.jooq.sql-dialect= # Sql dialect to use, auto-detected by default.
spring.jooq.sql-dialect= # Sql dialect to use, auto-detected by default.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment