forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
1,006 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...uator/src/main/java/org/springframework/boot/actuate/health/CouchbaseHealthIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2012-2016 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.actuate.health; | ||
|
||
import java.util.List; | ||
|
||
import com.couchbase.client.java.util.features.Version; | ||
|
||
import org.springframework.data.couchbase.core.CouchbaseOperations; | ||
import org.springframework.util.Assert; | ||
|
||
/** | ||
* {@link HealthIndicator} for Couchbase. | ||
* | ||
* @author Eddú Meléndez | ||
* @since 1.4.0 | ||
*/ | ||
public class CouchbaseHealthIndicator extends AbstractHealthIndicator { | ||
|
||
private CouchbaseOperations couchbaseOperations; | ||
|
||
public CouchbaseHealthIndicator(CouchbaseOperations couchbaseOperations) { | ||
Assert.notNull(couchbaseOperations, "CouchbaseOperations must not be null"); | ||
this.couchbaseOperations = couchbaseOperations; | ||
} | ||
|
||
@Override | ||
protected void doHealthCheck(Health.Builder builder) throws Exception { | ||
List<Version> versions = this.couchbaseOperations.getCouchbaseClusterInfo().getAllVersions(); | ||
builder.up().withDetail("version", versions.get(0).toString()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...ain/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2012-2016 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.couchbase; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import javax.validation.Validator; | ||
|
||
import com.couchbase.client.java.CouchbaseBucket; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration; | ||
import org.springframework.data.couchbase.config.CouchbaseBucketFactoryBean; | ||
import org.springframework.data.couchbase.core.mapping.event.ValidatingCouchbaseEventListener; | ||
|
||
/** | ||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration | ||
* Auto-Configuration} for Couchbase. | ||
* | ||
* @author Eddú Meléndez | ||
* @since 1.4.0 | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({ CouchbaseBucket.class, CouchbaseBucketFactoryBean.class }) | ||
@EnableConfigurationProperties(CouchbaseProperties.class) | ||
public class CouchbaseAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnBean(Validator.class) | ||
public ValidatingCouchbaseEventListener validationEventListener(Validator validator) { | ||
return new ValidatingCouchbaseEventListener(validator); | ||
} | ||
|
||
@Configuration | ||
static class CouchbaseConfiguration extends AbstractCouchbaseConfiguration { | ||
|
||
@Autowired | ||
private CouchbaseProperties properties; | ||
|
||
@Override | ||
protected List<String> getBootstrapHosts() { | ||
return Arrays.asList(this.properties.getHosts()); | ||
} | ||
|
||
@Override | ||
protected String getBucketName() { | ||
return this.properties.getBucketName(); | ||
} | ||
|
||
@Override | ||
protected String getBucketPassword() { | ||
return this.properties.getBucketPassword(); | ||
} | ||
|
||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
...e/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2012-2016 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.couchbase; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
/** | ||
* Configuration properties for Couchbase. | ||
* | ||
* @author Eddú Meléndez | ||
* @since 1.4.0 | ||
*/ | ||
@ConfigurationProperties(prefix = "spring.data.couchbase") | ||
public class CouchbaseProperties { | ||
|
||
/** | ||
* Couchabase server hosts. | ||
*/ | ||
private String[] hosts; | ||
|
||
/** | ||
* Couchbase bucket name. | ||
*/ | ||
private String bucketName; | ||
|
||
/** | ||
* Couchbase bucket password. | ||
*/ | ||
private String bucketPassword; | ||
|
||
public String[] getHosts() { | ||
return this.hosts; | ||
} | ||
|
||
public void setHosts(String[] hosts) { | ||
this.hosts = hosts; | ||
} | ||
|
||
public String getBucketName() { | ||
return this.bucketName; | ||
} | ||
|
||
public void setBucketName(String bucketName) { | ||
this.bucketName = bucketName; | ||
} | ||
|
||
public String getBucketPassword() { | ||
return this.bucketPassword; | ||
} | ||
|
||
public void setBucketPassword(String bucketPassword) { | ||
this.bucketPassword = bucketPassword; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...onfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2012-2016 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 Couchbase. | ||
*/ | ||
package org.springframework.boot.autoconfigure.couchbase; |
Oops, something went wrong.