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
6a70b901
Commit
6a70b901
authored
May 02, 2017
by
Sergey Kuptsov
Committed by
Stephane Nicoll
Jun 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add influxDB java client auto-configuration
See gh-9066
parent
9053bad2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
228 additions
and
1 deletion
+228
-1
pom.xml
spring-boot-autoconfigure/pom.xml
+5
-0
InfluxDBAutoConfiguration.java
.../boot/autoconfigure/influx/InfluxDBAutoConfiguration.java
+62
-0
InfluxDBProperties.java
...amework/boot/autoconfigure/influx/InfluxDBProperties.java
+67
-0
package-info.java
...ringframework/boot/autoconfigure/influx/package-info.java
+20
-0
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+2
-1
InfluxDBAutoConfigurationTest.java
...t/autoconfigure/influx/InfluxDBAutoConfigurationTest.java
+66
-0
pom.xml
spring-boot-dependencies/pom.xml
+6
-0
No files found.
spring-boot-autoconfigure/pom.xml
View file @
6a70b901
...
@@ -661,6 +661,11 @@
...
@@ -661,6 +661,11 @@
<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/InfluxDBAutoConfiguration.java
0 → 100644
View file @
6a70b901
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
influx
;
import
com.google.common.base.Strings
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDBFactory
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for InfluxDB.
*
* @author Sergey Kuptsov
*/
@Configuration
@ConditionalOnClass
(
InfluxDB
.
class
)
@EnableConfigurationProperties
(
InfluxDBProperties
.
class
)
public
class
InfluxDBAutoConfiguration
{
private
final
InfluxDBProperties
properties
;
public
InfluxDBAutoConfiguration
(
InfluxDBProperties
properties
)
{
this
.
properties
=
properties
;
}
@Bean
@ConditionalOnMissingBean
public
InfluxDB
influxDB
()
{
if
(
Strings
.
isNullOrEmpty
(
this
.
properties
.
getUser
()))
{
return
InfluxDBFactory
.
connect
(
this
.
properties
.
getUrl
()
);
}
else
{
return
InfluxDBFactory
.
connect
(
this
.
properties
.
getUrl
(),
this
.
properties
.
getUser
(),
this
.
properties
.
getPassword
()
);
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDBProperties.java
0 → 100644
View file @
6a70b901
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
influx
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
* Configuration properties for InfluxDB.
*
* @author Sergey Kuptsov
*/
@ConfigurationProperties
(
prefix
=
"spring.data.influx"
)
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
)
{
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
;
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/package-info.java
0 → 100644
View file @
6a70b901
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-configuration for InfluxDB.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
influx
;
spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
6a70b901
...
@@ -122,7 +122,8 @@ org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\
...
@@ -122,7 +122,8 @@ 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/InfluxDBAutoConfigurationTest.java
0 → 100644
View file @
6a70b901
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
influx
;
import
org.assertj.core.api.Java6Assertions
;
import
org.influxdb.InfluxDB
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
/**
* Tests for {@link InfluxDBAutoConfiguration}.
*
* @author Sergey Kuptsov
*/
public
class
InfluxDBAutoConfigurationTest
{
private
AnnotationConfigApplicationContext
context
;
@Before
public
void
setUp
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
}
@After
public
void
tearDown
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
public
void
canEnableConfiguration
()
{
this
.
context
.
register
(
InfluxDBAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.influx.url=http://localhost"
);
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
public
void
canEnableWithEmptyUserConfiguration
()
{
this
.
context
.
register
(
InfluxDBAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.influx.url=http://localhost"
);
this
.
context
.
refresh
();
Java6Assertions
.
assertThat
(
this
.
context
.
getBeansOfType
(
InfluxDB
.
class
)).
isNotEmpty
();
}
}
spring-boot-dependencies/pom.xml
View file @
6a70b901
...
@@ -190,6 +190,7 @@
...
@@ -190,6 +190,7 @@
<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>
...
@@ -2472,6 +2473,11 @@
...
@@ -2472,6 +2473,11 @@
<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>
...
...
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