org.springframework.data
spring-data-solr
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ElasticsearchRepositoriesAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ElasticsearchRepositoriesAutoConfiguration.java
new file mode 100644
index 00000000000..aedab9c4c7d
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ElasticsearchRepositoriesAutoConfiguration.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012-2014 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.data;
+
+import org.elasticsearch.client.Client;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
+import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean;
+
+/**
+ * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Elasticsearch
+ * Repositories.
+ *
+ * @author Artur Konczak
+ * @author Mohsin Husen
+ * @see EnableElasticsearchRepositories
+ * @since 1.1.0
+ */
+@Configuration
+@ConditionalOnClass({ Client.class, ElasticsearchRepository.class })
+@ConditionalOnMissingBean(ElasticsearchRepositoryFactoryBean.class)
+@Import(ElasticsearchRepositoriesAutoConfigureRegistrar.class)
+public class ElasticsearchRepositoriesAutoConfiguration {
+
+}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ElasticsearchRepositoriesAutoConfigureRegistrar.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ElasticsearchRepositoriesAutoConfigureRegistrar.java
new file mode 100644
index 00000000000..6e9bf017323
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ElasticsearchRepositoriesAutoConfigureRegistrar.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2012-2014 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.data;
+
+import java.lang.annotation.Annotation;
+
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
+import org.springframework.data.repository.config.RepositoryConfigurationExtension;
+
+/**
+ * {@link ImportBeanDefinitionRegistrar} used to auto-configure Spring Data Elasticsearch
+ * Repositories.
+ *
+ * @author Artur Konczak
+ * @author Mohsin Husen
+ * @since 1.1.0
+ */
+class ElasticsearchRepositoriesAutoConfigureRegistrar extends
+ AbstractRepositoryConfigurationSourceSupport {
+
+ @Override
+ protected Class extends Annotation> getAnnotation() {
+ return EnableElasticsearchRepositories.class;
+ }
+
+ @Override
+ protected Class> getConfiguration() {
+ return EnableElasticsearchRepositoriesConfiguration.class;
+ }
+
+ @Override
+ protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() {
+ return new ElasticsearchRepositoryConfigExtension();
+ }
+
+ @EnableElasticsearchRepositories
+ private static class EnableElasticsearchRepositoriesConfiguration {
+
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchAutoConfiguration.java
new file mode 100644
index 00000000000..1a3dfe6948d
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchAutoConfiguration.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2012-2014 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.elasticsearch;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.elasticsearch.client.Client;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+/**
+ * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
+ * Auto-configuration} for Elasticsearch.
+ *
+ * @author Artur Konczak
+ * @author Mohsin Husen
+ * @since 1.1.0
+ */
+@Configuration
+@ConditionalOnClass(Client.class)
+@EnableConfigurationProperties(ElasticsearchProperties.class)
+public class ElasticsearchAutoConfiguration implements DisposableBean {
+
+ private static Log logger = LogFactory.getLog(ElasticsearchAutoConfiguration.class);
+
+ @Autowired
+ private ElasticsearchProperties properties;
+
+ private Client client;
+
+ @Bean
+ public Client elasticsearchClient() {
+ this.client = this.properties.createClient();
+ return this.client;
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ if (this.client != null) {
+ try {
+ if (logger.isInfoEnabled()) {
+ logger.info("Closing Elasticsearch client");
+ }
+ if (this.client != null) {
+ this.client.close();
+ }
+ }
+ catch (final Exception ex) {
+ if (logger.isErrorEnabled()) {
+ logger.error("Error closing Elasticsearch client: ", ex);
+ }
+ }
+ }
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchDataAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchDataAutoConfiguration.java
new file mode 100644
index 00000000000..e82d84cd3f5
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchDataAutoConfiguration.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012-2014 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.elasticsearch;
+
+import org.elasticsearch.client.Client;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
+
+/**
+ * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Elasticsearch
+ * support.
+ *
+ * Registers a {@link ElasticsearchTemplate} if no other bean of the same type is
+ * configured.
+ *
+ * @author Artur Konczak
+ * @author Mohsin Husen
+ * @see EnableElasticsearchRepositories
+ * @since 1.1.0
+ */
+@Configuration
+@ConditionalOnClass({ Client.class, ElasticsearchTemplate.class })
+@AutoConfigureAfter(ElasticsearchAutoConfiguration.class)
+public class ElasticsearchDataAutoConfiguration {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public ElasticsearchTemplate elasticsearchTemplate(Client client) {
+ return new ElasticsearchTemplate(client);
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchProperties.java
new file mode 100644
index 00000000000..bea364afcda
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchProperties.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2012-2014 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.elasticsearch;
+
+import org.elasticsearch.client.Client;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.data.elasticsearch.client.NodeClientFactoryBean;
+import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
+import org.springframework.util.StringUtils;
+
+/**
+ * Configuration properties for Elasticsearch.
+ *
+ * @author Artur Konczak
+ * @author Mohsin Husen
+ * @since 1.1.0
+ */
+@ConfigurationProperties(prefix = "spring.data.elasticsearch")
+public class ElasticsearchProperties {
+
+ private String clusterName = "elasticsearch";
+
+ private String clusterNodes;
+
+ private boolean local = true;
+
+ public String getClusterName() {
+ return this.clusterName;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ public String getClusterNodes() {
+ return this.clusterNodes;
+ }
+
+ public void setClusterNodes(String clusterNodes) {
+ this.clusterNodes = clusterNodes;
+ }
+
+ public Client createClient() {
+ try {
+ return (StringUtils.hasLength(this.clusterNodes) ? createTransportClient()
+ : createNodeClient());
+ }
+ catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ private Client createNodeClient() throws Exception {
+ NodeClientFactoryBean factory = new NodeClientFactoryBean(this.local);
+ factory.setClusterName(this.clusterName);
+ factory.afterPropertiesSet();
+ return factory.getObject();
+ }
+
+ private Client createTransportClient() throws Exception {
+ TransportClientFactoryBean factory = new TransportClientFactoryBean();
+ factory.setClusterName(this.clusterName);
+ factory.setClusterNodes(this.clusterNodes);
+ factory.afterPropertiesSet();
+ return factory.getObject();
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
index 1696504f293..1b87fe19577 100644
--- a/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
+++ b/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
@@ -9,6 +9,7 @@ org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration,\
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
+org.springframework.boot.autoconfigure.data.ElasticsearchRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.JpaRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.MongoRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.SolrRepositoriesAutoConfiguration,\
@@ -22,6 +23,8 @@ org.springframework.boot.autoconfigure.jms.ActiveMQAutoConfiguration,\
org.springframework.boot.autoconfigure.jms.HornetQAutoConfiguration,\
org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration,\
org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\
+org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration,\
+org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchDataAutoConfiguration,\
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml
index b4f776cbea2..b1cf30eee36 100644
--- a/spring-boot-dependencies/pom.xml
+++ b/spring-boot-dependencies/pom.xml
@@ -182,6 +182,11 @@
spring-boot-starter-batch
1.1.0.BUILD-SNAPSHOT
+